diff --git a/tools/release/backport_node.py b/tools/release/backport_node.py index 61a931aa03..862da82b1e 100755 --- a/tools/release/backport_node.py +++ b/tools/release/backport_node.py @@ -14,7 +14,8 @@ Usage: $ backport_node.py This will apply the commit to /deps/v8 and create a commit in - the Node.js checkout and copy over the original commit message. + the Node.js checkout, increment patch level, and copy over the original + commit message. Optional flags: --no-review Run `gclient sync` on the V8 checkout before updating. @@ -23,9 +24,19 @@ Optional flags: import argparse import os import subprocess +import re import sys +from common_includes import * + TARGET_SUBDIR = os.path.join("deps", "v8") +VERSION_FILE = os.path.join("include", "v8-version.h") +VERSION_PATTERN = r'(?<=#define V8_PATCH_LEVEL )\d+' + +def Clean(options): + print ">> Cleaning target directory." + subprocess.check_call(["git", "clean", "-fd"], + cwd = os.path.join(options.node_path, TARGET_SUBDIR)) def CherryPick(options): print ">> Apply patch." @@ -42,6 +53,16 @@ def CherryPick(options): while raw_input("[RESOLVED]") != "RESOLVED": print ">> You need to type RESOLVED" +def UpdateVersion(options): + print ">> Increment patch level." + version_file = os.path.join(options.node_path, TARGET_SUBDIR, VERSION_FILE) + text = FileToText(version_file) + def increment(match): + patch = int(match.group(0)) + return str(patch + 1) + text = re.sub(VERSION_PATTERN, increment, text, flags=re.MULTILINE) + TextToFile(text, version_file) + def CreateCommit(options): print ">> Creating commit." # Find short hash from source. @@ -84,8 +105,10 @@ def ParseOptions(args): def Main(args): options = ParseOptions(args) + Clean(options) try: CherryPick(options) + UpdateVersion(options) CreateCommit(options) except: print ">> Failed. Resetting." diff --git a/tools/release/test_backport_node.py b/tools/release/test_backport_node.py index 99aeccfe5d..a2be9cf33d 100755 --- a/tools/release/test_backport_node.py +++ b/tools/release/test_backport_node.py @@ -10,6 +10,7 @@ import sys import tempfile import unittest +from common_includes import FileToText import backport_node # Base paths. @@ -62,5 +63,9 @@ class TestUpdateNode(unittest.TestCase): ) self.assertIn('+zonk', gitlog.strip()) + # Check version. + version_file = os.path.join(node_cwd, "deps", "v8", "include", "v8-version.h") + self.assertIn('#define V8_PATCH_LEVEL 4322', FileToText(version_file)) + if __name__ == "__main__": unittest.main() diff --git a/tools/release/testdata/node/deps/v8/include/v8-version.h b/tools/release/testdata/node/deps/v8/include/v8-version.h new file mode 100644 index 0000000000..fe8b2712e3 --- /dev/null +++ b/tools/release/testdata/node/deps/v8/include/v8-version.h @@ -0,0 +1,20 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8_INCLUDE_VERSION_H_ // V8_VERSION_H_ conflicts with src/version.h +#define V8_INCLUDE_VERSION_H_ + +// These macros define the version number for the current version. +// NOTE these macros are used by some of the tool scripts and the build +// system so their names cannot be changed without changing the scripts. +#define V8_MAJOR_VERSION 1 +#define V8_MINOR_VERSION 2 +#define V8_BUILD_NUMBER 3 +#define V8_PATCH_LEVEL 4321 + +// Use 1 for candidates and 0 otherwise. +// (Boolean macro values are not supported by all preprocessors.) +#define V8_IS_CANDIDATE_VERSION 0 + +#endif // V8_INCLUDE_VERSION_H_ diff --git a/tools/verify_source_deps.py b/tools/verify_source_deps.py index b5c166647f..e3a39c1d17 100755 --- a/tools/verify_source_deps.py +++ b/tools/verify_source_deps.py @@ -56,6 +56,7 @@ ALL_GYP_PREFIXES = [ GYP_UNSUPPORTED_FEATURES = [ 'gcmole', 'setup-isolate-deserialize.cc', + 'v8-version.h' ] GN_FILES = [ @@ -80,6 +81,7 @@ GN_UNSUPPORTED_FEATURES = [ 'qnx', 'solaris', 'vtune', + 'v8-version.h', 'x87', ]