@@ -27,15 +27,63 @@ if is_msvc
2727 # MSVC, cannot compile assembly files directly. They need to be preprocessed
2828 # with the C compiler first, then compiled with MASM.
2929 if meson .version().version_compare(' >=0.64.0' )
30- ffi_asm_sources = cc.preprocess(
31- ffi_asm_sources,
32- 33- include_directories : ffiinc,
34- )
35- add_languages (
36- ' masm' ,
37- native : false ,
38- )
30+ if meson .version().version_compare(' <1.10.0' ) and host_cpu_family == ' aarch64'
31+ # Custom logic to invoke armasm64 with Meson < 1.10.0.
32+ # Works around an issue with depfile support:
33+ # https://github.com/mesonbuild/wrapdb/issues/2469
34+ cl = find_program (' cl' )
35+ armasm64 = find_program (' armasm64' )
36+
37+ assembler_args = [armasm64, ' -o' , ' @OUTPUT@' , ' @INPUT@' ]
38+ if get_option (' buildtype' ).startswith(' debug' )
39+ assembler_args += [' -g' ]
40+ endif
41+
42+ ffi_asm_objs = []
43+ foreach asm_source : ffi_asm_sources
44+ incflags = [
45+ ' /I' + join_paths (meson .current_source_dir(), ' ..' ),
46+ ' /I' + join_paths (meson .current_build_dir(), ' ..' ),
47+ ' /I' + join_paths (meson .current_source_dir(), ' ..' , ' include' ),
48+ ' /I' + join_paths (meson .current_build_dir(), ' ..' , ' include' ),
49+ ' /I' + join_paths (meson .current_source_dir(), targetdir),
50+ ' /I' + join_paths (meson .current_build_dir(), targetdir),
51+ ]
52+ preproc_name = asm_source.underscorify() + ' .i'
53+ obj_name = asm_source.underscorify() + ' .obj'
54+ preproc = custom_target (
55+ preproc_name,
56+ input : asm_source,
57+ output : preproc_name,
58+ command : [
59+ cl,
60+ ' /nologo' ,
61+ ' /EP' ,
62+ ' /P' ,
63+ ' /Fi@OUTPUT@' ,
64+ ' -D' + target,
65+ ' @INPUT@' ,
66+ ] + incflags,
67+ )
68+ ffi_asm_objs += custom_target (
69+ obj_name,
70+ input : preproc,
71+ output : obj_name,
72+ command : assembler_args,
73+ )
74+ endforeach
75+ ffi_asm_sources = ffi_asm_objs
76+ else
77+ ffi_asm_sources = cc.preprocess(
78+ ffi_asm_sources,
79+ 80+ include_directories : ffiinc,
81+ )
82+ add_languages (
83+ ' masm' ,
84+ native : false ,
85+ )
86+ endif
3987 else
4088 error (' Meson >= 0.64 is required with MSVC' )
4189 endif
0 commit comments