diff options
author | 2010-11-29 09:12:20 +0100 | |
---|---|---|
committer | 2010-11-29 09:13:52 +0100 | |
commit | 7cf3e265b8bebfa2444ff0811cb789274ec0ffd7 (patch) | |
tree | 04efcd57d46b0f6c3a8e59aef9fb768a5135f33d | |
parent | Add setup.py. (diff) | |
download | chromium-tools-7cf3e265b8bebfa2444ff0811cb789274ec0ffd7.tar.gz chromium-tools-7cf3e265b8bebfa2444ff0811cb789274ec0ffd7.tar.bz2 chromium-tools-7cf3e265b8bebfa2444ff0811cb789274ec0ffd7.zip |
Add v8-extract-version.
-rw-r--r-- | setup.py | 2 | ||||
-rwxr-xr-x | v8-extract-version | 26 |
2 files changed, 27 insertions, 1 deletions
@@ -44,7 +44,7 @@ class my_install_scripts(install_scripts): setup( name="chromium-tools", version=get_version(), - scripts=["chromium-depot-tool", "v8-create-tarball"], + scripts=["chromium-depot-tool", "v8-create-tarball", "v8-extract-version"], cmdclass={ 'sdist': my_sdist, 'install_scripts': my_install_scripts, diff --git a/v8-extract-version b/v8-extract-version new file mode 100755 index 0000000..1979956 --- /dev/null +++ b/v8-extract-version @@ -0,0 +1,26 @@ +#!/usr/bin/python2 + +"""Extracts V8 version number based on given version.cc file.""" + +import re +import sys + +MAJOR_VERSION_PATTERN = re.compile(r"#define\s+MAJOR_VERSION\s+(.*)") +MINOR_VERSION_PATTERN = re.compile(r"#define\s+MINOR_VERSION\s+(.*)") +BUILD_NUMBER_PATTERN = re.compile(r"#define\s+BUILD_NUMBER\s+(.*)") +PATCH_LEVEL_PATTERN = re.compile(r"#define\s+PATCH_LEVEL\s+(.*)") + +patterns = [MAJOR_VERSION_PATTERN, + MINOR_VERSION_PATTERN, + BUILD_NUMBER_PATTERN, + PATCH_LEVEL_PATTERN] + +source = open(sys.argv[1]).read() +version_components = [] +for pattern in patterns: + version_components.append(pattern.search(source).group(1).strip()) + +if version_components[len(version_components) - 1] == '0': + version_components.pop() + +print '.'.join(version_components) |