1#!/usr/bin/python 2 3# Copyright (c) Steven Watanabe 2018. 4# Distributed under the Boost Software License, Version 1.0. (See 5# accompanying file LICENSE_1_0.txt or copy at 6# http://www.boost.org/LICENSE_1_0.txt) 7 8# Tests that a single main target can be used for 9# implicit dependencies of multiple different types. 10 11import BoostBuild 12 13t = BoostBuild.Tester(pass_toolset=False) 14 15t.write("input.sss", "") 16 17t.write("Jamroot.jam", """ 18import type ; 19import common ; 20import generators ; 21import "class" : new ; 22import feature : feature ; 23import toolset : flags ; 24 25type.register AAA : aaa ; 26type.register BBB : bbb ; 27type.register CCC : ccc ; 28type.register DDD : ddd ; 29type.register SSS : sss ; 30 31feature aaa-path : : free path ; 32feature bbb-path : : free path ; 33 34class aaa-action : action 35{ 36 rule adjust-properties ( property-set ) 37 { 38 local s = [ $(self.targets[1]).creating-subvariant ] ; 39 return [ $(property-set).add-raw 40 [ $(s).implicit-includes aaa-path : AAA ] ] ; 41 } 42} 43 44class aaa-generator : generator 45{ 46 rule action-class ( ) 47 { 48 return aaa-action ; 49 } 50} 51 52class bbb-action : action 53{ 54 rule adjust-properties ( property-set ) 55 { 56 local s = [ $(self.targets[1]).creating-subvariant ] ; 57 return [ $(property-set).add-raw 58 [ $(s).implicit-includes bbb-path : BBB ] ] ; 59 } 60} 61 62class bbb-generator : generator 63{ 64 rule action-class ( ) 65 { 66 return bbb-action ; 67 } 68} 69 70generators.register-standard common.copy : SSS : AAA ; 71generators.register-standard common.copy : SSS : BBB ; 72 73# Produce two targets from a single source 74rule make-aaa-bbb ( project name ? : property-set : sources * ) 75{ 76 local result ; 77 local aaa = [ generators.construct $(project) $(name) : AAA : 78 [ $(property-set).add-raw <location-prefix>a-loc ] : $(sources) ] ; 79 local bbb = [ generators.construct $(project) $(name) : BBB : 80 [ $(property-set).add-raw <location-prefix>b-loc ] : $(sources) ] ; 81 return [ $(aaa[1]).add $(bbb[1]) ] $(aaa[2-]) $(bbb[2-]) ; 82} 83 84generate input : input.sss : <generating-rule>@make-aaa-bbb ; 85explicit input ; 86 87flags make-ccc AAAPATH : <aaa-path> ; 88rule make-ccc ( target : sources * : properties * ) 89{ 90 ECHO aaa path\: [ on $(target) return $(AAAPATH) ] ; 91 common.copy $(target) : $(sources) ; 92} 93 94flags make-ddd BBBPATH : <bbb-path> ; 95rule make-ddd ( target : sources * : properties * ) 96{ 97 ECHO bbb path\: [ on $(target) return $(BBBPATH) ] ; 98 common.copy $(target) : $(sources) ; 99} 100 101generators.register [ new aaa-generator $(__name__).make-ccc : SSS : CCC ] ; 102generators.register [ new bbb-generator $(__name__).make-ddd : SSS : DDD ] ; 103 104# This should have <aaapath>bin/a-loc 105ccc output-c : input.sss : <implicit-dependency>input ; 106# This should have <bbbpath>bin/b-loc 107ddd output-d : input.sss : <implicit-dependency>input ; 108""") 109 110t.run_build_system() 111t.expect_output_lines(["aaa path: bin/a-loc", "bbb path: bin/b-loc"]) 112 113t.cleanup() 114