diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index b1f6d8556..415b554cb 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1100,7 +1100,13 @@ int dummy; args += ['--library=' + target.name] # Outputted header hname = os.path.join(self.get_target_dir(target), target.vala_header) - args += ['-H', hname, '--use-header'] + args += ['-H', hname] + if self.is_unity(target): + # Without this the declarations will get duplicated in the .c + # files and cause a build failure when all of them are + # #include-d in one .c file. + # https://github.com/mesonbuild/meson/issues/1969 + args += ['--use-header'] valac_outputs.append(hname) # Outputted vapi file vapiname = os.path.join(self.get_target_dir(target), target.vala_vapi) diff --git a/test cases/vala/7 shared library/lib/meson.build b/test cases/vala/7 shared library/lib/meson.build index 78646a860..edeeb96d1 100644 --- a/test cases/vala/7 shared library/lib/meson.build +++ b/test cases/vala/7 shared library/lib/meson.build @@ -1,4 +1,12 @@ -l = shared_library('valalib', 'mylib.vala', dependencies : valadeps) +args = [] +# https://github.com/mesonbuild/meson/issues/1969 +if get_option('unity') == 'on' + vala_args = ['-H', 'mylib.h'] +endif + +l = shared_library('valalib', 'mylib.vala', + vala_args : args, + dependencies : valadeps) shared_library('installed_vala_lib', 'mylib.vala', dependencies : valadeps,