diff options
| author | Florian "sp1rit" <sp1rit@disroot.org> | 2025-07-24 10:54:20 +0200 |
|---|---|---|
| committer | Jussi Pakkanen <jussi.pakkanen@mailbox.org> | 2025-07-25 20:32:48 +0300 |
| commit | 41eb18d16366002db123cba0fa0b72f62f2426f8 (patch) | |
| tree | a30869f7861bc2892b83525a676b24d12899e4b6 | |
| parent | 277d7268be5c730823ddac0cacd651c826043918 (diff) | |
| download | meson-41eb18d16366002db123cba0fa0b72f62f2426f8.tar.gz | |
build/process_compilers: Skip throwing error for headers
Dependencies should be able to provide headers in its sources, even tho
the target which uses the dependency may not use the language that
header is for.
A specific example is vala, where C and Vala dependencies share the same
name, so in meson they ought to share the same dependency object in
order to provide a Vala and/or C dependency depending on who is using
it. Doing so right now however fails, if the project of the dependency
user doesn't list vala in its used languages, even tho they might just
be interested in the C part of the dependency.
| -rw-r--r-- | mesonbuild/build.py | 2 | ||||
| -rw-r--r-- | test cases/vala/32 valaless vapigen/clib.c | 5 | ||||
| -rw-r--r-- | test cases/vala/32 valaless vapigen/clib.h | 3 | ||||
| -rw-r--r-- | test cases/vala/32 valaless vapigen/meson.build | 34 | ||||
| -rw-r--r-- | test cases/vala/32 valaless vapigen/test_clib.c | 9 |
5 files changed, 52 insertions, 1 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 72d376d17..fa8d21411 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -963,7 +963,7 @@ class BuildTarget(Target): self.compilers[lang] = compiler break else: - if is_known_suffix(s): + if is_known_suffix(s) and not is_header(s): path = pathlib.Path(str(s)).as_posix() m = f'No {self.for_machine.get_lower_case_name()} machine compiler for {path!r}' raise MesonException(m) diff --git a/test cases/vala/32 valaless vapigen/clib.c b/test cases/vala/32 valaless vapigen/clib.c new file mode 100644 index 000000000..a55ecd4b1 --- /dev/null +++ b/test cases/vala/32 valaless vapigen/clib.c @@ -0,0 +1,5 @@ +#include "clib.h" + +int clib_fun(void) { + return 42; +} diff --git a/test cases/vala/32 valaless vapigen/clib.h b/test cases/vala/32 valaless vapigen/clib.h new file mode 100644 index 000000000..4d855c9a8 --- /dev/null +++ b/test cases/vala/32 valaless vapigen/clib.h @@ -0,0 +1,3 @@ +#pragma once + +int clib_fun(void); diff --git a/test cases/vala/32 valaless vapigen/meson.build b/test cases/vala/32 valaless vapigen/meson.build new file mode 100644 index 000000000..22a99e5e8 --- /dev/null +++ b/test cases/vala/32 valaless vapigen/meson.build @@ -0,0 +1,34 @@ +project('valaless-vapigen', 'c') + +if host_machine.system() == 'cygwin' + error('MESON_SKIP_TEST Does not work with the Vala currently packaged in cygwin') +endif + +gnome = import('gnome') + +clib_src = [ + 'clib.c', + 'clib.h' +] + +clib_lib = shared_library('clib', clib_src) + +clib_gir = gnome.generate_gir(clib_lib, + sources: clib_src, + namespace: 'Clib', + nsversion: '0', + header: 'clib.h', + symbol_prefix: 'clib' +) + +clib_vapi = gnome.generate_vapi('clib', sources: clib_gir[0]) + +clib_dep = declare_dependency( + include_directories: include_directories('.'), + link_with: clib_lib, + sources: clib_gir, + dependencies: clib_vapi +) + + +test('clib-test', executable('clib-test', 'test_clib.c', dependencies: clib_dep)) diff --git a/test cases/vala/32 valaless vapigen/test_clib.c b/test cases/vala/32 valaless vapigen/test_clib.c new file mode 100644 index 000000000..6fd426ccb --- /dev/null +++ b/test cases/vala/32 valaless vapigen/test_clib.c @@ -0,0 +1,9 @@ +#include <stdlib.h> +#include <clib.h> + +int main(void) { + if (clib_fun () == 42) + return EXIT_SUCCESS; + else + return EXIT_FAILURE; +} |
