1 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 6 7# Usage: bjam [OPTION]... DIR[-CPP_FILE_NAME] 8# Build and run Boost.Contract tests and examples. 9# 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 16# feature checks 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) 22# bc_no=all_yes, 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 27# contracts at once: 28# y entry invariant 29# r preconditions 30# x exit invariant 31# s postconditions 32# e exception guarantees 33# k implementation checks 34# 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 $? 48 49import boost_contract_no ; 50import feature ; 51import testing ; 52import ../../config/checks/config : requires ; 53 54# Iff "no", link to boost_contract (else, no lib build so don't link to it). 55feature.feature bc_hdr : lib only : 56 composite propagated link-incompatible ; 57 58# This is boost_contract_no=all_yes,pre,pre_post,... 59feature.feature bc_no : all_yes [ boost_contract_no.combinations ] : 60 composite propagated link-incompatible ; 61for local comb in [ boost_contract_no.combinations ] { 62 feature.compose <bc_no>$(comb) : 63 [ boost_contract_no.defs_$(comb) ] ; 64} 65 66module boost_contract_build { 67 68rule project_requirements ( subdir ) { 69 return 70 <bc_hdr>lib:<library>../build//boost_contract 71 <include>$(subdir) 72 ; 73} 74 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). 79cxx11_requirements = [ requires cxx11_lambdas cxx11_variadic_macros ] ; 80 81rule 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) 85 ; 86} 87 88rule subdir-run ( subdir : cpp_fname cpp_files * : requirements * ) { 89 run $(subdir)/$(cpp_fname).cpp $(cpp_files) : : : [ project_requirements 90 $(subdir) ] $(requirements) : $(subdir)-$(cpp_fname) ; 91} 92 93rule subdir-lib ( subdir : cpp_fname cpp_files * : requirements * ) { 94 lib $(subdir)-$(cpp_fname) : $(subdir)/$(cpp_fname).cpp $(cpp_files) : 95 [ project_requirements $(subdir) ] $(requirements) ; 96} 97 98rule subdir-compile-fail-cxx11 ( subdir : cpp_fname cpp_files * : 99 requirements * ) { 100 subdir-compile-fail $(subdir) : $(cpp_fname) $(cpp_files) : 101 $(cxx11_requirements) $(requirements) ; 102} 103 104rule subdir-run-cxx11 ( subdir : cpp_fname cpp_files * : requirements * ) { 105 subdir-run $(subdir) : $(cpp_fname) $(cpp_files) : $(cxx11_requirements) 106 $(requirements) ; 107} 108 109rule subdir-lib-cxx11 ( subdir : cpp_fname cpp_files * : requirements * ) { 110 subdir-lib $(subdir) : $(cpp_fname) $(cpp_files) : $(cxx11_requirements) 111 $(requirements) ; 112} 113 114} # module 115 116