Jamfile.v2 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. #
  2. # This is Boost Jamfile for Boost.Build V2.
  3. #
  4. # Pass --v2 option to bjam to use this file. For example:
  5. #
  6. # bjam --v2 link=static
  7. #
  8. # TODO:
  9. # - handle boost version
  10. import modules ;
  11. import set ;
  12. import stage ;
  13. import package ;
  14. constant BOOST_VERSION : 1.33.0 ;
  15. project boost
  16. : requirements <include>.
  17. # disable auto-linking for all targets here,
  18. # primarily because it caused troubles with V2
  19. <define>BOOST_ALL_NO_LIB=1
  20. # Used to encode variant in target name. See the
  21. # 'tag' rule below.
  22. <tag>@$(__name__).tag
  23. : usage-requirements <include>.
  24. : build-dir bin.v2
  25. ;
  26. # Setup convenient aliases for all libraries.
  27. all-libraries = [ MATCH .*libs/(.*)/build/.*
  28. : [ glob libs/*/build/Jamfile.v2 ] ] ;
  29. # First, the complicated libraries: where the target name in
  30. # Jamfile is different from directory name.
  31. alias prg_exec_monitor : libs/test/build//boost_prg_exec_monitor ;
  32. alias test_exec_monitor : libs/test/build//boost_test_exec_monitor ;
  33. alias unit_test_framework : libs/test/build//boost_unit_test_framework ;
  34. alias bgl-vis : libs/graps/build//bgl-vis ;
  35. alias serialization : libs/serialization//serialization ;
  36. alias wserialization : libs/serialization//wserialization ;
  37. explicit prg_exec_monitor test_exec_monitor unit_test_framework
  38. bgl-vis serialization wserialization ;
  39. for local l in $(all-libraries)
  40. {
  41. if ! $(l) in test graph serialization
  42. {
  43. alias $(l) : libs/$(l)/build//boost_$(l) ;
  44. explicit $(l) ;
  45. }
  46. }
  47. alias headers : : : : <include>. ;
  48. # Decides which libraries are to be installed by looking at --with-<library>
  49. # --without-<library> arguments. Returns the list of directories under "libs"
  50. # which must be built at installed.
  51. rule libraries-to-install ( existing-libraries * )
  52. {
  53. local argv = [ modules.peek : ARGV ] ;
  54. local with-parameter = [ MATCH --with-(.*) : $(argv) ] ;
  55. local without-parameter = [ MATCH --without-(.*) : $(argv) ] ;
  56. # Do some checks
  57. if $(with-parameter) && $(without-parameter)
  58. {
  59. ECHO "error: both --with-<library> and --without-<library> specified" ;
  60. EXIT ;
  61. }
  62. local wrong = [ set.difference $(with-parameter) : $(existing-libraries) ] ;
  63. if $(wrong)
  64. {
  65. ECHO "error: wrong library name '$(wrong[1])' in the --with-<library> option." ;
  66. EXIT ;
  67. }
  68. local wrong = [ set.difference $(without-parameter) : $(existing-libraries) ] ;
  69. if $(wrong)
  70. {
  71. ECHO "error: wrong library name '$(wrong[1])' in the --without-<library> option." ;
  72. EXIT ;
  73. }
  74. if $(with-parameter)
  75. {
  76. return [ set.intersection $(existing-libraries) : $(with-parameter) ] ;
  77. }
  78. else
  79. {
  80. return [ set.difference $(existing-libraries) : $(without-parameter) ] ;
  81. }
  82. }
  83. # what kind of layout are we doing?
  84. layout = [ MATCH "^--layout=(.*)" : $(ARGV) ] ;
  85. layout ?= versioned ;
  86. layout-$(layout) = true ;
  87. # possible stage only location
  88. local stage-locate = [ MATCH "^--stagedir=(.*)" : $(ARGV) ] ;
  89. stage-locate ?= stage ;
  90. path-constant BOOST_STAGE_LOCATE : $(stage-locate) ;
  91. # location of python
  92. local python-root = [ MATCH "^--with-python-root=(.*)" : $(ARGV) ] ;
  93. PYTHON_ROOT ?= $(python-root) ;
  94. # Select the libraries to install.
  95. libraries = [ libraries-to-install $(all-libraries) ] ;
  96. # This rule is called by Boost.Build to determine the name of
  97. # target. We use it to encode build variant, compiler name and
  98. # boost version in the target name
  99. rule tag ( name : type ? : property-set )
  100. {
  101. if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
  102. {
  103. if $(layout) = versioned
  104. {
  105. name = [ stage.add-variant-and-compiler $(name)
  106. : $(type) : $(property-set) ] ;
  107. local version-tag = [ MATCH "^([^.]+)[.]([^.]+)" : $(BOOST_VERSION[1]) ] ;
  108. version-tag = $(version-tag:J="_") ;
  109. # On NT, library with version suffix won't be recognized
  110. # by linkers. On CYGWIN, we get strage duplicate symbol
  111. # errors when library is generated with version suffix.
  112. # On OSX, version suffix is not needed -- the linker expets
  113. # libFoo.1.2.3.dylib format.
  114. # AIX linkers don't accept version suffixes either.
  115. if [ $(property-set).get <os> ] in NT CYGWIN MACOSX AIX
  116. {
  117. return $(name:B)-$(version-tag)$(name:S) ;
  118. }
  119. else
  120. {
  121. return $(name:B)-$(version-tag)$(name:S).$(BOOST_VERSION) ;
  122. }
  123. }
  124. else
  125. {
  126. return [ stage.add-variant-and-compiler $(name)
  127. : $(type) : $(property-set) ] ;
  128. }
  129. }
  130. }
  131. # Install to system location.
  132. local patterns = *.hpp *.ipp *.h *.inc ;
  133. local dirs = boost boost/* boost/*/* ;
  134. # Complete install
  135. package.install install
  136. : <install-source-root>. # No specific requirements
  137. : # No binaries
  138. : libs/$(libraries)/build
  139. : [ glob $(dirs)/$(patterns) ]
  140. ;
  141. # Install just library.
  142. install stage : libs/$(libraries)/build
  143. : <location>$(stage-locate)
  144. ;
  145. # Just build the libraries, don't install them anywhere.
  146. # This is what happend with just "bjam --v2".
  147. alias build_all : libs/$(libraries)/build ;
  148. # This rule should be called from libraries' Jamfiles and will
  149. # create two targets, "install" and "stage", that will install
  150. # or stage that library. The --prefix option is respected, by
  151. # --with and --without options, naturally, are ignored.
  152. #
  153. # - libraries -- list of library targets to install.
  154. rule boost-install ( libraries * )
  155. {
  156. package.install install
  157. : <dependency>/boost//install-headers
  158. : # No binaries
  159. : $(libraries)
  160. : # No headers, it's handled by the dependency
  161. ;
  162. install stage : $(libraries) : <location>$(BOOST_STAGE_LOCATE) ;
  163. local c = [ project.current ] ;
  164. local project-module = [ $(c).project-module ] ;
  165. module $(project-module)
  166. {
  167. explicit stage ;
  168. }
  169. }
  170. # Make project ids of all libraries known.
  171. for local l in $(libraries)
  172. {
  173. use-project /boost/$(l) : libs/$(l)/build ;
  174. }
粤ICP备19079148号