diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2019-05-29 11:24:05 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2019-05-30 09:50:55 -0700 |
commit | 31ab9627533e1ae0a024c36226f703ac9ceab0a2 (patch) | |
tree | 8fbcecfad21c045e4d770ae1110266d19365ca56 /mesonbuild/dependencies | |
parent | eaa232987e3410198fa3a1eb422ca5b8a3baba8c (diff) | |
download | meson-31ab9627533e1ae0a024c36226f703ac9ceab0a2.zip meson-31ab9627533e1ae0a024c36226f703ac9ceab0a2.tar.gz meson-31ab9627533e1ae0a024c36226f703ac9ceab0a2.tar.bz2 |
dependencies/cmake: Handle spaces in set_target_properties
this is better, but it's still not perfect. cmake doesn't return quotes
to us in the trace output, and being 100% the same as cmake is pretty
much impossible without that information. What I've done should be a
"good enough" implementation without having to maintain a copy of every
property allowed in cmake, as well as custom properties.
Diffstat (limited to 'mesonbuild/dependencies')
-rw-r--r-- | mesonbuild/dependencies/base.py | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 5fc5c02..21cd821 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -1691,29 +1691,46 @@ class CMakeDependency(ExternalDependency): args = list(tline.args) targets = [] - while len(args) > 0: + while args: curr = args.pop(0) if curr == 'PROPERTIES': break targets.append(curr) - if (len(args) % 2) != 0: - raise self._gen_exception('CMake: set_target_properties() uneven number of property arguments\n{}'.format(tline)) - - while len(args) > 0: - propName = args.pop(0) - propVal = args.pop(0).split(';') - propVal = list(filter(lambda x: len(x) > 0, propVal)) - - if len(propVal) == 0: - continue + # Now we need to try to reconsitute the original quoted format of the + # arguments, as a property value could have spaces in it. Unlike + # set_property() this is not context free. There are two approaches I + # can think of, both have drawbacks: + # + # 1. Assume that the property will be capitalized, this is convention + # but cmake doesn't require it. + # 2. Maintain a copy of the list here: https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#target-properties + # + # Neither of these is awesome for obvious reasons. I'm going to try + # option 1 first and fall back to 2, as 1 requires less code and less + # synchroniztion for cmake changes. + + arglist = [] # type: typing.List[typing.Tuple[str, typing.List[str]]] + name = args.pop(0) + values = [] + for a in args: + if a.isupper(): + if values: + arglist.append((name, ' '.join(values).split(';'))) + name = a + values = [] + else: + values.append(a) + if values: + arglist.append((name, ' '.join(values).split(';'))) + for name, value in arglist: for i in targets: if i not in self.targets: raise self._gen_exception('CMake: set_target_properties() TARGET {} not found\n{}'.format(i, tline)) - self.targets[i].properies[propName] = propVal + self.targets[i].properies[name] = value def _lex_trace(self, trace): # The trace format is: '<file>(<line>): <func>(<args -- can contain \n> )\n' |