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

Code before:
    else:
      rtn = 'riscv32'

  return rtn


def host_arch_win():
  """Host architecture check using environ vars (better way to do this?)"""

  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, release=None, debug=None, release_define=None, debug_define=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'] = []
  if debug_define:
      configs['Debug']['defines'].append(debug_define)
  if release_define:
      configs['Release']['defines'].append(release_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'

Review comment (bug):
According to https://github.com/nodejs/gyp-next/blob/main/docs/InputFormatReference.md#processing-order, I think there is no way for us to generate a single `config.gypi` supporting two configurations at the same time, with variable expansions based on configurations, since the variables are expanded before merging the configuration objects.

So I'd suggest updating this to be a simple way: instead of https://github.com/nodejs/node/blob/e1fc3dc2fcf19d9278ab59c353aa1fa59290378b/configure.py#L2499-L2503

we could do:

```py
if options.debug:
  variables = variables | config_debug_vars
else:
  variables = variables | config_release_vars
```

Code after:
    if options.use_ccache_win:
      o['variables']['use_ccache_win'] = 1

    if not options.openssl_no_asm and options.dest_cpu in ('x86', 'x64'):
      nasm_version = get_nasm_version('nasm')
      o['variables']['nasm_version'] = nasm_version
      if nasm_version == '0.0':
        o['variables']['openssl_no_asm'] = 1
    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.