boost_contract_build.jam 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. # Copyright (C) 2008-2018 Lorenzo Caminiti
  2. # Distributed under the Boost Software License, Version 1.0 (see accompanying
  3. # file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
  4. # See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
  5. # Usage: bjam [OPTION]... DIR[-CPP_FILE_NAME]
  6. # Build and run Boost.Contract tests and examples.
  7. #
  8. # Options (common to BJam):
  9. # toolset=msvc,gcc,clang,... specify compiler
  10. # cxxstd=03,11,14,17,... specify C++ standard version
  11. # most tests and example use C++11 features
  12. # (lambda, variadic macros, etc.), delete
  13. # "bin.v2/project-cache.jam" to clear previous
  14. # feature checks
  15. # link=shared,static build Boost.Contract as shared (default) or static
  16. # library, this has no effect if `bc_hdr=only`
  17. # Options (specific to this lib):
  18. # bc_hdr=lib,only if `only` then do not build Boost.Contract as library
  19. # and use it as header-only instead (`lib` by default)
  20. # bc_no=all_yes,
  21. # 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
  22. # `all_yes` (default) turns off no contract, following
  23. # turn off specific contracts and can be combined wit each
  24. # other (only in the listed order) to disable multiple
  25. # contracts at once:
  26. # y entry invariant
  27. # r preconditions
  28. # x exit invariant
  29. # s postconditions
  30. # e exception guarantees
  31. # k implementation checks
  32. #
  33. # Examples (on Linux-based bash):
  34. # Build just "test/public_function/smoke.cpp" and "example/introduction.cpp":
  35. # [test]$ bjam cxxstd=11 public_function-smoke
  36. # [example]$ bjam cxxstd=11 features-introduction
  37. # Build all tests with all linkages (incl header-only) on multiple compilers:
  38. # [test]$ bjam cxxstd=11 -q toolset=msvc,gcc,clang link=static,header
  39. # [test]$ bjam cxxstd=11 -q toolset=msvc,gcc,clang bc_hdr=only
  40. # Build all tests with no postconditions and exception guarantees first, and
  41. # then again with no class invariants at exit:
  42. # [test]$ time bjam cxxstd=11 -q bc_no=se,x
  43. # Build most all test combinations (for shared and static lib, use bc_hdr=only
  44. # instead of link=... for header-only combinations) but takes forever...:
  45. # [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 $?
  46. import boost_contract_no ;
  47. import feature ;
  48. import testing ;
  49. import ../../config/checks/config : requires ;
  50. # Iff "no", link to boost_contract (else, no lib build so don't link to it).
  51. feature.feature bc_hdr : lib only :
  52. composite propagated link-incompatible ;
  53. # This is boost_contract_no=all_yes,pre,pre_post,...
  54. feature.feature bc_no : all_yes [ boost_contract_no.combinations ] :
  55. composite propagated link-incompatible ;
  56. for local comb in [ boost_contract_no.combinations ] {
  57. feature.compose <bc_no>$(comb) :
  58. [ boost_contract_no.defs_$(comb) ] ;
  59. }
  60. module boost_contract_build {
  61. rule project_requirements ( subdir ) {
  62. return
  63. <bc_hdr>lib:<library>../build//boost_contract
  64. <include>$(subdir)
  65. ;
  66. }
  67. # Most tests and examples require lambdas (even if lib technically does not).
  68. # Also C++11 variadic macros are usually required (for OLDOF, BASES, etc.) but
  69. # Boost.Config check for variadic macros is less stringent than Boost.PP's
  70. # chec (so Boost.PP check done also in code directly when strictly needed).
  71. cxx11_requirements = [ requires cxx11_lambdas cxx11_variadic_macros ] ;
  72. rule subdir-compile-fail ( subdir : cpp_fname cpp_files * : requirements * ) {
  73. compile-fail $(subdir)/$(cpp_fname).cpp $(cpp_files)
  74. : [ project_requirements $(subdir) ] $(requirements)
  75. : $(subdir)-$(cpp_fname)
  76. ;
  77. }
  78. rule subdir-run ( subdir : cpp_fname cpp_files * : requirements * ) {
  79. run $(subdir)/$(cpp_fname).cpp $(cpp_files) : : : [ project_requirements
  80. $(subdir) ] $(requirements) : $(subdir)-$(cpp_fname) ;
  81. }
  82. rule subdir-lib ( subdir : cpp_fname cpp_files * : requirements * ) {
  83. lib $(subdir)-$(cpp_fname) : $(subdir)/$(cpp_fname).cpp $(cpp_files) :
  84. [ project_requirements $(subdir) ] $(requirements) ;
  85. }
  86. rule subdir-compile-fail-cxx11 ( subdir : cpp_fname cpp_files * :
  87. requirements * ) {
  88. subdir-compile-fail $(subdir) : $(cpp_fname) $(cpp_files) :
  89. $(cxx11_requirements) $(requirements) ;
  90. }
  91. rule subdir-run-cxx11 ( subdir : cpp_fname cpp_files * : requirements * ) {
  92. subdir-run $(subdir) : $(cpp_fname) $(cpp_files) : $(cxx11_requirements)
  93. $(requirements) ;
  94. }
  95. rule subdir-lib-cxx11 ( subdir : cpp_fname cpp_files * : requirements * ) {
  96. subdir-lib $(subdir) : $(cpp_fname) $(cpp_files) : $(cxx11_requirements)
  97. $(requirements) ;
  98. }
  99. } # module