@@ -26,7 +26,55 @@ 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 : [
60+ cl,
61+ ' /nologo' ,
62+ ' /EP' ,
63+ ' /P' ,
64+ ' /Fi@OUTPUT@' ,
65+ ' -D' + target,
66+ ' @INPUT@' ,
67+ ] + incflags,
68+ )
69+ ffi_asm_objs += custom_target (
70+ obj_name,
71+ input : preproc,
72+ output : obj_name,
73+ command : assembler_args,
74+ )
75+ endforeach
76+ ffi_asm_sources = ffi_asm_objs
77+ else
3078 ffi_asm_sources = cc.preprocess(
3179 ffi_asm_sources,
3280@@ -36,8 +84,6 @@ if is_msvc
3684 ' masm' ,
3785 native : false ,
3886 )
39- else
40- error (' Meson >= 0.64 is required with MSVC' )
4187 endif
4288endif
4389
0 commit comments