3
# Copyright (C) 2006 Apple Computer, Inc.
5
# This library is free software; you can redistribute it and/or
6
# modify it under the terms of the GNU Library General Public
7
# License as published by the Free Software Foundation; either
8
# version 2 of the License, or (at your option) any later version.
10
# This library is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
# Library General Public License for more details.
15
# You should have received a copy of the GNU Library General Public License
16
# along with this library; see the file COPYING.LIB. If not, write to
17
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
# Boston, MA 02111-1307, USA.
21
# Usage: make-css-file-arrays.pl <header> <output> <input> ...
28
GetOptions('preprocessor=s' => \$preprocessor);
31
$preprocessor = "/usr/bin/gcc -E -P -x c++";
34
my $header = $ARGV[0];
40
open HEADER, ">", $header or die;
41
open OUT, ">", $out or die;
43
print HEADER "namespace WebCore {\n";
44
print OUT "namespace WebCore {\n";
47
$in =~ /(\w+)\.css$/ or die;
50
# Slurp in the CSS file.
51
open IN, $preprocessor . " " . $in . "|" or die;
52
my $text; { local $/; $text = <IN>; }
55
# Remove comments in a simple-minded way that will work fine for our files.
56
# Could do this a fancier way if we were worried about arbitrary CSS source.
57
$text =~ s|/\*.*?\*/||gs;
59
# Crunch whitespace just to make it a little smaller.
60
# Could do work to avoid doing this inside quote marks but our files don't have runs of spaces in quotes.
61
# Could crunch further based on places where whitespace is optional.
66
# Write out a C array of the characters.
67
my $length = length $text;
68
print HEADER "extern const char ${name}UserAgentStyleSheet[${length}];\n";
69
print OUT "extern const char ${name}UserAgentStyleSheet[${length}] = {\n";
71
while ($i < $length) {
74
while ($j < 16 && $i < $length) {
75
print OUT ", " unless $j == 0;
76
print OUT ord substr $text, $i, 1;
80
print OUT "," unless $i == $length;