Skip to content

Commit

Permalink
fix(builtin): windows fix for nodejs_binary entry point logic
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed Mar 26, 2020
1 parent 8644816 commit ed6cbe3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion internal/node/launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,13 @@ for ARG in "${ALL_ARGS[@]:-}"; do
case "$ARG" in
--bazel_node_modules_manifest=*) MODULES_MANIFEST="${ARG#--bazel_node_modules_manifest=}" ;;
--nobazel_patch_module_resolver)
MAIN="TEMPLATED_script_path"
declare MAIN=$(rlocation "TEMPLATED_entry_point_manifest_path")
if [[ ! -f "$MAIN" ]]; then
MAIN="TEMPLATED_entry_point_runfiles_path"
fi
if [[ ! -f "$MAIN" ]]; then
MAIN="TEMPLATED_entry_point_execroot_path"
fi
LAUNCHER_NODE_OPTIONS=( "--require" "$node_patches_script" )

# In this case we should always run the linker
Expand Down
10 changes: 9 additions & 1 deletion internal/node/node.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ def _to_execroot_path(ctx, file):
return "/".join(parts[2:])
return file.path

def _to_runfiles_path(ctx, file):
result = _to_execroot_path(ctx, file)
if result.startswith(ctx.bin_dir.path + "/"):
result = result[len(ctx.bin_dir.path) + 1:]
return result

def _nodejs_binary_impl(ctx):
node_modules_manifest = write_node_modules_manifest(ctx)
node_modules_depsets = []
Expand Down Expand Up @@ -216,6 +222,9 @@ def _nodejs_binary_impl(ctx):
expand_location_into_runfiles(ctx, a, ctx.attr.data)
for a in ctx.attr.templated_args
]),
"TEMPLATED_entry_point_execroot_path": _to_execroot_path(ctx, ctx.file.entry_point),
"TEMPLATED_entry_point_manifest_path": _to_manifest_path(ctx, ctx.file.entry_point),
"TEMPLATED_entry_point_runfiles_path": _to_runfiles_path(ctx, ctx.file.entry_point),
"TEMPLATED_env_vars": env_vars,
"TEMPLATED_expected_exit_code": str(expected_exit_code),
"TEMPLATED_link_modules_script": _to_manifest_path(ctx, ctx.file._link_modules_script),
Expand All @@ -225,7 +234,6 @@ def _nodejs_binary_impl(ctx):
"TEMPLATED_repository_args": _to_manifest_path(ctx, ctx.file._repository_args),
"TEMPLATED_require_patch_script": _to_manifest_path(ctx, ctx.outputs.require_patch_script),
"TEMPLATED_runfiles_helper_script": _to_manifest_path(ctx, ctx.file._runfiles_helper_script),
"TEMPLATED_script_path": _to_execroot_path(ctx, ctx.file.entry_point),
"TEMPLATED_vendored_node": "" if is_builtin else strip_external(ctx.file._node.path),
}
ctx.actions.expand_template(
Expand Down

0 comments on commit ed6cbe3

Please sign in to comment.