summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFaris Amali Alis <faris@starchild.my>2018-07-13 03:06:36 +0800
committerRyan Dahl <ry@tinyclouds.org>2018-07-12 15:06:36 -0400
commit7e5f0a7a663de3fea0520e40a65872f7704ea262 (patch)
tree9896b437b017e78592abeee914b1f24790d42bcd
parent791357115c0aa1e4f87f70c57327bc66928b5019 (diff)
Add nosnapshot executables for faster incremental builds (#359)
Fixes #311.
-rw-r--r--.travis.yml4
-rw-r--r--BUILD.gn51
-rw-r--r--src/from_filesystem.cc51
3 files changed, 98 insertions, 8 deletions
diff --git a/.travis.yml b/.travis.yml
index 1718e2eb3..d5e4af5d1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -42,10 +42,12 @@ install:
- gn args $BUILD_PATH --list
- ccache -s
# Travis hangs without -j2 argument to ninja.
- - ninja -j2 -C $BUILD_PATH mock_runtime_test handlers_test deno_cc deno
+ - ninja -j2 -C $BUILD_PATH mock_runtime_test handlers_test deno_cc deno_cc_nosnapshot deno deno_nosnapshot
script:
- ./tools/lint.py
- $BUILD_PATH/mock_runtime_test
- $BUILD_PATH/handlers_test
- $BUILD_PATH/deno_cc foo bar
+ - $BUILD_PATH/deno_cc_nosnapshot foo bar
- $BUILD_PATH/deno meow
+ - $BUILD_PATH/deno_nosnapshot meow
diff --git a/BUILD.gn b/BUILD.gn
index 2027562af..163df2607 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -15,9 +15,16 @@ config("deno_config") {
rust_executable("deno") {
source_root = "src/main.rs"
extern = [ "$rust_build:libc" ]
- deps = [
- ":libdeno",
- ]
+ deps = [ ":libdeno" ]
+}
+
+# This target is for fast incremental development.
+# When modifying the javascript runtime, this target will not go through the
+# extra process of building a snapshot and instead load the bundle from disk.
+rust_executable("deno_nosnapshot") {
+ source_root = "src/main.rs"
+ extern = [ "$rust_build:libc" ]
+ deps = [ ":libdeno_nosnapshot" ]
}
rust_staticlib("handlers") {
@@ -49,6 +56,22 @@ executable("deno_cc") {
configs += [ ":deno_config" ]
}
+# This target is for fast incremental development.
+# When modifying the javascript runtime, this target will not go through the
+# extra process of building a snapshot and instead load the bundle from disk.
+executable("deno_cc_nosnapshot") {
+ sources = [
+ "src/main.cc",
+ ]
+ deps = [
+ ":flatbufferjs",
+ ":handlers",
+ ":libdeno_nosnapshot",
+ ":msg_cpp",
+ ]
+ configs += [ ":deno_config" ]
+}
+
executable("mock_runtime_test") {
testonly = true
sources = [
@@ -58,7 +81,7 @@ executable("mock_runtime_test") {
]
deps = [
":create_snapshot_mock_runtime",
- ":deno_nosnapshot",
+ ":deno_bindings",
"//testing/gtest:gtest",
]
defines = [ "DENO_MOCK_RUNTIME" ]
@@ -72,12 +95,12 @@ static_library("libdeno") {
]
deps = [
":create_snapshot_deno",
- ":deno_nosnapshot",
+ ":deno_bindings",
]
configs += [ ":deno_config" ]
}
-v8_source_set("deno_nosnapshot") {
+v8_source_set("deno_bindings") {
sources = [
"src/binding.cc",
"src/deno.h",
@@ -96,7 +119,7 @@ executable("snapshot_creator") {
"src/snapshot_creator.cc",
]
deps = [
- ":deno_nosnapshot",
+ ":deno_bindings",
]
configs += [ ":deno_config" ]
}
@@ -139,6 +162,20 @@ run_node("bundle") {
]
}
+source_set("libdeno_nosnapshot") {
+ sources = [
+ "src/from_filesystem.cc",
+ ]
+ deps = [
+ ":bundle",
+ ":deno_bindings",
+ ]
+ configs += [ ":deno_config" ]
+ bundle_outputs = get_target_outputs(":bundle")
+ bundle_location = rebase_path(bundle_outputs[0])
+ defines = [ "BUNDLE_LOCATION=\"$bundle_location\"" ]
+}
+
# Due to bugs in Parcel we must run TSC independently in order to catch errors.
# https://github.com/parcel-bundler/parcel/issues/954
run_node("run_tsc") {
diff --git a/src/from_filesystem.cc b/src/from_filesystem.cc
new file mode 100644
index 000000000..b8854c6ff
--- /dev/null
+++ b/src/from_filesystem.cc
@@ -0,0 +1,51 @@
+// Copyright 2018 Ryan Dahl <ry@tinyclouds.org>
+// All rights reserved. MIT License.
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <string>
+
+#include "third_party/v8/include/v8.h"
+#include "third_party/v8/src/base/logging.h"
+
+#include "deno.h"
+#include "file_util.h"
+#include "internal.h"
+
+namespace deno {
+
+Deno* NewFromFileSystem(void* data, deno_recv_cb cb) {
+ printf("Reading javascript runtime bundle from " BUNDLE_LOCATION "\n");
+
+ std::string js_source;
+ CHECK(deno::ReadFileToString(BUNDLE_LOCATION, &js_source));
+
+ Deno* d = new Deno;
+ d->currentArgs = nullptr;
+ d->cb = cb;
+ d->data = data;
+ v8::Isolate::CreateParams params;
+ params.array_buffer_allocator =
+ v8::ArrayBuffer::Allocator::NewDefaultAllocator();
+ v8::Isolate* isolate = v8::Isolate::New(params);
+ AddIsolate(d, isolate);
+
+ v8::Locker locker(isolate);
+ v8::Isolate::Scope isolate_scope(isolate);
+ {
+ v8::HandleScope handle_scope(isolate);
+ auto context = v8::Context::New(isolate);
+ InitializeContext(isolate, context, BUNDLE_LOCATION, js_source.c_str());
+ d->context.Reset(d->isolate, context);
+ }
+
+ return d;
+}
+
+} // namespace deno
+
+extern "C" {
+Deno* deno_new(void* data, deno_recv_cb cb) {
+ return deno::NewFromFileSystem(data, cb);
+}
+}