Skip to content

Commit 7b8934d

Browse files
authored
build: use CARGO environment variable if set
When enabling support for Temporal, check for the `CARGO` environment variable to locate the `cargo` binary (defaulting to `cargo` if not set) and use this to build `deps/crates`. This will allow using Cargo on systems where the Cargo binary name is suffixed with the version, e.g. `cargo-1.82` on Ubuntu 24.04. PR-URL: #62421 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent f8ee196 commit 7b8934d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

configure.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,9 @@ def get_cargo_version(cargo):
14521452
except OSError:
14531453
error('''No acceptable cargo found!
14541454
1455-
Please make sure you have cargo installed on your system.''')
1455+
Please make sure you have cargo installed on your system and/or
1456+
consider adjusting the CARGO environment variable if you have installed
1457+
it in a non-standard prefix.''')
14561458

14571459
with proc:
14581460
cargo_ret = to_utf8(proc.communicate()[0])
@@ -1540,8 +1542,9 @@ def check_compiler(o):
15401542
# Minimum cargo and rustc versions should match values in BUILDING.md.
15411543
min_cargo_ver_tuple = (1, 82)
15421544
min_rustc_ver_tuple = (1, 82)
1543-
cargo_ver = get_cargo_version('cargo')
1544-
print_verbose(f'Detected cargo: {cargo_ver}')
1545+
cargo = os.environ.get('CARGO', 'cargo')
1546+
cargo_ver = get_cargo_version(cargo)
1547+
print_verbose(f'Detected cargo (CARGO={cargo}): {cargo_ver}')
15451548
cargo_ver_tuple = tuple(map(int, cargo_ver.split('.')))
15461549
if cargo_ver_tuple < min_cargo_ver_tuple:
15471550
warn(f'cargo {cargo_ver} too old, need cargo {".".join(map(str, min_cargo_ver_tuple))}')
@@ -2751,6 +2754,11 @@ def make_bin_override():
27512754
# will fail to run python scripts.
27522755
gyp_args += ['-Dpython=' + python]
27532756

2757+
if options.v8_enable_temporal_support and not options.shared_temporal_capi:
2758+
cargo = os.environ.get('CARGO')
2759+
if cargo:
2760+
gyp_args += ['-Dcargo=' + cargo]
2761+
27542762
if options.use_ninja:
27552763
gyp_args += ['-f', 'ninja-' + flavor]
27562764
elif flavor == 'win' and sys.platform != 'msys':

deps/crates/crates.gyp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
'variables': {
3+
'cargo%': 'cargo',
34
'cargo_vendor_dir': './vendor',
45
},
56
'conditions': [
@@ -48,7 +49,7 @@
4849
'<(node_crates_libpath)'
4950
],
5051
'action': [
51-
'cargo',
52+
'<(cargo)',
5253
'rustc',
5354
'<@(cargo_build_flags)',
5455
'--frozen',

0 commit comments

Comments
 (0)