Jamroot 18 KB

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