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
# 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
# found in the LICENSE file.
'''Reads the Webkit Version.xcconfig file looking for MAJOR_VERSION and
MINOR_VERSION, emitting them into a webkit_version.h header file as
'''Emits a webkit_version.h header file with
WEBKIT_MAJOR_VERSION and WEBKIT_MINOR_VERSION macros.
'''
......@@ -24,42 +23,13 @@ path = os.path.join(path, 'build', 'util')
sys.path.insert(0, path)
import lastchange
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 GetWebKitRevision(webkit_dir, version_file):
def GetWebKitRevision(webkit_src_dir):
"""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(
default_lastchange=None,
directory=os.path.join(webkit_dir, version_file_dir),
directory=webkit_src_dir,
directory_regex_prior_to_src_url='webkit')
if version_info.url == None:
......@@ -72,18 +42,13 @@ def GetWebKitRevision(webkit_dir, version_file):
return "%s@%s" % (version_info.url, version_info.revision)
def EmitVersionHeader(webkit_dir, version_file, output_dir):
'''Given webkit's version file, emit a header file that we can use from
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))
def EmitVersionHeader(webkit_src_dir, output_dir):
'''Emit a header file that we can use from within webkit_glue.cc.'''
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")
f = open(fname, 'wb')
......@@ -93,7 +58,7 @@ def EmitVersionHeader(webkit_dir, version_file, output_dir):
#define WEBKIT_VERSION_MAJOR %d
#define WEBKIT_VERSION_MINOR %d
#define WEBKIT_SVN_REVISION "%s"
""" % (version_file, major, minor, webkit_revision)
""" % (webkit_src_dir, major, minor, webkit_revision)
f.write(template)
f.close()
return 0
......
......@@ -4,13 +4,7 @@
{
'variables': {
'conditions': [
['inside_chromium_build==0', {
'webkit_src_dir': '../../../../..',
},{
'webkit_src_dir': '../../third_party/WebKit',
}],
],
'webkit_src_dir': '../../third_party/WebKit/Source',
},
'targets': [
{
......@@ -59,21 +53,18 @@
'action_name': 'webkit_version',
'inputs': [
'<(script)',
'<(webkit_src_dir)<(version_file)',
'../../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': [
'<(SHARED_INTERMEDIATE_DIR)/webkit_version.h',
],
'action': ['python', '<(script)', '<(webkit_src_dir)',
'<(version_file)', '<(SHARED_INTERMEDIATE_DIR)'],
'<(SHARED_INTERMEDIATE_DIR)'],
'variables': {
'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