From 01547e8c613dfcdef6e38802b384df4eddaf062c Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Thu, 26 Jan 2017 18:40:35 +0530 Subject: ninja: Fix build_by_default=false targets in tests Previously, build_by_default=false targets would not be built at all even if they were used in a test (as the exe or as a command-line argument) which would lead to a test failure. Now we look into all the defined tests and add all CustomTargets and BuildTargets used in them to the list of build_by_default targets. --- mesonbuild/backend/ninjabackend.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'mesonbuild/backend/ninjabackend.py') diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 628718f..49ccfca 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2161,11 +2161,28 @@ rule FORTRAN_DEP_HACK elem.write(outfile) def get_build_by_default_targets(self): - result = [] + result = {} + # Get all build and custom targets that must be built by default for t in self.build.get_targets().values(): if t.build_by_default or t.install or t.build_always: - result.append(t) - return result + result[t] = True + # Get all targets used as test executables and arguments. These must + # also be built by default. XXX: Sometime in the future these should be + # built only before running tests. + for t in self.build.get_tests(): + exe = t.exe + if hasattr(exe, 'held_object'): + exe = exe.held_object + if isinstance(exe, (build.CustomTarget, build.BuildTarget)) and exe not in result: + result[exe] = True + for arg in t.cmd_args: + if hasattr(arg, 'held_object'): + arg = arg.held_object + if not isinstance(arg, (build.CustomTarget, build.BuildTarget)): + continue + if arg not in result: + result[arg] = True + return result.keys() def generate_ending(self, outfile): targetlist = [] -- cgit v1.1 From fc4e3326012aceeb3a1ef4a616e42e9cdfeadb9f Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Thu, 26 Jan 2017 19:08:47 +0530 Subject: backends: Add support for build_by_default to vs2010 backend Always generate the vcxproj file, but only add it to the build configuration if it's either supposed to be built by default, or is a dependency of another target that is built by default. --- mesonbuild/backend/ninjabackend.py | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) (limited to 'mesonbuild/backend/ninjabackend.py') diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 49ccfca..9212316 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2160,34 +2160,10 @@ rule FORTRAN_DEP_HACK elem.add_item('pool', 'console') elem.write(outfile) - def get_build_by_default_targets(self): - result = {} - # Get all build and custom targets that must be built by default - for t in self.build.get_targets().values(): - if t.build_by_default or t.install or t.build_always: - result[t] = True - # Get all targets used as test executables and arguments. These must - # also be built by default. XXX: Sometime in the future these should be - # built only before running tests. - for t in self.build.get_tests(): - exe = t.exe - if hasattr(exe, 'held_object'): - exe = exe.held_object - if isinstance(exe, (build.CustomTarget, build.BuildTarget)) and exe not in result: - result[exe] = True - for arg in t.cmd_args: - if hasattr(arg, 'held_object'): - arg = arg.held_object - if not isinstance(arg, (build.CustomTarget, build.BuildTarget)): - continue - if arg not in result: - result[arg] = True - return result.keys() - def generate_ending(self, outfile): targetlist = [] ctlist = [] - for t in self.get_build_by_default_targets(): + for t in self.get_build_by_default_targets().values(): if isinstance(t, build.CustomTarget): # Create a list of all custom target outputs for o in t.get_outputs(): -- cgit v1.1