diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-04 20:03:50 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-04 20:03:50 +0000 |
commit | 467d8a78689a19aaa96c6700eb02dd94cac5eae1 (patch) | |
tree | 43f56d82d54fadefff979dcb5ba74c9a09cb2a4c /webkit | |
parent | 856ac4b39c729d184511244ebe0349e99e89879e (diff) | |
download | chromium_src-467d8a78689a19aaa96c6700eb02dd94cac5eae1.zip chromium_src-467d8a78689a19aaa96c6700eb02dd94cac5eae1.tar.gz chromium_src-467d8a78689a19aaa96c6700eb02dd94cac5eae1.tar.bz2 |
Pull the major and minor webkit version numbers from WebCore/Configurations/Version.xcconfig and generate a header file that allows us to keep our user agent info up to date.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@334 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/build/WebCore/WebCore.vcproj | 31 | ||||
-rw-r--r-- | webkit/build/webkit_version.py | 88 | ||||
-rw-r--r-- | webkit/build/webkit_version.rules | 18 | ||||
-rw-r--r-- | webkit/glue/webkit_glue.cc | 16 | ||||
-rw-r--r-- | webkit/glue/webkit_glue.h | 3 | ||||
-rw-r--r-- | webkit/webkit.sln | 1 | ||||
-rw-r--r-- | webkit/webkit_kjs.sln | 1 |
7 files changed, 155 insertions, 3 deletions
diff --git a/webkit/build/WebCore/WebCore.vcproj b/webkit/build/WebCore/WebCore.vcproj index 0484a7a..3340c09 100644 --- a/webkit/build/WebCore/WebCore.vcproj +++ b/webkit/build/WebCore/WebCore.vcproj @@ -13,6 +13,9 @@ /> </Platforms> <ToolFiles> + <ToolFile + RelativePath="..\webkit_version.rules" + /> </ToolFiles> <Configurations> <Configuration @@ -27,6 +30,9 @@ Name="VCCustomBuildTool" /> <Tool + Name="WebKitVersion" + /> + <Tool Name="VCXMLDataGeneratorTool" /> <Tool @@ -78,6 +84,9 @@ Name="VCCustomBuildTool" /> <Tool + Name="WebKitVersion" + /> + <Tool Name="VCXMLDataGeneratorTool" /> <Tool @@ -5753,6 +5762,28 @@ > </File> </Filter> + <Filter + Name="version" + > + <File + RelativePath="..\..\..\third_party\WebKit\WebCore\Configurations\Version.xcconfig" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="WebKitVersion" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="WebKitVersion" + /> + </FileConfiguration> + </File> + </Filter> </Files> <Globals> </Globals> diff --git a/webkit/build/webkit_version.py b/webkit/build/webkit_version.py new file mode 100644 index 0000000..52c0212 --- /dev/null +++ b/webkit/build/webkit_version.py @@ -0,0 +1,88 @@ +#!/usr/bin/python +# Copyright 2008, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +'''Reads the Webkit Version.xcconfig file looking for MAJOR_VERSION and +MINOR_VERSION, emitting them into a webkit_version.h header file as +WEBKIT_MAJOR_VERSION and WEBKIT_MINOR_VERSION macros. +''' + +import os +import re +import sys + +def ReadVersionFile(fname): + '''Reads the Webkit Version.xcconfig file looking for MAJOR_VERSION and + MINOR_VERSION. This function doesn't attempt to support the full syntax + of xcconfig files.''' + re_major = re.compile('MAJOR_VERSION\s*=\s*(\d+).*') + re_minor = re.compile('MINOR_VERSION\s*=\s*(\d+).*') + major = -1 + minor = -1 + f = open(fname, 'rb') + line = "not empty" + while line and not (major >= 0 and minor >= 0): + line = f.readline() + if major == -1: + match = re_major.match(line) + if match: + major = int(match.group(1)) + continue + if minor == -1: + match = re_minor.match(line) + if match: + minor = int(match.group(1)) + continue + assert(major >= 0 and minor >= 0) + return (major, minor) + +def EmitVersionHeader(version_file, output_dir): + '''Given webkit's version file, emit a header file that we can use from + within webkit_glue.cc. + ''' + (major, minor) = ReadVersionFile(version_file) + fname = os.path.join(output_dir, "webkit_version.h") + f = open(fname, 'wb') + template = """// webkit_version.h +// generated from %s + +#define WEBKIT_VERSION_MAJOR %d +#define WEBKIT_VERSION_MINOR %d +""" % (version_file, major, minor) + f.write(template) + f.close() + +def main(): + EmitVersionHeader(sys.argv[1], sys.argv[2]) + + +if __name__ == "__main__": + main() + +
\ No newline at end of file diff --git a/webkit/build/webkit_version.rules b/webkit/build/webkit_version.rules new file mode 100644 index 0000000..94e11e8 --- /dev/null +++ b/webkit/build/webkit_version.rules @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<VisualStudioToolFile + Name="WebKit Version" + Version="8.00" + > + <Rules> + <CustomBuildRule + Name="WebKitVersion" + DisplayName="WebKit Version" + CommandLine="$(SolutionDir)/../third_party/python_24/python.exe $(SolutionDir)/../webkit/build/webkit_version.py "$(InputPath)" "$(IntDir)"" + Outputs="$(IntDir)/webkit_version.h" + FileExtensions="*.xcconfig" + > + <Properties> + </Properties> + </CustomBuildRule> + </Rules> +</VisualStudioToolFile> diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc index 82de57d..ada0bdb 100644 --- a/webkit/glue/webkit_glue.cc +++ b/webkit/glue/webkit_glue.cc @@ -31,6 +31,7 @@ #include <mlang.h> #include "config.h" +#include "webkit_version.h" #pragma warning(push, 0) #include "BackForwardList.h" #include "Document.h" @@ -344,6 +345,10 @@ void NotifyFormStateChanged(const WebCore::Document* document) { delegate->OnNavStateChanged(webview); } +std::string GetWebKitVersion() { + return StringPrintf("%d.%d", WEBKIT_VERSION_MAJOR, WEBKIT_VERSION_MINOR); +} + const std::string& GetDefaultUserAgent() { static std::string user_agent; static bool generated_user_agent; @@ -368,11 +373,16 @@ const std::string& GetDefaultUserAgent() { // Derived from Safari's UA string. StringAppendF( &user_agent, - "Mozilla/5.0 (Windows; U; Windows NT %d.%d; en-US) AppleWebKit/525.13" - " (KHTML, like Gecko) %s Safari/525.13", + "Mozilla/5.0 (Windows; U; Windows NT %d.%d; en-US) AppleWebKit/%d.%d" + " (KHTML, like Gecko) %s Safari/%d.%d", info.dwMajorVersion, info.dwMinorVersion, - product.c_str()); + WEBKIT_VERSION_MAJOR, + WEBKIT_VERSION_MINOR, + product.c_str(), + WEBKIT_VERSION_MAJOR, + WEBKIT_VERSION_MINOR + ); generated_user_agent = true; } diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h index 80249fb..8306201 100644 --- a/webkit/glue/webkit_glue.h +++ b/webkit/glue/webkit_glue.h @@ -110,6 +110,9 @@ void DumpBackForwardList(WebView* view, void* previous_history_item, // Cleans up state left over from the previous test run. void ResetBeforeTestRun(WebView* view); +// Returns the WebKit version (major.minor). +std::string GetWebKitVersion(); + // Returns the user agent. const std::string& GetDefaultUserAgent(); diff --git a/webkit/webkit.sln b/webkit/webkit.sln index 629191b..10994ed 100644 --- a/webkit/webkit.sln +++ b/webkit/webkit.sln @@ -4,6 +4,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dependencies", "dependencie EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Glue", "build\glue\glue.vcproj", "{C66B126D-0ECE-4CA2-B6DC-FA780AFBBF09}" ProjectSection(ProjectDependencies) = postProject + {1C16337B-ACF3-4D03-AA90-851C5B5EADA6} = {1C16337B-ACF3-4D03-AA90-851C5B5EADA6} {2E2D3301-2EC4-4C0F-B889-87073B30F673} = {2E2D3301-2EC4-4C0F-B889-87073B30F673} {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} = {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} {60B43839-95E6-4526-A661-209F16335E0E} = {60B43839-95E6-4526-A661-209F16335E0E} diff --git a/webkit/webkit_kjs.sln b/webkit/webkit_kjs.sln index 0a59487..efe57ff 100644 --- a/webkit/webkit_kjs.sln +++ b/webkit/webkit_kjs.sln @@ -4,6 +4,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dependencies", "dependencie EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Glue", "build\glue\glue.vcproj", "{C66B126D-0ECE-4CA2-B6DC-FA780AFBBF09}" ProjectSection(ProjectDependencies) = postProject + {1C16337B-ACF3-4D03-AA90-851C5B5EADA6} = {1C16337B-ACF3-4D03-AA90-851C5B5EADA6} {2BCD6193-D243-422C-BB1A-BC219BF147B3} = {2BCD6193-D243-422C-BB1A-BC219BF147B3} {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} = {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} {60B43839-95E6-4526-A661-209F16335E0E} = {60B43839-95E6-4526-A661-209F16335E0E} |