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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/util/lastchange.py ('k') | webkit/glue/user_agent.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 '''Reads the Webkit Version.xcconfig file looking for MAJOR_VERSION and 6 '''Reads the Webkit Version.xcconfig file looking for MAJOR_VERSION and
7 MINOR_VERSION, emitting them into a webkit_version.h header file as 7 MINOR_VERSION, emitting them into a webkit_version.h header file as
8 WEBKIT_MAJOR_VERSION and WEBKIT_MINOR_VERSION macros. 8 WEBKIT_MAJOR_VERSION and WEBKIT_MINOR_VERSION macros.
9 ''' 9 '''
10 10
11 import os 11 import os
12 import re 12 import re
13 import sys 13 import sys
14 14
15 sys.path.insert(0, '../../build/util')
16 import lastchange
17
15 def ReadVersionFile(fname): 18 def ReadVersionFile(fname):
16 '''Reads the Webkit Version.xcconfig file looking for MAJOR_VERSION and 19 '''Reads the Webkit Version.xcconfig file looking for MAJOR_VERSION and
17 MINOR_VERSION. This function doesn't attempt to support the full syntax 20 MINOR_VERSION. This function doesn't attempt to support the full syntax
18 of xcconfig files.''' 21 of xcconfig files.'''
19 re_major = re.compile('MAJOR_VERSION\s*=\s*(\d+).*') 22 re_major = re.compile('MAJOR_VERSION\s*=\s*(\d+).*')
20 re_minor = re.compile('MINOR_VERSION\s*=\s*(\d+).*') 23 re_minor = re.compile('MINOR_VERSION\s*=\s*(\d+).*')
21 major = -1 24 major = -1
22 minor = -1 25 minor = -1
23 f = open(fname, 'rb') 26 f = open(fname, 'rb')
24 line = "not empty" 27 line = "not empty"
25 while line and not (major >= 0 and minor >= 0): 28 while line and not (major >= 0 and minor >= 0):
26 line = f.readline() 29 line = f.readline()
27 if major == -1: 30 if major == -1:
28 match = re_major.match(line) 31 match = re_major.match(line)
29 if match: 32 if match:
30 major = int(match.group(1)) 33 major = int(match.group(1))
31 continue 34 continue
32 if minor == -1: 35 if minor == -1:
33 match = re_minor.match(line) 36 match = re_minor.match(line)
34 if match: 37 if match:
35 minor = int(match.group(1)) 38 minor = int(match.group(1))
36 continue 39 continue
37 assert(major >= 0 and minor >= 0) 40 assert(major >= 0 and minor >= 0)
38 return (major, minor) 41 return (major, minor)
39 42
40 def EmitVersionHeader(version_file, output_dir): 43 def GetWebKitRevision(webkit_dir, version_file):
44 """Get the WebKit revision, in the form 'trunk@1234'."""
45
46 # "svn info" tells us what we want, but third_party/WebKit does *not*
47 # point at the upstream repo. So instead we run svn info on the directory
48 # containing the versioning file (which is some subdirectory of WebKit),
49 # then strip that path back off of the resulting URL.
50 version_file_dir = os.path.dirname(version_file)
51 version_info = lastchange.FetchVersionInfo(
52 default_lastchange=None,
53 directory=os.path.join(webkit_dir, version_file_dir))
54
55 # Now compute the real WebKit URL by stripping off the version file
56 # directory from the URL we get out of version_info.
57 # Further, we want to strip off the "http://svn..." from the left.
58 # This is the root URL from the repository.
59 assert version_info.url.startswith(version_info.root)
60 assert version_info.url.endswith(version_file_dir)
61 webkit_url = version_info.url[len(version_info.root):-len(version_file_dir)]
62 webkit_url = webkit_url.strip('/')
63
64 return "%s@%s" % (webkit_url, version_info.revision)
65
66
67 def EmitVersionHeader(webkit_dir, version_file, output_dir):
41 '''Given webkit's version file, emit a header file that we can use from 68 '''Given webkit's version file, emit a header file that we can use from
42 within webkit_glue.cc. 69 within webkit_glue.cc.
43 ''' 70 '''
44 (major, minor) = ReadVersionFile(version_file) 71
72 # See .gypi file for discussion of this workaround for the version file.
73 assert version_file[0] == '/'
74 version_file = version_file[1:]
75
76 major, minor = ReadVersionFile(os.path.join(webkit_dir, version_file))
77
78 webkit_revision = GetWebKitRevision(webkit_dir, version_file)
79
45 fname = os.path.join(output_dir, "webkit_version.h") 80 fname = os.path.join(output_dir, "webkit_version.h")
46 f = open(fname, 'wb') 81 f = open(fname, 'wb')
47 template = """// webkit_version.h 82 template = """// webkit_version.h
48 // generated from %s 83 // generated from %s
49 84
50 #define WEBKIT_VERSION_MAJOR %d 85 #define WEBKIT_VERSION_MAJOR %d
51 #define WEBKIT_VERSION_MINOR %d 86 #define WEBKIT_VERSION_MINOR %d
52 """ % (version_file, major, minor) 87 #define WEBKIT_SVN_REVISION "%s"
88 """ % (version_file, major, minor, webkit_revision)
53 f.write(template) 89 f.write(template)
54 f.close() 90 f.close()
55 91
56 def main(): 92 def main():
57 EmitVersionHeader(sys.argv[1], sys.argv[2]) 93 EmitVersionHeader(*sys.argv[1:])
58 94
59 95
60 if __name__ == "__main__": 96 if __name__ == "__main__":
61 main() 97 main()
62 98
63 99
OLDNEW
« 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