Ensure that $lang_args and $lang_link_args are properly parsed

Currently we don't handle things correctly if we get a string we should
split, and the linker and needs compiler arguments. It would result in
two unsplit strings in a list, instead of the split arguments in a list

Fixes: #8348
0.57
Dylan Baker 4 years ago committed by Nirbheek Chauhan
parent b4f5550843
commit a0dc97f8fc
  1. 24
      mesonbuild/compilers/compilers.py
  2. 11
      test cases/common/237 proper args splitting/main.c
  3. 9
      test cases/common/237 proper args splitting/meson.build
  4. 9
      test cases/common/237 proper args splitting/test.json

@ -1227,22 +1227,18 @@ def get_global_options(lang: str,
argkey = OptionKey('args', lang=lang, machine=for_machine)
largkey = argkey.evolve('link_args')
# We shouldn't need listify here, but until we have a separate
# linker-driver representation and can have that do the combine we have to
# do it this way.
compile_args = mesonlib.listify(env.options.get(argkey, []))
link_args = mesonlib.listify(env.options.get(largkey, []))
cargs = coredata.UserArrayOption(
description + ' compiler',
env.options.get(argkey, []), split_args=True, user_input=True, allow_dups=True)
largs = coredata.UserArrayOption(
description + ' linker',
env.options.get(largkey, []), split_args=True, user_input=True, allow_dups=True)
# This needs to be done here, so that if we have string values in the env
# options that we can safely combine them *after* they've been split
if comp.INVOKES_LINKER:
link_args = compile_args + link_args
largs.set_value(largs.value + cargs.value)
opts: 'KeyedOptionDictType' = {
argkey: coredata.UserArrayOption(
description + ' compiler',
compile_args, split_args=True, user_input=True, allow_dups=True),
largkey: coredata.UserArrayOption(
description + ' linker',
link_args, split_args=True, user_input=True, allow_dups=True),
}
opts: 'KeyedOptionDictType' = {argkey: cargs, largkey: largs}
return opts

@ -0,0 +1,11 @@
#ifndef FOO
# error "FOO is not defined"
#endif
#ifndef BAR
# error "BAR is not defined"
#endif
int main(void) {
return 0;
}

@ -0,0 +1,9 @@
project('proper args splitting', 'c')
test(
'main',
executable(
'main',
'main.c',
)
)

@ -0,0 +1,9 @@
{
"matrix": {
"options": {
"c_args": [
{ "val": "-DFOO -DBAR" }
]
}
}
}
Loading…
Cancel
Save