diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/build.py | 38 | ||||
-rw-r--r-- | tools/gn.rs | 139 | ||||
-rwxr-xr-x | tools/http_benchmark.py | 3 | ||||
-rwxr-xr-x | tools/setup.py | 5 | ||||
-rw-r--r-- | tools/target_test.py | 36 |
5 files changed, 9 insertions, 212 deletions
diff --git a/tools/build.py b/tools/build.py deleted file mode 100755 index 82426f5b2..000000000 --- a/tools/build.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python -# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -from __future__ import print_function -import argparse -import os -import sys -import third_party -from util import build_path, enable_ansi_colors, run - -parser = argparse.ArgumentParser() -parser.add_argument( - "--release", help="Use target/release", action="store_true") - - -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 __name__ == '__main__': - sys.exit(main(sys.argv)) diff --git a/tools/gn.rs b/tools/gn.rs deleted file mode 100644 index ba1bea7bc..000000000 --- a/tools/gn.rs +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -// This is used in cli/build.rs and core/build.rs to interface with the GN build -// system (which defines the deno build). - -use std::env; -use std::path::{self, Path, PathBuf}; -use std::process::Command; - -pub struct Build { - gn_mode: String, - root: PathBuf, - pub gn_out_dir: String, - pub gn_out_path: PathBuf, - pub check_only: bool, -} - -impl Build { - pub fn setup() -> Build { - let gn_mode = if cfg!(target_os = "windows") { - // On Windows, we need to link with a release build of libdeno, because - // rust always uses the release CRT. - // TODO(piscisaureus): make linking with debug libdeno possible. - String::from("release") - } else { - // Cargo sets PROFILE to either "debug" or "release", which conveniently - // matches the build modes we support. - env::var("PROFILE").unwrap() - }; - - // cd into workspace root. - assert!(env::set_current_dir("..").is_ok()); - - let root = env::current_dir().unwrap(); - // If not using host default target the output folder will change - // target/release will become target/$TARGET/release - // Gn should also be using this output directory as well - // most things will work with gn using the default - // output directory but some tests depend on artifacts - // being in a specific directory relative to the main build output - let gn_out_path = root.join(format!("target/{}", gn_mode.clone())); - let gn_out_dir = normalize_path(&gn_out_path); - - // Tell Cargo when to re-run this file. We do this first, so these directives - // can take effect even if something goes wrong later in the build process. - println!("cargo:rerun-if-env-changed=DENO_BUILD_PATH"); - // TODO: this is obviously not appropriate here. - println!("cargo:rerun-if-env-changed=APPVEYOR_REPO_COMMIT"); - - // This helps Rust source files locate the snapshot, source map etc. - println!("cargo:rustc-env=GN_OUT_DIR={}", gn_out_dir); - - // Detect if we're being invoked by the rust language server (RLS). - // Unfortunately we can't detect whether we're being run by `cargo check`. - let check_only = env::var_os("CARGO") - .map(PathBuf::from) - .as_ref() - .and_then(|p| p.file_stem()) - .and_then(|f| f.to_str()) - .map(|s| s.starts_with("rls")) - .unwrap_or(false); - - if check_only { - // Enable the 'check_only' feature, which enables some workarounds in the - // rust source code to compile successfully without a bundle and snapshot - println!("cargo:rustc-cfg=feature=\"check-only\""); - } - - Build { - gn_out_dir, - gn_out_path, - check_only, - gn_mode, - root, - } - } - - pub fn run(&self, gn_target: &str) { - if !self.gn_out_path.join("build.ninja").exists() { - let status = Command::new("python") - .env("DENO_BUILD_PATH", &self.gn_out_dir) - .env("DENO_BUILD_MODE", &self.gn_mode) - .env("DEPOT_TOOLS_WIN_TOOLCHAIN", "0") - .arg("./tools/setup.py") - .status() - .expect("setup.py failed"); - assert!(status.success()); - } - - let mut ninja = Command::new("third_party/depot_tools/ninja"); - let ninja = if !cfg!(target_os = "windows") { - &mut ninja - } else { - // Windows needs special configuration. This is similar to the function of - // python_env() in //tools/util.py. - let python_path: Vec<String> = vec![ - "third_party/python_packages", - "third_party/python_packages/win32", - "third_party/python_packages/win32/lib", - "third_party/python_packages/Pythonwin", - ] - .into_iter() - .map(|p| self.root.join(p).into_os_string().into_string().unwrap()) - .collect(); - let orig_path = String::from(";") - + &env::var_os("PATH").unwrap().into_string().unwrap(); - let path = self - .root - .join("third_party/python_packages/pywin32_system32") - .into_os_string() - .into_string() - .unwrap(); - ninja - .env("PYTHONPATH", python_path.join(";")) - .env("PATH", path + &orig_path) - .env("DEPOT_TOOLS_WIN_TOOLCHAIN", "0") - }; - - let status = ninja - .arg(gn_target) - .arg("-C") - .arg(&self.gn_out_dir) - .status() - .expect("ninja failed"); - assert!(status.success()); - } -} - -// Utility function to make a path absolute, normalizing it to use forward -// slashes only. The returned value is an owned String, otherwise panics. -fn normalize_path<T: AsRef<Path>>(path: T) -> String { - path - .as_ref() - .to_str() - .unwrap() - .to_owned() - .chars() - .map(|c| if path::is_separator(c) { '/' } else { c }) - .collect() -} diff --git a/tools/http_benchmark.py b/tools/http_benchmark.py index 2394ad160..30e5ba675 100755 --- a/tools/http_benchmark.py +++ b/tools/http_benchmark.py @@ -151,7 +151,8 @@ def hyper_http(hyper_hello_exe): def http_benchmark(build_dir): hyper_hello_exe = os.path.join(build_dir, "hyper_hello") - core_http_bench_exe = os.path.join(build_dir, "deno_core_http_bench") + core_http_bench_exe = os.path.join(build_dir, + "examples/deno_core_http_bench") deno_exe = os.path.join(build_dir, "deno") return { # "deno_tcp" was once called "deno" diff --git a/tools/setup.py b/tools/setup.py index 9f5059358..ddb9dc3e8 100755 --- a/tools/setup.py +++ b/tools/setup.py @@ -140,11 +140,6 @@ def generate_gn_args(mode): # https://github.com/mozilla/sccache/issues/264 out += ["treat_warnings_as_errors=false"] - # Look for sccache; if found, set rustc_wrapper. - rustc_wrapper = cacher - if rustc_wrapper: - out += ['rustc_wrapper=%s' % gn_string(rustc_wrapper)] - return out diff --git a/tools/target_test.py b/tools/target_test.py index 8ccabba53..f14aa01d7 100644 --- a/tools/target_test.py +++ b/tools/target_test.py @@ -5,15 +5,6 @@ from test_util import DenoTestCase, run_tests from util import executable_suffix, tests_path, run, run_output -# In the ninja/gn we build and test individually libdeno_test, cli_test, -# deno_core_test, deno_core_http_bench_test. When building with cargo, however -# we just run "cargo test". -# This is hacky but is only temporarily here until the ninja/gn build is -# removed. -def is_cargo_test(): - return "CARGO_TEST" in os.environ - - class TestTarget(DenoTestCase): @staticmethod def check_exists(filename): @@ -32,28 +23,15 @@ class TestTarget(DenoTestCase): run([bin_file], quiet=True) def test_cargo_test(self): - if is_cargo_test(): - cargo_test = ["cargo", "test", "--all", "--locked"] - if os.environ["DENO_BUILD_MODE"] == "release": - run(cargo_test + ["--release"]) - else: - run(cargo_test) + cargo_test = ["cargo", "test", "--all", "--locked"] + if "DENO_BUILD_MODE" in os.environ and \ + os.environ["DENO_BUILD_MODE"] == "release": + run(cargo_test + ["--release"]) + else: + run(cargo_test) def test_libdeno(self): - if not is_cargo_test(): - self._test("libdeno_test") - - def test_cli(self): - if not is_cargo_test(): - self._test("cli_test") - - def test_core(self): - if not is_cargo_test(): - self._test("deno_core_test") - - def test_core_http_benchmark(self): - if not is_cargo_test(): - self._test("deno_core_http_bench_test") + self._test("libdeno_test") def test_no_color(self): t = os.path.join(tests_path, "no_color.js") |