summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml17
-rw-r--r--Cargo.toml4
-rw-r--r--README.md25
-rwxr-xr-xtools/build.py69
-rwxr-xr-xtools/run_hooks.py16
-rwxr-xr-xtools/sync_third_party.py (renamed from tools/build_third_party.py)0
6 files changed, 100 insertions, 31 deletions
diff --git a/.travis.yml b/.travis.yml
index 8c819d78d..94edc6245 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,31 +20,24 @@ install:
- export PATH=$PATH:$DEPOT_TOOLS_PATH
# Sync dependencies.
# TODO(ry) These sync steps are very terrible and only here temporarily.
- # A single deno_deps git submodule should be created which contains V8,
- # node_modules, depot_tools, rustc, and other deps.
- # Building Deno *should not* depend on yarn, gclient, rustup, cargo, nor any
- # internet connection.
+ # rustc should be added to deno_third_party. Ultimately Deno *should not*
+ # depend on yarn, gclient, rustup, cargo, nor any internet connection.
- curl -sSf https://sh.rustup.rs | sh -s -- -y
- export PATH=$HOME/.cargo/bin:$PATH
- rustc --version
# TODO(ry) Do not depend on run_hooks because it calls
# //third_party/depot_tools/download_from_google_storage.py
- # Use git lfs and combine run_hooks with build_third_party?
+ # Use git lfs and combine run_hooks with sync_third_party?
- ./tools/run_hooks.py
# ccache needs the custom LLVM to be in PATH and other variables.
- export PATH=`pwd`/third_party/llvm-build/Release+Asserts/bin:$PATH
- export CCACHE_CPP2=yes
- export CCACHE_SLOPPINESS=time_macros
- # In case gn gen args change, delete args.gn to avoid using cached values.
- - rm -f $BUILD_PATH/args.gn
+ - ccache -s
# is_debug, use_allocator, and ccache are used to speed travis.
# use_custom_libcxx=false and use_sysroot=false seem to be required to build on
# Ubuntu 14.04
- - gn gen $BUILD_PATH --args='is_debug=false use_allocator="none" cc_wrapper="ccache" use_custom_libcxx=false use_sysroot=false'
- - gn args $BUILD_PATH --list
- - ccache -s
- # Travis hangs without -j2 argument to ninja.
- - ninja -j2 -C $BUILD_PATH :all
+ - ./tools/build.py --build_path=$BUILD_PATH --args='is_debug=false use_allocator="none" use_custom_libcxx=false use_sysroot=false'
script:
- ./tools/lint.py
- ./tools/test.py $BUILD_PATH
diff --git a/Cargo.toml b/Cargo.toml
index 89fd4a71a..afb81d744 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,5 @@
# Dummy package info required by `cargo fetch`
- # Called from tools/build_third_party.py
+ # Called from tools/sync_third_party.py
# Should not be called with `cargo build`
[package]
name = "deno"
@@ -8,4 +8,4 @@ version = "0.0.0"
[dependencies]
url = "1.7.1"
libc = "0.2.42"
-log = "0.4.3" \ No newline at end of file
+log = "0.4.3"
diff --git a/README.md b/README.md
index 2363f5d7a..e8a2f8b17 100644
--- a/README.md
+++ b/README.md
@@ -78,18 +78,25 @@ To build:
cd deno
./tools/run_hooks.py
- # Configure
- ./third_party/depot_tools/gn gen out/default
- ./third_party/depot_tools/gn gen out/release --args='cc_wrapper="ccache" is_official_build=true'
- ./third_party/depot_tools/gn gen out/debug --args='cc_wrapper="ccache" is_debug=true '
-
# Build
- ./third_party/depot_tools/ninja -C out/default/ deno
+ ./tools/build.py
+
+ # Run
+ ./out/debug/deno tests/002_hello.ts
Other useful commands:
- ./third_party/depot_tools/gn args out/default/ --list
- ./third_party/depot_tools/gn args out/default/
- ./third_party/depot_tools/gn desc out/default/ :deno
+ # Call ninja manually.
+ ./third_party/depot_tools/ninja -C out/debug :all
+ # Build a release binary.
+ ./tools/build.py --mode=release :deno
+ # List executable targets.
+ ./third_party/depot_tools/gn ls out/debug //:* --as=output --type=executable
+ # List build configuation.
+ ./third_party/depot_tools/gn args out/debug/ --list
+ # Edit build configuration.
+ ./third_party/depot_tools/gn args out/debug/
+ # Describe a target.
+ ./third_party/depot_tools/gn desc out/debug/ :deno
./third_party/depot_tools/gn help
diff --git a/tools/build.py b/tools/build.py
new file mode 100755
index 000000000..fb061eae3
--- /dev/null
+++ b/tools/build.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+# Copyright 2018 the Deno authors. All rights reserved. MIT license.
+import argparse
+import os
+import sys
+from os.path import join
+from util import run
+import distutils.spawn
+
+parser = argparse.ArgumentParser(description='')
+parser.add_argument(
+ '--build_path', default='', help='Directory to build into.')
+parser.add_argument(
+ '--args', default='', help='Specifies build arguments overrides.')
+parser.add_argument(
+ '--mode', default='debug', help='Build configuration: debug, release.')
+options, targets = parser.parse_known_args()
+
+root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+third_party_path = join(root_path, "third_party")
+depot_tools_path = join(third_party_path, "depot_tools")
+gn_path = join(depot_tools_path, "gn")
+ninja_path = join(depot_tools_path, "ninja")
+
+# Add third_party/depot_tools to PATH because some google tools (e.g.
+# tool_wrapper, download_from_google_storage) use some google specific python
+# wrapper.
+os.environ["PATH"] = depot_tools_path + os.pathsep + os.environ["PATH"]
+
+os.chdir(root_path)
+
+if options.build_path:
+ build_path = options.build_path
+else:
+ build_path = join(root_path, "out", options.mode)
+
+gn_args = []
+if options.args:
+ gn_args += options.args.split()
+
+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])
+
+target = " ".join(targets) if targets else ":all"
+run([ninja_path, "-C", build_path, target])
diff --git a/tools/run_hooks.py b/tools/run_hooks.py
index 2ec671186..58178a69c 100755
--- a/tools/run_hooks.py
+++ b/tools/run_hooks.py
@@ -9,14 +9,14 @@ depot_tools_path = os.path.join(third_party_path, "depot_tools")
os.chdir(root_path)
-def download(fn):
+def download(filename):
run([
+ "python",
os.path.join(depot_tools_path + '/download_from_google_storage.py'),
- '--no_resume', '--platform=' + sys.platform, '--no_auth', '--bucket',
- 'chromium-gn', '-s',
- os.path.join(root_path, fn)
- ],
- quiet=True)
+ '--platform=' + sys.platform, '--no_auth', '--bucket=chromium-gn',
+ '--sha1_file',
+ os.path.join(root_path, filename)
+ ])
if sys.platform == 'win32':
@@ -25,5 +25,5 @@ elif sys.platform == 'darwin':
download("third_party/v8/buildtools/mac/gn.sha1")
elif sys.platform.startswith('linux'):
download("third_party/v8/buildtools/linux64/gn.sha1")
-run(['python', 'third_party/v8/tools/clang/scripts/update.py', '--if-needed'],
- quiet=True)
+
+run(['python', 'third_party/v8/tools/clang/scripts/update.py', '--if-needed'])
diff --git a/tools/build_third_party.py b/tools/sync_third_party.py
index f32d669b2..f32d669b2 100755
--- a/tools/build_third_party.py
+++ b/tools/sync_third_party.py