1# Copyright Rene Rivera 2011-2019
2# Distributed under the Boost Software License, Version 1.0.
3# (See accompanying file LICENSE_1_0.txt or copy at
4# http://www.boost.org/LICENSE_1_0.txt)
5
6import ../tools/check/predef : require check : predef-require predef-check ;
7import common ;
8import path ;
9import regex ;
10
11# This deals with the unfortunate aspect of a Boost monolithic release
12# not having the modular include dirs. This is a kludge that just removes
13# the direct dependency to the header if it can't find it.
14local PREDEF_H = $(BOOST_PREDEF_INCLUDE)/boost/predef.h ;
15if ! [ path.exists $(PREDEF_H) ]
16{
17    PREDEF_H = ;
18}
19
20project
21    :   requirements
22        <include>$(BOOST_PREDEF_INCLUDE)
23        # Add explicit dependency since we don't have header scanner for
24        # .m and .mm files.
25        <dependency>$(PREDEF_H)
26    ;
27
28using testing ;
29
30test-suite predef-info :
31    [ run info_as_cpp.cpp : : : <test-info>always_show_run_output ]
32    [ run info_as_c.c : : : <test-info>always_show_run_output ]
33    [ run info_as_objcpp.mm : : : <test-info>always_show_run_output ]
34    [ run info_as_objc.m : : : <test-info>always_show_run_output ]
35    ;
36
37test-suite predef :
38    [ run version.cpp ]
39    [ run make.cpp ]
40    [ compile macos_endian.c : [ predef-require "BOOST_OS_MACOS" : cpp ] ]
41    [ compile macos_vs_bsd.c : [ predef-require "BOOST_OS_MACOS" : cpp ] ]
42    [ run check_value.cpp : : : <test-info>always_show_run_output
43        [ predef-check "BOOST_COMP_CLANG > 0.0.0" "BOOST_OS_LINUX == 0" : : <cxxflags>-DCHECK_VALUE=true ] ]
44    [ run workaround.cpp ]
45    [ compile workaround_strict_config.cpp ]
46    [ run tested_at.cpp ]
47    [ compile-fail tested_at_outdated.cpp : <test-info>always_show_run_output ]
48	[ compile platform_windows.cpp ]
49    ;
50
51local HEADERS = [ path.glob
52    $(BOOST_PREDEF_INCLUDE)/predef
53    $(BOOST_PREDEF_INCLUDE)/predef/architecture
54    $(BOOST_PREDEF_INCLUDE)/predef/architecture/x86
55    $(BOOST_PREDEF_INCLUDE)/predef/compiler
56    $(BOOST_PREDEF_INCLUDE)/predef/hardware
57    $(BOOST_PREDEF_INCLUDE)/predef/hardware/simd
58    $(BOOST_PREDEF_INCLUDE)/predef/hardware/simd/arm
59    $(BOOST_PREDEF_INCLUDE)/predef/hardware/simd/ppc
60    $(BOOST_PREDEF_INCLUDE)/predef/hardware/simd/x86
61    $(BOOST_PREDEF_INCLUDE)/predef/hardware/simd/x86_amd
62    $(BOOST_PREDEF_INCLUDE)/predef/language
63    $(BOOST_PREDEF_INCLUDE)/predef/library
64    $(BOOST_PREDEF_INCLUDE)/predef/library/c
65    $(BOOST_PREDEF_INCLUDE)/predef/library/std
66    $(BOOST_PREDEF_INCLUDE)/predef/os
67    $(BOOST_PREDEF_INCLUDE)/predef/os/bsd
68    $(BOOST_PREDEF_INCLUDE)/predef/other
69    $(BOOST_PREDEF_INCLUDE)/predef/platform
70    : *.h
71    ] ;
72local single_header_cpp ;
73for local h in $(HEADERS)
74{
75    local header_include = [ path.relative $(h) [ path.make $(BOOST_PREDEF_INCLUDE) ] ] ;
76    local header_cpp = [ regex.replace $(header_include:S=.cpp) "/" "_" ] ;
77    .HEADER($(header_cpp:B:S=)) = $(header_include) ;
78    make $(header_cpp) : : @gen_single_header_cpp ;
79    explicit $(header_cpp) ;
80    compile $(header_cpp) : <warnings-as-errors>on <warnings>all : $(header_cpp:B:S=) ;
81    explicit $(header_cpp:B:S=) ;
82    single_header_cpp += $(header_cpp:B:S=) ;
83}
84
85test-suite predef-headers : $(single_header_cpp) ;
86
87.file_touch_cmd = [ common.file-touch-command ] ;
88
89rule gen_single_header_cpp ( target * : source * : properties * )
90{
91    HEADER on $(target) = $(.HEADER($(target[1]:B))) ;
92}
93actions gen_single_header_cpp
94{
95    $(.file_touch_cmd) @($(<):<=":>=":O=F:E=#include <$(HEADER)>)
96}
97
98# Minimal testing done for predef for CI. Since
99# we don't have many we can just do all of them.
100alias minimal : predef predef-info ;
101
102# Full testing target for regular regression tests.
103alias full : predef predef-info ;
104
105# Extra's target.
106alias extra : predef-headers ;
107
108explicit minimal ;
109explicit extra ;
110