Jamroot 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. # Copyright Vladimir Prus 2002-2006.
  2. # Copyright Dave Abrahams 2005-2006.
  3. # Copyright René Ferdinand Rivera Morell 2005-2024.
  4. # Copyright Douglas Gregor 2005.
  5. #
  6. # Distributed under the Boost Software License, Version 1.0.
  7. # (See accompanying file LICENSE_1_0.txt or copy at
  8. # http://www.boost.org/LICENSE_1_0.txt)
  9. # Usage:
  10. #
  11. # b2 [options] [properties] [install|stage]
  12. #
  13. # Builds and installs Boost.
  14. #
  15. # Targets and Related Options:
  16. #
  17. # install Install headers and compiled library files to the
  18. # ======= configured locations (below).
  19. #
  20. # --prefix=<PREFIX> Install architecture independent files here.
  21. # Default: C:\Boost on Windows
  22. # Default: /usr/local on Unix, Linux, etc.
  23. #
  24. # --exec-prefix=<EPREFIX> Install architecture dependent files here.
  25. # Default: <PREFIX>
  26. #
  27. # --libdir=<LIBDIR> Install library files here.
  28. # Default: <EPREFIX>/lib
  29. #
  30. # --includedir=<HDRDIR> Install header files here.
  31. # Default: <PREFIX>/include
  32. #
  33. # --cmakedir=<CMAKEDIR> Install CMake configuration files here.
  34. # Default: <LIBDIR>/cmake
  35. #
  36. # --no-cmake-config Do not install CMake configuration files.
  37. #
  38. # stage Build and install only compiled library files to the
  39. # ===== stage directory.
  40. #
  41. # --stagedir=<STAGEDIR> Install library files here
  42. # Default: ./stage
  43. #
  44. # Other Options:
  45. #
  46. # --build-type=<type> Build the specified pre-defined set of variations of
  47. # the libraries. Note, that which variants get built
  48. # depends on what each library supports.
  49. #
  50. # -- minimal -- (default) Builds a minimal set of
  51. # variants. On Windows, these are static
  52. # multithreaded libraries in debug and release
  53. # modes, using shared runtime. On Linux, these are
  54. # static and shared multithreaded libraries in
  55. # release mode.
  56. #
  57. # -- complete -- Build all possible variations.
  58. #
  59. # --build-dir=DIR Build in this location instead of building within
  60. # the distribution tree. Recommended!
  61. #
  62. # --show-libraries Display the list of Boost libraries that require
  63. # build and installation steps, and then exit.
  64. #
  65. # --layout=<layout> Determine whether to choose library names and header
  66. # locations such that multiple versions of Boost or
  67. # multiple compilers can be used on the same system.
  68. #
  69. # -- versioned -- Names of boost binaries include
  70. # the Boost version number, name and version of
  71. # the compiler and encoded build properties. Boost
  72. # headers are installed in a subdirectory of
  73. # <HDRDIR> whose name contains the Boost version
  74. # number.
  75. #
  76. # -- tagged -- Names of boost binaries include the
  77. # encoded build properties such as variant and
  78. # threading, but do not including compiler name
  79. # and version, or Boost version. This option is
  80. # useful if you build several variants of Boost,
  81. # using the same compiler.
  82. #
  83. # -- system -- Binaries names do not include the
  84. # Boost version number or the name and version
  85. # number of the compiler. Boost headers are
  86. # installed directly into <HDRDIR>. This option is
  87. # intended for system integrators building
  88. # distribution packages.
  89. #
  90. # The default value is 'versioned' on Windows, and
  91. # 'system' on Unix.
  92. #
  93. # --buildid=ID Add the specified ID to the name of built libraries.
  94. # The default is to not add anything.
  95. #
  96. # --python-buildid=ID Add the specified ID to the name of built libraries
  97. # that depend on Python. The default is to not add
  98. # anything. This ID is added in addition to --buildid.
  99. #
  100. # --help This message.
  101. #
  102. # --with-<library> Build and install the specified <library>. If this
  103. # option is used, only libraries specified using this
  104. # option will be built.
  105. #
  106. # --without-<library> Do not build, stage, or install the specified
  107. # <library>. By default, all libraries are built.
  108. #
  109. # Properties:
  110. #
  111. # toolset=toolset Indicate the toolset to build with.
  112. #
  113. # variant=debug|release Select the build variant
  114. #
  115. # link=static|shared Whether to build static or shared libraries
  116. #
  117. # threading=single|multi Whether to build single or multithreaded binaries
  118. #
  119. # runtime-link=static|shared
  120. # Whether to link to static or shared C and C++
  121. # runtime.
  122. #
  123. require-b2 5.1.0 ;
  124. # TODO:
  125. # - handle boost version
  126. # - handle python options such as pydebug
  127. import boostcpp ;
  128. import package ;
  129. import sequence ;
  130. import xsltproc ;
  131. import set ;
  132. import path ;
  133. import link ;
  134. import notfile ;
  135. import virtual-target ;
  136. import "class" : new ;
  137. import property-set ;
  138. import threadapi-feature ;
  139. import option ;
  140. import property ;
  141. import project ;
  142. # Backslash because of `bcp --namespace`
  143. import tools/boost\_install/boost-install ;
  144. path-constant BOOST_ROOT : . ;
  145. constant BOOST_VERSION : 1.91.0 ;
  146. constant BOOST_JAMROOT_MODULE : $(__name__) ;
  147. # Allow subprojects to simply `import config : requires ;` to get access to the requires rule
  148. import-search $(BOOST_ROOT)/libs/config/checks ;
  149. import-search $(BOOST_ROOT)/libs/predef/tools/check ;
  150. boostcpp.set-version $(BOOST_VERSION) ;
  151. use-project /boost/architecture : libs/config/checks/architecture ;
  152. local all-headers =
  153. [ MATCH .*libs/(.*)/include/boost : [ glob libs/*/include/boost libs/*/*/include/boost ] ] ;
  154. for dir in $(all-headers)
  155. {
  156. link-directory $(dir)-headers : libs/$(dir)/include/boost : <location>. ;
  157. explicit $(dir)-headers ;
  158. }
  159. if $(all-headers)
  160. {
  161. constant BOOST_MODULARLAYOUT : $(all-headers) ;
  162. }
  163. project /boost
  164. : requirements <include>.
  165. [ boostcpp.platform ]
  166. # Disable auto-linking for all targets here, primarily because it caused
  167. # troubles with V2.
  168. <define>BOOST_ALL_NO_LIB=1
  169. # Used to encode variant in target name. See the 'tag' rule below.
  170. <tag>@$(__name__).tag
  171. <conditional>@handle-static-runtime
  172. <conditional>@clang-darwin-cxxstd-11
  173. # Comeau does not support shared lib
  174. <toolset>como:<link>static
  175. <toolset>como-linux:<define>_GNU_SOURCE=1
  176. # When building docs within Boost, we want the standard Boost style
  177. <xsl:param>boost.defaults=Boost
  178. <conditional>@threadapi-feature.detect
  179. : usage-requirements <include>.
  180. : default-build
  181. <visibility>hidden
  182. <threading>multi
  183. : build-dir bin.v2
  184. ;
  185. # General, top-level, modular project searching. Also include tools in the
  186. # project search.
  187. project-search /boost : libs tools ;
  188. # Temporary custom project searching to account for special library paths.
  189. project-search /boost : libs/numeric ;
  190. project-search /boost/numeric_conversion : libs/numeric/conversion ;
  191. # This rule is called by Boost.Build to determine the name of target. We use it
  192. # to encode the build variant, compiler name and boost version in the target
  193. # name.
  194. #
  195. rule tag ( name : type ? : property-set )
  196. {
  197. return [ boostcpp.tag $(name) : $(type) : $(property-set) ] ;
  198. }
  199. rule python-tag ( name : type ? : property-set )
  200. {
  201. return [ boostcpp.python-tag $(name) : $(type) : $(property-set) ] ;
  202. }
  203. rule handle-static-runtime ( properties * )
  204. {
  205. # Using static runtime with shared libraries is impossible on Linux, and
  206. # dangerous on Windows. Therefore, we disallow it. This might be drastic,
  207. # but it was disabled for a while without anybody complaining.
  208. local argv = [ modules.peek : ARGV ] ;
  209. if <link>shared in $(properties)
  210. && <runtime-link>static in $(properties)
  211. # For CW, static runtime is needed so that std::locale works.
  212. && ! ( <toolset>cw in $(properties) )
  213. && ! --allow-shared-static in $(argv)
  214. {
  215. boostcpp.emit-shared-static-warning ;
  216. return <build>no ;
  217. }
  218. }
  219. rule clang-darwin-cxxstd-11 ( properties * )
  220. {
  221. # AppleClang defaults to C++03
  222. local result = [ property.select <cxxstd> : $(properties) ] ;
  223. if <toolset-clang:platform>darwin in $(properties)
  224. {
  225. result ?= <cxxstd>11 ;
  226. }
  227. return $(result) ;
  228. }
  229. # All libraries.
  230. local all-libraries
  231. = [ MATCH .*libs/(.*)/meta/libraries.json : [ glob libs/*/meta/libraries.json ] ] ;
  232. # Find all the libraries that have something to build (the old way).
  233. local all-libraries-to-build
  234. = [ MATCH .*libs/(.*)/build/.* : [ glob libs/*/build/Jamfile.v2 ]
  235. [ glob libs/*/build/Jamfile ] ] ;
  236. all-libraries-to-build = [ sequence.unique $(all-libraries-to-build) ] ;
  237. # The function_types library has a Jamfile, but it's used for maintenance
  238. # purposes, there's no library to build and install.
  239. all-libraries-to-build = [ set.difference $(all-libraries-to-build) : function_types ] ;
  240. # Find all the libraries that have a library-root build declaration (modular way).
  241. local all-libraries-modular-build
  242. = [ MATCH .*libs/(.*)/build.jam : [ glob libs/*/build.jam ] ] ;
  243. # Modular and not are mutually exclusive as they have different lib targets.
  244. local all-libraries-old-build = [ set.difference $(all-libraries-to-build) : $(all-libraries-modular-build) ] ;
  245. # The header only libraries that are not of the new modular form. For which we
  246. # will create synthetic projects and targets to simulate the new modular form.
  247. local all-libraries-to-declare
  248. = [ set.difference $(all-libraries)
  249. : $(all-libraries-modular-build) $(all-libraries-old-build) ] ;
  250. if ! [ glob libs/numeric/conversion/build.jam ]
  251. {
  252. all-libraries-to-declare += numeric_conversion ;
  253. }
  254. if ! [ glob libs/numeric/interval/build.jam ]
  255. {
  256. all-libraries-to-declare += interval ;
  257. }
  258. if ! [ glob libs/numeric/odeint/build.jam ]
  259. {
  260. all-libraries-to-declare += odeint ;
  261. }
  262. if ! [ glob libs/numeric/ublas/build.jam ]
  263. {
  264. all-libraries-to-declare += ublas ;
  265. }
  266. all-libraries-to-declare = [ SORT $(all-libraries-to-declare) ] ;
  267. # ECHO "INFO: Build Libraries:" [ SORT $(all-libraries-old-build) ] ;
  268. # ECHO "INFO: Modular Libraries:" [ SORT $(all-libraries-modular-build) ] ;
  269. # ECHO "INFO: Declared Libraries:" [ SORT $(all-libraries-to-declare) ] ;
  270. # EXIT : 0 ;
  271. # Setup convenient aliases for all libraries.
  272. # First, the complicated libraries: where the target name in Jamfile is
  273. # different from its directory name.
  274. explicit
  275. [ alias prg_exec_monitor : libs/test/build//boost_prg_exec_monitor ]
  276. [ alias test_exec_monitor : libs/test/build//boost_test_exec_monitor ]
  277. [ alias unit_test_framework : libs/test/build//boost_unit_test_framework ]
  278. [ alias serialization : libs/serialization/build//boost_serialization ]
  279. [ alias wserialization : libs/serialization/build//boost_wserialization ]
  280. ;
  281. for local l in $(all-libraries-old-build)
  282. {
  283. if ! $(l) in test graph serialization headers
  284. {
  285. explicit [ alias $(l) : libs/$(l)/build//boost_$(l) ] ;
  286. }
  287. }
  288. for local l in $(all-libraries-modular-build)
  289. {
  290. if ! $(l) in test graph serialization headers
  291. {
  292. explicit [ alias $(l) : /boost/$(l)//boost_$(l) ] ;
  293. }
  294. }
  295. rule do-nothing { }
  296. rule generate-alias ( project name : property-set : sources * )
  297. {
  298. local action-name = [ $(property-set).get <action> ] ;
  299. local m = [ MATCH ^@(.*) : $(action-name) ] ;
  300. property-set = [ property-set.empty ] ;
  301. local action = [ new action $(sources) : $(m[1]) : $(property-set) ] ;
  302. local t = [ new notfile-target $(name) : $(project) : $(action) ] ;
  303. return [ virtual-target.register $(t) ] ;
  304. }
  305. generate headers : $(all-headers)-headers : <generating-rule>@generate-alias <action>@do-nothing : : <include>. ;
  306. #alias headers : $(all-headers)-headers : : : <include>. ;
  307. explicit headers ;
  308. # Make project ids of all libraries known.
  309. for local l in $(all-libraries-old-build)
  310. {
  311. use-project /boost/$(l) : libs/$(l)/build ;
  312. }
  313. if [ path.exists $(BOOST_ROOT)/tools/inspect/build ]
  314. {
  315. use-project /boost/tools/inspect : tools/inspect/build ;
  316. }
  317. if [ path.exists $(BOOST_ROOT)/libs/wave/tool/build ]
  318. {
  319. use-project /boost/libs/wave/tool : $(BOOST_ROOT)/libs/wave/tool/build ;
  320. }
  321. # Make the boost-install rule visible in subprojects
  322. # This rule should be called from libraries' Jamfiles and will create two
  323. # targets, "install" and "stage", that will install or stage that library. The
  324. # --prefix option is respected, but --with and --without options, naturally, are
  325. # ignored.
  326. #
  327. # - libraries -- list of library targets to install.
  328. rule boost-install ( libraries * )
  329. {
  330. boost-install.boost-install $(libraries) ;
  331. }
  332. # Creates a library target, adding autolink support and also creates
  333. # stage and install targets via boost-install, above.
  334. rule boost-lib ( name : sources * : requirements * : default-build * : usage-requirements * )
  335. {
  336. autolink = <link>shared:<define>BOOST_$(name:U)_DYN_LINK=1 ;
  337. name = boost_$(name) ;
  338. lib $(name)
  339. : $(sources)
  340. : $(requirements) $(autolink)
  341. : $(default-build)
  342. : $(usage-requirements) $(autolink)
  343. ;
  344. boost-install $(name) ;
  345. }
  346. # Declare special top-level targets that build and install the desired variants
  347. # of the libraries.
  348. boostcpp.declare-targets $(all-libraries-to-build) ;
  349. # Declare a Boost library and run related declaration rules. This should be
  350. # called from the libroot/build.jam to define the components of a Boost lib.
  351. # The first arg is the base ID of the library. Each subsequence arg is a
  352. # Boost (boost-x) declaration rule to call with arguments.
  353. #
  354. # For example:
  355. #
  356. # call-if : boost-library serialization
  357. # : install boost_serialization boost_wserialization ;
  358. #
  359. rule boost-library ( id ? : options * : * )
  360. {
  361. # ECHO "INFO: Declare Boost library:" $(id) ;
  362. local called-boost-install ;
  363. for n in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
  364. {
  365. local option = $($(n)) ;
  366. if $(option)
  367. {
  368. call-if : boost-$(option[1]) $(option[2-]) ;
  369. if $(option[1]) = install
  370. {
  371. called-boost-install = true ;
  372. }
  373. }
  374. }
  375. if ! $(called-boost-install)
  376. {
  377. # If the library didn't indicate an install build target it's likely
  378. # header only. We should declare empty install targets to allow for
  379. # generic handling.
  380. boost-install.boost-install ;
  381. }
  382. }
  383. # Declare projects and targets for all placeholder, header only, not yet
  384. # modular libraries.
  385. #
  386. # NOTE: This has to be after the boost-* rule definitions to ensure that those
  387. # are available for import into the new projects.
  388. local location = [ project.attribute $(__name__) location ] ;
  389. for local lib in $(all-libraries-to-declare)
  390. {
  391. local lib-path
  392. = [ path.join $(location) libs $(lib) ] ;
  393. if $(lib) = numeric_conversion
  394. {
  395. lib-path = [ path.join $(location) libs/numeric/conversion ] ;
  396. }
  397. else if $(lib) in interval odeint ublas
  398. {
  399. lib-path = [ path.join $(location) libs/numeric/$(lib) ] ;
  400. }
  401. local lib-module
  402. = [ project.load $(lib-path) : synthesize ] ;
  403. modules.poke $(lib-module) : BOOST_LIB_PROJECT : /boost/$(lib) ;
  404. modules.poke $(lib-module) : BOOST_LIB_TARGET : boost_$(lib) ;
  405. project.push-current [ project.target $(lib-module) ] ;
  406. module $(lib-module)
  407. {
  408. project $(BOOST_LIB_PROJECT)
  409. : requirements
  410. <implicit-dependency>/boost//headers
  411. ;
  412. alias $(BOOST_LIB_TARGET) ;
  413. }
  414. project.pop-current ;
  415. }
  416. # Backslash because of `bcp --namespace`
  417. if ! [ project.search /boost/tools/boost\_install ]
  418. {
  419. use-project /boost/tools/boost\_install : tools/boost\_install ;
  420. }
  421. # Ensure "modular" libraries' projects are loaded before build request is
  422. # calculated. This is necessary for subprojects that define custom features
  423. # to be set by users on command line.
  424. # This part should stay at the bottom of the file, because subprojects may rely
  425. # on rules or constants from it.
  426. for local l in $(all-libraries-modular-build)
  427. {
  428. # project.find returns the module for the project, which ensures that the
  429. # project is loaded. The convoluted way the rule is invoked is due to the
  430. # fact that project.find can only be called from a project target instance.
  431. modules.call-in [ project.target $(__name__) ]
  432. : project.find /boost/$(l)
  433. : $(location) ;
  434. }
粤ICP备19079148号