MAINT: Massive cleanup with meson native checks
Co-authored-by: rgommers <rgommers@users.noreply.github.com>
This commit is contained in:
parent
36c53a6841
commit
382587d8ec
66
meson.build
66
meson.build
|
@ -81,58 +81,30 @@ endif
|
||||||
|
|
||||||
_check_prefix = []
|
_check_prefix = []
|
||||||
conf_data = configuration_data()
|
conf_data = configuration_data()
|
||||||
is_win = build_machine.system() == 'win'
|
is_win = host_machine.system() == 'windows' or host_machine.system() == 'cygwin'
|
||||||
conf_data.set('OS_WINDOWS', is_win)
|
conf_data.set('OS_WINDOWS', is_win)
|
||||||
|
hostcpu = host_machine.cpu_family()
|
||||||
|
|
||||||
getarch_array = [
|
defarch_array = [
|
||||||
# Redundant, we have build_machine.system() for windows
|
# {'system': ['windows', 'cygwin'], 'def': ['OS_WINDOWS']},
|
||||||
{'checks': ['WIN32', 'WIN64', 'CYGWIN32'], 'addl': ['_WIN64', '_WIN32'], 'name': 'Windows', 'def': ['OS_WINDOWS']},
|
{'cpu': ['aarch64'], 'def': ['ARCH_ARGM64']},
|
||||||
{'checks': ['i386', 'x86_64'], 'addl': ['_M_IX86', '_M_X64'], 'name': 'Intel AMD', 'def': ['INTEL_AMD']},
|
{'cpu': ['alpha'], 'def': ['ARCH_ALPHA']},
|
||||||
{'checks': ['powerpc', 'ppc', 'POWERPC'], 'addl': ['__powerpc', 'powerpc', 'ppc', '_POWER'], 'name': 'PowerPC', 'def': ['POWER', 'ARCH_POWER']},
|
{'cpu': ['arm'], 'def': ['ARCH_ARM']},
|
||||||
{'checks': ['zarch', 's390x'], 'name': 'zarch', 'def': ['ARCH_ZARCH', 'ZARCH']},
|
{'cpu': ['x86_64'], 'def': ['INTEL_AMD']},
|
||||||
{'checks': ['ia64'], 'name': 'IA64', 'def': ['ARCH_IA64']},
|
{'cpu': ['s390x'], 'def': ['ARCH_ZARCH', 'ZARCH']},
|
||||||
{'name': 'Alpha', 'addl': ['__alpha'], 'def': ['ARCH_ALPHA']},
|
{'cpu': ['ia64'], 'def': ['ARCH_IA64']},
|
||||||
{'name': 'SPARC', 'addl': ['sparc'], 'def': ['ARCH_SPARC']},
|
{'cpu': ['sparc'], 'def': ['ARCH_SPARC']},
|
||||||
{'checks': ['mips'], 'name': 'MIPS', 'def': ['ARCH_MIPS']},
|
{'cpu': ['mips'], 'def': ['ARCH_MIPS']},
|
||||||
{'name': 'MIPS 64', 'addl': ['__mips64'], 'def': ['ARCH_MIPS64']},
|
{'cpu': ['mips64'], 'def': ['ARCH_MIPS64']},
|
||||||
{'name': 'LOONGARCH 64', 'addl': ['__loongarch64'], 'def': ['ARCH_LOONGARCH64']},
|
{'cpu': ['loongarch64'], 'def': ['ARCH_LOONGARCH64']},
|
||||||
{'name': 'RISCV 64', 'addl': ['__riscv'], 'def': ['ARCH_RISCV64']},
|
{'cpu': ['riscv64'], 'def': ['ARCH_RISCV64']},
|
||||||
{'checks': ['arm'], 'name': 'ARM', 'def': ['ARCH_ARM']},
|
{'cpu': ['ppc64', 'ppc'], 'def': ['ARCH_POWER', 'POWER']},
|
||||||
{'checks': ['aarch64'], 'name': 'ARM 64', 'def': ['ARCH_ARM64']},
|
|
||||||
]
|
]
|
||||||
|
|
||||||
foreach arch : getarch_array
|
foreach arch : defarch_array
|
||||||
check_str = ''
|
is_cpu = hostcpu in arch['cpu']
|
||||||
if arch.has_key('checks')
|
|
||||||
foreach check : arch['checks']
|
|
||||||
if check_str == ''
|
|
||||||
check_str += 'defined(__' + check + '__)'
|
|
||||||
else
|
|
||||||
check_str += ' || defined(__' + check + '__)'
|
|
||||||
endif
|
|
||||||
endforeach
|
|
||||||
endif
|
|
||||||
if arch.has_key('addl')
|
|
||||||
foreach check : arch['addl']
|
|
||||||
if check_str == ''
|
|
||||||
check_str += 'defined(' + check + ')'
|
|
||||||
else
|
|
||||||
check_str += ' || defined(' + check + ')'
|
|
||||||
endif
|
|
||||||
endforeach
|
|
||||||
endif
|
|
||||||
|
|
||||||
sname = arch['name']
|
|
||||||
code = f'''
|
|
||||||
#if !(@check_str@)
|
|
||||||
#error "Not @sname@"
|
|
||||||
#endif
|
|
||||||
'''
|
|
||||||
# message(code)
|
|
||||||
|
|
||||||
is_arch = cc.compiles(code, name: arch['name'])
|
|
||||||
foreach def : arch['def']
|
foreach def : arch['def']
|
||||||
conf_data.set(def, is_arch)
|
conf_data.set(def, is_cpu)
|
||||||
endforeach
|
endforeach
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue