From MozillaZine Knowledge Base
(Difference between revisions)
Revision as of 12:12, 17 April 2005
These scripts can be used to build XPI packages for extensions automatically in Windows environment. See also bash build script.
- Taken from roachfiend's build script, which uses 7-Zip and Windows cmd/command.com shell.
Here’s what you need to do:
- Install 7-Zip.
- Copy C:\Program Files\7-Zip\7z.exe to C:\WINDOWS\system32 (This will put 7z.exe in your system’s path, which will make it accessible from the command prompt).
- It’s a good practice to build your extensions somewhere far away from random scripts and clutter, so create a new folder somewhere and call it whatever your extension is named. Make sure it matches the internal .jar file that you previously referenced in your install.rdf file. You can always rename the final .xpi to something more intricate afterward, but for packaging, it’s best to keep it simple.
- Copy the following script and paste it in a text editor and save it as build.bat in your newly-made folder:
7z a -tzip "%x%.jar" * -r -mx=0
move "%x%.jar" ..build\chrome
copy install.* build
7z a -tzip "%x%.xpi" * -r -mx=9
move "%x%.xpi" ..
rd build /s/q
- Now, you can build or modify your extensions easily. Just use the new folder as your base of creation, so that would contain the install files and chrome folder. Whenever you want to create your new file, just double-click build.bat, and your new extension will pop out in the same folder. Each time you use the build.bat script, it will delete your old file and create a new one.
Alternative Winrar version of the above script
- Like for the 7zip version, you should copy Winrar.exe to C:\WINDOWS\system32.
winrar.exe a -r -ibck -m0 -afzip -n@"..\list.txt" "%x%.jar"
move "%x%.jar" "..\build\chrome\"
copy install.rdf build
winrar.exe a -s -ibck -r -m5 -afzip "%x%.xpi"
move "%x%.xpi" ..\
rd build /s/q
- On the 4th line, you'll notice that there's an unusual switch: -n@"..\list.txt". This command tells winrar to include only the files that you have specified in a list.txt file. This switch is extremely useful for making sure that you don't include SVN or CVS files in your package. Below is an example list.txt file. You will want to modify this as necessary.
- The list.txt file should be placed in the same directory as your build.bat file.
- Of course, you may not need to exclude any files from your package, so in this case you can simply remove the -n@"..\list.txt" switch.