summaryrefslogtreecommitdiff
blob: a6e271b479d9b89601dbc2acb0632f9d2b6f8726 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/python2
# Copyright 2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

"""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)