1#!/usr/local/bin/python3.8 2 3# Copyright 2018 Steven Watanabe 4# Distributed under the Boost Software License, Version 1.0. 5# (See accompanying file LICENSE_1_0.txt or copy at 6# http://www.boost.org/LICENSE_1_0.txt) 7 8# Tests the <relevant> feature 9 10import BoostBuild 11 12t = BoostBuild.Tester(use_test_config=False) 13 14t.write("xxx.jam", """ 15import type ; 16import feature : feature ; 17import toolset : flags ; 18import generators ; 19type.register XXX : xxx ; 20type.register YYY : yyy ; 21feature xxxflags : : free ; 22generators.register-standard xxx.run : YYY : XXX ; 23# xxxflags is relevant because it is used by flags 24flags xxx.run OPTIONS : <xxxflags> ; 25actions run 26{ 27 echo okay > $(<) 28} 29""") 30 31t.write("zzz.jam", """ 32import xxx ; 33import type ; 34import feature : feature ; 35import generators ; 36type.register ZZZ : zzz ; 37feature zzz.enabled : off on : propagated ; 38# zzz.enabled is relevant because it is used in the generator's 39# requirements 40generators.register-standard zzz.run : XXX : ZZZ : <zzz.enabled>on ; 41actions run 42{ 43 echo okay > $(<) 44} 45""") 46 47t.write("aaa.jam", """ 48import zzz ; 49import type ; 50import feature : feature ; 51import generators ; 52import toolset : flags ; 53type.register AAA : aaa ; 54feature aaaflags : : free ; 55generators.register-standard aaa.run : ZZZ : AAA ; 56flags aaa.run OPTIONS : <aaaflags> ; 57actions run 58{ 59 echo okay > $(<) 60} 61""") 62 63t.write("Jamroot.jam", """ 64import xxx ; 65import zzz ; 66import aaa ; 67import feature : feature ; 68 69# f1 is relevant, because it is composite and <xxxflags> is relevant 70feature f1 : n y : composite propagated ; 71feature.compose <f1>y : <xxxflags>-no1 ; 72# f2 is relevant, because it is used in a conditional 73feature f2 : n y : propagated ; 74# f3 is relevant, because it is used to choose the target alternative 75feature f3 : n y : propagated ; 76# f4 is relevant, because it is marked as such explicitly 77feature f4 : n y : propagated ; 78# f5 is relevant because of the conditional usage-requirements 79feature f5 : n y : propagated ; 80# f6 is relevant because the indirect conditional indicates so 81feature f6 : n y : propagated ; 82# f7 is relevant because the icond7 says so 83feature f7 : n y : propagated ; 84 85# The same as f[n], except not propagated 86feature g1 : n y : composite ; 87feature.compose <g1>y : <xxxflags>-no1 ; 88feature g2 : n y ; 89feature g3 : n y ; 90feature g4 : n y ; 91feature g5 : n y ; 92feature g6 : n y ; 93feature g7 : n y ; 94 95project : default-build 96 <f1>y <f2>y <f3>y <f4>y <f5>y <f6>y <f7>y 97 <g1>y <g2>y <g3>y <g4>y <g5>y <g6>y <g7>y <zzz.enabled>on ; 98 99rule icond6 ( properties * ) 100{ 101 local result ; 102 if <f6>y in $(properties) || <g6>y in $(properties) 103 { 104 result += <xxxflags>-yes6 ; 105 } 106 return $(result) 107 <relevant>xxxflags:<relevant>f6 108 <relevant>xxxflags:<relevant>g6 ; 109} 110 111rule icond7 ( properties * ) 112{ 113 local result ; 114 if <f7>y in $(properties) || <g7>y in $(properties) 115 { 116 result += <aaaflags>-yes7 ; 117 } 118 return $(result) 119 <relevant>aaaflags:<relevant>f7 120 <relevant>aaaflags:<relevant>g7 ; 121} 122 123zzz out : in.yyy 124 : <f2>y:<xxxflags>-no2 <g2>y:<xxxflags>-no2 <relevant>f4 <relevant>g4 125 <conditional>@icond6 126 : 127 : <f5>y:<aaaflags>-yes5 <g5>y:<aaaflags>-yes5 <conditional>@icond7 128 ; 129alias out : : <f3>n ; 130alias out : : <g3>n ; 131# Features that are relevant for out are also relevant for check-propagate 132aaa check-propagate : out ; 133""") 134 135t.write("in.yyy", "") 136 137t.run_build_system() 138t.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") 139t.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") 140t.expect_addition("bin/f1-y/f2-y/f3-y/f4-y/f5-y/f6-y/f7-y/zzz.enabled-on/check-propagate.aaa") 141 142t.cleanup() 143