diff options
-rw-r--r-- | build.py | 23 | ||||
-rw-r--r-- | test cases/common/104 stringdef/meson.build | 3 | ||||
-rw-r--r-- | test cases/common/104 stringdef/stringdef.c | 10 | ||||
-rw-r--r-- | test cases/failing/24 backslash/comparer.c (renamed from test cases/common/104 backslash/comparer.c) | 0 | ||||
-rw-r--r-- | test cases/failing/24 backslash/meson.build (renamed from test cases/common/104 backslash/meson.build) | 0 |
5 files changed, 36 insertions, 0 deletions
@@ -46,6 +46,27 @@ known_shlib_kwargs = known_basic_kwargs.copy() known_shlib_kwargs.update({'version' : True, 'soversion' : True}) +backslash_explanation = \ +'''Compiler arguments have a backslash "\\" character. This is unfortunately not +permitted. The reason for this is that backslash is a shell quoting character +that behaves differently across different systems. Because of this is it not +possible to make it work reliably across all the platforms Meson needs to +support. + +There are several different ways of working around this issue. Most of the time +you are using this to provide a -D define to your compiler. Try instead to +create a config.h file and put all of your definitions in it using +configure_file(). + +Another approach is to move the backslashes into the source and have the other +bits in the def. So you would have an arg -DPLAIN_TEXT="foo" and then in your +C sources something like this: + +const char *fulltext = "\\\\" PLAIN_TEXT; + +We are fully aware that these are not really usable or pleasant ways to do +this but it's the best we can do given the way shell quoting works. +''' class InvalidArguments(coredata.MesonException): pass @@ -513,6 +534,8 @@ class BuildTarget(): for a in args: if not isinstance(a, (str, File)): raise InvalidArguments('A non-string passed to compiler args.') + if isinstance(a, str) and '\\' in a: + raise InvalidArguments(backslash_explanation) if language in self.extra_args: self.extra_args[language] += args else: diff --git a/test cases/common/104 stringdef/meson.build b/test cases/common/104 stringdef/meson.build new file mode 100644 index 0000000..3f9170e --- /dev/null +++ b/test cases/common/104 stringdef/meson.build @@ -0,0 +1,3 @@ +project('stringdef', 'c') + +test('stringdef', executable('stringdef', 'stringdef.c', c_args : '-DFOO="bar"')) diff --git a/test cases/common/104 stringdef/stringdef.c b/test cases/common/104 stringdef/stringdef.c new file mode 100644 index 0000000..69ea656 --- /dev/null +++ b/test cases/common/104 stringdef/stringdef.c @@ -0,0 +1,10 @@ +#include<stdio.h> +#include<string.h> + +int main(int argc, char **argv) { + if(strcmp(FOO, "bar")) { + printf("FOO is misquoted: %s\n", FOO); + return 1; + } + return 0; +} diff --git a/test cases/common/104 backslash/comparer.c b/test cases/failing/24 backslash/comparer.c index f562f5e..f562f5e 100644 --- a/test cases/common/104 backslash/comparer.c +++ b/test cases/failing/24 backslash/comparer.c diff --git a/test cases/common/104 backslash/meson.build b/test cases/failing/24 backslash/meson.build index dba891e..dba891e 100644 --- a/test cases/common/104 backslash/meson.build +++ b/test cases/failing/24 backslash/meson.build |