mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
Add nosnapshot executables for faster incremental builds (#359)
Fixes #311.
This commit is contained in:
parent
791357115c
commit
7e5f0a7a66
3 changed files with 98 additions and 8 deletions
|
@ -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
|
||||
|
|
51
BUILD.gn
51
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") {
|
||||
|
|
51
src/from_filesystem.cc
Normal file
51
src/from_filesystem.cc
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue