From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/boost/tools/build/test/unused.py | 81 ++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/boost/tools/build/test/unused.py (limited to 'src/boost/tools/build/test/unused.py') diff --git a/src/boost/tools/build/test/unused.py b/src/boost/tools/build/test/unused.py new file mode 100644 index 000000000..2b185d0de --- /dev/null +++ b/src/boost/tools/build/test/unused.py @@ -0,0 +1,81 @@ +#!/usr/bin/python + +# Copyright 2003 Vladimir Prus +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# Test that unused sources are at least reported. + +import BoostBuild + +t = BoostBuild.Tester(["-d+2"], use_test_config=False) + +t.write("a.cpp", "int main() {}\n") +t.write("b.cpp", "\n") +t.write("b.xyz", "") +t.write("jamroot.jam", """\ +import "class" : new ; +import modules ; +import project ; +import targets ; +import type ; +import virtual-target ; + +type.register X : xyz ; + +class test-target-class : basic-target +{ + rule construct ( name : source-targets * : property-set ) + { + local result = [ property-set.empty ] ; + if ! [ modules.peek : GENERATE_NOTHING ] + { + result += [ virtual-target.from-file b.xyz : . : $(self.project) ] ; + if ! [ modules.peek : GENERATE_ONLY_UNUSABLE ] + { + result += [ virtual-target.from-file b.cpp : . : $(self.project) + ] ; + } + } + return $(result) ; + } + + rule compute-usage-requirements ( rproperties : targets * ) + { + return [ property-set.create FOO ] ; + } +} + +rule make-b-main-target +{ + local project = [ project.current ] ; + targets.main-target-alternative [ new test-target-class b : $(project) ] ; +} + +exe a : a.cpp b c ; +make-b-main-target ; +alias c ; # Expands to nothing, intentionally. +""") + +t.run_build_system() + +# The second invocation should do nothing, and produce no warning. The previous +# invocation might have printed executed actions and other things, so it is not +# easy to check if a warning was issued or not. +t.run_build_system(stdout="") + +t.run_build_system(["-sGENERATE_ONLY_UNUSABLE=1"], stdout="") + +# Check that even if main target generates nothing, its usage requirements are +# still propagated to dependants. +t.write("a.cpp", """\ +#ifndef FOO + #error We refuse to compile without FOO being defined! + We_refuse_to_compile_without_FOO_being_defined +#endif +int main() {} +""") +t.run_build_system(["-sGENERATE_NOTHING=1"]) + +t.cleanup() -- cgit v1.2.3