This further simplifies behavior to match the "build vs host" decision we did with `c_args` vs `build_c_args`. The rules are now simply: - `native: true` affects `native: true` targets - `native: false` affects `native: false` targets - No native flag is the same as `native: false` I like this because you don't even have to know what "build" and "host" mean to understand how it works, and it doesn't depend on whether the overall build is cross or not. Fixes #4933pull/5572/head
parent
6e4e0028a1
commit
9149aaba9c
5 changed files with 58 additions and 67 deletions
@ -0,0 +1,16 @@ |
||||
## Projects args can be set separately for build and host machines (potentially breaking change) |
||||
|
||||
Simplify `native` flag behavior in `add_global_arguments`, |
||||
`add_global_link_arguments`, `add_project_arguments` and |
||||
`add_project_link_arguments`. The rules are now very simple: |
||||
|
||||
- `native: true` affects `native: true` targets |
||||
|
||||
- `native: false` affects `native: false` targets |
||||
|
||||
- No native flag is the same as `native: false` |
||||
|
||||
This further simplifies behavior to match the "build vs host" decision done in |
||||
last release with `c_args` vs `build_c_args`. The underlying motivation in both |
||||
cases is to execute the same commands whether the overall build is native or |
||||
cross. |
@ -1,22 +1,23 @@ |
||||
project('global arg test', 'cpp', 'c') |
||||
|
||||
add_global_arguments('-DMYTHING', language : 'c') |
||||
add_global_arguments('-DMYCPPTHING', language : 'cpp') |
||||
add_global_arguments('-DMYTHING', language : 'c', native : true) |
||||
add_global_arguments('-DMYTHING', language : 'c', native : false) |
||||
add_global_arguments('-DMYCPPTHING', language : 'cpp', native : true) |
||||
add_global_arguments('-DMYCPPTHING', language : 'cpp', native : false) |
||||
|
||||
add_global_arguments('-DGLOBAL_NATIVE', language : 'c', native : true) |
||||
add_global_arguments('-DGLOBAL_CROSS', language : 'c', native : false) |
||||
add_global_arguments('-DGLOBAL_BUILD', language : 'c', native : true) |
||||
add_global_arguments('-DGLOBAL_HOST', language : 'c', native : false) |
||||
|
||||
if meson.is_cross_build() |
||||
c_args = ['-DARG_CROSS'] |
||||
else |
||||
c_args = ['-DARG_NATIVE'] |
||||
endif |
||||
build_c_args = ['-DARG_BUILD'] |
||||
c_args = ['-DARG_HOST'] |
||||
|
||||
add_global_arguments('-DMYCANDCPPTHING', language: ['c', 'cpp']) |
||||
add_global_arguments('-DMYCANDCPPTHING', language: ['c', 'cpp'], native: true) |
||||
add_global_arguments('-DMYCANDCPPTHING', language: ['c', 'cpp'], native: false) |
||||
|
||||
exe1 = executable('prog', 'prog.c', c_args : c_args) |
||||
exe2 = executable('prog2', 'prog.cc') |
||||
exe1 = executable('prog1', 'prog.c', c_args : build_c_args, native : true) |
||||
exe2 = executable('prog2', 'prog.c', c_args : c_args, native : false) |
||||
exe3 = executable('prog3', 'prog.cc') |
||||
|
||||
test('prog1', exe1) |
||||
test('prog2', exe2) |
||||
|
||||
test('prog3', exe3) |
||||
|
Loading…
Reference in new issue