All assignments in meson should be by value, so mutable objects (i.e. environment() and configuration_data()) should be copied automatically on assignment. Fixes #831.pull/997/head
parent
5898fb094c
commit
627d859809
4 changed files with 60 additions and 2 deletions
@ -0,0 +1,20 @@ |
||||
project('foo', 'c') |
||||
|
||||
a = configuration_data() |
||||
a.set('HELLO', 1) |
||||
|
||||
b = a |
||||
|
||||
assert(a.has('HELLO'), 'Original config data should be set on a') |
||||
assert(b.has('HELLO'), 'Original config data should be set on copy') |
||||
|
||||
configure_file(output : 'b.h', configuration : b) |
||||
|
||||
# This should still work, as we didn't use the original above but a copy! |
||||
a.set('WORLD', 1) |
||||
|
||||
assert(a.has('WORLD'), 'New config data should have been set') |
||||
assert(not b.has('WORLD'), 'New config data set should not affect var copied earlier') |
||||
|
||||
configure_file(output : 'a.h', configuration : a) |
||||
|
@ -0,0 +1,23 @@ |
||||
#include<stdio.h> |
||||
#include<string.h> |
||||
#include<stdlib.h> |
||||
|
||||
int main(int argc, char **argv) { |
||||
if(strcmp(getenv("first"), "something-else") != 0) { |
||||
fprintf(stderr, "First envvar is wrong. %s\n", getenv("first")); |
||||
return 1; |
||||
} |
||||
if(strcmp(getenv("second"), "val2") != 0) { |
||||
fprintf(stderr, "Second envvar is wrong.\n"); |
||||
return 1; |
||||
} |
||||
if(strcmp(getenv("third"), "val3:and_more") != 0) { |
||||
fprintf(stderr, "Third envvar is wrong.\n"); |
||||
return 1; |
||||
} |
||||
if(strstr(getenv("PATH"), "fakepath:") != NULL) { |
||||
fprintf(stderr, "Third envvar is wrong.\n"); |
||||
return 1; |
||||
} |
||||
return 0; |
||||
} |
Loading…
Reference in new issue