[tools] backport_node.py increments V8 version in target.

R=franzih@chromium.org, machenbach@chromium.org

Review-Url: https://codereview.chromium.org/2846883002
Cr-Commit-Position: refs/heads/master@{#44943}
This commit is contained in:
yangguo 2017-04-27 07:50:10 -07:00 committed by Commit bot
parent 1dfcc4b687
commit 2b7a431ea3
4 changed files with 51 additions and 1 deletions

View File

@ -14,7 +14,8 @@ Usage:
$ backport_node.py <path_to_v8> <path_to_node> <commit-hash>
This will apply the commit to <path_to_node>/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."

View File

@ -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()

View File

@ -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_

View File

@ -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',
]