-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancements to --build-v8-with-gn #58
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,6 @@ def FindGn(options): | |
return os.path.join(options.v8_path, "buildtools", os_path, "gn") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is directly copied over from V8 upstream (e.g. using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
def GenerateBuildFiles(options): | ||
print "Setting GN args." | ||
gn = FindGn(options) | ||
gn_args = [] | ||
gn_args.extend(GN_ARGS) | ||
|
@@ -56,47 +55,57 @@ def GenerateBuildFiles(options): | |
flag = flag.replace("target_cpu=ia32", "target_cpu=\"x86\"") | ||
gn_args.append(flag) | ||
if options.mode == "DEBUG": | ||
gn_args.append("is_debug = true") | ||
gn_args.append("is_debug=true") | ||
else: | ||
gn_args.append("is_debug = false") | ||
gn_args.append("is_debug=false") | ||
|
||
if not os.path.isdir(options.build_path): | ||
os.makedirs(options.build_path) | ||
with open(os.path.join(options.build_path, "args.gn"), "w") as args_file: | ||
args_file.write("\n".join(gn_args)) | ||
subprocess.check_call([gn, "gen", "-C", options.build_path], | ||
cwd=options.v8_path) | ||
args = [gn, "gen", options.build_path, "-q", | ||
"--args=" + ' '.join(gn_args)] | ||
subprocess.check_call(args, cwd=options.v8_path) | ||
|
||
def Build(options): | ||
print "Building." | ||
depot_tools = node_common.EnsureDepotTools(options.v8_path, False) | ||
ninja = os.path.join(depot_tools, "ninja") | ||
subprocess.check_call([ninja, "-v", "-C", options.build_path, BUILD_TARGET], | ||
cwd=options.v8_path) | ||
if sys.platform == 'win32': | ||
# Required because there is an extension-less file called "ninja". | ||
ninja += '.exe' | ||
args = [ninja, "-C", options.build_path, BUILD_TARGET] | ||
|
||
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, cwd=options.v8_path) | ||
|
||
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") | ||
parser.add_argument("--build_path", help="Path to build result") | ||
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("--build", help="Run ninja as opposed to gn gen.", | ||
action="store_true") | ||
options = parser.parse_args(args) | ||
|
||
assert options.host_os | ||
assert options.mode == "Debug" or options.mode == "Release" | ||
options.build_path = os.path.abspath(options.build_path) | ||
|
||
assert options.v8_path | ||
options.v8_path = os.path.abspath(options.v8_path) | ||
assert os.path.isdir(options.v8_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) | ||
|
||
assert options.build_path | ||
options.build_path = os.path.abspath(options.build_path) | ||
return options | ||
|
||
|
||
if __name__ == "__main__": | ||
options = ParseOptions(sys.argv[1:]) | ||
GenerateBuildFiles(options) | ||
Build(options) | ||
if not options.build: | ||
GenerateBuildFiles(options) | ||
else: | ||
Build(options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this also include
--build-v8-with-gn
? Otherwise both flags would have to be passed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sgtm. Done.