Commit d6c32cf0 authored by abarth@chromium.org's avatar abarth@chromium.org

Remove Chromium dependency on WebCore/Configurations/Version.xcconfig file.

Review URL: https://codereview.chromium.org/14096010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194533 0039d316-1c4b-4281-b951-d872f2087c98
parent d29d61b2
#!/usr/bin/env python #!/usr/bin/env python
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
'''Reads the Webkit Version.xcconfig file looking for MAJOR_VERSION and '''Emits a webkit_version.h header file with
MINOR_VERSION, emitting them into a webkit_version.h header file as
WEBKIT_MAJOR_VERSION and WEBKIT_MINOR_VERSION macros. WEBKIT_MAJOR_VERSION and WEBKIT_MINOR_VERSION macros.
''' '''
...@@ -24,42 +23,13 @@ path = os.path.join(path, 'build', 'util') ...@@ -24,42 +23,13 @@ path = os.path.join(path, 'build', 'util')
sys.path.insert(0, path) sys.path.insert(0, path)
import lastchange import lastchange
def ReadVersionFile(fname):
'''Reads the Webkit Version.xcconfig file looking for MAJOR_VERSION and def GetWebKitRevision(webkit_src_dir):
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 GetWebKitRevision(webkit_dir, version_file):
"""Get the WebKit revision, in the form 'trunk@1234'.""" """Get the WebKit revision, in the form 'trunk@1234'."""
# "svn info" tells us what we want, but third_party/WebKit does *not*
# point at the upstream repo. So instead we run svn info on the directory
# containing the versioning file (which is some subdirectory of WebKit).
version_file_dir = os.path.dirname(version_file)
version_info = lastchange.FetchVersionInfo( version_info = lastchange.FetchVersionInfo(
default_lastchange=None, default_lastchange=None,
directory=os.path.join(webkit_dir, version_file_dir), directory=webkit_src_dir,
directory_regex_prior_to_src_url='webkit') directory_regex_prior_to_src_url='webkit')
if version_info.url == None: if version_info.url == None:
...@@ -72,18 +42,13 @@ def GetWebKitRevision(webkit_dir, version_file): ...@@ -72,18 +42,13 @@ def GetWebKitRevision(webkit_dir, version_file):
return "%s@%s" % (version_info.url, version_info.revision) return "%s@%s" % (version_info.url, version_info.revision)
def EmitVersionHeader(webkit_dir, version_file, output_dir): def EmitVersionHeader(webkit_src_dir, output_dir):
'''Given webkit's version file, emit a header file that we can use from '''Emit a header file that we can use from within webkit_glue.cc.'''
within webkit_glue.cc.
'''
# See .gypi file for discussion of this workaround for the version file.
assert version_file[0] == '/'
version_file = version_file[1:]
major, minor = ReadVersionFile(os.path.join(webkit_dir, version_file))
webkit_revision = GetWebKitRevision(webkit_dir, version_file) # These are hard-coded from when we forked Blink. Presumably these
# would be better in a header somewhere.
major, minor = (537, 36)
webkit_revision = GetWebKitRevision(webkit_src_dir)
fname = os.path.join(output_dir, "webkit_version.h") fname = os.path.join(output_dir, "webkit_version.h")
f = open(fname, 'wb') f = open(fname, 'wb')
...@@ -93,7 +58,7 @@ def EmitVersionHeader(webkit_dir, version_file, output_dir): ...@@ -93,7 +58,7 @@ def EmitVersionHeader(webkit_dir, version_file, output_dir):
#define WEBKIT_VERSION_MAJOR %d #define WEBKIT_VERSION_MAJOR %d
#define WEBKIT_VERSION_MINOR %d #define WEBKIT_VERSION_MINOR %d
#define WEBKIT_SVN_REVISION "%s" #define WEBKIT_SVN_REVISION "%s"
""" % (version_file, major, minor, webkit_revision) """ % (webkit_src_dir, major, minor, webkit_revision)
f.write(template) f.write(template)
f.close() f.close()
return 0 return 0
......
...@@ -4,13 +4,7 @@ ...@@ -4,13 +4,7 @@
{ {
'variables': { 'variables': {
'conditions': [ 'webkit_src_dir': '../../third_party/WebKit/Source',
['inside_chromium_build==0', {
'webkit_src_dir': '../../../../..',
},{
'webkit_src_dir': '../../third_party/WebKit',
}],
],
}, },
'targets': [ 'targets': [
{ {
...@@ -59,21 +53,18 @@ ...@@ -59,21 +53,18 @@
'action_name': 'webkit_version', 'action_name': 'webkit_version',
'inputs': [ 'inputs': [
'<(script)', '<(script)',
'<(webkit_src_dir)<(version_file)',
'../../build/util/lastchange.py', # Used by the script. '../../build/util/lastchange.py', # Used by the script.
# This depends on the svn revision of webkit_src_dir but does
# not list it as a dependency. Incremental builds will have
# the wrong WEBKIT_SVN_REVISION.
], ],
'outputs': [ 'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/webkit_version.h', '<(SHARED_INTERMEDIATE_DIR)/webkit_version.h',
], ],
'action': ['python', '<(script)', '<(webkit_src_dir)', 'action': ['python', '<(script)', '<(webkit_src_dir)',
'<(version_file)', '<(SHARED_INTERMEDIATE_DIR)'], '<(SHARED_INTERMEDIATE_DIR)'],
'variables': { 'variables': {
'script': '../build/webkit_version.py', 'script': '../build/webkit_version.py',
# version_file is a relative path from |webkit_src_dir| to
# the version file. But gyp will eat the variable unless
# it looks like an absolute path, so write it like one and
# then use it carefully above.
'version_file': '/Source/WebCore/Configurations/Version.xcconfig',
}, },
}, },
], ],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment