Skip to content

Commit cfd50f2

Browse files
zcbenzUlisesGascon
authored andcommitted
build: fix building when there is only python3
PR-URL: #48462 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Jiawen Geng <[email protected]>
1 parent 9346f15 commit cfd50f2

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
@@ -2120,6 +2120,17 @@ def make_bin_override():
21202120
gyp_args = ['--no-parallel', '-Dconfiguring_node=1']
21212121
gyp_args += ['-Dbuild_type=' + config['BUILDTYPE']]
21222122

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

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

node.gyp

+2-2
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@
754754
'<(fipsmodule)',
755755
],
756756
'action': [
757-
'python', 'tools/copyfile.py',
757+
'<(python)', 'tools/copyfile.py',
758758
'<(fipsmodule_internal)',
759759
'<(fipsmodule)',
760760
],
@@ -764,7 +764,7 @@
764764
'inputs': [ '<(opensslconfig)', ],
765765
'outputs': [ '<(opensslconfig_internal)', ],
766766
'action': [
767-
'python', 'tools/enable_fips_include.py',
767+
'<(python)', 'tools/enable_fips_include.py',
768768
'<(opensslconfig)',
769769
'<(opensslconfig_internal)',
770770
'<(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)