| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 '''Emits a webkit_version.h header file with | |
| 7 WEBKIT_MAJOR_VERSION and WEBKIT_MINOR_VERSION macros. | |
| 8 ''' | |
| 9 | |
| 10 import os | |
| 11 import re | |
| 12 import sys | |
| 13 | |
| 14 # Get the full path of the current script which would be something like | |
| 15 # src/webkit/build/webkit_version.py and navigate backwards twice to strip the | |
| 16 # last two path components to get to the srcroot. | |
| 17 # This is to ensure that the script can load the lastchange module by updating | |
| 18 # the sys.path variable with the desired location. | |
| 19 path = os.path.dirname(os.path.realpath(__file__)) | |
| 20 path = os.path.dirname(os.path.dirname(path)) | |
| 21 path = os.path.join(path, 'build', 'util') | |
| 22 | |
| 23 sys.path.insert(0, path) | |
| 24 import lastchange | |
| 25 | |
| 26 | |
| 27 def GetWebKitRevision(webkit_src_dir): | |
| 28 """Get the WebKit revision, in the form 'trunk@1234'.""" | |
| 29 | |
| 30 version_info = lastchange.FetchVersionInfo( | |
| 31 default_lastchange=None, | |
| 32 directory=webkit_src_dir, | |
| 33 directory_regex_prior_to_src_url='webkit') | |
| 34 | |
| 35 if version_info.url == None: | |
| 36 version_info.url = 'Unknown URL' | |
| 37 version_info.url = version_info.url.strip('/') | |
| 38 | |
| 39 if version_info.revision == None: | |
| 40 version_info.revision = '0' | |
| 41 | |
| 42 return "%s@%s" % (version_info.url, version_info.revision) | |
| 43 | |
| 44 | |
| 45 def EmitVersionHeader(webkit_src_dir, output_dir): | |
| 46 '''Emit a header file that we can use from within webkit_glue.cc.''' | |
| 47 | |
| 48 # These are hard-coded from when we forked Blink. Presumably these | |
| 49 # would be better in a header somewhere. | |
| 50 major, minor = (537, 36) | |
| 51 webkit_revision = GetWebKitRevision(webkit_src_dir) | |
| 52 | |
| 53 fname = os.path.join(output_dir, "webkit_version.h") | |
| 54 f = open(fname, 'wb') | |
| 55 template = """// webkit_version.h | |
| 56 // generated from %s | |
| 57 | |
| 58 #define WEBKIT_VERSION_MAJOR %d | |
| 59 #define WEBKIT_VERSION_MINOR %d | |
| 60 #define WEBKIT_SVN_REVISION "%s" | |
| 61 """ % (webkit_src_dir, major, minor, webkit_revision) | |
| 62 f.write(template) | |
| 63 f.close() | |
| 64 return 0 | |
| 65 | |
| 66 | |
| 67 def main(): | |
| 68 return EmitVersionHeader(*sys.argv[1:]) | |
| 69 | |
| 70 | |
| 71 if __name__ == "__main__": | |
| 72 sys.exit(main()) | |
| OLD | NEW |