#!/usr/bin/python # Copyright 2018 Steven Watanabe # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE.txt or copy at # https://www.bfgroup.xyz/b2/LICENSE.txt) # Tests the feature import BoostBuild t = BoostBuild.Tester(use_test_config=False) t.write("xxx.jam", """ import type ; import feature : feature ; import toolset : flags ; import generators ; type.register XXX : xxx ; type.register YYY : yyy ; feature xxxflags : : free ; generators.register-standard xxx.run : YYY : XXX ; # xxxflags is relevant because it is used by flags flags xxx.run OPTIONS : ; actions run { echo okay > $(<) } """) t.write("zzz.jam", """ import xxx ; import type ; import feature : feature ; import generators ; type.register ZZZ : zzz ; feature zzz.enabled : off on : propagated ; # zzz.enabled is relevant because it is used in the generator's # requirements generators.register-standard zzz.run : XXX : ZZZ : on ; actions run { echo okay > $(<) } """) t.write("aaa.jam", """ import zzz ; import type ; import feature : feature ; import generators ; import toolset : flags ; type.register AAA : aaa ; feature aaaflags : : free ; generators.register-standard aaa.run : ZZZ : AAA ; flags aaa.run OPTIONS : ; actions run { echo okay > $(<) } """) t.write("Jamroot.jam", """ import xxx ; import zzz ; import aaa ; import feature : feature ; # f1 is relevant, because it is composite and is relevant feature f1 : n y : composite propagated ; feature.compose y : -no1 ; # f2 is relevant, because it is used in a conditional feature f2 : n y : propagated ; # f3 is relevant, because it is used to choose the target alternative feature f3 : n y : propagated ; # f4 is relevant, because it is marked as such explicitly feature f4 : n y : propagated ; # f5 is relevant because of the conditional usage-requirements feature f5 : n y : propagated ; # f6 is relevant because the indirect conditional indicates so feature f6 : n y : propagated ; # f7 is relevant because the icond7 says so feature f7 : n y : propagated ; # The same as f[n], except not propagated feature g1 : n y : composite ; feature.compose y : -no1 ; feature g2 : n y ; feature g3 : n y ; feature g4 : n y ; feature g5 : n y ; feature g6 : n y ; feature g7 : n y ; project : default-build y y y y y y y y y y y y y y on ; rule icond6 ( properties * ) { local result ; if y in $(properties) || y in $(properties) { result += -yes6 ; } return $(result) xxxflags:f6 xxxflags:g6 ; } rule icond7 ( properties * ) { local result ; if y in $(properties) || y in $(properties) { result += -yes7 ; } return $(result) aaaflags:f7 aaaflags:g7 ; } zzz out : in.yyy : y:-no2 y:-no2 f4 g4 @icond6 : : y:-yes5 y:-yes5 @icond7 ; alias out : : n ; alias out : : n ; # Features that are relevant for out are also relevant for check-propagate aaa check-propagate : out ; """) t.write("in.yyy", "") t.run_build_system() t.expect_addition("bin/f1-y/f2-y/f3-y/f4-y/f6-y/g1-y/g2-y/g3-y/g4-y/g6-y/out.xxx") t.expect_addition("bin/f1-y/f2-y/f3-y/f4-y/f6-y/g1-y/g2-y/g3-y/g4-y/g6-y/zzz.enabled-on/out.zzz") t.expect_addition("bin/f1-y/f2-y/f3-y/f4-y/f5-y/f6-y/f7-y/zzz.enabled-on/check-propagate.aaa") t.cleanup()