mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 21:50:00 -05:00
Use include_bytes! instead of incbin.
This is the second attempt at this patch. The first version was reverted
in 2ffd78daf9
The problem, I suspect, was that the snapshot was represented as a
source_set, which inserted a node into the dependency tree.
include_bytes does properly insert the snapshot into rustc's depfile but
the use of source_set confused gn. Now the that the deno executable has
the create_deno_snapshot as a direct dependency, changes will be
propagated.
This commit is contained in:
parent
7d02971c2c
commit
f727214db0
4 changed files with 30 additions and 96 deletions
88
BUILD.gn
88
BUILD.gn
|
@ -111,6 +111,14 @@ ts_sources = [
|
||||||
"third_party/yarn.lock",
|
"third_party/yarn.lock",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
group("deno_deps") {
|
||||||
|
deps = [
|
||||||
|
":create_snapshot_deno",
|
||||||
|
":msg_rs",
|
||||||
|
"libdeno:libdeno",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
rust_executable("deno") {
|
rust_executable("deno") {
|
||||||
source_root = "src/main.rs"
|
source_root = "src/main.rs"
|
||||||
extern = main_extern
|
extern = main_extern
|
||||||
|
@ -119,51 +127,6 @@ rust_executable("deno") {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
source_set("snapshot") {
|
|
||||||
sources = [
|
|
||||||
"src/snapshot.cc",
|
|
||||||
]
|
|
||||||
configs += [ "libdeno:deno_config" ]
|
|
||||||
inputs = [
|
|
||||||
"$target_gen_dir/snapshot_deno.bin",
|
|
||||||
]
|
|
||||||
deps = [
|
|
||||||
":create_snapshot_deno",
|
|
||||||
]
|
|
||||||
|
|
||||||
# snapshot.cc doesn't need to depend on libdeno, it just needs deno_buf.
|
|
||||||
include_dirs = [ "libdeno/" ]
|
|
||||||
|
|
||||||
# src/snapshot.cc uses an assembly '.incbin' directive to embed the snapshot.
|
|
||||||
# This causes trouble when using sccache: since the snapshot file is not
|
|
||||||
# inlined by the c preprocessor, sccache doesn't take its contents into
|
|
||||||
# consideration, leading to false-positive cache hits.
|
|
||||||
# Maybe other caching tools have this issue too, but ccache is unaffected.
|
|
||||||
# Therefore, if a cc_wrapper is used that isn't ccache, include a generated
|
|
||||||
# header file that contains the the sha256 hash of the snapshot.
|
|
||||||
if (cc_wrapper != "" && cc_wrapper != "ccache") {
|
|
||||||
hash_h = "$target_gen_dir/bundle/hash.h"
|
|
||||||
inputs += [ hash_h ]
|
|
||||||
deps += [ ":bundle_hash_h" ]
|
|
||||||
if (is_win) {
|
|
||||||
cflags = [ "/FI" + rebase_path(hash_h, target_out_dir) ]
|
|
||||||
} else {
|
|
||||||
cflags = [
|
|
||||||
"-include",
|
|
||||||
rebase_path(hash_h, target_out_dir),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rust_executable("hyper_hello") {
|
|
||||||
source_root = "tools/hyper_hello.rs"
|
|
||||||
extern = [
|
|
||||||
"$rust_build:hyper",
|
|
||||||
"$rust_build:ring",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
rust_test("test_rs") {
|
rust_test("test_rs") {
|
||||||
source_root = "src/main.rs"
|
source_root = "src/main.rs"
|
||||||
extern = main_extern
|
extern = main_extern
|
||||||
|
@ -172,14 +135,12 @@ rust_test("test_rs") {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
v8_static_library("deno_deps") {
|
rust_executable("hyper_hello") {
|
||||||
complete_static_lib = true
|
source_root = "tools/hyper_hello.rs"
|
||||||
public_deps = [
|
extern = [
|
||||||
":msg_rs",
|
"$rust_build:hyper",
|
||||||
":snapshot",
|
"$rust_build:ring",
|
||||||
"libdeno:libdeno",
|
|
||||||
]
|
]
|
||||||
configs = [ "libdeno:deno_config" ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generates the core TypeScript type library for deno that will be
|
# Generates the core TypeScript type library for deno that will be
|
||||||
|
@ -236,29 +197,6 @@ run_node("bundle") {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
action("bundle_hash_h") {
|
|
||||||
script = "//tools/sha256sum.py"
|
|
||||||
inputs = get_target_outputs(":bundle")
|
|
||||||
outputs = [
|
|
||||||
"$target_gen_dir/bundle/hash.h",
|
|
||||||
]
|
|
||||||
deps = [
|
|
||||||
":bundle",
|
|
||||||
]
|
|
||||||
args = [
|
|
||||||
"--format",
|
|
||||||
"__attribute__((__unused__)) static const int dummy_%s = 0;",
|
|
||||||
"--outfile",
|
|
||||||
rebase_path(outputs[0], root_build_dir),
|
|
||||||
]
|
|
||||||
foreach(input, inputs) {
|
|
||||||
args += [
|
|
||||||
"--infile",
|
|
||||||
rebase_path(input, root_build_dir),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ts_flatbuffer("msg_ts") {
|
ts_flatbuffer("msg_ts") {
|
||||||
sources = [
|
sources = [
|
||||||
"src/msg.fbs",
|
"src/msg.fbs",
|
||||||
|
|
|
@ -97,7 +97,7 @@ fn main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
let state = Arc::new(isolate::IsolateState::new(flags, rest_argv));
|
let state = Arc::new(isolate::IsolateState::new(flags, rest_argv));
|
||||||
let snapshot = unsafe { snapshot::deno_snapshot.clone() };
|
let snapshot = snapshot::deno_snapshot();
|
||||||
let mut isolate = isolate::Isolate::new(snapshot, state, ops::dispatch);
|
let mut isolate = isolate::Isolate::new(snapshot, state, ops::dispatch);
|
||||||
tokio_util::init(|| {
|
tokio_util::init(|| {
|
||||||
isolate
|
isolate
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
|
||||||
|
|
||||||
#include "deno.h"
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
|
|
||||||
extern const char snapshot_start asm("snapshot_start");
|
|
||||||
extern const char snapshot_end asm("snapshot_end");
|
|
||||||
asm(".data\n"
|
|
||||||
"snapshot_start: .incbin \"gen/snapshot_deno.bin\"\n"
|
|
||||||
"snapshot_end:\n"
|
|
||||||
".globl snapshot_start;\n"
|
|
||||||
".globl snapshot_end;");
|
|
||||||
extern const deno_buf deno_snapshot = {
|
|
||||||
nullptr, 0, reinterpret_cast<uint8_t*>(const_cast<char*>(&snapshot_start)),
|
|
||||||
static_cast<size_t>(&snapshot_end - &snapshot_start)};
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +1,19 @@
|
||||||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||||
use libdeno::deno_buf;
|
use libdeno::deno_buf;
|
||||||
extern "C" {
|
use std;
|
||||||
pub static deno_snapshot: deno_buf;
|
|
||||||
|
pub fn deno_snapshot() -> deno_buf {
|
||||||
|
let data =
|
||||||
|
include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/snapshot_deno.bin"));
|
||||||
|
let ptr = data.as_ptr();
|
||||||
|
// TODO The cast is not necessary here. deno_buf specifies mutable
|
||||||
|
// pointers when it doesn't necessarally need mutable. So maybe the deno_buf
|
||||||
|
// type should be broken into a mutable and non-mutable version?
|
||||||
|
let ptr_mut = ptr as *mut u8;
|
||||||
|
deno_buf {
|
||||||
|
alloc_ptr: std::ptr::null_mut(),
|
||||||
|
alloc_len: 0,
|
||||||
|
data_ptr: ptr_mut,
|
||||||
|
data_len: data.len(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue