boostcpp.jam 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  1. # Boost.Build support specific for the Boost C++ Libraries.
  2. # Copyright Vladimir Prus 2002-2010.
  3. # Copyright Dave Abrahams 2005-2006.
  4. # Copyright Rene Rivera 2005-2007.
  5. # Copyright Douglas Gregor 2005.
  6. #
  7. # Distributed under the Boost Software License, Version 1.0.
  8. # (See accompanying file LICENSE_1_0.txt or copy at
  9. # http://www.boost.org/LICENSE_1_0.txt)
  10. import "class" : new ;
  11. import common ;
  12. import configure ;
  13. import build-system ;
  14. import generate ;
  15. import modules ;
  16. import option ;
  17. import os ;
  18. import package ;
  19. import path ;
  20. import project ;
  21. import regex ;
  22. import sequence ;
  23. import set ;
  24. import targets ;
  25. import feature ;
  26. import property ;
  27. import version : version-less ;
  28. ##############################################################################
  29. #
  30. # 0. General setup. Parse options, check them.
  31. #
  32. ##############################################################################
  33. BOOST_ROOT = [ modules.binding $(__name__) ] ;
  34. BOOST_ROOT = $(BOOST_ROOT:D) ;
  35. rule set-version ( version )
  36. {
  37. BOOST_VERSION = $(version) ;
  38. local version-tag =
  39. [ MATCH "^([^.]+)[.]([^.]+)[.]([^.]+)" : $(BOOST_VERSION) ] ;
  40. if $(version-tag[3]) = 0
  41. {
  42. version-tag = $(version-tag[1-2]) ;
  43. }
  44. BOOST_VERSION_TAG = $(version-tag:J=_) ;
  45. }
  46. # Option to choose how many variants to build. The default is "minimal".
  47. build-type = [ option.get build-type ] ;
  48. build-type ?= minimal ;
  49. if ! ( $(build-type) in complete minimal )
  50. {
  51. EXIT The value of the --build-type option should be either 'complete' or
  52. 'minimal' ;
  53. }
  54. # What kind of layout are we doing?
  55. layout = [ option.get layout : "" ] ;
  56. layout = [ MATCH (versioned|tagged|system)(-(.+))? : $(layout) ] ;
  57. if $(layout[3])
  58. {
  59. layout-version = $(layout[3]) ;
  60. layout = $(layout[1]) ;
  61. if [ version-less [ regex.split $(layout-version) "[.]" ] : 1 66 ]
  62. {
  63. layout-version = 1.40 ;
  64. }
  65. else if [ version-less [ regex.split $(layout-version) "[.]" ] : 1 69 ]
  66. {
  67. layout-version = 1.66 ;
  68. }
  69. }
  70. layout-version ?= 1.69 ;
  71. # On Windows, we used versioned layout by default in order to be compatible with
  72. # autolink. On other systems, we use system layout which is what every other
  73. # program uses. Note that the Windows check is static, and will not be affected
  74. # by specific build properties used.
  75. if ! $(layout)
  76. {
  77. if [ os.name ] = NT
  78. {
  79. layout = versioned ;
  80. }
  81. else
  82. {
  83. layout = system ;
  84. }
  85. }
  86. layout-$(layout) = true ;
  87. if $(layout) = system && $(build-type) = complete
  88. {
  89. ECHO error\: Cannot use --layout=system with --build-type complete. ;
  90. ECHO error\: Please use either --layout=versioned or --layout=tagged ;
  91. ECHO error\: if you wish to build multiple variants. ;
  92. if [ os.name ] != NT
  93. {
  94. ECHO error\: Note that --layout=system is used by default on Unix
  95. starting with Boost 1.40. ;
  96. }
  97. EXIT ;
  98. }
  99. # Possible stage only location.
  100. stage-locate = [ option.get stagedir ] ;
  101. stage-locate ?= stage ;
  102. BOOST_STAGE_LOCATE = $(stage-locate) ;
  103. # Custom build ID.
  104. build-id = [ option.get buildid ] ;
  105. if $(build-id)
  106. {
  107. BUILD_ID = [ regex.replace $(build-id) "[*\\/:.\"\' ]" _ ] ;
  108. }
  109. # Python build id (for Python libraries only).
  110. python-id = [ option.get "python-buildid" ] ;
  111. if $(python-id)
  112. {
  113. PYTHON_ID = [ regex.replace $(python-id) "[*\\/:.\"\']" _ ] ;
  114. }
  115. if $(layout) = versioned
  116. {
  117. switch $(layout-version)
  118. {
  119. case 1.40 :
  120. .format-name-args =
  121. <base> <toolset> <threading> <runtime> ;
  122. case 1.66 :
  123. .format-name-args =
  124. <base> <toolset> <threading> <runtime> <arch-and-model> ;
  125. case 1.69 :
  126. .format-name-args =
  127. <base> <toolset> <threading> <runtime> <arch-and-model> ;
  128. }
  129. }
  130. else if $(layout) = tagged
  131. {
  132. switch $(layout-version)
  133. {
  134. case 1.40 :
  135. .format-name-args =
  136. <base> <threading> <runtime> ;
  137. case 1.66 :
  138. .format-name-args =
  139. <base> <threading> <runtime> ;
  140. case 1.69 :
  141. .format-name-args =
  142. <base> <threading> <runtime> <arch-and-model> ;
  143. }
  144. }
  145. else if $(layout) = system
  146. {
  147. .format-name-args = <base> ;
  148. }
  149. else
  150. {
  151. .format-name-error = true ;
  152. }
  153. ################################################################################
  154. #
  155. # 1. 'tag' function adding decorations suitable to the properties if versioned
  156. # or tagged layout is requested. Called from Jamroot.
  157. #
  158. ################################################################################
  159. rule tag ( name : type ? : property-set )
  160. {
  161. if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
  162. {
  163. local args = $(.format-name-args) ;
  164. if $(layout) = versioned
  165. {
  166. args += -$(BOOST_VERSION_TAG) ;
  167. }
  168. local result = [ common.format-name
  169. $(args) -$(BUILD_ID)
  170. : $(name) : $(type) : $(property-set) ] ;
  171. if $(.format-name-error)
  172. {
  173. EXIT error\: invalid layout '$(layout:E=)' ;
  174. }
  175. # Optionally add version suffix. On NT, library with version suffix will
  176. # not be recognized by linkers. On CYGWIN, we get strage duplicate
  177. # symbol errors when library is generated with version suffix. On OSX,
  178. # version suffix is not needed -- the linker expects the
  179. # libFoo.1.2.3.dylib format. AIX linkers do not accept version suffixes
  180. # either. Pgi compilers can not accept a library with version suffix.
  181. if $(type) = SHARED_LIB &&
  182. ! [ $(property-set).get <target-os> ] in windows cygwin darwin aix &&
  183. ! [ $(property-set).get <toolset> ] in pgi
  184. {
  185. result = $(result).$(BOOST_VERSION) ;
  186. }
  187. return $(result) ;
  188. }
  189. }
  190. # Specialized tag function to use for libraries linking to Python.
  191. # Appends value of --python-buildid if provided.
  192. rule python-tag ( name : type ? : property-set )
  193. {
  194. local result = $(name) ;
  195. if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB && $(PYTHON_ID)
  196. {
  197. result = $(result)-$(PYTHON_ID) ;
  198. }
  199. # forward to the boost tagging rule
  200. return [ tag $(result) : $(type) : $(property-set) ] ;
  201. }
  202. ################################################################################
  203. #
  204. # 2. Declare targets that build and install all libraries. Specifically:
  205. #
  206. # - 'stage-proper' that puts all libraries in stage/lib
  207. # - 'install-proper' that install libraries and headers to system location
  208. # - 'stage-unversioned' that creates links to libraries without boost version
  209. # in name
  210. # - 'install-unversioned' which creates unversioned linked to installed
  211. # libraries.
  212. #
  213. ################################################################################
  214. # Worker function suitable to the 'generate' metatarget. Creates a link to
  215. # 'source', striping any version number information from the name.
  216. rule make-unversioned-links ( project name ? : property-set : sources * )
  217. {
  218. local filter ;
  219. if [ modules.peek : NT ]
  220. {
  221. filter = "(.*[.]lib)" ;
  222. }
  223. else
  224. {
  225. filter =
  226. "(.*[.]so)[.0-9]*"
  227. "(.*[.]dylib)"
  228. "(.*[.]a)" ;
  229. }
  230. local result ;
  231. for local s in $(sources)
  232. {
  233. local m = [ MATCH "^(.*)-[0-9_]+$(filter)$" : [ $(s).name ] ] ;
  234. if $(m)
  235. {
  236. local ea = [ $(s).action ] ;
  237. local ep = [ $(ea).properties ] ;
  238. local a = [ new non-scanning-action $(s) : symlink.ln : $(ep) ] ;
  239. result += [ new file-target $(m:J=) exact : [ $(s).type ] :
  240. $(project) : $(a) ] ;
  241. }
  242. }
  243. return $(result) ;
  244. }
  245. rule filtered-target ( name : message + : sources + : requirements * )
  246. {
  247. message $(name)-message : warning\: $(message) ;
  248. alias $(name) : $(sources) : $(requirements) ;
  249. alias $(name) : $(name)-message ;
  250. local p = [ project.current ] ;
  251. $(p).mark-target-as-explicit $(name) ;
  252. $(p).mark-target-as-explicit $(name)-message ;
  253. }
  254. rule declare_install_and_stage_proper_targets ( libraries * : headers * : modular-headers * )
  255. {
  256. local p = [ project.current ] ;
  257. for local l in $(libraries)
  258. {
  259. if $(l) = locale
  260. {
  261. filtered-target $(l)-for-install :
  262. Skipping Boost.Locale library with threading=single. :
  263. libs/$(l)/build : <threading>multi ;
  264. }
  265. else if $(l) = wave
  266. {
  267. filtered-target $(l)-for-install :
  268. Skipping Boost.Wave library with threading=single. :
  269. libs/$(l)/build : <threading>multi ;
  270. }
  271. else if $(l) = thread
  272. {
  273. filtered-target $(l)-for-install :
  274. Skipping Boost.Thread library with threading=single. :
  275. libs/$(l)/build : <threading>multi ;
  276. }
  277. else
  278. {
  279. alias $(l)-for-install : libs/$(l)/build ;
  280. $(p).mark-target-as-explicit $(l)-for-install ;
  281. }
  282. }
  283. local library-targets = $(libraries)-for-install ;
  284. local install-requirements ;
  285. if $(layout-versioned)
  286. {
  287. install-requirements +=
  288. <install-header-subdir>boost-$(BOOST_VERSION_TAG)/boost ;
  289. }
  290. else
  291. {
  292. install-requirements += <install-header-subdir>boost ;
  293. }
  294. if [ os.name ] = NT
  295. {
  296. install-requirements += <install-default-prefix>C:/Boost ;
  297. }
  298. else
  299. {
  300. install-requirements += <install-default-prefix>/usr/local ;
  301. }
  302. p = [ project.current ] ;
  303. # These headers will be installed from the modular
  304. # layout, and should be ignored in the global boost/
  305. local skip-headers ;
  306. # Install modular headers.
  307. for local lib in $(modular-headers)
  308. {
  309. local header-root = $(BOOST_ROOT)/libs/$(lib)/include/boost ;
  310. local lib-headers =
  311. [ path.glob-tree $(header-root) : *.hpp *.ipp *.h *.inc *.SUNWCCh : CVS .svn ]
  312. [ path.glob-tree $(header-root)/compatibility/cpp_c_headers : c* : CVS .svn ]
  313. [ path.glob $(header-root)/tr1/tr1 : * : bcc32 sun CVS .svn ]
  314. ;
  315. skip-headers += [ sequence.transform path.relative-to [ path.make $(header-root) ] : $(lib-headers) ] ;
  316. package.install install-$(lib)-headers
  317. : <install-source-root>$(header-root)
  318. $(install-requirements)
  319. <install-no-version-symlinks>on
  320. : # binaries
  321. : # libraries
  322. : $(lib-headers)
  323. ;
  324. $(p).mark-target-as-explicit install-$(lib)-headers ;
  325. }
  326. # Filter out headers that were created by b2 headers
  327. local header-root = [ path.make $(BOOST_ROOT)/boost ] ;
  328. headers = [ set.difference $(headers) : $(header-root)/$(skip-headers) ] ;
  329. # Complete install.
  330. package.install install-proper
  331. : <install-source-root>$(BOOST_ROOT)/boost
  332. $(install-requirements)
  333. <install-no-version-symlinks>on
  334. :
  335. : $(libraries)-for-install
  336. : $(headers)
  337. ;
  338. $(p).mark-target-as-explicit install-proper ;
  339. # Install just library.
  340. install stage-proper
  341. : $(libraries)-for-install
  342. : <location>$(stage-locate)/lib
  343. <install-dependencies>on <install-type>LIB
  344. <install-no-version-symlinks>on
  345. ;
  346. $(p).mark-target-as-explicit stage-proper ;
  347. # Commented out as it does not seem to work. Whoever wrote this originally,
  348. # left some typos in the code, but when that got corrected and the code got
  349. # enabled - it started reporting ambiguous/duplicate target Boost Build
  350. # errors. Anyone requiring unversioned staged libraries needs to correct
  351. # those errors before reenabling this code. For more detailed information
  352. # see the related Boost library development mailing list thread at
  353. # 'http://lists.boost.org/Archives/boost/2012/06/194312.php'.
  354. # (06.07.2012.) (Jurko)
  355. #~ if $(layout-versioned) && ( [ modules.peek : NT ] || [ modules.peek : UNIX ] )
  356. #~ {
  357. #~ generate stage-unversioned : stage-proper :
  358. #~ <generating-rule>@boostcpp.make-unversioned-links ;
  359. #~ $(p).mark-target-as-explicit stage-unversioned ;
  360. #~
  361. #~ generate install-unversioned : install-proper :
  362. #~ <generating-rule>@boostcpp.make-unversioned-links ;
  363. #~ $(p).mark-target-as-explicit install-unversioned ;
  364. #~ }
  365. #~ else
  366. {
  367. # Create do-nothing aliases.
  368. alias stage-unversioned ;
  369. $(p).mark-target-as-explicit stage-unversioned ;
  370. alias install-unversioned ;
  371. $(p).mark-target-as-explicit install-unversioned ;
  372. }
  373. }
  374. ################################################################################
  375. #
  376. # 3. Declare top-level targets 'stage' and 'install'. These examine the
  377. # --build-type option and, in case it is 'complete', build the 'install-proper'
  378. # and 'stage-proper' targets with a number of property sets.
  379. #
  380. ################################################################################
  381. class top-level-target : alias-target-class
  382. {
  383. import modules ;
  384. rule __init__ ( name : project : sources * : requirements *
  385. : default-build * : usage-requirements * )
  386. {
  387. alias-target-class.__init__ $(name) : $(project) : $(sources) :
  388. $(requirements) : $(default-build) : $(usage-requirements) ;
  389. self.build-type = [ modules.peek boostcpp : build-type ] ;
  390. # On Linux, we build the release variant by default, since few users
  391. # will ever want to debug C++ Boost libraries, and there is no ABI
  392. # incompatibility between debug and release variants. We build shared
  393. # and static libraries since that is what most packages seem to provide
  394. # (.so in libfoo and .a in libfoo-dev).
  395. self.minimal-properties = [ property-set.create <variant>release
  396. <threading>multi <link>shared <link>static <runtime-link>shared ] ;
  397. # On Windows, new IDE projects use:
  398. #
  399. # runtime-link=dynamic, threading=multi, variant=(debug|release)
  400. #
  401. # and in addition, C++ Boost's autolink defaults to static linking.
  402. self.minimal-properties-win = [ property-set.create <variant>debug
  403. <variant>release <threading>multi <link>static <runtime-link>shared
  404. <address-model>32 <address-model>64 ] ;
  405. self.complete-properties = [ property-set.create
  406. <variant>debug <variant>release
  407. <threading>multi
  408. <link>shared <link>static
  409. <runtime-link>shared <runtime-link>static ] ;
  410. self.complete-properties-win = [ property-set.create
  411. <variant>debug <variant>release
  412. <threading>multi
  413. <link>shared <link>static
  414. <runtime-link>shared <runtime-link>static
  415. <address-model>32 <address-model>64 ] ;
  416. }
  417. rule generate ( property-set )
  418. {
  419. modules.poke : top-level-targets : [ modules.peek : top-level-targets ]
  420. $(self.name) ;
  421. local os = [ $(property-set).get <target-os> ] ;
  422. # Because we completely override the parent's 'generate' we need to
  423. # check for default feature values ourselves.
  424. if ! $(os)
  425. {
  426. os = [ feature.defaults <target-os> ] ;
  427. os = $(os:G=) ;
  428. }
  429. local build-type-set ;
  430. if $(self.build-type) = minimal
  431. {
  432. if $(os) = windows
  433. {
  434. build-type-set = $(self.minimal-properties-win) ;
  435. }
  436. else
  437. {
  438. build-type-set = $(self.minimal-properties) ;
  439. }
  440. }
  441. else if $(self.build-type) = complete
  442. {
  443. if $(os) = windows
  444. {
  445. build-type-set = $(self.complete-properties-win) ;
  446. }
  447. else
  448. {
  449. build-type-set = $(self.complete-properties) ;
  450. }
  451. }
  452. else
  453. {
  454. import errors ;
  455. errors.error "Unknown build type" ;
  456. }
  457. if $(build-type-set)
  458. {
  459. local expanded = [ targets.apply-default-build $(property-set)
  460. : $(build-type-set) ] ;
  461. # Filter inappopriate combinations.
  462. local filtered ;
  463. for local p in $(expanded)
  464. {
  465. # See comment in handle-static-runtime regarding this logic.
  466. if [ $(p).get <link> ] = shared
  467. && [ $(p).get <runtime-link> ] = static
  468. && [ $(p).get <toolset> ] != cw
  469. {
  470. # Skip this.
  471. }
  472. else
  473. {
  474. filtered += $(p) ;
  475. }
  476. }
  477. return [ build-multiple $(filtered) ] ;
  478. }
  479. }
  480. rule build-multiple ( property-sets * )
  481. {
  482. local usage-requirements = [ property-set.empty ] ;
  483. local result ;
  484. for local p in $(property-sets)
  485. {
  486. local r = [ alias-target-class.generate $(p) ] ;
  487. if $(r)
  488. {
  489. usage-requirements = [ $(usage-requirements).add $(r[1]) ] ;
  490. result += $(r[2-]) ;
  491. }
  492. }
  493. return $(usage-requirements) [ sequence.unique $(result) ] ;
  494. }
  495. }
  496. rule declare_top_level_targets ( libraries * : headers * : modular-headers * )
  497. {
  498. declare_install_and_stage_proper_targets $(libraries) : $(headers) : $(modular-headers) ;
  499. targets.create-metatarget top-level-target : [ project.current ]
  500. : install
  501. : install-$(modular-headers)-headers install-proper install-unversioned
  502. ;
  503. targets.create-metatarget top-level-target : [ project.current ]
  504. : stage
  505. : stage-proper stage-unversioned headers
  506. ;
  507. p = [ project.current ] ;
  508. $(p).mark-target-as-explicit install stage ;
  509. # This target is built by default, and will forward to 'stage' after
  510. # producing some explanations.
  511. targets.create-metatarget top-level-target : [ project.current ]
  512. : forward
  513. : explain stage
  514. ;
  515. }
  516. stage-abs = [ path.native [ path.root $(stage-locate)/lib [ path.pwd ] ] ] ;
  517. ################################################################################
  518. #
  519. # 4. Add hook to report configuration before the build, and confirmation with
  520. # setup instructions after the build.
  521. #
  522. ################################################################################
  523. message explain : "\nBuilding the Boost C++ Libraries.\n\n" ;
  524. local p = [ project.current ] ;
  525. $(p).mark-target-as-explicit explain ;
  526. rule pre-build ( )
  527. {
  528. local tl = [ modules.peek : top-level-targets ] ;
  529. if stage in $(tl) || install in $(tl)
  530. {
  531. # FIXME: Remove 'if' when Boost regression tests start using trunk bjam.
  532. if PAD in [ RULENAMES ]
  533. {
  534. configure.print-component-configuration ;
  535. }
  536. }
  537. }
  538. IMPORT $(__name__) : pre-build : : $(__name__).pre-build ;
  539. build-system.set-pre-build-hook $(__name__).pre-build ;
  540. # FIXME: Revise stage_abs.
  541. rule post-build ( ok ? )
  542. {
  543. if forward in [ modules.peek : top-level-targets ]
  544. {
  545. if $(ok)
  546. {
  547. local include-path = [ path.native $(BOOST_ROOT) ] ;
  548. ECHO "
  549. The Boost C++ Libraries were successfully built!
  550. The following directory should be added to compiler include paths:
  551. $(include-path)
  552. The following directory should be added to linker library paths:
  553. $(stage-abs)
  554. " ;
  555. }
  556. }
  557. }
  558. IMPORT $(__name__) : post-build : : $(__name__).post-build ;
  559. build-system.set-post-build-hook $(__name__).post-build ;
  560. ################################################################################
  561. #
  562. # 5. Top-level setup.
  563. #
  564. ################################################################################
  565. # Decides which libraries are to be installed by looking at --with-<library>
  566. # --without-<library> arguments. Returns the list of directories under "libs"
  567. # which must be built and installed.
  568. #
  569. rule libraries-to-install ( existing-libs * )
  570. {
  571. local argv = [ modules.peek : ARGV ] ;
  572. local with-parameter = [ MATCH ^--with-(.*) : $(argv) ] ;
  573. local without-parameter = [ MATCH ^--without-(.*) : $(argv) ] ;
  574. if ! $(with-parameter) && ! $(without-parameter)
  575. {
  576. # Nothing is specified on command line. See if maybe project-config.jam
  577. # has some choices.
  578. local libs = [ modules.peek project-config : libraries ] ;
  579. with-parameter = [ MATCH ^--with-(.*) : $(libs) ] ;
  580. without-parameter = [ MATCH ^--without-(.*) : $(libs) ] ;
  581. }
  582. # Do some checks.
  583. if $(with-parameter) && $(without-parameter)
  584. {
  585. EXIT error\: both --with-<library> and --without-<library> specified ;
  586. }
  587. local wrong = [ set.difference $(with-parameter) : $(existing-libs) ] ;
  588. if $(wrong)
  589. {
  590. EXIT error\: wrong library name '$(wrong[1])' in the --with-<library>
  591. option. ;
  592. }
  593. local wrong = [ set.difference $(without-parameter) : $(existing-libs) ] ;
  594. if $(wrong)
  595. {
  596. EXIT error\: wrong library name '$(wrong[1])' in the --without-<library>
  597. option. ;
  598. }
  599. if $(with-parameter)
  600. {
  601. return [ set.intersection $(existing-libs) : $(with-parameter) ] ;
  602. }
  603. else
  604. {
  605. return [ set.difference $(existing-libs) : $(without-parameter) ] ;
  606. }
  607. }
  608. rule declare-targets ( all-libraries * : headers * : modular-headers * )
  609. {
  610. configure.register-components $(all-libraries) ;
  611. # Select the libraries to install.
  612. libraries = [ libraries-to-install $(all-libraries) ] ;
  613. configure.components-building $(libraries) ;
  614. if [ option.get "show-libraries" : : true ]
  615. {
  616. ECHO The following libraries require building\: ;
  617. for local l in $(libraries)
  618. {
  619. ECHO " - $(l)" ;
  620. }
  621. EXIT ;
  622. }
  623. declare_top_level_targets $(libraries) : $(headers) : $(modular-headers) ;
  624. }
  625. # Returns the properties identifying the toolset. We'll use them
  626. # below to configure checks. These are essentially same as in
  627. # configure.builds, except we don't use address-model and
  628. # architecture - as we're trying to detect them here.
  629. #
  630. rule toolset-properties ( properties * )
  631. {
  632. local toolset = [ property.select <toolset> : $(properties) ] ;
  633. local toolset-version-property = "<toolset-$(toolset:G=):version>" ;
  634. return [ property.select <target-os> <toolset> $(toolset-version-property) : $(properties) ] ;
  635. }
  636. feature.feature deduced-address-model : 32 64 : propagated optional composite hidden ;
  637. feature.compose <deduced-address-model>32 : <address-model>32 ;
  638. feature.compose <deduced-address-model>64 : <address-model>64 ;
  639. rule deduce-address-model ( properties * )
  640. {
  641. local result ;
  642. local filtered = [ toolset-properties $(properties) ] ;
  643. local names = 32 64 ;
  644. local idx = [ configure.find-builds "default address-model" : $(filtered)
  645. : /boost/architecture//32 "32-bit"
  646. : /boost/architecture//64 "64-bit" ] ;
  647. result = $(names[$(idx)]) ;
  648. if $(result)
  649. {
  650. # Normally, returning composite feature here is equivalent to forcing
  651. # consituent properties as well. But we only want to indicate toolset
  652. # deduced default, so also pick whatever address-model is explicitly
  653. # specified, if any.
  654. result = <deduced-address-model>$(result) [ property.select <address-model> : $(properties) ] ;
  655. }
  656. return $(result) ;
  657. }
  658. rule address-model ( )
  659. {
  660. return <conditional>@boostcpp.deduce-address-model ;
  661. }
  662. local deducable-architectures = arm mips1 power sparc x86 combined ;
  663. feature.feature deduced-architecture : $(deducable-architectures) : propagated optional composite hidden ;
  664. for a in $(deducable-architectures)
  665. {
  666. feature.compose <deduced-architecture>$(a) : <architecture>$(a) ;
  667. }
  668. rule deduce-architecture ( properties * )
  669. {
  670. local result ;
  671. local filtered = [ toolset-properties $(properties) ] ;
  672. local names = arm mips1 power sparc x86 combined ;
  673. local idx = [ configure.find-builds "default architecture" : $(filtered)
  674. : /boost/architecture//arm
  675. : /boost/architecture//mips1
  676. : /boost/architecture//power
  677. : /boost/architecture//sparc
  678. : /boost/architecture//x86
  679. : /boost/architecture//combined ] ;
  680. result = $(names[$(idx)]) ;
  681. if $(result)
  682. {
  683. # See comment in deduce-address-model.
  684. result = <deduced-architecture>$(result) [ property.select <architecture> : $(properties) ] ;
  685. }
  686. return $(result) ;
  687. }
  688. rule architecture ( )
  689. {
  690. return <conditional>@boostcpp.deduce-architecture ;
  691. }
粤ICP备19079148号