diff options
author | Bert Belder <bertbelder@gmail.com> | 2018-08-26 01:38:23 +0200 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2018-08-26 18:27:23 +0200 |
commit | 79f60f67319fb5bb52923e6a6b1122a93025ebbf (patch) | |
tree | 0a09903f775616cd188c293acdf96dab379ed807 | |
parent | 26707446fc83a6f6c7152153db43db4152698f58 (diff) |
build: do not bake absolute paths into deno_ns
-rw-r--r-- | BUILD.gn | 6 | ||||
-rw-r--r-- | libdeno/from_filesystem.cc | 17 |
2 files changed, 13 insertions, 10 deletions
@@ -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\"", ] } diff --git a/libdeno/from_filesystem.cc b/libdeno/from_filesystem.cc index fa50c0515..0852f1558 100644 --- a/libdeno/from_filesystem.cc +++ b/libdeno/from_filesystem.cc @@ -15,11 +15,17 @@ namespace deno { Deno* NewFromFileSystem(void* data, deno_recv_cb cb) { + 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(BUNDLE_LOCATION, &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); } |