0.53.2 版本的meson 存在两个bug,造成无法编译成功。编译之前先修改之。修改办法: 编辑《site-packages》下的文件。
1. environment.py中的get_exe_wrapper。如果不修改则会尝试在build环境运行host程序。
- def get_exe_wrapper(self):
- if not self.need_exe_wrapper():
- from .dependencies import NonExistingExternalProgram
- return NonExistingExternalProgram()
- ''' modify by zry
- from .dependencies import EmptyExternalProgram
- return EmptyExternalProgram()
- '''
- return self.exe_wrapper
2. interpreter.py 文件中的add_languages。如果不修改,则会检测、编译build环境下的文件。
- def add_languages(self, args: T.Sequence[str], required: bool) -> bool:
- success=False
- if self.coredata.is_cross_build():
- success = self.add_languages_for(args, required, MachineChoice.HOST)
- else:
- success = self.add_languages_for(args, required, MachineChoice.BUILD)
- self.coredata.copy_build_options_from_regular_ones()
- ''' modify by zry
- success = self.add_languages_for(args, required, MachineChoice.BUILD)
- success &= self.add_languages_for(args, required, MachineChoice.HOST)
- if not self.coredata.is_cross_build():
- self.coredata.copy_build_options_from_regular_ones()
- '''
- return success
3. 配置cross-file
- [binaries]
- c = 'armv7a-linux-androideabi27-clang.cmd'
- cpp = 'armv7a-linux-androideabi27-clang++.cmd'
- ld = 'arm-linux-androideabi-ld.gold.exe'
- ar = 'arm-linux-androideabi-ar.exe'
- strip = 'arm-linux-androideabi-strip.exe'
- #pkgconfig = '/usr/bin/i586-mingw32msvc-pkg-config'
- #exe_wrapper = 'wine' # A command used to run generated executables.
- [properties]
- sizeof_int = 4
- sizeof_wchar_t = 2
- sizeof_void* = 4
- alignment_char = 1
- alignment_void* = 4
- alignment_double = 4
- has_function_printf = true
- c_args = ['-DCROSS=1', '-ID:\android-ndk-r21\sysroot']
- #c_link_args = ['-some_link_arg']
- sys_root = 'D:\android-ndk-r21\platforms\android-27\arch-arm'
- needs_exe_wrapper = false
- [host_machine]
- system = 'android'
- cpu_family = 'arm'
- cpu = 'armv7a'
- endian = 'little'
- [paths]
- prefix = 'E:\Test\meson\install'
- libdir = 'lib'
- bindir = 'bin'
4. 将NDK的toolchains\llvm\prebuilt\windows-x86_64\bin 添加到PATH 路径中。
5. meson armbuild --cross-file android-arm.ini