-
Notifications
You must be signed in to change notification settings - Fork 109
/
create_xpi.pl
68 lines (52 loc) · 1.56 KB
/
create_xpi.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/perl
#############################################################################
# This script will create an extension build. Usually, this script #
# shouldn't be run directly, use make_devbuild.pl instead. #
#############################################################################
use strict;
use warnings;
use lib qw(. ..);
use Packager;
my $manifest = readFile("chrome.manifest");
unless ($manifest =~ /\bjar:chrome\/(\S+?)\.jar\b/)
{
die "Could not find JAR file name in chrome.manifest";
}
my $baseName = $1;
my %params = ();
my $xpiFile = shift @ARGV || "$baseName.xpi";
if (@ARGV && $ARGV[0] =~ /^\+/)
{
$params{devbuild} = $ARGV[0];
shift @ARGV;
}
else
{
$params{postprocess_line} = \&removeTimeLine;
}
$params{locales} = \@ARGV if @ARGV;
my $pkg = Packager->new(\%params);
$pkg->readVersion('version');
$pkg->readLocales('chrome/locale') unless exists $params{locales};
chdir('chrome');
$pkg->makeJAR("$baseName.jar", 'content', 'skin', 'locale', '-/tests', '-/mochitest', '-/.incomplete');
chdir('..');
my @files = grep {-e $_} ('components', 'defaults', 'install.rdf', 'chrome.manifest', 'icon.png');
$pkg->makeXPI($xpiFile, "chrome/$baseName.jar", @files);
unlink("chrome/$baseName.jar");
sub removeTimeLine
{
my ($file, $line) = @_;
return "\n" if $file =~ /\.js$/ && $line =~ /\btimeLine\.(\w+)\(/;
return $line;
}
sub readFile
{
my $file = shift;
open(local *FILE, "<", $file) || die "Could not read file '$file'";
binmode(FILE);
local $/;
my $result = <FILE>;
close(FILE);
return $result;
}