3 # Based on make_names.pl
5 # Copyright (C) 2005, 2006, 2007, 2009 Apple Inc. All rights reserved.
6 # Copyright (C) 2009, Julien Chaffraix <jchaffraix@webkit.org>
7 # Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
8 # Copyright (C) 2009 Robert Hogan <robert@roberthogan.net>
10 # Redistribution and use in source and binary forms, with or without
11 # modification, are permitted provided that the following conditions
14 # 1. Redistributions of source code must retain the above copyright
15 # notice, this list of conditions and the following disclaimer.
16 # 2. Redistributions in binary form must reproduce the above copyright
17 # notice, this list of conditions and the following disclaimer in the
18 # documentation and/or other materials provided with the distribution.
19 # 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
20 # its contributors may be used to endorse or promote products derived
21 # from this software without specific prior written permission.
23 # THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
24 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 # DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
27 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 # This script reads Version.xcconfig and returns either or both of the major and minor
35 # WebKit version numbers. It is currently used by WebKit.pri.
43 my $usage = "generate-webkitversion --config WebKit/mac/Configurations/Version.xcconfig --outputDir <outputdir>";
45 my $major_version = "";
46 my $minor_version = "";
47 # The appropriate Apple-maintained Version.xcconfig file for WebKit version information is in WebKit/mac/Configurations/.
48 my $configFile = "./Soure/WebKit/mac/Configurations/Version.xcconfig";
51 GetOptions('config=s' => \$configFile,
52 'outputDir=s' => \$outputDir);
54 die "You must specify a --config <file> " unless (length($configFile));
55 die "You must specify a --outputDir <outputdir> " unless (length($outputDir));
57 die "./Source/WebKit/mac/Configurations/Version.xcconfig does not exist: use --config <file> to specify its correct location." unless (-e $configFile);
58 die "$outputDir/ does not exist: use --outputDir <directory> to specify the location of an output directory that exists" unless (-e "$outputDir");
60 unless (open INPUT, "<", $configFile) { print STDERR "File does not exist: $configFile\n";}
61 while (my $line = <INPUT>) {
63 if ($line =~ /^MAJOR_VERSION\s+=\s+\d+;/) {
64 $line =~ s/^(MAJOR_VERSION)\s+(=)\s+(\d+);/$3/;
65 $major_version = $line;
67 if ($line =~ /^MINOR_VERSION\s+=\s+\d+;/) {
68 $line =~ s/^(MINOR_VERSION)\s+(=)\s+(\d+);/$3/;
69 $minor_version = $line;
73 $major_version = "531" unless (length($major_version));
74 $minor_version = "3" unless (length($minor_version));
76 my $webKitVersionPath = "$outputDir/WebKitVersion.h";
78 printWebKitVersionHeaderFile("$webKitVersionPath");
80 sub printLicenseHeader
84 * THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT.
87 * Copyright (C) 2009 Apple Computer, Inc. All rights reserved.
89 * Redistribution and use in source and binary forms, with or without
90 * modification, are permitted provided that the following conditions
92 * 1. Redistributions of source code must retain the above copyright
93 * notice, this list of conditions and the following disclaimer.
94 * 2. Redistributions in binary form must reproduce the above copyright
95 * notice, this list of conditions and the following disclaimer in the
96 * documentation and/or other materials provided with the distribution.
98 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
99 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
100 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
101 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
102 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
103 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
104 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
105 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
106 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
107 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
108 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
115 sub printWebKitVersionHeaderFile
117 my $headerPath = shift;
119 open F, ">$headerPath";
121 printLicenseHeader($F);
123 print F "#ifndef WebKitVersion_h\n";
124 print F "#define WebKitVersion_h\n\n";
126 print F "#define WEBKIT_MAJOR_VERSION $major_version\n";
127 print F "#define WEBKIT_MINOR_VERSION $minor_version\n\n";
129 print F "#endif //WebKitVersion_h\n";