def get_binary_sizes(build_dir): # Because cargo's OUT_DIR is not predictable, we have to search the build # tree for these files... files = find_exts([build_dir], ["js", "map", "bin"]) path_dict = { "deno": os.path.join(build_dir, "deno" + executable_suffix), } for f in files: if f.endswith("CLI_SNAPSHOT.js"): path_dict["CLI_SNAPSHOT.js"] = f elif f.endswith("CLI_SNAPSHOT.js.map"): path_dict["CLI_SNAPSHOT.js.map"] = f elif f.endswith("CLI_SNAPSHOT.bin"): path_dict["CLI_SNAPSHOT.bin"] = f elif f.endswith("COMPILER_SNAPSHOT.js"): path_dict["COMPILER_SNAPSHOT.js"] = f elif f.endswith("COMPILER_SNAPSHOT.js.map"): path_dict["COMPILER_SNAPSHOT.js.map"] = f elif f.endswith("COMPILER_SNAPSHOT.bin"): path_dict["COMPILER_SNAPSHOT.bin"] = f sizes = {} for name, path in path_dict.items(): assert os.path.exists(path) sizes[name] = os.path.getsize(path) return sizes
def rustfmt(): print "rustfmt" qrun([ "rustfmt", "--config-path", rustfmt_config, ] + find_exts(["cli", "core", "tools"], [".rs"]))
def prettier(): print "prettier" files = find_exts([".github", "js", "tests", "tools", "website", "core"], [".js", ".json", ".ts", ".md"], skip=["tools/clang", "js/deps", "js/gen"]) qrun(["node", prettier_path, "--write", "--loglevel=error"] + ["rollup.config.js"] + files)
def yapf(): print "yapf" qrun( [sys.executable, "third_party/python_packages/bin/yapf", "-i"] + find_exts(["tools", "build_extra", "deno_typescript", "cli_snapshots"], [".py"], skip=["tools/clang"]), env=python_env())
def rustfmt(): print "rustfmt" qrun([ "rustfmt", "--config-path", rustfmt_config, ] + find_exts(["cli", "core", "tools", "deno_typescript", "cli_snapshots"], [".rs"]))
def clang_format(): print("clang_format") run([clang_format_path, "-i", "-style", "Google"] + find_exts(["src", "test"], [".cpp", ".hpp"]))
from glob import glob import os from third_party import third_party_path, fix_symlinks, google_env, clang_format_path 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") +
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) 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"],
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(root_path, ".rustfmt.toml") 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") +
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(root_path, ".rustfmt.toml") 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(["core"], [".cc", ".h"])) 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()) 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") +
def delete_lockfile(): lockfiles = find_exts([path.join(rust_crates_path, "registry/index")], ['.cargo-index-lock']) for lockfile in lockfiles: os.remove(lockfile)
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())
def clang_format(): print "clang_format" qrun([clang_format_path, "-i", "-style", "Google"] + find_exts(["core"], [".cc", ".h"]))
#!/usr/bin/env python import os from third_party import third_party_path, fix_symlinks, 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) # TODO(ry) Use third_party/depot_tools/clang-format. run(["clang-format", "-i", "-style", "Google"] + find_exts("src", ".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()) # TODO(ry) Install yapf in third_party. run(["yapf", "-i"] + find_exts("tools/", ".py") + find_exts("build_extra", ".py")) run(["node", prettier, "--write"] + find_exts("js/", ".js", ".ts") + ["rollup.config.js", "tsconfig.json", "tslint.json"]) # Set RUSTFMT_FLAGS for extra flags. rustfmt_extra_args = [] if 'RUSTFMT_FLAGS' in os.environ: rustfmt_extra_args += os.environ['RUSTFMT_FLAGS'].split()
def delete_lockfile(): lockfiles = find_exts( path.join(rust_crates_path, "registry/index"), '.cargo-index-lock') for lockfile in lockfiles: os.remove(lockfile)
#!/usr/bin/env python # Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. # Does google-lint on c++ files and ts-lint on typescript files import os import sys from util import enable_ansi_colors, find_exts, root_path, run enable_ansi_colors() third_party_path = os.path.join(root_path, "third_party") cpplint = os.path.join(third_party_path, "cpplint", "cpplint.py") tslint = os.path.join(third_party_path, "node_modules", "tslint", "bin", "tslint") os.chdir(root_path) run([ "python", cpplint, "--filter=-build/include_subdir", "--repository=libdeno", "--extensions=cc,h", "--recursive", "libdeno" ]) run(["node", tslint, "-p", ".", "--exclude", "**/gen/**/*.ts"]) run([ "node", tslint, "./js/**/*_test.ts", "./tests/**/*.ts", "./core/*.js", "--exclude", "**/gen/**/*.ts", "--project", "tsconfig.json" ]) run([sys.executable, "third_party/depot_tools/pylint.py"] + find_exts(["tools", "build_extra"], [".py"], skip=["tools/clang"]))
#!/usr/bin/env python # Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. # Does google-lint on c++ files and ts-lint on typescript files import os import sys from util import enable_ansi_colors, run, find_exts enable_ansi_colors() root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) third_party_path = os.path.join(root_path, "third_party") cpplint = os.path.join(third_party_path, "cpplint", "cpplint.py") tslint = os.path.join(third_party_path, "node_modules", "tslint", "bin", "tslint") os.chdir(root_path) run([ "python", cpplint, "--filter=-build/include_subdir", "--repository=src", "--extensions=cc,h", "--recursive", "src/." ]) run(["node", tslint, "-p", ".", "--exclude", "**/gen/**/*.ts"]) run([ "node", tslint, "./js/**/*_test.ts", "./tests/**/*.ts", "--exclude", "**/gen/**/*.ts", "--project", "tsconfig.json" ]) run([sys.executable, "third_party/depot_tools/pylint.py"] + find_exts(["tools", "build_extra"], [".py"], skip=["tools/clang"]))
from glob import glob import os from third_party import third_party_path, fix_symlinks, google_env, clang_format_path from util import root_path, run, find_exts, platform 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")) # yapf: disable run(["node", prettier, "--write"] +