Skip to content

Commit 3a849c1

Browse files
authored
Add initial support for windows (#34)
1 parent bee6ced commit 3a849c1

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
| [node_binary](#node_binary) | Build a node_modules tree and execute an entrypoint module script. |
2121
| [mocha_test](#mocha_test) | Run a mocha test script. |
2222

23+
<table><tr>
24+
<td><img src="https://www.kernel.org/theme/images/logos/tux.png" height="48"/></td>
25+
<td><img src="https://upload.wikimedia.org/wikipedia/commons/f/fa/Apple_logo_black.svg" height="48"/></td>
26+
<td><img src="https://upload.wikimedia.org/wikipedia/commons/5/5f/Windows_logo_-_2012.svg" height="48"/></td>
27+
</tr></table>
2328

2429
## node_repositories
2530

node/internal/node_binary.bzl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ def _create_launcher(ctx, output_dir, node):
6767
'cd $ROOT/%s' % output_dir,
6868
'&&',
6969
'exec',
70-
'node',
70+
ctx.executable._node.basename,
7171
] + ctx.attr.node_args + [
7272
entrypoint,
7373
] + ctx.attr.script_args + [
7474
'$@',
7575
]
7676

7777
lines = [
78-
'#!/usr/bin/env bash',
78+
'#!/usr/bin/env bash', # TODO(user): fix for windows
7979
'set -e',
8080

8181
# Set the execution root to the same directory where the
@@ -87,6 +87,7 @@ def _create_launcher(ctx, output_dir, node):
8787

8888
# Resolve to this node instance if other scripts have
8989
# '/usr/bin/env node' shebangs
90+
# TODO: fix for windows
9091
'export PATH="$ROOT:$PATH"',
9192

9293
' '.join(cmd)
@@ -120,7 +121,7 @@ def node_binary_impl(ctx):
120121
content = manifest_content.to_json(),
121122
)
122123

123-
node = ctx.new_file('%s/node' % output_dir)
124+
node = ctx.new_file('%s/%s' % (output_dir, ctx.executable._node.basename))
124125
ctx.action(
125126
mnemonic = 'CopyNode',
126127
inputs = [ctx.executable._node],

node/internal/node_repositories.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ _node_repository = repository_rule(
9595
default = "d67d2eb9456aab925416ad58aa18b9680e66a4bcc243a89b22e646f7fffc4ff9",
9696
),
9797
"windows_sha256": attr.string(
98-
default = "a03512d8f17d8312c6fece68a9c20aaa8e2268de18edfea847aa6a35af3a95ba",
98+
default = "617590f06f9a0266ceecb3fd17120fc2fbf8669980974f339a83f3b56ed05f7b",
9999
),
100100
},
101101
)

node/internal/yarn_modules.bzl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ def _yarn_modules_impl(ctx):
3636
fail("You must specify a package.json file OR deps (not both!)")
3737

3838
# Gather required resources
39-
node = ctx.path(ctx.attr._node)
39+
node_label = ctx.attr._node
40+
if ctx.os.name.lower().find("windows") != -1:
41+
node_label = ctx.attr._node_exe
42+
node = ctx.path(node_label)
43+
4044
parse_yarn_lock_js = ctx.path(ctx.attr._parse_yarn_lock_js)
4145
yarn_js = ctx.path(ctx.attr._yarn_js)
4246

@@ -79,6 +83,13 @@ yarn_modules = repository_rule(
7983
executable = True,
8084
cfg = "host",
8185
),
86+
"_node_exe": attr.label(
87+
default = Label("@node//:node.exe"),
88+
single_file = True,
89+
allow_files = True,
90+
executable = True,
91+
cfg = "host",
92+
),
8293
"_parse_yarn_lock_js": attr.label(
8394
default = Label("//node:internal/parse_yarn_lock.js"),
8495
single_file = True,

0 commit comments

Comments
 (0)