From d1ccca9d2bd913194a70beb762876f46e46060a0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 25 Oct 2023 11:43:37 +0900 Subject: [PATCH] build: fix building when there is only python3 PR-URL: https://github.com/nodejs/node/pull/48462 Reviewed-By: Luigi Pinca Reviewed-By: Jiawen Geng --- configure.py | 15 +++++++++++---- node.gyp | 4 ++-- tools/gyp/pylib/gyp/generator/msvs.py | 1 + tools/v8_gypfiles/toolchain.gypi | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/configure.py b/configure.py index 8be9e9ca5c4..33671a03429 100755 --- a/configure.py +++ b/configure.py @@ -2121,6 +2121,17 @@ write('config.mk', do_not_edit + config_str) gyp_args = ['--no-parallel', '-Dconfiguring_node=1'] gyp_args += ['-Dbuild_type=' + config['BUILDTYPE']] +# 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] elif flavor == 'win' and sys.platform != 'msys': @@ -2133,10 +2144,6 @@ if options.compile_commands_json: 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)] diff --git a/node.gyp b/node.gyp index 93e4235a0f3..3f6915b266f 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 fd950057847..568109035ed 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) diff --git a/tools/v8_gypfiles/toolchain.gypi b/tools/v8_gypfiles/toolchain.gypi index bcecdb21aeb..b311c04d292 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%': '