]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/flags.py
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)
8 # Tests the check-has-flag rule
12 t
= BoostBuild
.Tester(use_test_config
=False)
14 # We need an object file before we can run the actual test.
15 t
.write('input.cpp', 'void f() {}\n')
16 t
.write('Jamroot.jam', 'obj input : input.cpp ;')
19 linker_input
= t
.glob_file('bin/$toolset/debug*/input.obj')
21 # Check every possible result of pass or fail.
22 t
.write('Jamroot.jam', '''
25 OBJECT_FILE = [ modules.peek : OBJECT_FILE ] ;
26 obj fail_cpp : test.cpp : [ check-has-flag <cxxflags>--illegal-flag-cpp
27 : <define>ERROR : <define>OK ] ;
28 obj pass_cpp : test.cpp : [ check-has-flag <cxxflags>-DMACRO_CPP
29 : <define>OK : <define>ERROR ] ;
30 obj fail_c : test.cpp : [ check-has-flag <cflags>--illegal-flag-c
31 : <define>ERROR : <define>OK ] ;
32 obj pass_c : test.cpp : [ check-has-flag <cflags>-DMACRO_C
33 : <define>OK : <define>ERROR ] ;
34 obj fail_link : test.cpp : [ check-has-flag <linkflags>--illegal-flag-link
35 : <define>ERROR : <define>OK ] ;
36 # The only thing that we can be certain the linker
37 # will accept is the name of an object file.
38 obj pass_link : test.cpp : [ check-has-flag <linkflags>$(OBJECT_FILE)
39 : <define>OK : <define>ERROR ] ;
42 t
.write('test.cpp', '''
47 #error ERROR not defined
51 # Don't check the status immediately, so that we have a chance
52 # to print config.log. Also, we need a minimum of d2 to make
53 # sure that we always see the commands and output.
54 t
.run_build_system(['-sOBJECT_FILE=' + linker_input
, '-d2'], status
=None)
57 log_file
= t
.read('bin/config.log')
58 BoostBuild
.annotation("config.log", log_file
)
61 t
.expect_output_lines([' - has --illegal-flag-cpp : no',
62 ' - has -DMACRO_CPP : yes',
63 ' - has --illegal-flag-c : no',
64 ' - has -DMACRO_C : yes',
65 ' - has --illegal-flag-link : no',
66 ' - has *bin*/input.* : yes'])
67 t
.expect_addition('bin/$toolset/debug*/fail_cpp.obj')
68 t
.expect_addition('bin/$toolset/debug*/pass_cpp.obj')
69 t
.expect_addition('bin/$toolset/debug*/fail_c.obj')
70 t
.expect_addition('bin/$toolset/debug*/pass_c.obj')
71 t
.expect_addition('bin/$toolset/debug*/fail_link.obj')
72 t
.expect_addition('bin/$toolset/debug*/pass_link.obj')