Skip to content

Commit

Permalink
fix(builtin): fix localWorkspacePath logic
Browse files Browse the repository at this point in the history
If the manifest has an entry in the output_base but not in the binDir or genDir, we get a wrong path for later resolutions

Fixes bazel-contrib#1087
  • Loading branch information
alexeagle committed Sep 4, 2019
1 parent df37fca commit 9da2a95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/node/node.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def _nodejs_binary_impl(ctx):
# also be sure to include the params file in the program inputs
node_tool_files += [ctx.outputs.templated_args_file]

node_tool_files.append(ctx.file._loader_template)
substitutions = {
"TEMPLATED_args": " ".join([
expand_location_into_runfiles(ctx, a)
Expand Down
4 changes: 3 additions & 1 deletion internal/node/node_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ function loadRunfilesManifest(manifestPath) {
const runfilesManifest = Object.create(null);
const reverseRunfilesManifest = Object.create(null);
const input = fs.readFileSync(manifestPath, {encoding: 'utf-8'});
const outputBase = manifestPath.substring(0, manifestPath.indexOf('/execroot/'));

// Absolute path that refers to the local workspace path. We need to determine the absolute
// path to the local workspace because it allows us to support absolute path resolving
Expand All @@ -124,7 +125,7 @@ function loadRunfilesManifest(manifestPath) {
// runfile refers to a different workspace, or the current runfile resolves to a file
// in the bazel-out directory (bin/genfiles directory).
if (localWorkspacePath || !runfilesPath.startsWith(USER_WORKSPACE_NAME) ||
realPath.includes(BIN_DIR) || realPath.includes(GEN_DIR)) {
realPath.startsWith(outputBase)) {
continue;
}

Expand All @@ -149,6 +150,7 @@ function loadRunfilesManifest(manifestPath) {
genRoot = `${execRoot}${GEN_DIR}/`;
}

log_verbose(`using outputBase ${outputBase}`);
log_verbose(`using binRoot ${binRoot}`);
log_verbose(`using genRoot ${genRoot}`);
log_verbose(`using localWorkspacePath ${localWorkspacePath}`);
Expand Down

0 comments on commit 9da2a95

Please sign in to comment.