# Copyright (C) 2008-2016 Lorenzo Caminiti # Distributed under the Boost Software License, Version 1.0 (see accompanying # file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt). # See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html import testing ; import os ; import feature ; if ! [ os.environ BOOST_ROOT ] { exit "Error: set BOOST_ROOT environment variable to Boost root directory" ; } local BOOST_ROOT = [ os.environ BOOST_ROOT ] ; echo "Using Boost libraries from \"$(BOOST_ROOT)\" (see $BOOST_ROOT)" ; use-project boost : $(BOOST_ROOT) ; project : requirements gcc:-std=c++11 clang:-std=c++11 "./include" $(BOOST_ROOT) $(BOOST_ROOT)/stage/lib gcc:/boost/system//boost_system clang:/boost/system//boost_system ; rule subdir-usage ( ) { echo " Usage: [time] bjam [-aq] [OPTION]... DIR[-CPP_FILE_NAME] [--clean] [; echo $?] Build and run Boost.Contract tests and examples. Options: toolset=msvc,gcc,clang use different compilers boost_contract-link=shared,static, compile Boost.Contract lib as shared, header static, or header-only boost_contract-no=all_on,entryinv, selectively turn off contract checking pre,exitinv,post, entryinv_pre,entryinv_exitinv,entryinv_post,pre_exitinv, pre_post,exitinv_post,pre_exitinv_post, entryinv_exitinv_post,entryinv_pre_post, entryinv_pre_exitinv,entryinv_pre_exitinv_post " ; } rule subdir-compile-fail ( subdir : cpp_fname : requirements * ) { compile-fail $(subdir)/$(cpp_fname).cpp : shared:../build//boost_contract static:../build//boost_contract $(subdir) $(requirements) : $(subdir)-$(cpp_fname) ; } rule subdir-run ( subdir : cpp_fname : requirements * ) { run $(subdir)/$(cpp_fname).cpp : : : shared:../build//boost_contract static:../build//boost_contract $(subdir) $(requirements) : $(subdir)-$(cpp_fname) ; } rule subdir-run-with-no ( subdir : cpp_fname : requirements * ) { # Aliases explicitly built or implicitly when building all tests... alias $(subdir)-$(cpp_fname)-no_entryinv : $(subdir)-$(cpp_fname) : entryinv ; alias $(subdir)-$(cpp_fname)-no_pre : $(subdir)-$(cpp_fname) : pre ; alias $(subdir)-$(cpp_fname)-no_exitinv : $(subdir)-$(cpp_fname) : exitinv ; alias $(subdir)-$(cpp_fname)-no_post : $(subdir)-$(cpp_fname) : post ; alias $(subdir)-$(cpp_fname)-no_entryinv_pre : $(subdir)-$(cpp_fname) : entryinv_pre ; alias $(subdir)-$(cpp_fname)-no_entryinv_exitinv : $(subdir)-$(cpp_fname) : entryinv_exitinv ; alias $(subdir)-$(cpp_fname)-no_entryinv_post : $(subdir)-$(cpp_fname) : entryinv_post ; alias $(subdir)-$(cpp_fname)-no_pre_exitinv : $(subdir)-$(cpp_fname) : pre_exitinv ; alias $(subdir)-$(cpp_fname)-no_pre_post : $(subdir)-$(cpp_fname) : pre_post ; alias $(subdir)-$(cpp_fname)-no_exitinv_post : $(subdir)-$(cpp_fname) : exitinv_post ; alias $(subdir)-$(cpp_fname)-no_pre_exitinv_post : $(subdir)-$(cpp_fname) : pre_exitinv_post ; alias $(subdir)-$(cpp_fname)-no_entryinv_exitinv_post : $(subdir)-$(cpp_fname) : entryinv_exitinv_post ; alias $(subdir)-$(cpp_fname)-no_entry_pre_post : $(subdir)-$(cpp_fname) : entryinv_pre_post ; alias $(subdir)-$(cpp_fname)-no_entryinv_pre_exitinv : $(subdir)-$(cpp_fname) : entryinv_pre_exitinv ; alias $(subdir)-$(cpp_fname)-no_entryinv_pre_exitinv_post : $(subdir)-$(cpp_fname) : entryinv_pre_exitinv_post ; # ...otherwise only this is built when building just subdir. subdir-run $(subdir) : $(cpp_fname) : $(requirements) ; } rule subdir-lib ( subdir : cpp_fname : requirements * ) { lib $(subdir)-$(cpp_fname) : $(subdir)/$(cpp_fname).cpp : shared:../build//boost_contract static:../build//boost_contract $(subdir) $(requirements) ; } feature.feature boost_contract-link : shared static header : composite propagated link-incompatible ; feature.compose shared : shared ; feature.compose static : static ; feature.compose header : BOOST_CONTRACT_HEADER_ONLY ; feature.feature boost_contract-no : all_on entryinv pre exitinv post entryinv_pre entryinv_exitinv entryinv_post pre_exitinv pre_post exitinv_post pre_exitinv_post entryinv_exitinv_post entryinv_pre_post entryinv_pre_exitinv entryinv_pre_exitinv_post : composite propagated link-incompatible ; # 1 contract off. feature.compose entryinv : BOOST_CONTRACT_NO_ENTRY_INVARIANTS ; feature.compose pre : BOOST_CONTRACT_NO_PRECONDITIONS ; feature.compose exitinv : BOOST_CONTRACT_NO_EXIT_INVARIANTS ; feature.compose post : BOOST_CONTRACT_NO_POSTCONDITIONS ; # 2 contracts off. feature.compose entryinv_pre : BOOST_CONTRACT_NO_ENTRY_INVARIANTS BOOST_CONTRACT_NO_PRECONDITIONS ; feature.compose entryinv_exitinv : BOOST_CONTRACT_NO_ENTRY_INVARIANTS BOOST_CONTRACT_NO_EXIT_INVARIANTS ; feature.compose entryinv_post : BOOST_CONTRACT_NO_ENTRY_INVARIANTS BOOST_CONTRACT_NO_POSTCONDITIONS ; feature.compose pre_exitinv : BOOST_CONTRACT_NO_PRECONDITIONS BOOST_CONTRACT_NO_EXIT_INVARIANTS ; feature.compose pre_post : BOOST_CONTRACT_NO_PRECONDITIONS BOOST_CONTRACT_NO_POSTCONDITIONS ; feature.compose exitinv_post : BOOST_CONTRACT_NO_EXIT_INVARIANTS BOOST_CONTRACT_NO_POSTCONDITIONS ; # 3 contracts off. feature.compose pre_exitinv_post : BOOST_CONTRACT_NO_PRECONDITIONS BOOST_CONTRACT_NO_EXIT_INVARIANTS BOOST_CONTRACT_NO_POSTCONDITIONS ; feature.compose entryinv_exitinv_post : BOOST_CONTRACT_NO_ENTRY_INVARIANTS BOOST_CONTRACT_NO_EXIT_INVARIANTS BOOST_CONTRACT_NO_POSTCONDITIONS ; feature.compose entryinv_pre_post : BOOST_CONTRACT_NO_ENTRY_INVARIANTS BOOST_CONTRACT_NO_PRECONDITIONS BOOST_CONTRACT_NO_POSTCONDITIONS ; feature.compose entryinv_pre_exitinv : BOOST_CONTRACT_NO_ENTRY_INVARIANTS BOOST_CONTRACT_NO_PRECONDITIONS BOOST_CONTRACT_NO_EXIT_INVARIANTS ; # All 4 contracts oof. feature.compose entryinv_pre_exitinv_post : BOOST_CONTRACT_NO_ENTRY_INVARIANTS BOOST_CONTRACT_NO_PRECONDITIONS BOOST_CONTRACT_NO_EXIT_INVARIANTS BOOST_CONTRACT_NO_POSTCONDITIONS ;