This should be useful for helping to control variable scope within Meson. CMake has something similar for controlling scope.pull/9125/head
parent
a2f110ff77
commit
1dc13e9951
7 changed files with 57 additions and 2 deletions
@ -0,0 +1,16 @@ |
||||
## `unset_variable()` |
||||
|
||||
`unset_variable()` can be used to unset a variable. Reading a variable after |
||||
calling `unset_variable()` will raise an exception unless the variable is set |
||||
again. |
||||
|
||||
```meson |
||||
# tests/meson.build |
||||
tests = ['test1', 'test2'] |
||||
|
||||
# ... |
||||
|
||||
unset_variable('tests') |
||||
|
||||
# tests is no longer usable until it is set again |
||||
``` |
@ -0,0 +1,15 @@ |
||||
project('variable scope') |
||||
|
||||
x = 1 |
||||
|
||||
assert(is_variable('x')) |
||||
|
||||
assert(get_variable('x') == 1) |
||||
|
||||
set_variable('x', 10) |
||||
|
||||
assert(get_variable('x') == 10) |
||||
|
||||
unset_variable('x') |
||||
|
||||
assert(not is_variable('x')) |
Loading…
Reference in new issue