]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/build/test/generator_selection.py
update sources to v12.2.3
[ceph.git] / ceph / src / boost / tools / build / test / generator_selection.py
CommitLineData
7c673cae
FG
1#!/usr/bin/python
2
3# Copyright 2008, 2012 Jurko Gospodnetic
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 that generators get selected correctly.
9#
10# We do not use the internal C++-compiler CPP --> OBJ generator to avoid
11# problems with specific compilers or their configurations, e.g. IBM's AIX test
12# runner 'AIX Version 5.3 TL7 SP5 (5300-07-05-0831)' using the 'IBM XL C/C++
13# for AIX, V12.1 (Version: 12.01.0000.0000)' reporting errors when run with a
14# source file whose suffix is not '.cpp'.
15
16import BoostBuild
17
18
19###############################################################################
20#
21# test_generator_added_after_already_building_a_target_of_its_target_type()
22# -------------------------------------------------------------------------
23#
24###############################################################################
25
26def test_generator_added_after_already_building_a_target_of_its_target_type():
27 """
28 Regression test for a Boost Build bug causing it to not use a generator
29 if it got added after already building a target of its target type.
30
31 """
32 t = BoostBuild.Tester()
33
34 t.write("dummy.cpp", "void f() {}\n")
35
36 t.write("jamroot.jam", """\
37import common ;
38import generators ;
39import type ;
40type.register MY_OBJ : my_obj ;
41generators.register-standard common.copy : CPP : MY_OBJ ;
42
43# Building this dummy target must not cause a later defined CPP target type
44# generator not to be recognized as viable.
45my-obj dummy : dummy.cpp ;
46alias the-other-obj : Other//other-obj ;
47""")
48
49 t.write("Other/source.extension", "A dummy source file.")
50
51 t.write("Other/mygen.jam", """\
52import common ;
53import generators ;
54import type ;
55type.register MY_TYPE : extension ;
56generators.register-standard $(__name__).generate-a-cpp-file : MY_TYPE : CPP ;
57rule generate-a-cpp-file { ECHO Generating a CPP file... ; }
58CREATE-FILE = [ common.file-creation-command ] ;
59actions generate-a-cpp-file { $(CREATE-FILE) "$(<)" }
60""")
61
62 t.write("Other/mygen.py", """\
63import b2.build.generators as generators
64import b2.build.type as type
65
66from b2.manager import get_manager
67
68import os
69
70type.register('MY_TYPE', ['extension'])
71generators.register_standard('mygen.generate-a-cpp-file', ['MY_TYPE'], ['CPP'])
72if os.name == 'nt':
73 action = 'echo void g() {} > "$(<)"'
74else:
75 action = 'echo "void g() {}" > "$(<)"'
76def f(*args):
77 print "Generating a CPP file..."
78
79get_manager().engine().register_action("mygen.generate-a-cpp-file", action,
80 function=f)
81""")
82
83 t.write("Other/jamfile.jam", """\
84import mygen ;
85my-obj other-obj : source.extension ;
86""")
87
88 t.run_build_system()
89 t.expect_output_lines("Generating a CPP file...")
b32b8144
FG
90 t.expect_addition("bin/$toolset/debug*/dummy.my_obj")
91 t.expect_addition("Other/bin/$toolset/debug*/other-obj.cpp")
92 t.expect_addition("Other/bin/$toolset/debug*/other-obj.my_obj")
7c673cae
FG
93 t.expect_nothing_more()
94
95 t.cleanup()
96
97
98###############################################################################
99#
100# test_using_a_derived_source_type_created_after_generator_already_used()
101# -----------------------------------------------------------------------
102#
103###############################################################################
104
105def test_using_a_derived_source_type_created_after_generator_already_used():
106 """
107 Regression test for a Boost Build bug causing it to not use a generator
108 with a source type derived from one of the generator's sources but created
109 only after already using the generateor.
110
111 """
112 t = BoostBuild.Tester()
113
114 t.write("dummy.xxx", "Hello. My name is Peter Pan.\n")
115
116 t.write("jamroot.jam", """\
117import common ;
118import generators ;
119import type ;
120type.register XXX : xxx ;
121type.register YYY : yyy ;
122generators.register-standard common.copy : XXX : YYY ;
123
124# Building this dummy target must not cause a later defined XXX2 target type not
125# to be recognized as a viable source type for building YYY targets.
126yyy dummy : dummy.xxx ;
127alias the-test-output : Other//other ;
128""")
129
130 t.write("Other/source.xxx2", "Hello. My name is Tinkerbell.\n")
131
132 t.write("Other/jamfile.jam", """\
133import type ;
134type.register XXX2 : xxx2 : XXX ;
135# We are careful not to do anything between defining our new XXX2 target type
136# and using the XXX --> YYY generator that could potentially cover the Boost
137# Build bug by clearing its internal viable source target type state.
138yyy other : source.xxx2 ;
139""")
140
141 t.run_build_system()
b32b8144
FG
142 t.expect_addition("bin/$toolset/debug*/dummy.yyy")
143 t.expect_addition("Other/bin/$toolset/debug*/other.yyy")
7c673cae
FG
144 t.expect_nothing_more()
145
146 t.cleanup()
147
148
149###############################################################################
150#
151# main()
152# ------
153#
154###############################################################################
155
156test_generator_added_after_already_building_a_target_of_its_target_type()
157test_using_a_derived_source_type_created_after_generator_already_used()