diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2018-07-26 20:15:55 -0400 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-07-29 00:24:16 -0400 |
commit | db65c723ae9c4e765e30a05ed6c96f04754dc3f1 (patch) | |
tree | 4043f0f7cfc0d4bb51bbc38f6f6c9316282f3602 /tools/setup.py | |
parent | 604a8a640cf1f825218fdb5b23351cd46fc56747 (diff) |
Rename run_hooks.py to setup.py
Moves 'gn gen' into setup.py
Make tools/build.py more ergonomic.
Diffstat (limited to 'tools/setup.py')
-rwxr-xr-x | tools/setup.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tools/setup.py b/tools/setup.py new file mode 100755 index 000000000..84bd0aba4 --- /dev/null +++ b/tools/setup.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python +import third_party +from util import run, build_path, build_mode +import os +import distutils.spawn + +third_party.fix_symlinks() +third_party.download_gn() +third_party.download_clang() + + +def get_gn_args(): + out = [] + if build_mode() == "release": + out += ["is_official_build=true"] + elif build_mode() == "debug": + pass + else: + print "Bad mode {}. Use 'release' or 'debug' (default)" % build_mode() + sys.exit(1) + if "DENO_BUILD_ARGS" in os.environ: + out += os.environ["DENO_BUILD_ARGS"].split() + + # Check if ccache is in the path, and if so we cc_wrapper. + ccache_path = distutils.spawn.find_executable("ccache") + if ccache_path: + out += [r'cc_wrapper="%s"' % ccache_path] + + print "DENO_BUILD_ARGS:", out + + return out + + +# gn gen. +for mode in ["release", "debug"]: + os.environ["DENO_BUILD_MODE"] = mode + + gn_args = get_gn_args() + + # mkdir $build_path(). We do this so we can write args.gn before running gn gen. + if not os.path.isdir(build_path()): + os.makedirs(build_path()) + + # Rather than using gn gen --args we manually write the args.gn override file. + # This is to avoid quoting/escaping complications when passing overrides as + # command-line arguments. + args_filename = os.path.join(build_path(), "args.gn") + if not os.path.exists(args_filename) or gn_args: + with open(args_filename, "w+") as f: + f.write("\n".join(gn_args) + "\n") + + run([third_party.gn_path, "gen", build_path()], + env=third_party.google_env()) |