Skip to content

Commit 54ebfc1

Browse files
zcbenztargos
authored andcommitted
build: fix building when there is only python3
PR-URL: #48462 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
1 parent f1d79b3 commit 54ebfc1

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

configure.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -2121,6 +2121,17 @@ def make_bin_override():
21212121
gyp_args = ['--no-parallel', '-Dconfiguring_node=1']
21222122
gyp_args += ['-Dbuild_type=' + config['BUILDTYPE']]
21232123

2124+
# Remove the trailing .exe from the executable name, otherwise the python.exe
2125+
# would be rewrote as python_host.exe due to hack in GYP for supporting cross
2126+
# compilation on Windows.
2127+
# See https://github.com/nodejs/node/pull/32867 for related change.
2128+
python = sys.executable
2129+
if flavor == 'win' and python.lower().endswith('.exe'):
2130+
python = python[:-4]
2131+
# Always set 'python' variable, otherwise environments that only have python3
2132+
# will fail to run python scripts.
2133+
gyp_args += ['-Dpython=' + python]
2134+
21242135
if options.use_ninja:
21252136
gyp_args += ['-f', 'ninja-' + flavor]
21262137
elif flavor == 'win' and sys.platform != 'msys':
@@ -2133,10 +2144,6 @@ def make_bin_override():
21332144
os.path.islink('./compile_commands.json') and os.unlink('./compile_commands.json')
21342145
os.symlink('./out/' + config['BUILDTYPE'] + '/compile_commands.json', './compile_commands.json')
21352146

2136-
# override the variable `python` defined in common.gypi
2137-
if bin_override is not None:
2138-
gyp_args += ['-Dpython=' + sys.executable]
2139-
21402147
# pass the leftover non-whitespace positional arguments to GYP
21412148
gyp_args += [arg for arg in args if not str.isspace(arg)]
21422149

node.gyp

+2-2
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@
762762
'<(fipsmodule)',
763763
],
764764
'action': [
765-
'python', 'tools/copyfile.py',
765+
'<(python)', 'tools/copyfile.py',
766766
'<(fipsmodule_internal)',
767767
'<(fipsmodule)',
768768
],
@@ -772,7 +772,7 @@
772772
'inputs': [ '<(opensslconfig)', ],
773773
'outputs': [ '<(opensslconfig_internal)', ],
774774
'action': [
775-
'python', 'tools/enable_fips_include.py',
775+
'<(python)', 'tools/enable_fips_include.py',
776776
'<(opensslconfig)',
777777
'<(opensslconfig_internal)',
778778
'<(fipsconfig)',

tools/gyp/pylib/gyp/generator/msvs.py

+1
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ def _BuildCommandLineForRuleRaw(
438438
# Support a mode for using cmd directly.
439439
# Convert any paths to native form (first element is used directly).
440440
# TODO(quote): regularize quoting path names throughout the module
441+
command[1] = '"%s"' % command[1]
441442
arguments = ['"%s"' % i for i in arguments]
442443
# Collapse into a single command.
443444
return input_dir_preamble + " ".join(command + arguments)

tools/v8_gypfiles/toolchain.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
'has_valgrind%': 0,
4242
'coverage%': 0,
4343
'v8_target_arch%': '<(target_arch)',
44-
'v8_host_byteorder%': '<!(python -c "import sys; print(sys.byteorder)")',
44+
'v8_host_byteorder%': '<!("<(python)" -c "import sys; print(sys.byteorder)")',
4545
'force_dynamic_crt%': 0,
4646

4747
# Setting 'v8_can_use_vfp32dregs' to 'true' will cause V8 to use the VFP

0 commit comments

Comments
 (0)