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