source: trunk/third/firefox/config/make-chromelist.pl @ 21695

Revision 21695, 5.0 KB checked in by rbasch, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21694, which included commits to RCS files with non-trunk default branches.
Line 
1#!/usr/bin/perl -w
2
3# ***** BEGIN LICENSE BLOCK *****
4# Version: MPL 1.1/GPL 2.0/LGPL 2.1
5#
6# The contents of this file are subject to the Mozilla Public License Version
7# 1.1 (the "License"); you may not use this file except in compliance with
8# the License. You may obtain a copy of the License at
9# http://www.mozilla.org/MPL/
10#
11# Software distributed under the License is distributed on an "AS IS" basis,
12# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13# for the specific language governing rights and limitations under the
14# License.
15#
16# The Original Code is the Chrome/CVS Location Matcher.
17#
18# The Initial Developer of the Original Code is
19# Gervase Markham.
20# Portions created by the Initial Developer are Copyright (C) 2001
21# the Initial Developer. All Rights Reserved.
22#
23# Contributor(s):
24#
25# Alternatively, the contents of this file may be used under the terms of
26# either the GNU General Public License Version 2 or later (the "GPL"), or
27# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28# in which case the provisions of the GPL or the LGPL are applicable instead
29# of those above. If you wish to allow use of your version of this file only
30# under the terms of either the GPL or the LGPL, and not to allow others to
31# use your version of this file under the terms of the MPL, indicate your
32# decision by deleting the provisions above and replace them with the notice
33# and other provisions required by the GPL or the LGPL. If you do not delete
34# the provisions above, a recipient may use your version of this file under
35# the terms of any one of the MPL, the GPL or the LGPL.
36#
37# ***** END LICENSE BLOCK *****
38
39# Version 0.5
40#
41# This file creates a large list of the mappings between chrome path and CVS
42# paths which are recorded in the jar.mn files throughout the tree. This list
43# is shipped with builds to make it easier for people to create chrome patches
44# using them.
45
46use Fcntl qw(:DEFAULT :flock);
47use File::Basename;
48use Cwd;
49use mozLock;
50
51# This is necessary because this module is not present in Perl versions less
52# than 5.004_05.
53eval q{use File::Spec};
54exit if $@;
55
56# This file takes two parameters - the jar file to process, and the chrome
57# directory we are compiling into.
58my ($chrome, $jar, $flock) = @ARGV;
59
60my $nofilelocks = $flock ? ($flock eq "-l") : 0;
61
62# OS setup - which chrome does your OS use?
63#
64# The $^O variable contains some representation of what OS you are on.
65# Find its value on your platform by running the following command:
66# perl -e 'print $^O . "\n";'
67# and set the relevant booleans accordingly depending on what
68# chrome your platform uses. There are currently three sorts of chrome:
69# win, mac, and unix.
70 
71my $win32 = ($^O =~ /((MS)?win32)|cygwin|os2/i) ? 1 : 0;
72my $macos = ($^O =~ /MacOS|darwin/i)     ? 1 : 0;
73my $unix  = !($win32 || $macos)          ? 1 : 0;
74
75# Testing only - generate chromelist.txt for other platforms
76# $macos = 1;
77# $unix = 0;
78
79my $chromelist = File::Spec->catfile($chrome, "chromelist.txt");
80my $lockfile = $chromelist . ".lck";
81
82mozLock($lockfile) unless $nofilelocks;
83
84open(BIGLIST, ">>" . $chromelist) or die "Can't open chromelist.txt";
85open(JARFILE, "<$jar");
86
87# Find the absolute directory the jar.mn file is in
88my $stub = File::Spec->catdir(getcwd(), dirname($jar));
89
90# Convert back to Unix-style directory names for the CVS version
91if ($macos) { $stub =~ tr|:|/|; }
92if ($win32) { $stub =~ tr|\\|/|; }
93
94# Turn the absolute path into a relative path inside the CVS tree
95$stub =~ s|.*mozilla/?||;
96
97my $jarfilename = "";
98 
99while (<JARFILE>)
100{
101  # Tidy up the line
102  chomp;
103  s/^[\s|\+]+//; # Some lines have a + sign before them
104  s/\s+$//;
105
106  # There's loads of things we aren't interested in
107  next if m/^\s*#/;          # Comments
108  next if m/^$/;             # Blank lines
109  next if m/\.gif\)\s*$/i;   # Graphics
110  next if m/\.png\)\s*$/i;
111  next if m/\.jpe?g\)\s*$/i;
112  next if ($stub =~ m|/win/|)  and !$win32;
113  next if ($stub =~ m|/unix/|) and !$unix;
114  next if ($stub =~ m|/mac/|)  and !$macos;
115
116  if (m/\s*(.*)\.jar:/)      # e.g. "comm.jar:"
117  {
118    $jarfilename = $1;
119    next;
120  }
121         
122  # Split up the common format, which is e.g.:
123  # messenger/skin/fred/foo.xul (xpfe/barney/wilma/foo.xul)
124  m/(.*)\s+\((.*)\)/;
125  my $chromefile = $1;
126  my $cvsfile = $2; 
127
128  # Deal with those jar.mns which have just a single line,
129  # implying that the file is in the current directory.
130  if (!$1 || $1 eq "")
131  {
132    $chromefile = File::Spec::Unix->canonpath("$jarfilename/$_");
133    $_ =~ /.*\/(.*?)$/;
134    $cvsfile = File::Spec::Unix->canonpath($1);
135  } else {
136    $chromefile = File::Spec::Unix->canonpath("$jarfilename/$chromefile");
137    $cvsfile = File::Spec::Unix->canonpath($cvsfile);
138  }
139
140  # Convert to platform-specific separator for the chrome version.
141  # This permits easy grepping of the file for a given path.
142  if ($macos) { $chromefile =~ tr|/|:|; }
143  if ($win32) { $chromefile =~ tr|/|\\|; }
144
145  $cvsfile = File::Spec::Unix->catfile($stub, $cvsfile);
146 
147  print BIGLIST "$chromefile ($cvsfile)\n";
148}
149
150mozUnlock($lockfile) unless $nofilelocks;
151
152exit(0);
153
Note: See TracBrowser for help on using the repository browser.