Skip to content

Commit

Permalink
build: remove absolute path
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed Nov 1, 2018
1 parent 9aa3640 commit b73b651
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
6 changes: 1 addition & 5 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,7 @@ after_test:
Select-String $trap -Path $files -SimpleMatch | where {
# V8 took the liberty to produce an absolute path in their ninja
# output. We can't do much about that, so we just ignore it.
$_.Line -notmatch "v8/builtins-generated/bytecodes-builtins-list.h" -and
# The absolute path to snapshot_libdeno_test.bin is passed to test_cc
# via pre-processor variable. It's absolute because we want to be able
# to execute test_cc from both the project root and the build root.
$_.Line -notmatch "snapshot_libdeno_test.bin"
$_.Line -notmatch "v8/builtins-generated/bytecodes-builtins-list.h"
} | tee -Variable line_matches
if ($line_matches) {
$ctx = $line_matches.Line |
Expand Down
4 changes: 2 additions & 2 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ v8_executable("test_cc") {
data = [
"$target_gen_dir/snapshot_libdeno_test.bin",
]
snapshot_abs_path = rebase_path(data[0])
defines = [ "SNAPSHOT_PATH=\"$snapshot_abs_path\"" ]
snapshot_path = rebase_path(data[0], root_build_dir)
defines = [ "SNAPSHOT_PATH=\"$snapshot_path\"" ]
configs = [ ":deno_config" ]
}

Expand Down
12 changes: 10 additions & 2 deletions libdeno/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
deno_buf snapshot = {nullptr, 0, nullptr, 0};

int main(int argc, char** argv) {
// Locate the snapshot.
std::string exe_path;
if (!deno::ExePath(&exe_path)) {
std::cerr << "deno::ExePath() failed" << std::endl;
return 1;
}
std::string snapshot_path = deno::Dirname(exe_path) + SNAPSHOT_PATH;

// Load the snapshot.
std::string contents;
if (!deno::ReadFileToString(SNAPSHOT_PATH, &contents)) {
printf("Failed to read file %s\n", SNAPSHOT_PATH);
if (!deno::ReadFileToString(snapshot_path.c_str(), &contents)) {
std::cerr << "Failed to read snapshot from " << snapshot_path << std::endl;
return 1;
}
snapshot.data_ptr =
Expand Down

0 comments on commit b73b651

Please sign in to comment.