diff options
author | Florian "sp1rit"​ <sp1rit@disroot.org> | 2025-07-31 10:10:44 +0200 |
---|---|---|
committer | Jussi Pakkanen <jussi.pakkanen@mailbox.org> | 2025-08-10 22:38:30 +0300 |
commit | 651aede977179c5fe382744e3dd91ca8e01d050c (patch) | |
tree | 5ca295a29b89a2baa1a76f1a2af6d74cb5167737 | |
parent | f49bdd473ca063c9e928c2e96bdb30582d2129bf (diff) | |
download | meson-651aede977179c5fe382744e3dd91ca8e01d050c.zip meson-651aede977179c5fe382744e3dd91ca8e01d050c.tar.gz meson-651aede977179c5fe382744e3dd91ca8e01d050c.tar.bz2 |
build: Throw an error instead of warning for sourceless targets
We might run into an assertion failure down the road, if we don't fail
here. Specifically
project('proj')
executable('bin', 'header.h')
will throw during the ninja generation.
-rw-r--r-- | mesonbuild/build.py | 4 | ||||
-rw-r--r-- | test cases/common/44 pkgconfig-gen/meson.build | 2 | ||||
-rw-r--r-- | test cases/common/44 pkgconfig-gen/simple7.c | 0 | ||||
-rw-r--r-- | test cases/failing/136 target with no sources/meson.build (renamed from test cases/warning/8 target with no sources/meson.build) | 0 | ||||
-rw-r--r-- | test cases/failing/136 target with no sources/test.json | 7 | ||||
-rw-r--r-- | test cases/warning/8 target with no sources/test.json | 7 | ||||
-rw-r--r-- | unittests/allplatformstests.py | 2 |
7 files changed, 10 insertions, 12 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 041cb19..cfba923 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -760,9 +760,7 @@ class BuildTarget(Target): if not any([[src for src in self.sources if not is_header(src)], self.generated, self.objects, self.link_whole_targets, self.structured_sources, kwargs.pop('_allow_no_sources', False)]): - mlog.warning(f'Build target {name} has no sources. ' - 'This was never supposed to be allowed but did because of a bug, ' - 'support will be removed in a future release of Meson') + raise MesonException(f'Build target {name} has no sources.') self.check_unknown_kwargs(kwargs) self.validate_install() self.check_module_linking() diff --git a/test cases/common/44 pkgconfig-gen/meson.build b/test cases/common/44 pkgconfig-gen/meson.build index fd6371e..624126c 100644 --- a/test cases/common/44 pkgconfig-gen/meson.build +++ b/test cases/common/44 pkgconfig-gen/meson.build @@ -189,7 +189,7 @@ endtestcase # Make sure the -uninstalled.pc file contains both include directories. # See dependencies/test2.c that gets built against both simple7.pc and # simple7-uninstalled.pc. -simple7 = library('simple7', include_directories: 'inc1') +simple7 = library('simple7', 'simple7.c', include_directories: 'inc1') dep = declare_dependency(include_directories: 'inc2') install_headers('inc1/inc1.h', 'inc2/inc2.h') pkgg.generate(simple7, libraries: dep) diff --git a/test cases/common/44 pkgconfig-gen/simple7.c b/test cases/common/44 pkgconfig-gen/simple7.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/common/44 pkgconfig-gen/simple7.c diff --git a/test cases/warning/8 target with no sources/meson.build b/test cases/failing/136 target with no sources/meson.build index 2a8ee11..2a8ee11 100644 --- a/test cases/warning/8 target with no sources/meson.build +++ b/test cases/failing/136 target with no sources/meson.build diff --git a/test cases/failing/136 target with no sources/test.json b/test cases/failing/136 target with no sources/test.json new file mode 100644 index 0000000..9cef755 --- /dev/null +++ b/test cases/failing/136 target with no sources/test.json @@ -0,0 +1,7 @@ +{ + "stdout": [ + { + "line": "test cases/failing/136 target with no sources/meson.build:3:0: ERROR: Build target no sources has no sources." + } + ] +} diff --git a/test cases/warning/8 target with no sources/test.json b/test cases/warning/8 target with no sources/test.json deleted file mode 100644 index 30e5b05..0000000 --- a/test cases/warning/8 target with no sources/test.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "stdout": [ - { - "line": "WARNING: Build target no sources has no sources. This was never supposed to be allowed but did because of a bug, support will be removed in a future release of Meson" - } - ] -} diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 04cbfc6..ebcb1f5 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -4819,7 +4819,7 @@ class AllPlatformTests(BasePlatformTests): for_machine=MachineChoice.HOST, sources=[], structured_sources=None, objects=[], environment=env, compilers=env.coredata.compilers[MachineChoice.HOST], - kwargs={}) + kwargs={'_allow_no_sources': True}) target.process_compilers_late() return target.filename |