Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Unified Diff: webkit/build/webkit_version.py

Issue 6354014: webkit: expose webkit branch and revision number in about pages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready for commit Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/util/lastchange.py ('k') | webkit/glue/user_agent.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/build/webkit_version.py
diff --git a/webkit/build/webkit_version.py b/webkit/build/webkit_version.py
index 9f8fbabf89fa05d84955ffcebd8a5343a0dcbb8a..58110727fee9250058c4318e8f50eb402008f741 100755
--- a/webkit/build/webkit_version.py
+++ b/webkit/build/webkit_version.py
@@ -12,6 +12,9 @@ import os
import re
import sys
+sys.path.insert(0, '../../build/util')
+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
@@ -37,11 +40,43 @@ def ReadVersionFile(fname):
assert(major >= 0 and minor >= 0)
return (major, minor)
-def EmitVersionHeader(version_file, output_dir):
+def GetWebKitRevision(webkit_dir, version_file):
+ """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),
+ # then strip that path back off of the resulting URL.
+ version_file_dir = os.path.dirname(version_file)
+ version_info = lastchange.FetchVersionInfo(
+ default_lastchange=None,
+ directory=os.path.join(webkit_dir, version_file_dir))
+
+ # Now compute the real WebKit URL by stripping off the version file
+ # directory from the URL we get out of version_info.
+ # Further, we want to strip off the "http://svn..." from the left.
+ # This is the root URL from the repository.
+ assert version_info.url.startswith(version_info.root)
+ assert version_info.url.endswith(version_file_dir)
+ webkit_url = version_info.url[len(version_info.root):-len(version_file_dir)]
+ webkit_url = webkit_url.strip('/')
+
+ return "%s@%s" % (webkit_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.
'''
- (major, minor) = ReadVersionFile(version_file)
+
+ # 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)
+
fname = os.path.join(output_dir, "webkit_version.h")
f = open(fname, 'wb')
template = """// webkit_version.h
@@ -49,12 +84,13 @@ def EmitVersionHeader(version_file, output_dir):
#define WEBKIT_VERSION_MAJOR %d
#define WEBKIT_VERSION_MINOR %d
-""" % (version_file, major, minor)
+#define WEBKIT_SVN_REVISION "%s"
+""" % (version_file, major, minor, webkit_revision)
f.write(template)
f.close()
def main():
- EmitVersionHeader(sys.argv[1], sys.argv[2])
+ EmitVersionHeader(*sys.argv[1:])
if __name__ == "__main__":
« no previous file with comments | « build/util/lastchange.py ('k') | webkit/glue/user_agent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698