@@ -1397,6 +1397,50 @@ def get_openssl_version(o): |
1397 | 1397 | warn(f'Failed to determine OpenSSL version from header: {e}') |
1398 | 1398 | return 0 |
1399 | 1399 |
|
| 1400 | +def get_cargo_version(cargo): |
| 1401 | + try: |
| 1402 | + proc = subprocess.Popen(shlex.split(cargo) + ['--version'], |
| 1403 | + stdin=subprocess.PIPE, stderr=subprocess.PIPE, |
| 1404 | + stdout=subprocess.PIPE) |
| 1405 | + except OSError: |
| 1406 | + error('''No acceptable cargo found! |
| 1407 | +
|
| 1408 | + Please make sure you have cargo installed on your system.''') |
| 1409 | + |
| 1410 | + with proc: |
| 1411 | + cargo_ret = to_utf8(proc.communicate()[0]) |
| 1412 | + |
| 1413 | + match = re.match(r"cargo ([0-9]+\.[0-9]+\.[0-9]+)", cargo_ret) |
| 1414 | + |
| 1415 | + if match: |
| 1416 | + return match.group(1) |
| 1417 | + |
| 1418 | + warn(f'Could not recognize `cargo`: {cargo_ret}') |
| 1419 | + return '0.0' |
| 1420 | + |
| 1421 | +def get_rustc_version(rustc): |
| 1422 | + try: |
| 1423 | + proc = subprocess.Popen(shlex.split(rustc) + ['--version'], |
| 1424 | + stdin=subprocess.PIPE, stderr=subprocess.PIPE, |
| 1425 | + stdout=subprocess.PIPE) |
| 1426 | + except OSError: |
| 1427 | + error('''No acceptable rustc compiler found! |
| 1428 | +
|
| 1429 | + Please make sure you have a rust compiler installed on your system and/or |
| 1430 | + consider adjusting the RUSTC environment variable if you have installed |
| 1431 | + it in a non-standard prefix.''') |
| 1432 | + |
| 1433 | + with proc: |
| 1434 | + rustc_ret = to_utf8(proc.communicate()[0]) |
| 1435 | + |
| 1436 | + match = re.match(r"rustc ([0-9]+\.[0-9]+\.[0-9]+)", rustc_ret) |
| 1437 | + |
| 1438 | + if match: |
| 1439 | + return match.group(1) |
| 1440 | + |
| 1441 | + warn(f'Could not recognize `rustc`: {rustc_ret}') |
| 1442 | + return '0.0' |
| 1443 | + |
1400 | 1444 | # Note: Apple clang self-reports as clang 4.2.0 and gcc 4.2.1. It passes |
1401 | 1445 | # the version check more by accident than anything else but a more rigorous |
1402 | 1446 | # check involves checking the build number against an allowlist. I'm not |
@@ -1444,6 +1488,24 @@ def check_compiler(o): |
1444 | 1488 |
|
1445 | 1489 | o['variables']['llvm_version'] = get_llvm_version(CC) if is_clang else '0.0' |
1446 | 1490 |
|
| 1491 | + # cargo and rustc are needed for Temporal. |
| 1492 | + if options.v8_enable_temporal_support and not options.shared_temporal_capi: |
| 1493 | + # Minimum cargo and rustc versions should match values in BUILDING.md. |
| 1494 | + min_cargo_ver_tuple = (1, 82) |
| 1495 | + min_rustc_ver_tuple = (1, 82) |
| 1496 | + cargo_ver = get_cargo_version('cargo') |
| 1497 | + print_verbose(f'Detected cargo: {cargo_ver}') |
| 1498 | + cargo_ver_tuple = tuple(map(int, cargo_ver.split('.'))) |
| 1499 | + if cargo_ver_tuple < min_cargo_ver_tuple: |
| 1500 | + warn(f'cargo {cargo_ver} too old, need cargo {".".join(map(str, min_cargo_ver_tuple))}') |
| 1501 | + # cargo supports RUSTC environment variable to override "rustc". |
| 1502 | + rustc = os.environ.get('RUSTC', 'rustc') |
| 1503 | + rustc_ver = get_rustc_version(rustc) |
| 1504 | + print_verbose(f'Detected rustc (RUSTC={rustc}): {rustc_ver}') |
| 1505 | + rust_ver_tuple = tuple(map(int, rustc_ver.split('.'))) |
| 1506 | + if rust_ver_tuple < min_rustc_ver_tuple: |
| 1507 | + warn(f'rustc {rustc_ver} too old, need rustc {".".join(map(str, min_rustc_ver_tuple))}') |
| 1508 | + |
1447 | 1509 | # Need xcode_version or gas_version when openssl asm files are compiled. |
1448 | 1510 | if options.without_ssl or options.openssl_no_asm or options.shared_openssl: |
1449 | 1511 | return |
|