10 #print "sed -i \"s/$old/$new/\" $file\n";
11 print `sed -i "s/$old/$new/g" $file`;
14 # Execution starts here
18 GetOptions ("fsharp" => \$fsharp);
21 if (!$name || $name eq '') {
22 print "name: $name\n";
23 print "Usage: ./create-extension [--fsharp] EXTENSION_NAME\n\n";
24 print "Example: ./create-extension AlarmClock\n";
28 if ($name !~ m/^[A-Z][a-zA-Z0-9]+$/) {
29 print "name should start with upper-case letter, and consist only of letters and numbers\n";
33 my $dir = "src/$name";
35 if (-d $dir || -e $dir) {
36 print "$dir already exists; remove it or choose a new name\n";
41 my $proj_type = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}";
44 $proj_type = "{4925A630-B079-445d-BCD4-3A9C94FE9307}";
47 # TODO ensure the working copy of git is clean
49 print "Creating new extension: '$name'\n";
52 print `mkdir -p $dir`;
54 print `cp -R build/extension-templates/$ext/* $dir/`;
56 # Rename files appropriately
57 my $name_source = $name . 'Source';
58 print `mv $dir/Banshee.Template/TemplateSource.$ext $dir/Banshee.Template/$name_source.$ext`;
59 print `mv $dir/Banshee.Template/ $dir/Banshee.$name`;
60 print `mv $dir/Template.addin.xml $dir/$name.addin.xml`;
61 print `mv $dir/Template.${ext}proj $dir/$name.${ext}proj`;
64 if (not -f "build/gen-guid.exe") {
65 `gmcs build/gen-guid.cs`;
67 my $guid = `mono build/gen-guid.exe`; chomp($guid); $guid = uc($guid);
68 replace ("$dir/$name.${ext}proj", "TEMPLATE-GUID", $guid);
70 # Replace the extension name
71 replace ("$dir/Makefile.am", "EXTENSION-NAME", $name);
72 replace ("$dir/$name.addin.xml", "EXTENSION-NAME", $name);
73 replace ("$dir/$name.${ext}proj", "EXTENSION-NAME", $name);
74 replace ("$dir/Banshee.$name/$name_source.${ext}", "EXTENSION-NAME", $name);
77 replace ("configure.ac", 'src\\/Makefile', 'src\\/Makefile\nsrc\\/' . $name. '\\/Makefile');
78 replace ("configure.ac", "Extensions:", 'Extensions:\n ' . $name . ':' . (' ' x (20 - length($name))) . "yes");
80 # Add to src/Makefile.am
81 my $subdirs = "SUBDIRS = \\\\\\";
82 replace ("src/Makefile.am", $subdirs, $subdirs . ' \n ' . $name . ' \\\\\\');
83 replace ("src/Makefile.am", " \$", "");
85 # Add to Extensions.sln
86 replace ("Extensions.sln", "Visual Studio 2010", 'Visual Studio 2010\n' .
87 'Project(\"' . $proj_type . '\") = \"' . $name . '\", \"src\\\\\\'. $name . '\\\\\\' . $name . '.' . $ext . 'proj\", \"{' . $guid . '}\"\nEndProject');
88 replace ("Extensions.sln", "postSolution", 'postSolution\n'.
89 "\t\t{$guid}.Debug|x86.ActiveCfg = Debug|Any CPU".'\n'.
90 "\t\t{$guid}.Debug|x86.Build.0 = Debug|Any CPU".'\n'.
91 "\t\t{$guid}.Release|x86.ActiveCfg = Release|Any CPU".'\n'.
92 "\t\t{$guid}.Release|x86.Build.0 = Release|Any CPU");
94 # Add everything to git, ready to commit
95 print `git add configure.ac src/Makefile.am Extensions.sln`;
96 print `git add $dir/`;
97 #print `git commit -m "[$name] Initial skeleton"`;
100 print "Running ./autogen.sh\n";
101 `./autogen.sh` || die "Failed running ./autogen.sh - run it yourself to get the error";
104 print "Running make";
111 print "\nYour extension has been created, and all the necessary files ready \n";
112 print "to commit to git:\n\n";
116 print "\nYou can commit it now, or after you've started customizing it!\n";
118 print "\nYou can undo the creation of this extension, and revert to the last commit with\n";
119 print "git reset --hard HEAD\n";
121 print "\nYou can run Banshee with your newely created extension right now! Just run:\n";
124 print "\nNOTE: Do not forget to enable your extension within Preferences > Extensions\n";