def gn_gen(mode): os.environ["DENO_BUILD_MODE"] = mode # Rather than using gn gen --args we write directly to the args.gn file. # This is to avoid quoting/escaping complications when passing overrides as # command-line arguments. args_filename = os.path.join(build_path(), "args.gn") # Check if args.gn exists, and if it was auto-generated or handcrafted. existing_gn_args, hand_edited = read_gn_args(args_filename) # If args.gn wasn't handcrafted, regenerate it. if hand_edited: print "%s: Using gn options from hand edited '%s'." % (mode, args_filename) gn_args = existing_gn_args else: print "%s: Writing gn options to '%s'." % (mode, args_filename) gn_args = generate_gn_args(mode) if gn_args != existing_gn_args: write_gn_args(args_filename, gn_args) for line in gn_args: print " " + line run([third_party.gn_path, "gen", build_path()], env=third_party.google_env())
def clang_format(): print "clang-format" exe = get_buildtools_tool_path("clang-format") source_files = git_ls_files(root_path, ["*.cc", "*.h"]) run([exe, "-i", "-style", "Google", "--"] + source_files, env=google_env(), quiet=True)
def gn_gen(mode): os.environ["DENO_BUILD_MODE"] = mode # Rather than using gn gen --args we write directly to the args.gn file. # This is to avoid quoting/escaping complications when passing overrides as # command-line arguments. args_filename = os.path.join(build_path(), "args.gn") # Check if args.gn exists, and if it was auto-generated or handcrafted. existing_gn_args, hand_edited = read_gn_args(args_filename) # If args.gn wasn't handcrafted, regenerate it. if hand_edited: print "%s: Using gn options from hand edited '%s'." % (mode, args_filename) gn_args = existing_gn_args else: print "%s: Writing gn options to '%s'." % (mode, args_filename) gn_args = generate_gn_args(mode) if gn_args != existing_gn_args: write_gn_args(args_filename, gn_args) for line in gn_args: print " " + line run([third_party.gn_path, "gen", build_path()], env=third_party.google_env())
def download_prebuilt(sha1_file): run([ "python", tp('depot_tools/download_from_google_storage.py'), '--platform=' + sys.platform, '--no_auth', '--bucket=denoland', '--sha1_file', sha1_file, ], env=google_env())
def download_prebuilt(sha1_file): run([ "python", tp('depot_tools/download_from_google_storage.py'), '--platform=' + sys.platform, '--no_auth', '--bucket=denoland', '--sha1_file', sha1_file, ], env=google_env())
def main(argv): enable_ansi_colors() ninja_args = argv[1:] if not "-C" in ninja_args: if not os.path.isdir(build_path()): print("Build directory '%s' does not exist." % build_path(), "Run tools/setup.py") sys.exit(1) ninja_args = ["-C", build_path()] + ninja_args run([third_party.ninja_path] + ninja_args, env=third_party.google_env(), quiet=True)
def main(argv): enable_ansi_colors() third_party.fix_symlinks() ninja_args = argv[1:] if not "-C" in ninja_args: if not os.path.isdir(build_path()): print("Build directory '%s' does not exist." % build_path(), "Run tools/setup.py") sys.exit(1) ninja_args = ["-C", build_path()] + ninja_args run([third_party.ninja_path] + ninja_args, env=third_party.google_env(), quiet=True)
def maybe_add_default_target(args): lines = run_output( [third_party.ninja_path, "-t", "targets"], env=third_party.google_env(), quiet=True).split("\n") targets = [l.rsplit(":", 1)[0] for l in lines] deno_targets = [target for target in targets if target.startswith(":")] deno_targets += [target.lstrip(":") for target in deno_targets] target_specified = False for a in args: if a in deno_targets: target_specified = True break if not target_specified: args += [":all"] return args
def download_v8_prebuilt(): if sys.platform == 'win32': sha1_file = "prebuilt/win/v8.lib.sha1" elif sys.platform.startswith('linux'): sha1_file = "prebuilt/linux64/libv8.a.sha1" elif sys.platform == 'darwin': sha1_file = "prebuilt/mac/libv8.a.sha1" run([ "python", tp('depot_tools/download_from_google_storage.py'), '--platform=' + sys.platform, '--no_auth', '--bucket=denoland', '--sha1_file', sha1_file, ], env=google_env())
def gn_gen(mode): 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())
def main(argv): enable_ansi_colors() args, rest_argv = parser.parse_known_args(argv) if "DENO_BUILD_MODE" not in os.environ: if args.release: os.environ["DENO_BUILD_MODE"] = "release" ninja_args = rest_argv[1:] if not "-C" in ninja_args: if not os.path.isdir(build_path()): print("Build directory '%s' does not exist." % build_path(), "Run tools/setup.py") sys.exit(1) ninja_args = ["-C", build_path()] + ninja_args run([third_party.ninja_path] + ninja_args, env=third_party.google_env(), quiet=True)
if options.mode == "release": gn_args += ["is_official_build=true"] elif options.mode == "debug": pass else: print "Bad mode {}. Use 'release' or 'debug' (default)" % options.mode sys.exit(1) # Check if ccache is in the path, and if so we cc_wrapper. ccache_path = distutils.spawn.find_executable("ccache") if ccache_path: gn_args += [r'cc_wrapper="%s"' % ccache_path] # 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 = join(build_path, "args.gn") if not os.path.exists(args_filename) or options.args: with open(args_filename, "w+") as f: f.write("\n".join(gn_args) + "\n") run([gn_path, "gen", build_path], env=google_env()) target = " ".join(targets) if targets else ":all" run([ninja_path, "-C", build_path, target], env=google_env())
from util import root_path, run, find_exts fix_symlinks() prettier = os.path.join(third_party_path, "node_modules", "prettier", "bin-prettier.js") tools_path = os.path.join(root_path, "tools") rustfmt_config = os.path.join(tools_path, "rustfmt.toml") os.chdir(root_path) run([clang_format_path, "-i", "-style", "Google"] + find_exts("libdeno", ".cc", ".h")) for fn in ["BUILD.gn", ".gn"] + find_exts("build_extra", ".gn", ".gni"): run(["third_party/depot_tools/gn", "format", fn], env=google_env()) # We use `glob()` instead of `find_exts()` in the tools directory, because: # * On Windows, `os.walk()` (called by `find_exts()`) follows symlinks. # * The tools directory contains a symlink 'clang', pointing at the directory # 'third_party/v8/tools/clang', which contains many .py files. # * These third party python files shouldn't be formatted. # * The tools directory has no subdirectories, so `glob()` is sufficient. # TODO(ry) Install yapf in third_party. run(["yapf", "-i"] + glob("tools/*.py") + find_exts("build_extra", ".py")) run(["node", prettier, "--write"] + find_exts("js/", ".js", ".ts") + find_exts("tests/", ".js", ".ts") + find_exts("website/", ".js", ".ts") + ["rollup.config.js", "tsconfig.json", "tslint.json"]) # Requires rustfmt 0.8.2 (flags were different in previous versions)
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import os import sys import third_party from util import run_output, build_path out_filename = sys.argv[1] args_list = run_output([ third_party.gn_path, "args", build_path(), "--list", "--short", "--overrides-only" ], quiet=True, env=third_party.google_env(), exit_on_fail=True).out with open(out_filename, "w") as f: f.write(args_list)
os.chdir(root_path) def qrun(cmd, env=None): run(cmd, quiet=True, env=env) print "clang_format" qrun([clang_format_path, "-i", "-style", "Google"] + find_exts(["libdeno"], [".cc", ".h"])) print "gn format" for fn in ["BUILD.gn", ".gn"] + find_exts(["build_extra", "libdeno"], [".gn", ".gni"]): qrun(["third_party/depot_tools/gn", "format", fn], env=google_env()) print "yapf" qrun( [sys.executable, "third_party/python_packages/bin/yapf", "-i"] + find_exts( ["tools", "build_extra"], [".py"], skip=["tools/clang"]), env=python_env()) print "prettier" qrun(["node", prettier, "--write", "--loglevel=error"] + ["rollup.config.js"] + glob("*.json") + glob("*.md") + find_exts([".github", "js", "tests", "tools", "website", "core"], [".js", ".json", ".ts", ".md"], skip=["tools/clang", "js/deps"])) print "rustfmt"
if not os.path.isdir(build_path()): print "DENO_BUILD_PATH does not exist. Run tools/setup.py" sys.exit(1) os.chdir(build_path()) def maybe_add_default_target(args): lines = run_output( [third_party.ninja_path, "-t", "targets"], env=third_party.google_env(), quiet=True).split("\n") targets = [l.rsplit(":", 1)[0] for l in lines] deno_targets = [target for target in targets if target.startswith(":")] deno_targets += [target.lstrip(":") for target in deno_targets] target_specified = False for a in args: if a in deno_targets: target_specified = True break if not target_specified: args += [":all"] return args ninja_args = maybe_add_default_target(sys.argv[1:]) run([third_party.ninja_path] + ninja_args, env=third_party.google_env(), quiet=True)
def gn_format(): print "gn format" exe = get_buildtools_tool_path("gn") source_files = git_ls_files(root_path, ["*.gn", "*.gni"]) run([exe, "format", "--"] + source_files, env=google_env(), quiet=True)
def gn_format(): print "gn format" for fn in ["BUILD.gn", ".gn"] + find_exts(["build_extra", "cli", "core"], [".gn", ".gni"]): qrun(["third_party/depot_tools/gn", "format", fn], env=google_env())