From 1a120f356584022c1e4e08e93178e22dba2ef2fc Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 15 Jun 2023 11:02:46 +0900 Subject: [PATCH 1/5] build: fix building when there is only python3 --- tools/v8_gypfiles/toolchain.gypi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/v8_gypfiles/toolchain.gypi b/tools/v8_gypfiles/toolchain.gypi index bcecdb21aeb368..fbfcc403d85753 100644 --- a/tools/v8_gypfiles/toolchain.gypi +++ b/tools/v8_gypfiles/toolchain.gypi @@ -41,7 +41,7 @@ 'has_valgrind%': 0, 'coverage%': 0, 'v8_target_arch%': '<(target_arch)', - 'v8_host_byteorder%': ' Date: Sat, 17 Jun 2023 09:25:48 +0900 Subject: [PATCH 2/5] build: always set 'python' variable when running GYP --- configure.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.py b/configure.py index 8be9e9ca5c4af8..4a725d8971ebf5 100755 --- a/configure.py +++ b/configure.py @@ -2121,6 +2121,10 @@ def make_bin_override(): gyp_args = ['--no-parallel', '-Dconfiguring_node=1'] gyp_args += ['-Dbuild_type=' + config['BUILDTYPE']] +# always set 'python' variable, otherwise environments that only have python3 +# will fail to run python scripts +gyp_args += ['-Dpython=' + sys.executable] + if options.use_ninja: gyp_args += ['-f', 'ninja-' + flavor] elif flavor == 'win' and sys.platform != 'msys': @@ -2133,10 +2137,6 @@ def make_bin_override(): os.path.islink('./compile_commands.json') and os.unlink('./compile_commands.json') os.symlink('./out/' + config['BUILDTYPE'] + '/compile_commands.json', './compile_commands.json') -# override the variable `python` defined in common.gypi -if bin_override is not None: - gyp_args += ['-Dpython=' + sys.executable] - # pass the leftover non-whitespace positional arguments to GYP gyp_args += [arg for arg in args if not str.isspace(arg)] From ce31e662fcf6a9355288261598c92153f2cc0f87 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 23 Oct 2023 02:33:20 +0100 Subject: [PATCH 3/5] build: add quotes when executing binary --- tools/v8_gypfiles/toolchain.gypi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/v8_gypfiles/toolchain.gypi b/tools/v8_gypfiles/toolchain.gypi index fbfcc403d85753..b311c04d29281f 100644 --- a/tools/v8_gypfiles/toolchain.gypi +++ b/tools/v8_gypfiles/toolchain.gypi @@ -41,7 +41,7 @@ 'has_valgrind%': 0, 'coverage%': 0, 'v8_target_arch%': '<(target_arch)', - 'v8_host_byteorder%': ' Date: Tue, 24 Oct 2023 01:08:57 +0100 Subject: [PATCH 4/5] build: work around gyp hack for win arm64 --- configure.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/configure.py b/configure.py index 4a725d8971ebf5..33671a034290df 100755 --- a/configure.py +++ b/configure.py @@ -2121,9 +2121,16 @@ def make_bin_override(): gyp_args = ['--no-parallel', '-Dconfiguring_node=1'] gyp_args += ['-Dbuild_type=' + config['BUILDTYPE']] -# always set 'python' variable, otherwise environments that only have python3 -# will fail to run python scripts -gyp_args += ['-Dpython=' + sys.executable] +# Remove the trailing .exe from the executable name, otherwise the python.exe +# would be rewrote as python_host.exe due to hack in GYP for supporting cross +# compilation on Windows. +# See https://github.com/nodejs/node/pull/32867 for related change. +python = sys.executable +if flavor == 'win' and python.lower().endswith('.exe'): + python = python[:-4] +# Always set 'python' variable, otherwise environments that only have python3 +# will fail to run python scripts. +gyp_args += ['-Dpython=' + python] if options.use_ninja: gyp_args += ['-f', 'ninja-' + flavor] From ef4d45cdb9daf0cbca0cf26cd9c29e5b38f70c08 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Oct 2023 04:43:03 +0100 Subject: [PATCH 5/5] gyp: add quotes for action's executable --- node.gyp | 4 ++-- tools/gyp/pylib/gyp/generator/msvs.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/node.gyp b/node.gyp index 93e4235a0f3efd..3f6915b266fc38 100644 --- a/node.gyp +++ b/node.gyp @@ -762,7 +762,7 @@ '<(fipsmodule)', ], 'action': [ - 'python', 'tools/copyfile.py', + '<(python)', 'tools/copyfile.py', '<(fipsmodule_internal)', '<(fipsmodule)', ], @@ -772,7 +772,7 @@ 'inputs': [ '<(opensslconfig)', ], 'outputs': [ '<(opensslconfig_internal)', ], 'action': [ - 'python', 'tools/enable_fips_include.py', + '<(python)', 'tools/enable_fips_include.py', '<(opensslconfig)', '<(opensslconfig_internal)', '<(fipsconfig)', diff --git a/tools/gyp/pylib/gyp/generator/msvs.py b/tools/gyp/pylib/gyp/generator/msvs.py index fd950057847980..568109035ed976 100644 --- a/tools/gyp/pylib/gyp/generator/msvs.py +++ b/tools/gyp/pylib/gyp/generator/msvs.py @@ -438,6 +438,7 @@ def _BuildCommandLineForRuleRaw( # Support a mode for using cmd directly. # Convert any paths to native form (first element is used directly). # TODO(quote): regularize quoting path names throughout the module + command[1] = '"%s"' % command[1] arguments = ['"%s"' % i for i in arguments] # Collapse into a single command. return input_dir_preamble + " ".join(command + arguments)