Meson should ignore arguments for compiler checks that are added using add_*_arguments, however it should honor the arguments passed via the env using CFLAGS of the like and given explicitly as project option. This check ensures that this happens properly for compiler.get_define and compiler.compiles checks.pull/9865/head
parent
b8928027f4
commit
576f70a184
3 changed files with 76 additions and 0 deletions
@ -0,0 +1,43 @@ |
||||
project('ignoring args for checks', 'c', |
||||
version : '0.1', |
||||
default_options : 'werror=true', |
||||
) |
||||
|
||||
test_program = ''' |
||||
#ifdef @0@ |
||||
#error FAIL FAIL FAIL |
||||
FAIL FAIL FAIL |
||||
#endif |
||||
''' |
||||
|
||||
add_project_arguments('-DMESON_CC_CHECKS_SHOULDNT_SEE_ME__FUNC=1', language: 'c') |
||||
|
||||
cc = meson.get_compiler('c') |
||||
|
||||
define_to_check = get_option('define_to_check') |
||||
define_expected = true |
||||
|
||||
if define_to_check == '' |
||||
add_project_arguments('-DMESON_CC_CHECKS_SHOULDNT_SEE_ME__FUNC=1', language: 'c') |
||||
define_to_check = 'MESON_CC_CHECKS_SHOULDNT_SEE_ME__FUNC' |
||||
define_expected = false |
||||
endif |
||||
|
||||
|
||||
if define_expected |
||||
if cc.get_define(define_to_check) == '' |
||||
error('Compiler argument has no effect on compiler check (compiler.get_define) but should!') |
||||
endif |
||||
|
||||
if cc.compiles(test_program.format(define_to_check)) |
||||
error('Compiler argument has no effect on compiler check (compiler.compiles) but should!') |
||||
endif |
||||
else |
||||
if cc.get_define(define_to_check) != '' |
||||
error('Compiler argument has effect on compiler check (compiler.get_define) but should not!') |
||||
endif |
||||
|
||||
if not cc.compiles(test_program.format(define_to_check)) |
||||
error('Compiler argument has effect on compiler check (compiler.compiles) but should not!') |
||||
endif |
||||
endif |
@ -0,0 +1 @@ |
||||
option('define_to_check', type : 'string', value : '') |
@ -0,0 +1,32 @@ |
||||
{ |
||||
"env" : { |
||||
"CFLAGS": "-DMESON_CC_CHECKS_SHOULD_SEE_ME__ENV=1" |
||||
}, |
||||
"matrix": { |
||||
"options": { |
||||
"c_args": [ |
||||
{ "val": "-DMESON_CC_CHECKS_SHOULD_SEE_ME__ARG=1" }, |
||||
{ "val": null } |
||||
], |
||||
"define_to_check" : [ |
||||
{ "val": "MESON_CC_CHECKS_SHOULD_SEE_ME__ARG" }, |
||||
{ "val": "MESON_CC_CHECKS_SHOULD_SEE_ME__ENV" }, |
||||
{ "val": null } |
||||
] |
||||
}, |
||||
"exclude": [ |
||||
{ |
||||
"c_args": "-DMESON_CC_CHECKS_SHOULD_SEE_ME__ARG=1", |
||||
"define_to_check": "MESON_CC_CHECKS_SHOULD_SEE_ME__ENV" |
||||
}, |
||||
{ |
||||
"c_args": null, |
||||
"define_to_check": "MESON_CC_CHECKS_SHOULD_SEE_ME__ARG" |
||||
}, |
||||
{ |
||||
"c_args": "-DMESON_CC_CHECKS_SHOULD_SEE_ME__ARG=1", |
||||
"define_to_check": null |
||||
} |
||||
] |
||||
} |
||||
} |
Loading…
Reference in new issue