2 # Copyright (C) 2008-2018 Lorenzo Caminiti
3 # Distributed under the Boost Software License, Version 1.0 (see accompanying
4 # file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
5 # See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
7 # Usage: bjam [OPTION]... DIR[-CPP_FILE_NAME]
8 # Build and run Boost.Contract tests and examples.
10 # Options (common to BJam):
11 # toolset=msvc,gcc,clang,... specify compiler
12 # cxxstd=03,11,14,17,... specify C++ standard version
13 # most tests and example use C++11 features
14 # (lambda, variadic macros, etc.), delete
15 # "bin.v2/project-cache.jam" to clear previous
17 # link=shared,static build Boost.Contract as shared (default) or static
18 # library, this has no effect if `bc_hdr=only`
19 # Options (specific to this lib):
20 # bc_hdr=lib,only if `only` then do not build Boost.Contract as library
21 # and use it as header-only instead (`lib` by default)
23 # y,r,x,s,e,k,yr,yx,ys,ye,yk,rx,rs,re,rk,xs,xe,xk,se,sk,ek,yrx,yrs,yre,yrk,yxs,yxe,yxk,yse,ysk,yek,rxs,rxe,rxk,rse,rsk,rek,xse,xsk,xek,sek,yrxs,yrxe,yrxk,yrse,yrsk,yrek,yxse,yxsk,yxek,ysek,rxse,rxsk,rxek,rsek,xsek,yrxse,yrxsk,yrxek,yrsek,yxsek,rxsek,yrxsek
24 # `all_yes` (default) turns off no contract, following
25 # turn off specific contracts and can be combined wit each
26 # other (only in the listed order) to disable multiple
32 # e exception guarantees
33 # k implementation checks
35 # Examples (on Linux-based bash):
36 # Build just "test/public_function/smoke.cpp" and "example/introduction.cpp":
37 # [test]$ bjam cxxstd=11 public_function-smoke
38 # [example]$ bjam cxxstd=11 features-introduction
39 # Build all tests with all linkages (incl header-only) on multiple compilers:
40 # [test]$ bjam cxxstd=11 -q toolset=msvc,gcc,clang link=static,header
41 # [test]$ bjam cxxstd=11 -q toolset=msvc,gcc,clang bc_hdr=only
42 # Build all tests with no postconditions and exception guarantees first, and
43 # then again with no class invariants at exit:
44 # [test]$ time bjam cxxstd=11 -q bc_no=se,x
45 # Build most all test combinations (for shared and static lib, use bc_hdr=only
46 # instead of link=... for header-only combinations) but takes forever...:
47 # [test]$ rm -f ../../../bin.v2/project-cache.jam ; bjam cxxstd=11 -q toolset=msvc,gcc,clang link=shared,static bc_no=all_yes,y,r,x,s,e,k,yr,yx,ys,ye,yk,rx,rs,re,rk,xs,xe,xk,se,sk,ek,yrx,yrs,yre,yrk,yxs,yxe,yxk,yse,ysk,yek,rxs,rxe,rxk,rse,rsk,rek,xse,xsk,xek,sek,yrxs,yrxe,yrxk,yrse,yrsk,yrek,yxse,yxsk,yxek,ysek,rxse,rxsk,rxek,rsek,xsek,yrxse,yrxsk,yrxek,yrsek,yxsek,rxsek,yrxsek > 00.out ; echo $?
49 import boost_contract_no ;
52 import ../../config/checks/config : requires ;
54 # Iff "no", link to boost_contract (else, no lib build so don't link to it).
55 feature.feature bc_hdr : lib only :
56 composite propagated link-incompatible ;
58 # This is boost_contract_no=all_yes,pre,pre_post,...
59 feature.feature bc_no : all_yes [ boost_contract_no.combinations ] :
60 composite propagated link-incompatible ;
61 for local comb in [ boost_contract_no.combinations ] {
62 feature.compose <bc_no>$(comb) :
63 [ boost_contract_no.defs_$(comb) ] ;
66 module boost_contract_build {
68 rule project_requirements ( subdir ) {
70 <bc_hdr>lib:<library>../build//boost_contract
75 # Most tests and examples require lambdas (even if lib technically does not).
76 # Also C++11 variadic macros are usually required (for OLDOF, BASES, etc.) but
77 # Boost.Config check for variadic macros is less stringent than Boost.PP's
78 # chec (so Boost.PP check done also in code directly when strictly needed).
79 cxx11_requirements = [ requires cxx11_lambdas cxx11_variadic_macros ] ;
81 rule subdir-compile-fail ( subdir : cpp_fname cpp_files * : requirements * ) {
82 compile-fail $(subdir)/$(cpp_fname).cpp $(cpp_files)
83 : [ project_requirements $(subdir) ] $(requirements)
84 : $(subdir)-$(cpp_fname)
88 rule subdir-run ( subdir : cpp_fname cpp_files * : requirements * ) {
89 run $(subdir)/$(cpp_fname).cpp $(cpp_files) : : : [ project_requirements
90 $(subdir) ] $(requirements) : $(subdir)-$(cpp_fname) ;
93 rule subdir-lib ( subdir : cpp_fname cpp_files * : requirements * ) {
94 lib $(subdir)-$(cpp_fname) : $(subdir)/$(cpp_fname).cpp $(cpp_files) :
95 [ project_requirements $(subdir) ] $(requirements) ;
98 rule subdir-compile-fail-cxx11 ( subdir : cpp_fname cpp_files * :
100 subdir-compile-fail $(subdir) : $(cpp_fname) $(cpp_files) :
101 $(cxx11_requirements) $(requirements) ;
104 rule subdir-run-cxx11 ( subdir : cpp_fname cpp_files * : requirements * ) {
105 subdir-run $(subdir) : $(cpp_fname) $(cpp_files) : $(cxx11_requirements)
109 rule subdir-lib-cxx11 ( subdir : cpp_fname cpp_files * : requirements * ) {
110 subdir-lib $(subdir) : $(cpp_fname) $(cpp_files) : $(cxx11_requirements)