Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix building when there is only python3 #48462

Merged
merged 5 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2121,6 +2121,17 @@ def make_bin_override():
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':
Expand All @@ -2133,10 +2144,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)]

Expand Down
4 changes: 2 additions & 2 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@
'<(fipsmodule)',
],
'action': [
'python', 'tools/copyfile.py',
'<(python)', 'tools/copyfile.py',
'<(fipsmodule_internal)',
'<(fipsmodule)',
],
Expand All @@ -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)',
Expand Down
1 change: 1 addition & 0 deletions tools/gyp/pylib/gyp/generator/msvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also upstream to https://github.com/nodejs/gyp-next

# Collapse into a single command.
return input_dir_preamble + " ".join(command + arguments)
Expand Down
2 changes: 1 addition & 1 deletion tools/v8_gypfiles/toolchain.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
'has_valgrind%': 0,
'coverage%': 0,
'v8_target_arch%': '<(target_arch)',
'v8_host_byteorder%': '<!(python -c "import sys; print(sys.byteorder)")',
'v8_host_byteorder%': '<!("<(python)" -c "import sys; print(sys.byteorder)")',
'force_dynamic_crt%': 0,

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