Commit ae9ac2a1 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠 Committed by Akira TAGOH
Browse files

meson: fix cross-compilation issues with gperf header file preprocessing

Pass c_args to the compiler when preprocessing the gperf header file,
they might contain important bits without which compilation/preprocessing
might fail (e.g. with clang on Android). cc.cmd_array() does not include
the c_args and we can't easily look them up from the file, so
we have to retrieve from the introspection info.

This is basically the Meson equivalent to commit 57103773.
parent 7bfbaecf
import argparse
import subprocess
import json
import os
import re
......@@ -7,12 +8,23 @@ if __name__== '__main__':
parser = argparse.ArgumentParser()
args = parser.parse_known_args()
print (args[0].output)
# c_args might contain things that are essential for crosscompilation, but
# are not included in cc.cmd_array(), so we have to look them up ourselves
host_cargs = []
buildroot = args[0].buildroot
with open(os.path.join(buildroot, 'meson-info', 'intro-buildoptions.json')) as json_file:
bopts = json.load(json_file)
for opt in bopts:
if opt['name'] == 'c_args' and opt['section'] == 'compiler' and opt['machine'] == 'host':
host_cargs = opt['value']
cpp = args[1]
ret = + [args[0].input], stdout=subprocess.PIPE, check=True)
ret = + host_cargs + [args[0].input], stdout=subprocess.PIPE, check=True)
stdout = ret.stdout.decode('utf8')
......@@ -44,10 +44,13 @@ endif
cpp += ['-I', join_paths(meson.current_source_dir(), '..')]
# Can use meson.project_build_dir() once we require Meson 0.56
project_build_dir = meson.current_build_dir() / '..'
fcobjshash_gperf = custom_target('fcobjshash.gperf',
input: 'fcobjshash.gperf.h',
output: 'fcobjshash.gperf',
command: [python3, files('')[0], '@INPUT@', '@OUTPUT@', cpp],
command: [python3, files('')[0], '@INPUT@', '@OUTPUT@', project_build_dir, cpp],
build_by_default: true,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment