Commit f534c933 authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

Remove outdated node scripts

R=petermarshall@chromium.org

Change-Id: Ib0cfb056ed328a4c6cb0851921f913613b3f1a51
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1591611Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61237}
parent b327a917
#!/usr/bin/env python
# Copyright 2017 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.
"""
Use this script to build libv8_monolith.a as dependency for Node.js
Required dependencies can be fetched with fetch_deps.py.
Usage: build_gn.py <Debug/Release> <v8-path> <build-path> [<build-flags>]...
Build flags are passed either as "strings" or numeric value. True/false
are represented as 1/0. E.g.
v8_promise_internal_field_count=2
target_cpu="x64"
v8_enable_disassembler=0
"""
import argparse
import os
import subprocess
import sys
import node_common
GN_ARGS = [
"v8_monolithic=true",
"is_component_build=false",
"v8_use_external_startup_data=false",
"use_custom_libcxx=false",
]
BUILD_TARGET = "v8_monolith"
def FindTargetOs(flags):
for flag in flags:
if flag.startswith("target_os="):
return flag[len("target_os="):].strip('"')
raise Exception('No target_os was set.')
def FindGn(options):
if options.host_os == "linux":
os_path = "linux64"
elif options.host_os == "mac":
os_path = "mac"
elif options.host_os == "win":
os_path = "win"
else:
raise "Operating system not supported by GN"
return os.path.join(options.v8_path, "buildtools", os_path, "gn")
def GenerateBuildFiles(options):
gn = FindGn(options)
gn_args = list(GN_ARGS)
target_os = FindTargetOs(options.flag)
if target_os != "win":
gn_args.append("use_sysroot=false")
for flag in options.flag:
flag = flag.replace("=1", "=true")
flag = flag.replace("=0", "=false")
flag = flag.replace("target_cpu=ia32", "target_cpu=\"x86\"")
gn_args.append(flag)
if options.mode == "Debug":
gn_args.append("is_debug=true")
else:
gn_args.append("is_debug=false")
flattened_args = ' '.join(gn_args)
if options.extra_gn_args:
flattened_args += ' ' + options.extra_gn_args
args = [gn, "gen", options.build_path, "-q", "--args=" + flattened_args]
subprocess.check_call(args)
def Build(options):
depot_tools = node_common.EnsureDepotTools(options.v8_path, False)
ninja = os.path.join(depot_tools, "ninja")
if sys.platform == 'win32':
# Required because there is an extension-less file called "ninja".
ninja += ".exe"
args = [ninja, "-C", options.build_path, BUILD_TARGET]
if options.max_load:
args += ["-l" + options.max_load]
if options.max_jobs:
args += ["-j" + options.max_jobs]
else:
with open(os.path.join(options.build_path, "args.gn")) as f:
if "use_goma = true" in f.read():
args += ["-j500"]
subprocess.check_call(args)
def ParseOptions(args):
parser = argparse.ArgumentParser(
description="Build %s with GN" % BUILD_TARGET)
parser.add_argument("--mode", help="Build mode (Release/Debug)")
parser.add_argument("--v8_path", help="Path to V8", required=True)
parser.add_argument("--build_path", help="Path to build result",
required=True)
parser.add_argument("--flag", help="Translate GYP flag to GN",
action="append")
parser.add_argument("--host_os", help="Current operating system")
parser.add_argument("--bundled-win-toolchain",
help="Value for DEPOT_TOOLS_WIN_TOOLCHAIN")
parser.add_argument("--bundled-win-toolchain-root",
help="Value for DEPOT_TOOLS_WIN_TOOLCHAIN_ROOT")
parser.add_argument("--depot-tools", help="Absolute path to depot_tools")
parser.add_argument("--extra-gn-args", help="Additional GN args")
parser.add_argument("--build", help="Run ninja as opposed to gn gen.",
action="store_true")
parser.add_argument("--max-jobs", help="ninja's -j parameter")
parser.add_argument("--max-load", help="ninja's -l parameter")
options = parser.parse_args(args)
options.build_path = os.path.abspath(options.build_path)
if not options.build:
assert options.host_os
assert options.mode == "Debug" or options.mode == "Release"
options.v8_path = os.path.abspath(options.v8_path)
assert os.path.isdir(options.v8_path)
return options
if __name__ == "__main__":
options = ParseOptions(sys.argv[1:])
# Build can result in running gn gen, so need to set environment variables
# for build as well as generate.
if options.bundled_win_toolchain:
os.environ['DEPOT_TOOLS_WIN_TOOLCHAIN'] = options.bundled_win_toolchain
if options.bundled_win_toolchain_root:
os.environ['DEPOT_TOOLS_WIN_TOOLCHAIN_ROOT'] = (
options.bundled_win_toolchain_root)
if options.depot_tools:
os.environ['PATH'] = (
options.depot_tools + os.path.pathsep + os.environ['PATH'])
if not options.build:
GenerateBuildFiles(options)
else:
Build(options)
#!/usr/bin/env python
# Copyright 2017 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.
import os
import shutil
import subprocess
import sys
import tempfile
import unittest
import update_node
# Base paths.
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
TEST_DATA = os.path.join(BASE_DIR, 'testdata')
# Expectations.
EXPECTED_GITIGNORE = """
/third_party/googletest/*
!/third_party/googletest/src
/third_party/googletest/src/*
!/third_party/googletest/src/googletest
/third_party/googletest/src/googletest/*
!/third_party/googletest/src/googletest/include
/third_party/googletest/src/googletest/include/*
!/third_party/googletest/src/googletest/include/gtest
/third_party/googletest/src/googletest/include/gtest/*
!/third_party/googletest/src/googletest/include/gtest/gtest_prod.h
!/third_party/jinja2
!/third_party/markupsafe
/unrelated
"""
EXPECTED_GIT_DIFF = """
create mode 100644 deps/v8/base/trace_event/common/common
rename deps/v8/baz/{delete_me => v8_new} (100%)
delete mode 100644 deps/v8/include/v8-version.h
rename deps/v8/{delete_me => new/v8_new} (100%)
create mode 100644 deps/v8/third_party/googletest/src/googletest/include/gtest/gtest_prod.h
create mode 100644 deps/v8/third_party/jinja2/jinja2
create mode 100644 deps/v8/third_party/markupsafe/markupsafe
create mode 100644 deps/v8/v8_new
"""
ADDED_FILES = [
'v8_new',
'new/v8_new',
'baz/v8_new',
'/third_party/googletest/src/googletest/include/gtest/gtest_new',
'/third_party/googletest/src/googletest/include/gtest/new/gtest_new',
'/third_party/googletest/src/googletest/include/gtest/baz/gtest_new',
'third_party/jinja2/jinja2',
'third_party/markupsafe/markupsafe'
]
REMOVED_FILES = [
'delete_me',
'baz/delete_me',
'testing/gtest/delete_me',
'testing/gtest/baz/delete_me',
]
def gitify(path):
files = os.listdir(path)
subprocess.check_call(['git', 'init'], cwd=path)
subprocess.check_call(['git', 'add'] + files, cwd=path)
subprocess.check_call(['git', 'commit', '-m', 'Initial'], cwd=path)
class TestUpdateNode(unittest.TestCase):
def setUp(self):
self.workdir = tempfile.mkdtemp(prefix='tmp_test_node_')
def tearDown(self):
shutil.rmtree(self.workdir)
def testUpdate(self):
v8_cwd = os.path.join(self.workdir, 'v8')
node_cwd = os.path.join(self.workdir, 'node')
# Set up V8 test fixture.
shutil.copytree(src=os.path.join(TEST_DATA, 'v8'), dst=v8_cwd)
gitify(v8_cwd)
for repository in update_node.SUB_REPOSITORIES:
gitify(os.path.join(v8_cwd, *repository))
# Set up node test fixture.
shutil.copytree(src=os.path.join(TEST_DATA, 'node'), dst=node_cwd)
gitify(os.path.join(node_cwd))
# Add a patch.
with open(os.path.join(v8_cwd, 'v8_foo'), 'w') as f:
f.write('zonk')
subprocess.check_call(['git', 'add', 'v8_foo'], cwd=v8_cwd)
# Run update script.
update_node.Main([v8_cwd, node_cwd, "--commit", "--with-patch"])
# Check expectations.
with open(os.path.join(node_cwd, 'deps', 'v8', '.gitignore')) as f:
actual_gitignore = f.read()
self.assertEquals(EXPECTED_GITIGNORE.strip(), actual_gitignore.strip())
for f in ADDED_FILES:
added_file = os.path.join(node_cwd, 'deps', 'v8', *f.split('/'))
self.assertTrue(os.path.exists(added_file))
for f in REMOVED_FILES:
removed_file = os.path.join(node_cwd, 'deps', 'v8', *f.split('/'))
self.assertFalse(os.path.exists(removed_file))
gitlog = subprocess.check_output(
['git', 'diff', 'master', '--summary'],
cwd=node_cwd,
)
self.assertEquals(EXPECTED_GIT_DIFF.strip(), gitlog.strip())
# Check patch.
gitlog = subprocess.check_output(
['git', 'diff', 'master', '--cached', '--', 'deps/v8/v8_foo'],
cwd=node_cwd,
)
self.assertIn('+zonk', gitlog.strip())
if __name__ == "__main__":
unittest.main()
/unrelated
/testing/gtest/*
!/testing/gtest/include
/testing/gtest/include/*
!/testing/gtest/include/gtest
/testing/gtest/include/gtest/*
!/testing/gtest/include/gtest/gtest_prod.h
// 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_
/unrelated
/third_party/jinja2
/third_party/markupsafe
#!/usr/bin/env python
# Copyright 2017 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.
"""
Use this script to update V8 in a Node.js checkout.
Requirements:
- Node.js checkout in which V8 should be updated.
- V8 checkout at the commit to which Node.js should be updated.
Usage:
$ update_node.py <path_to_v8> <path_to_node>
This will synchronize the content of <path_to_node>/deps/v8 with <path_to_v8>,
and a few V8 dependencies require in Node.js. It will also update .gitignore
appropriately.
Optional flags:
--gclient Run `gclient sync` on the V8 checkout before updating.
--commit Create commit with the updated V8 in the Node.js checkout.
--with-patch Also include currently staged files in the V8 checkout.
"""
# for py2/py3 compatibility
from __future__ import print_function
import argparse
import os
import shutil
import subprocess
import sys
import stat
import node_common
TARGET_SUBDIR = os.path.join("deps", "v8")
SUB_REPOSITORIES = [ ["base", "trace_event", "common"],
["third_party", "googletest", "src"] ]
DELETE_FROM_GITIGNORE = [ "/base",
"/third_party/googletest/src" ]
# Node.js requires only a single header file from gtest to build V8.
ADD_TO_GITIGNORE = [ "/third_party/googletest/*",
"!/third_party/googletest/BUILD.gn",
"!/third_party/googletest/src",
"/third_party/googletest/src/*",
"!/third_party/googletest/src/googletest",
"/third_party/googletest/src/googletest/*",
"!/third_party/googletest/src/googletest/include",
"/third_party/googletest/src/googletest/include/*",
"!/third_party/googletest/src/googletest/include/gtest",
"/third_party/googletest/src/googletest/include/gtest/*",
"!/third_party/googletest/src/googletest/include/gtest/gtest_prod.h" ]
# Node.js owns deps/v8/gypfiles in their downstream repository.
FILES_TO_KEEP = [ "gypfiles" ]
def RunGclient(path):
assert os.path.isdir(path)
print(">> Running gclient sync")
subprocess.check_call(["gclient", "sync", "--nohooks"], cwd=path)
def CommitPatch(options):
"""Makes a dummy commit for the changes in the index.
On trybots, bot_updated applies the patch to the index. We commit it to make
the fake git clone fetch it into node.js. We can leave the commit, as
bot_update will ensure a clean state on each run.
"""
print(">> Committing patch")
subprocess.check_call(
["git", "-c", "user.name=fake", "-c", "user.email=fake@chromium.org",
"commit", "--allow-empty", "-m", "placeholder-commit"],
cwd=options.v8_path,
)
def UpdateTarget(repository, options, files_to_keep):
source = os.path.join(options.v8_path, *repository)
target = os.path.join(options.node_path, TARGET_SUBDIR, *repository)
print(">> Updating target directory %s" % target)
print(">> from active branch at %s" % source)
if not os.path.exists(target):
os.makedirs(target)
# Remove possible remnants of previous incomplete runs.
node_common.UninitGit(target)
git_args = []
git_args.append(["init"]) # initialize target repo
if files_to_keep:
git_args.append(["add"] + files_to_keep) # add and commit
git_args.append(["commit", "-m", "keep files"]) # files we want to keep
git_args.append(["clean", "-fxd"]) # nuke everything else
git_args.append(["remote", "add", "source", source]) # point to source repo
git_args.append(["fetch", "source", "HEAD"]) # sync to current branch
git_args.append(["checkout", "-f", "FETCH_HEAD"]) # switch to that branch
git_args.append(["clean", "-fxd"]) # delete removed files
if files_to_keep:
git_args.append(["cherry-pick", "master"]) # restore kept files
try:
for args in git_args:
subprocess.check_call(["git"] + args, cwd=target)
except:
raise
finally:
node_common.UninitGit(target)
def UpdateGitIgnore(options):
file_name = os.path.join(options.node_path, TARGET_SUBDIR, ".gitignore")
assert os.path.isfile(file_name)
print(">> Updating .gitignore with lines")
with open(file_name) as gitignore:
content = gitignore.readlines()
content = [x.strip() for x in content]
for x in DELETE_FROM_GITIGNORE:
if x in content:
print("- %s" % x)
content.remove(x)
for x in ADD_TO_GITIGNORE:
if x not in content:
print("+ %s" % x)
content.append(x)
content.sort(key=lambda x: x[1:] if x.startswith("!") else x)
with open(file_name, "w") as gitignore:
for x in content:
gitignore.write("%s\n" % x)
def CreateCommit(options):
print(">> Creating commit.")
# Find git hash from source.
githash = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"],
cwd=options.v8_path).strip()
# Create commit at target.
git_commands = [
["git", "checkout", "-b", "update_v8_to_%s" % githash], # new branch
["git", "add", "."], # add files
["git", "commit", "-m", "Update V8 to %s" % githash] # new commit
]
for command in git_commands:
subprocess.check_call(command, cwd=options.node_path)
def ParseOptions(args):
parser = argparse.ArgumentParser(description="Update V8 in Node.js")
parser.add_argument("v8_path", help="Path to V8 checkout")
parser.add_argument("node_path", help="Path to Node.js checkout")
parser.add_argument("--gclient", action="store_true", help="Run gclient sync")
parser.add_argument("--commit", action="store_true", help="Create commit")
parser.add_argument("--with-patch", action="store_true",
help="Apply also staged files")
options = parser.parse_args(args)
assert os.path.isdir(options.v8_path)
options.v8_path = os.path.abspath(options.v8_path)
assert os.path.isdir(options.node_path)
options.node_path = os.path.abspath(options.node_path)
return options
def Main(args):
options = ParseOptions(args)
if options.gclient:
RunGclient(options.v8_path)
# Commit patch on trybots to main V8 repository.
if options.with_patch:
CommitPatch(options)
# Update main V8 repository.
UpdateTarget([""], options, FILES_TO_KEEP)
# Patch .gitignore before updating sub-repositories.
UpdateGitIgnore(options)
for repo in SUB_REPOSITORIES:
UpdateTarget(repo, options, None)
if options.commit:
CreateCommit(options)
if __name__ == "__main__":
Main(sys.argv[1:])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment