1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-22 15:10:44 -05:00

build: do not bake absolute paths into deno_ns

This commit is contained in:
Bert Belder 2018-08-26 01:38:23 +02:00
parent 26707446fc
commit 79f60f6731
No known key found for this signature in database
GPG key ID: 7A77887B2E2ED461
2 changed files with 14 additions and 11 deletions

View file

@ -243,9 +243,8 @@ run_node("bundle") {
source_set("libdeno_nosnapshot") {
bundle_outputs = get_target_outputs(":bundle")
bundle_location = rebase_path(bundle_outputs[0])
bundle_rel_location = rebase_path(bundle_outputs[0], root_build_dir)
bundle_map_location = rebase_path(bundle_outputs[1])
bundle_location = rebase_path(bundle_outputs[0], root_build_dir)
bundle_map_location = rebase_path(bundle_outputs[1], root_build_dir)
inputs = bundle_outputs
sources = [
"libdeno/from_filesystem.cc",
@ -257,7 +256,6 @@ source_set("libdeno_nosnapshot") {
configs += [ ":deno_config" ]
defines = [
"BUNDLE_LOCATION=\"$bundle_location\"",
"BUNDLE_REL_LOCATION=\"$bundle_rel_location\"",
"BUNDLE_MAP_LOCATION=\"$bundle_map_location\"",
]
}

View file

@ -15,11 +15,17 @@
namespace deno {
Deno* NewFromFileSystem(void* data, deno_recv_cb cb) {
std::string js_source;
CHECK(deno::ReadFileToString(BUNDLE_LOCATION, &js_source));
std::string exe_path;
CHECK(deno::ExePath(&exe_path));
std::string exe_dir = deno::Dirname(exe_path); // Always ends with a slash.
std::string js_source_path = exe_dir + BUNDLE_LOCATION;
std::string js_source;
CHECK(deno::ReadFileToString(js_source_path.c_str(), &js_source));
std::string js_source_map_path = exe_dir + BUNDLE_MAP_LOCATION;
std::string js_source_map;
CHECK(deno::ReadFileToString(BUNDLE_MAP_LOCATION, &js_source_map));
CHECK(deno::ReadFileToString(js_source_map_path.c_str(), &js_source_map));
Deno* d = new Deno;
d->currentArgs = nullptr;
@ -36,10 +42,9 @@ Deno* NewFromFileSystem(void* data, deno_recv_cb cb) {
{
v8::HandleScope handle_scope(isolate);
auto context = v8::Context::New(isolate);
// BUNDLE_LOCATION is absolute so deno_ns can load the bundle independently
// of the cwd. However for source maps to work, the bundle location relative
// to the build path must be supplied: BUNDLE_REL_LOCATION.
InitializeContext(isolate, context, BUNDLE_REL_LOCATION, js_source,
// For source maps to work, the bundle location that is passed to
// InitializeContext must be a relative path.
InitializeContext(isolate, context, BUNDLE_LOCATION, js_source,
&js_source_map);
d->context.Reset(d->isolate, context);
}