1#!/usr/local/bin/python3.8
2
3# Copyright 2003 Vladimir Prus
4# Distributed under the Boost Software License, Version 1.0.
5# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
6
7import BoostBuild
8import string
9
10t = BoostBuild.Tester(pass_toolset=0)
11
12t.write("a.cpp", "\n")
13
14t.write("yfc1.jam", """\
15import feature ;
16import generators ;
17
18feature.extend toolset : yfc1 ;
19rule init ( ) { }
20
21generators.register-standard yfc1.compile : CPP : OBJ : <toolset>yfc1 ;
22generators.register-standard yfc1.link : OBJ : EXE : <toolset>yfc1 ;
23
24actions compile { yfc1-compile }
25actions link { yfc1-link }
26""")
27
28t.write(
29    'yfc1.py',
30"""
31from b2.build import feature, generators
32from b2.manager import get_manager
33
34MANAGER = get_manager()
35ENGINE = MANAGER.engine()
36
37feature.extend('toolset', ['yfc1'])
38
39generators.register_standard('yfc1.compile', ['CPP'], ['OBJ'], ['<toolset>yfc1'])
40generators.register_standard('yfc1.link', ['OBJ'], ['EXE'], ['<toolset>yfc1'])
41
42ENGINE.register_action(
43    'yfc1.compile',
44    'yfc1-compile'
45)
46
47ENGINE.register_action(
48    'yfc1.link',
49    'yfc1-link'
50)
51
52def init(*args):
53    pass
54
55"""
56)
57
58t.write("yfc2.jam", """\
59import feature ;
60import toolset ;
61
62feature.extend toolset : yfc2 ;
63toolset.inherit yfc2 : yfc1 ;
64rule init ( ) { }
65
66actions link { yfc2-link }
67""")
68
69t.write(
70    'yfc2.py',
71"""
72from b2.build import feature, toolset
73from b2.manager import get_manager
74
75MANAGER = get_manager()
76ENGINE = MANAGER.engine()
77
78feature.extend('toolset', ['yfc2'])
79toolset.inherit('yfc2', 'yfc1')
80
81ENGINE.register_action('yfc2.link', 'yfc2-link')
82
83def init(*args):
84    pass
85"""
86)
87
88t.write("jamfile.jam", "exe a : a.cpp ;")
89t.write("jamroot.jam", "using yfc1 ;")
90
91t.run_build_system(["-n", "-d2", "yfc1"])
92t.fail_test(t.stdout().find("yfc1-link") == -1)
93
94# Make sure we do not have to explicitly 'use' yfc1.
95t.write("jamroot.jam", "using yfc2 ;")
96
97t.run_build_system(["-n", "-d2", "yfc2"])
98t.fail_test(t.stdout().find("yfc2-link") == -1)
99
100t.cleanup()
101