| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 42 major = int(match.group(1)) | 42 major = int(match.group(1)) |
| 43 continue | 43 continue |
| 44 if minor == -1: | 44 if minor == -1: |
| 45 match = re_minor.match(line) | 45 match = re_minor.match(line) |
| 46 if match: | 46 if match: |
| 47 minor = int(match.group(1)) | 47 minor = int(match.group(1)) |
| 48 continue | 48 continue |
| 49 assert(major >= 0 and minor >= 0) | 49 assert(major >= 0 and minor >= 0) |
| 50 return (major, minor) | 50 return (major, minor) |
| 51 | 51 |
| 52 |
| 52 def GetWebKitRevision(webkit_dir, version_file): | 53 def GetWebKitRevision(webkit_dir, version_file): |
| 53 """Get the WebKit revision, in the form 'trunk@1234'.""" | 54 """Get the WebKit revision, in the form 'trunk@1234'.""" |
| 54 | 55 |
| 55 # "svn info" tells us what we want, but third_party/WebKit does *not* | 56 # "svn info" tells us what we want, but third_party/WebKit does *not* |
| 56 # point at the upstream repo. So instead we run svn info on the directory | 57 # point at the upstream repo. So instead we run svn info on the directory |
| 57 # containing the versioning file (which is some subdirectory of WebKit). | 58 # containing the versioning file (which is some subdirectory of WebKit). |
| 58 version_file_dir = os.path.dirname(version_file) | 59 version_file_dir = os.path.dirname(version_file) |
| 59 version_info = lastchange.FetchVersionInfo( | 60 version_info = lastchange.FetchVersionInfo( |
| 60 default_lastchange=None, | 61 default_lastchange=None, |
| 61 directory=os.path.join(webkit_dir, version_file_dir), | 62 directory=os.path.join(webkit_dir, version_file_dir), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 88 f = open(fname, 'wb') | 89 f = open(fname, 'wb') |
| 89 template = """// webkit_version.h | 90 template = """// webkit_version.h |
| 90 // generated from %s | 91 // generated from %s |
| 91 | 92 |
| 92 #define WEBKIT_VERSION_MAJOR %d | 93 #define WEBKIT_VERSION_MAJOR %d |
| 93 #define WEBKIT_VERSION_MINOR %d | 94 #define WEBKIT_VERSION_MINOR %d |
| 94 #define WEBKIT_SVN_REVISION "%s" | 95 #define WEBKIT_SVN_REVISION "%s" |
| 95 """ % (version_file, major, minor, webkit_revision) | 96 """ % (version_file, major, minor, webkit_revision) |
| 96 f.write(template) | 97 f.write(template) |
| 97 f.close() | 98 f.close() |
| 99 return 0 |
| 100 |
| 98 | 101 |
| 99 def main(): | 102 def main(): |
| 100 EmitVersionHeader(*sys.argv[1:]) | 103 return EmitVersionHeader(*sys.argv[1:]) |
| 101 | 104 |
| 102 | 105 |
| 103 if __name__ == "__main__": | 106 if __name__ == "__main__": |
| 104 main() | 107 sys.exit(main()) |
| OLD | NEW |