Skip to content

Commit

Permalink
Missing .bzl bits
Browse files Browse the repository at this point in the history
  • Loading branch information
Silic0nS0ldier committed Nov 15, 2023
1 parent 3bb0885 commit 15125c5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
20 changes: 0 additions & 20 deletions internal/linker/link_node_modules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -101,33 +101,13 @@ def write_node_modules_manifest(ctx, extra_data = [], mnemonic = None, link_work
_debug(ctx.var, "Linking %s: %s" % (k, v))
mappings[k] = v

# Convert mappings to a module sets (modules per package package_path)
# {
# "package_path": {
# "package_name": "source_path",
# ...
# },
# ...
# }
module_sets = {}
for k, v in mappings.items():
map_key_split = k.split(":")
package_name = map_key_split[0]
package_path = map_key_split[1] if len(map_key_split) > 1 else ""
source_path = v[1]
if package_path not in module_sets:
module_sets[package_path] = {}
module_sets[package_path][package_name] = source_path

# Write the result to a file, and use the magic node option --bazel_node_modules_manifest
# The launcher.sh will peel off this argument and pass it to the linker rather than the program.
prefix = ctx.label.name
if mnemonic != None:
prefix += "_%s" % mnemonic
modules_manifest = ctx.actions.declare_file("_%s.module_mappings.json" % prefix)
content = {
"bin": ctx.bin_dir.path,
"module_sets": module_sets,
"roots": node_modules_roots,
"workspace": ctx.workspace_name,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/node/node.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def _nodejs_binary_impl(ctx):

# Provide the target name as an environment variable avaiable to all actions for the
# runfiles helpers to use.
env_vars = "export BAZEL_TARGET=%s\n" % ctx.label
env_vars += """export NM_SYMLINKS="$(mktemp -d)/nm-symlinks.json"\n"""

# Add all env vars from the ctx attr
for [key, value] in ctx.attr.env.items():
Expand Down

0 comments on commit 15125c5

Please sign in to comment.