From ddce4ee3a44ea822ddfc68a4f4fba55bdd2f12e7 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Tue, 21 Sep 2021 10:25:52 -0700 Subject: [PATCH] Make it clear to node-gyp which action arguments are paths 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`). --- binding.gyp | 9 +++++---- node/build_node_bridge.py | 6 ------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/binding.gyp b/binding.gyp index 089e873afa..c9619872b3 100644 --- a/binding.gyp +++ b/binding.gyp @@ -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': [ diff --git a/node/build_node_bridge.py b/node/build_node_bridge.py index 34f1da7151..9d86dbee47 100755 --- a/node/build_node_bridge.py +++ b/node/build_node_bridge.py @@ -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)