Skip to content

Commit

Permalink
Make it clear to node-gyp which action arguments are paths
Browse files Browse the repository at this point in the history
On Windows, node-gyp tries to be helpful by changing forward slashes
to backslashes and making paths relative to the source root rather
than the build directory, and indeed we rely on that. However, it has
to guess what's a path and what isn't. Previously, we worked around
that by manually stripping the prepended "..\", but the node-gyp
maintainers suggested a better workaround of using joined arguments
instead (`--foo=bar` instead of `--foo bar`).
  • Loading branch information
jrose-signal committed Sep 21, 2021
1 parent 0d5d700 commit ddce4ee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
9 changes: 5 additions & 4 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
'action': [
'python3',
'node/build_node_bridge.py',
# Use separated arguments for paths, joined arguments for non-paths.
'--out-dir', '<(PRODUCT_DIR)/',
'--os-name', '<(NODE_OS_NAME)',
'--configuration', '<(CONFIGURATION_NAME)',
'--os-name=<(NODE_OS_NAME)',
'--configuration=<(CONFIGURATION_NAME)',
'--cargo-build-dir', '<(INTERMEDIATE_DIR)/rust',
'--cargo-target', '<(CARGO_ARCH)-<(CARGO_TARGET_SUFFIX)',
'--node-arch', '<(target_arch)'
'--cargo-target=<(CARGO_ARCH)-<(CARGO_TARGET_SUFFIX)',
'--node-arch=<(target_arch)'
],
'inputs': [],
'outputs': [
Expand Down
6 changes: 0 additions & 6 deletions node/build_node_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,16 @@ def main(args=None):
if node_os_name is None:
print('ERROR: --os-name is required')
return 1
if node_os_name.startswith('..\\'):
node_os_name = node_os_name[3:]

cargo_target = options.cargo_target
if cargo_target is None:
print('ERROR: --cargo-target is required')
return 1
if cargo_target.startswith('..\\'):
cargo_target = cargo_target[3:]

node_arch = options.node_arch
if node_arch is None:
print('ERROR: --node_arch is required')
return 1
if node_arch.startswith('..\\'):
node_arch = node_arch[3:]

out_dir = options.out_dir.strip('"') or os.path.join('build', configuration_name)

Expand Down

0 comments on commit ddce4ee

Please sign in to comment.