Bug 452390 Tracemonkey will crash if the compiler doesn't have FASTCALL r=danderson
[wine-gecko.git] / embedding / config / GenerateManifest.pm
blob502798542d338ac29226245be99921c379c68c69
1 #!perl -w
2 package GenerateManifest;
4 require 5.004;
6 use strict;
7 use File::stat;
8 require Exporter;
10 use vars qw(@ISA @EXPORT);
12 # Package that generates a jar manifest from an input file
14 @ISA = qw(Exporter);
15 @EXPORT = qw(
16 GenerateManifest
19 my(%embed_files) = ();
22 sub GenerateManifest ($$$$$$$$) {
23 my($moz, $manifest, $chrome, $locale, $platform, $out_desc, $dir_sep, $verbose) = @_;
24 local(*OUTDESC) = $out_desc;
26 parse_input_manifest($moz, $manifest, $chrome, $locale, $verbose);
27 dump_output_manifest($moz, $manifest, $chrome, $locale, $platform, *OUTDESC, $dir_sep, $verbose);
31 sub parse_input_manifest ($$$$$) {
32 my($moz, $manifest, $chrome, $locale, $verbose) = @_;
34 print STDERR "Parsing \"$manifest\"\n" unless !$verbose;
36 local(*MANIFEST);
37 open(MANIFEST, "<$manifest") or die ("Error: Cannot open manifest \"$manifest\".\n");
38 while(<MANIFEST>) {
39 chomp;
40 s/^\s+//;
41 s/\s+$//;
43 # Skip comments & blank lines
44 next if (/^\#/);
45 next if (/^\s*$/);
47 # Read key & data
48 my($key, $value) = split(/,/, $_);
50 # Strip out any remaining whitespace from key & value
51 for ($key) {
52 s/\s+$//;
54 for ($value) {
55 s/^\s+//;
58 $embed_files{$key} = $value;
60 close(MANIFEST);
63 sub dump_output_manifest ($$$$$$$$) {
64 my($moz, $manifest, $chrome, $locale, $platform, $out_desc, $dir_sep, $verbose) = @_;
65 local(*OUTDESC) = $out_desc;
67 print OUTDESC "embed.jar:\n";
68 while (my($key, $value) = each %embed_files) {
70 $key =~ s/XXXX/$locale/g;
71 $value =~ s/XXXX/$locale/g;
72 $key =~ s/YYYY/$platform/g;
73 $value =~ s/YYYY/$platform/g;
74 if ( $dir_sep ne "/" ) { # swap / for $dir_sep
75 $value =~ s/\//$dir_sep/g;
78 # Run ls on the dir/file to ensure it's there and to get a file list back
79 my($ls_path) = "$chrome$dir_sep$value";
80 my($is_dir) = (-d $ls_path) ? 1 : 0;
81 my($is_file) = (-f $ls_path) ? 1 : 0;
83 print STDERR "Listing \"$ls_path\"\n" unless !$verbose;
85 if (!$is_dir && !$is_file) {
86 print STDERR "Warning: File or directory \"$ls_path\" does not exist.\n";
87 next;
90 # this code previously used |ls -1| to get a dir listing, but that
91 # doesn't work in MacPerl. Instead just use opendir() to get the
92 # file list (if it's a directory), or add the single file to our list
93 # if it's called out individually in the manifest.
94 my(@dirList) = ();
95 if ( $is_file ) {
96 @dirList = ($ls_path);
98 else {
99 opendir(CHROMEDIR, $ls_path);
100 @dirList = readdir(CHROMEDIR);
101 closedir(CHROMEDIR);
104 my($chrome_file) = "";
105 my($real_file) = "";
106 foreach (@dirList) {
107 if ($is_dir) {
108 $chrome_file = "$key$dir_sep$_";
109 $real_file = "$value$dir_sep$_";
111 else {
112 $chrome_file = $key;
113 $real_file = $value;
115 # Ignore directories which are returned by ls
116 if (! -d "$chrome$dir_sep$real_file") {
117 # before we put the file into the manifest, make sure it
118 # uses '/' as the separator. That's what manifest files expect.
119 $real_file =~ s/$dir_sep/\//g;
120 $chrome_file =~ s/$dir_sep/\//g;
121 print OUTDESC " $chrome_file ($real_file)\n";