diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2020-06-21 19:48:39 -0400 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2020-06-24 22:53:09 +0300 |
commit | d0f468fef11f576cbbb2e704517f7b2d010750a1 (patch) | |
tree | 275ff7405bf24abd55c922dedf5c6b0427052a50 | |
parent | 35f2a2444f9298b59f0f2cd60b71d31c96ffb511 (diff) | |
download | meson-d0f468fef11f576cbbb2e704517f7b2d010750a1.zip meson-d0f468fef11f576cbbb2e704517f7b2d010750a1.tar.gz meson-d0f468fef11f576cbbb2e704517f7b2d010750a1.tar.bz2 |
pkgconfig: Add missing cflags in uninstalled files
Fixes: #7365
-rw-r--r-- | mesonbuild/modules/pkgconfig.py | 27 | ||||
-rwxr-xr-x | run_unittests.py | 5 | ||||
-rw-r--r-- | test cases/common/47 pkgconfig-gen/dependencies/main.c | 4 | ||||
-rw-r--r-- | test cases/common/47 pkgconfig-gen/meson.build | 3 |
4 files changed, 20 insertions, 19 deletions
diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index 18baf0c..b7a12ff 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -372,18 +372,18 @@ class PkgConfigModule(ExtensionModule): if len(deps.priv_libs) > 0: ofile.write('Libs.private: {}\n'.format(' '.join(generate_libs_flags(deps.priv_libs)))) - def generate_compiler_flags(): - cflags_buf = [] - for f in deps.cflags: - cflags_buf.append(self._escape(f)) - return cflags_buf - - cflags = generate_compiler_flags() - ofile.write('Cflags: ') + cflags = [] if uninstalled: - ofile.write(' '.join(generate_uninstalled_cflags(deps.pub_libs + deps.priv_libs))) - elif not dataonly and cflags: - ofile.write('{}\n'.format(' '.join(cflags))) + cflags += generate_uninstalled_cflags(deps.pub_libs + deps.priv_libs) + else: + for d in subdirs: + if d == '.': + cflags.append('-I${includedir}') + else: + cflags.append(self._escape(PurePath('-I${includedir}') / d)) + cflags += [self._escape(f) for f in deps.cflags] + if cflags and not dataonly: + ofile.write('Cflags: {}\n'.format(' '.join(cflags))) @FeatureNewKwargs('pkgconfig.generate', '0.54.0', ['uninstalled_variables']) @FeatureNewKwargs('pkgconfig.generate', '0.42.0', ['extra_cflags']) @@ -448,11 +448,6 @@ class PkgConfigModule(ExtensionModule): libraries = [mainlib] + libraries deps = DependenciesHelper(state, filebase) - for d in subdirs: - if d == '.': - deps.add_cflags(['-I${includedir}']) - else: - deps.add_cflags(self._escape(PurePath('-I${includedir}') / d)) deps.add_pub_libs(libraries) deps.add_priv_libs(kwargs.get('libraries_private', [])) deps.add_pub_reqs(kwargs.get('requires', [])) diff --git a/run_unittests.py b/run_unittests.py index 1a96f8f..9e8aa50 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -3177,8 +3177,9 @@ int main(int argc, char **argv) { self.assertEqual(foo_dep.get_link_args(), link_args) # Ensure include args are properly quoted incdir = PurePath(prefix) / PurePath('include') - cargs = ['-I' + incdir.as_posix()] - self.assertEqual(foo_dep.get_compile_args(), cargs) + cargs = ['-I' + incdir.as_posix(), '-DLIBFOO'] + # pkg-config and pkgconf does not respect the same order + self.assertEqual(sorted(foo_dep.get_compile_args()), sorted(cargs)) def test_array_option_change(self): def get_opt(): diff --git a/test cases/common/47 pkgconfig-gen/dependencies/main.c b/test cases/common/47 pkgconfig-gen/dependencies/main.c index 61708d3..397d40c 100644 --- a/test cases/common/47 pkgconfig-gen/dependencies/main.c +++ b/test cases/common/47 pkgconfig-gen/dependencies/main.c @@ -1,5 +1,9 @@ #include <simple.h> +#ifndef LIBFOO +#error LIBFOO should be defined in pkgconfig cflags +#endif + int main(int argc, char *argv[]) { return simple_function() == 42 ? 0 : 1; diff --git a/test cases/common/47 pkgconfig-gen/meson.build b/test cases/common/47 pkgconfig-gen/meson.build index c251b9f..eb2afe4 100644 --- a/test cases/common/47 pkgconfig-gen/meson.build +++ b/test cases/common/47 pkgconfig-gen/meson.build @@ -43,7 +43,8 @@ pkgg.generate( name : 'libfoo', version : libver, description : 'A foo library.', - variables : ['foo=bar', 'datadir=${prefix}/data'] + variables : ['foo=bar', 'datadir=${prefix}/data'], + extra_cflags : ['-DLIBFOO'], ) pkgg.generate( |