Skip to content

Commit 651aede

Browse files
sp1ritCSjpakkane
authored andcommitted
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.
1 parent f49bdd4 commit 651aede

File tree

7 files changed

+10
-12
lines changed

7 files changed

+10
-12
lines changed

mesonbuild/build.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,9 +760,7 @@ def __init__(
760760

761761
if not any([[src for src in self.sources if not is_header(src)], self.generated, self.objects,
762762
self.link_whole_targets, self.structured_sources, kwargs.pop('_allow_no_sources', False)]):
763-
mlog.warning(f'Build target {name} has no sources. '
764-
'This was never supposed to be allowed but did because of a bug, '
765-
'support will be removed in a future release of Meson')
763+
raise MesonException(f'Build target {name} has no sources.')
766764
self.check_unknown_kwargs(kwargs)
767765
self.validate_install()
768766
self.check_module_linking()

test cases/common/44 pkgconfig-gen/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ endtestcase
189189
# Make sure the -uninstalled.pc file contains both include directories.
190190
# See dependencies/test2.c that gets built against both simple7.pc and
191191
# simple7-uninstalled.pc.
192-
simple7 = library('simple7', include_directories: 'inc1')
192+
simple7 = library('simple7', 'simple7.c', include_directories: 'inc1')
193193
dep = declare_dependency(include_directories: 'inc2')
194194
install_headers('inc1/inc1.h', 'inc2/inc2.h')
195195
pkgg.generate(simple7, libraries: dep)

test cases/common/44 pkgconfig-gen/simple7.c

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"stdout": [
3+
{
4+
"line": "test cases/failing/136 target with no sources/meson.build:3:0: ERROR: Build target no sources has no sources."
5+
}
6+
]
7+
}

test cases/warning/8 target with no sources/test.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

unittests/allplatformstests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4819,7 +4819,7 @@ def output_name(name, type_):
48194819
for_machine=MachineChoice.HOST, sources=[],
48204820
structured_sources=None,
48214821
objects=[], environment=env, compilers=env.coredata.compilers[MachineChoice.HOST],
4822-
kwargs={})
4822+
kwargs={'_allow_no_sources': True})
48234823
target.process_compilers_late()
48244824
return target.filename
48254825

0 commit comments

Comments
 (0)