From 9b5df6e442672f8e7d6ead666a766234ccf41277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Sat, 13 May 2017 22:14:03 +0200 Subject: [PATCH] ninja: Deduplicate dependent vapis The Vala compiler does not like being fed the same .vapi multiple times. --- mesonbuild/backend/ninjabackend.py | 8 ++++---- test cases/vala/18 vapi consumed twice/app.vala | 11 +++++++++++ test cases/vala/18 vapi consumed twice/beer.vala | 10 ++++++++++ .../vala/18 vapi consumed twice/meson.build | 15 +++++++++++++++ .../vala/18 vapi consumed twice/person.vala | 16 ++++++++++++++++ 5 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 test cases/vala/18 vapi consumed twice/app.vala create mode 100644 test cases/vala/18 vapi consumed twice/beer.vala create mode 100644 test cases/vala/18 vapi consumed twice/meson.build create mode 100644 test cases/vala/18 vapi consumed twice/person.vala diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index f7e84dc96..d08d560c0 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -20,7 +20,7 @@ from .. import mlog from .. import dependencies from .. import compilers from ..compilers import CompilerArgs -from ..mesonlib import File, MesonException +from ..mesonlib import File, MesonException, OrderedSet from ..mesonlib import get_meson_script, get_compiler_for_source, Popen_safe from .backends import CleanTrees, InstallData from ..build import InvalidArguments @@ -976,7 +976,7 @@ int dummy; the same name as the BuildTarget and return the path to it relative to the build directory. """ - result = [] + result = OrderedSet() for dep in target.link_targets: for i in dep.sources: if hasattr(i, 'fname'): @@ -984,9 +984,9 @@ int dummy; if i.endswith('vala'): vapiname = dep.name + '.vapi' fullname = os.path.join(self.get_target_dir(dep), vapiname) - result.append(fullname) + result.add(fullname) break - return result + return list(result) def split_vala_sources(self, t): """ diff --git a/test cases/vala/18 vapi consumed twice/app.vala b/test cases/vala/18 vapi consumed twice/app.vala new file mode 100644 index 000000000..cd94a42b9 --- /dev/null +++ b/test cases/vala/18 vapi consumed twice/app.vala @@ -0,0 +1,11 @@ +namespace App { + public static int main(string[] args) { + var person = new Person(); + print("Favorite beer of \"%s\" is %s\n", person.name, person.favorite_beer.flavor); + + var beer = new Beer("tasty"); + print("This beer is %s\n", beer.flavor); + + return 0; + } +} diff --git a/test cases/vala/18 vapi consumed twice/beer.vala b/test cases/vala/18 vapi consumed twice/beer.vala new file mode 100644 index 000000000..cee38ad43 --- /dev/null +++ b/test cases/vala/18 vapi consumed twice/beer.vala @@ -0,0 +1,10 @@ +public class Beer : Object { + public string flavor { + get; + construct; + } + + public Beer(string flavor) { + Object(flavor: flavor); + } +} diff --git a/test cases/vala/18 vapi consumed twice/meson.build b/test cases/vala/18 vapi consumed twice/meson.build new file mode 100644 index 000000000..6a7f5ebc5 --- /dev/null +++ b/test cases/vala/18 vapi consumed twice/meson.build @@ -0,0 +1,15 @@ +project('vapi consumed twice', 'vala', 'c') + +base_deps = [dependency('glib-2.0'), dependency('gobject-2.0')] + +beer = library('beer', 'beer.vala', dependencies : base_deps) +beer_dep = declare_dependency(link_with : beer) + +person = library('person', 'person.vala', link_with : beer, + dependencies : base_deps) +person_dep = declare_dependency(link_with : person, dependencies : [beer_dep]) + +app = executable('app', 'app.vala', + dependencies : base_deps + [person_dep, beer_dep]) + +test('valavapiconsumedtwicetest', app) diff --git a/test cases/vala/18 vapi consumed twice/person.vala b/test cases/vala/18 vapi consumed twice/person.vala new file mode 100644 index 000000000..36b0025e2 --- /dev/null +++ b/test cases/vala/18 vapi consumed twice/person.vala @@ -0,0 +1,16 @@ +public class Person : Object { + public string name { + get { + return "Joe Badger"; + } + } + + public Beer favorite_beer { + get; + construct; + } + + public Person() { + Object(favorite_beer: new Beer("smooth")); + } +}