Repository: nodejs/node
File: configure.py (Python)

Code before:

  observed_arch = os.environ.get('PROCESSOR_ARCHITECTURE', 'AMD64')
  arch = os.environ.get('PROCESSOR_ARCHITEW6432', observed_arch)

  matchup = {
    'AMD64'  : 'x64',
    'arm'    : 'arm',
    'mips'   : 'mips',
    'ARM64'  : 'arm64'
  }

  return matchup.get(arch, 'x64')

def set_configuration_variable(configs, name, release=None, debug=None):
  configs['Release']['variables'][name] = release
  configs['Debug']['variables'][name] = debug

def set_configuration_variable_and_defines(configs, name, define, release=None, debug=None):
  set_configuration_variable(configs, name, release, debug)
  if configs['Debug'].get('defines') is None:
      configs['Debug']['defines'] = []
  if configs['Release'].get('defines') is None:
      configs['Release']['defines'] = []
  configs['Debug']['defines'].append(define)
  configs['Release']['defines'].append(define)

def configure_arm(o):
  if options.arm_float_abi:
    arm_float_abi = options.arm_float_abi
  elif is_arm_hard_float_abi():
    arm_float_abi = 'hard'
  else:
    arm_float_abi = 'default'

  arm_fpu = 'vfp'

  if is_arch_armv7():
    arm_fpu = 'vfpv3'
    o['variables']['arm_version'] = '7'
  else:
    o['variables']['arm_version'] = '6' if is_arch_armv6() else 'default'

  o['variables']['arm_thumb'] = 0      # -marm
  o['variables']['arm_float_abi'] = arm_float_abi

  if options.dest_os == 'android':
    arm_fpu = 'vfpv3'
    o['variables']['arm_version'] = '7'

  o['variables']['arm_fpu'] = options.arm_fpu or arm_fpu


Review comment (suggestion):
This might be a GYP issue, but it seems that variables defined inside a conditions block are not reflected when evaluating other conditions.
In this case, the value of v8_enable_v8_checks set in configure.py (https://github.com/nodejs/node/blob/main/configure.py#L1530-L1532
) does not appear to be used when evaluating the condition 'v8_enable_v8_checks==1' in tools/v8_gypfiles/features.gypi (https://github.com/nodejs/node/blob/main/tools/v8_gypfiles/features.gypi#L405-L407
).

Therefore, I’m setting the defines directly.

Code after:
    return

  ok, is_clang, clang_version, gcc_version, is_apple = try_check_compiler(CXX, 'c++')
  o['variables']['clang'] = B(is_clang)
  version_str = ".".join(map(str, clang_version if is_clang else gcc_version))
  print_verbose(f"Detected {'Apple ' if is_apple else ''}{'clang ' if is_clang else ''}C++ compiler (CXX={CXX}) version: {version_str}")
  if not ok:
    warn(f'failed to autodetect C++ compiler version (CXX={CXX})')
  elif ((is_apple and clang_version < (17, 0, 0)) or (not is_apple and clang_version < (19, 1, 0))) if is_clang else gcc_version < (12, 2, 0):
    warn(f"C++ compiler (CXX={CXX}, {version_str}) too old, need g++ 12.2.0 or clang++ 19.1.0{' or Apple clang++ 17.0.0' if is_apple else ''}")

  ok, is_clang, clang_version, gcc_version, is_apple = try_check_compiler(CC, 'c')
  version_str = ".".join(map(str, clang_version if is_clang else gcc_version))
  print_verbose(f"Detected {'Apple ' if is_apple else ''}{'clang ' if is_clang else ''}C compiler (CC={CC}) version: {version_str}")
  if not ok:
    warn(f'failed to autodetect C compiler version (CC={CC})')
  elif not is_clang and gcc_version < (4, 2, 0):
    # clang 3.2 is a little white lie because any clang version will probably
    # do for the C bits.  However, we might as well encourage people to upgrade
    # to a version that is not completely ancient.
    warn(f'C compiler (CC={CC}, {version_str}) too old, need gcc 4.2 or clang 3.2')

  o['variables']['llvm_version'] = get_llvm_version(CC) if is_clang else '0.0'

  # cargo and rustc are needed for Temporal.
  if options.v8_enable_temporal_support and not options.shared_temporal_capi:
    # Minimum cargo and rustc versions should match values in BUILDING.md.
    min_cargo_ver_tuple = (1, 82)
    min_rustc_ver_tuple = (1, 82)
    cargo_ver = get_cargo_version('cargo')
    print_verbose(f'Detected cargo: {cargo_ver}')
    cargo_ver_tuple = tuple(map(int, cargo_ver.split('.')))
    if cargo_ver_tuple < min_cargo_ver_tuple:
      warn(f'cargo {cargo_ver} too old, need cargo {".".join(map(str, min_cargo_ver_tuple))}')
    # cargo supports RUSTC environment variable to override "rustc".
    rustc = os.environ.get('RUSTC', 'rustc')
    rustc_ver = get_rustc_version(rustc)
    print_verbose(f'Detected rustc (RUSTC={rustc}): {rustc_ver}')
    rust_ver_tuple = tuple(map(int, rustc_ver.split('.')))
    if rust_ver_tuple < min_rustc_ver_tuple:
      warn(f'rustc {rustc_ver} too old, need rustc {".".join(map(str, min_rustc_ver_tuple))}')

  # Need xcode_version or gas_version when openssl asm files are compiled.
  if options.without_ssl or options.openssl_no_asm or options.shared_openssl:
    return

  if is_clang:
    if sys.platform == 'darwin':
      o['variables']['xcode_version'] = get_xcode_version(CC)
  else:
    o['variables']['gas_version'] = get_gas_version(CC)