From ca30550e065991f9b2438e2a6fabc64fd2248806 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Wed, 30 Dec 2020 13:43:49 +0200 Subject: [PATCH] Handle uppercase dependency names in wraps. --- mesonbuild/wrap/wrap.py | 7 +++++-- test cases/common/234 wrap case/meson.build | 6 ++++++ test cases/common/234 wrap case/prog.c | 13 +++++++++++++ .../common/234 wrap case/subprojects/up_down.wrap | 5 +++++ .../234 wrap case/subprojects/up_down/meson.build | 3 +++ .../234 wrap case/subprojects/up_down/up_down.h | 3 +++ 6 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 test cases/common/234 wrap case/meson.build create mode 100644 test cases/common/234 wrap case/prog.c create mode 100644 test cases/common/234 wrap case/subprojects/up_down.wrap create mode 100644 test cases/common/234 wrap case/subprojects/up_down/meson.build create mode 100644 test cases/common/234 wrap case/subprojects/up_down/up_down.h diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 6d2b91a5a..bb153c55c 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -116,8 +116,8 @@ class PackageDefinition: try: self.config = configparser.ConfigParser(interpolation=None) self.config.read(self.filename) - except configparser.Error: - raise WrapException('Failed to parse {}'.format(self.basename)) + except configparser.Error as e: + raise WrapException('Failed to parse {}: {}'.format(self.basename, str(e))) self.parse_wrap_section() if self.type == 'redirect': # [wrap-redirect] have a `filename` value pointing to the real wrap @@ -251,6 +251,9 @@ class Resolver: self.provided_programs.setdefault(k, v) def find_dep_provider(self, packagename: str) -> T.Optional[T.Union[str, T.List[str]]]: + # Python's ini parser converts all key values to lowercase. + # Thus the query name must also be in lower case. + packagename = packagename.lower() # Return value is in the same format as fallback kwarg: # ['subproject_name', 'variable_name'], or 'subproject_name'. wrap = self.provided_deps.get(packagename) diff --git a/test cases/common/234 wrap case/meson.build b/test cases/common/234 wrap case/meson.build new file mode 100644 index 000000000..2b82bf392 --- /dev/null +++ b/test cases/common/234 wrap case/meson.build @@ -0,0 +1,6 @@ +project('CaSe DePenDenCy In Wrap', 'c') + +d = dependency('UP_down') + +e = executable('prog', 'prog.c', dependencies: d) +test('prog', e) diff --git a/test cases/common/234 wrap case/prog.c b/test cases/common/234 wrap case/prog.c new file mode 100644 index 000000000..5183deabd --- /dev/null +++ b/test cases/common/234 wrap case/prog.c @@ -0,0 +1,13 @@ +#include +#include + +int main(int argc, char **argv) { + if(argc == 42) { + printf("Very sneaky, %s\n", argv[0]); + } +#ifdef UP_IS_DOWN + return 0; +#else + return 1; +#endif +} diff --git a/test cases/common/234 wrap case/subprojects/up_down.wrap b/test cases/common/234 wrap case/subprojects/up_down.wrap new file mode 100644 index 000000000..d66818fe8 --- /dev/null +++ b/test cases/common/234 wrap case/subprojects/up_down.wrap @@ -0,0 +1,5 @@ +[wrap-file] +directory = up_down + +[provide] +UP_down = up_down_dep diff --git a/test cases/common/234 wrap case/subprojects/up_down/meson.build b/test cases/common/234 wrap case/subprojects/up_down/meson.build new file mode 100644 index 000000000..5db89d15d --- /dev/null +++ b/test cases/common/234 wrap case/subprojects/up_down/meson.build @@ -0,0 +1,3 @@ +project('up down', 'c') + +up_down_dep = declare_dependency(include_directories: '.') diff --git a/test cases/common/234 wrap case/subprojects/up_down/up_down.h b/test cases/common/234 wrap case/subprojects/up_down/up_down.h new file mode 100644 index 000000000..8d968ce14 --- /dev/null +++ b/test cases/common/234 wrap case/subprojects/up_down/up_down.h @@ -0,0 +1,3 @@ +#pragma once + +#define UP_IS_DOWN