From 4f4076bfc0dacbc5f804ad2d970054ab43d162b3 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 20 Oct 2022 09:13:59 +0200 Subject: nasm: Harcode default path on Windows NASM's installer does not add itself into PATH, even when installed by choco. --- mesonbuild/compilers/detect.py | 4 ++++ test cases/nasm/2 asm language/meson.build | 13 +++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py index 8644d75..849024c 100644 --- a/mesonbuild/compilers/detect.py +++ b/mesonbuild/compilers/detect.py @@ -1151,6 +1151,10 @@ def detect_nasm_compiler(env: 'Environment', for_machine: MachineChoice) -> Comp popen_exceptions: T.Dict[str, Exception] = {} for comp in compilers: + if comp == ['nasm'] and is_windows() and not shutil.which(comp[0]): + # nasm is not in PATH on Windows by default + default_path = os.path.join(os.environ['ProgramFiles'], 'NASM') + comp[0] = shutil.which(comp[0], path=default_path) or comp[0] try: output = Popen_safe(comp + ['--version'])[1] except OSError as e: diff --git a/test cases/nasm/2 asm language/meson.build b/test cases/nasm/2 asm language/meson.build index ced2ded..e1ef10a 100644 --- a/test cases/nasm/2 asm language/meson.build +++ b/test cases/nasm/2 asm language/meson.build @@ -1,18 +1,15 @@ project('test', 'c') -nasm = find_program('nasm', required: false) -yasm = find_program('yasm', required: false) -if not nasm.found() and not yasm.found() - assert(not add_languages('nasm', required: false)) - error('MESON_SKIP_TEST: nasm not available') -endif - if not host_machine.cpu_family().startswith('x86') assert(not add_languages('nasm', required: false)) error('MESON_SKIP_TEST: nasm only supported for x86 and x86_64') endif -add_languages('nasm') +if not add_languages('nasm', required: false) + nasm = find_program('nasm', 'yasm', required: false) + assert(not nasm.found()) + error('MESON_SKIP_TEST: nasm not found') +endif config_file = configure_file( output: 'config.asm', -- cgit v1.1