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

Side by Side Diff: tools/push-to-trunk/generate_version.py

Issue 850263002: Revert of Auto-generate v8 version based on tags. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « tools/gyp/v8.gyp ('k') | no next file » | 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/env python 1 #!/usr/bin/env python
2 # Copyright 2014 the V8 project authors. All rights reserved. 2 # Copyright 2014 the V8 project 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 """ 6 """
7 Script to set v8's version file to the version given by the latest tag. 7 Script to set v8's version file to the version given by the latest tag.
8 """ 8 """
9 9
10 10
11 import os 11 import os
12 import re 12 import re
13 import subprocess 13 import subprocess
14 import sys 14 import sys
15 15
16 16
17 CWD = os.path.abspath( 17 CWD = os.path.abspath(
18 os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) 18 os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
19 VERSION_CC = os.path.join(CWD, "src", "version.cc") 19 VERSION_CC = os.path.join(CWD, "src", "version.cc")
20 20
21 def main(): 21 def main():
22 if len(sys.argv) != 2:
23 print "Error: Specify the output file path for version.cc"
24 return 1
25 version_out = sys.argv[1]
26 assert os.path.exists(os.path.dirname(version_out))
27
28 tag = subprocess.check_output( 22 tag = subprocess.check_output(
29 "git describe --tags", 23 "git describe --tags",
30 shell=True, 24 shell=True,
31 cwd=CWD, 25 cwd=CWD,
32 ).strip() 26 ).strip()
33 assert tag 27 assert tag
34 28
35 # Check for commits not exactly matching a tag. Those are candidate builds 29 # Check for commits not exactly matching a tag. Those are candidate builds
36 # for the next version. The output has the form 30 # for the next version. The output has the form
37 # <tag name>-<n commits>-<hash>. 31 # <tag name>-<n commits>-<hash>.
(...skipping 11 matching lines...) Expand all
49 assert len(version_levels) == 4 43 assert len(version_levels) == 4
50 44
51 major, minor, build, patch = version_levels 45 major, minor, build, patch = version_levels
52 46
53 # Increment build level for candidate builds. 47 # Increment build level for candidate builds.
54 if candidate == "1": 48 if candidate == "1":
55 build = str(int(build) + 1) 49 build = str(int(build) + 1)
56 patch = "0" 50 patch = "0"
57 51
58 # Modify version.cc with the new values. 52 # Modify version.cc with the new values.
53 with open(VERSION_CC, "r") as f:
54 text = f.read()
59 output = [] 55 output = []
60 with open(VERSION_CC, "r") as f: 56 for line in text.split("\n"):
61 for line in f: 57 for definition, substitute in (
62 for definition, substitute in ( 58 ("MAJOR_VERSION", major),
63 ("MAJOR_VERSION", major), 59 ("MINOR_VERSION", minor),
64 ("MINOR_VERSION", minor), 60 ("BUILD_NUMBER", build),
65 ("BUILD_NUMBER", build), 61 ("PATCH_LEVEL", patch),
66 ("PATCH_LEVEL", patch), 62 ("IS_CANDIDATE_VERSION", candidate)):
67 ("IS_CANDIDATE_VERSION", candidate)): 63 if line.startswith("#define %s" % definition):
68 if line.startswith("#define %s" % definition): 64 line = re.sub("\d+$", substitute, line)
69 line = re.sub("\d+$", substitute, line) 65 output.append(line)
70 output.append(line) 66 with open(VERSION_CC, "w") as f:
71 with open(version_out, "w") as f: 67 f.write("\n".join(output))
72 f.write("".join(output))
73 68
74 # Log what was done. 69 # Log what was done.
75 candidate_txt = " (candidate)" if candidate == "1" else "" 70 candidate_txt = " (candidate)" if candidate == "1" else ""
76 patch_txt = ".%s" % patch if patch != "0" else "" 71 patch_txt = ".%s" % patch if patch != "0" else ""
77 version_txt = ("%s.%s.%s%s%s" % 72 version_txt = ("%s.%s.%s%s%s" %
78 (major, minor, build, patch_txt, candidate_txt)) 73 (major, minor, build, patch_txt, candidate_txt))
79 print "Modified version.cc. Set V8 version to %s" % version_txt 74 print "Modified version.cc. Set V8 version to %s" % version_txt
80 return 0 75 return 0
81 76
82 if __name__ == "__main__": 77 if __name__ == "__main__":
83 sys.exit(main()) 78 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/gyp/v8.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698