Jamroot.jam 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. # Copyright 2019 Rene Rivera
  2. # Copyright 2017 Steven Watanabe
  3. # Copyright 2016 Vladimir Prus
  4. # Copyright 2017 Edward Diener
  5. # Distributed under the Boost Software License, Version 1.0.
  6. # (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
  7. import "class" : new ;
  8. import bison ;
  9. import errors ;
  10. import feature ;
  11. import indirect ;
  12. import os ;
  13. # import package ;
  14. import path ;
  15. import set ;
  16. import stage : add-install-dir ;
  17. import toolset ;
  18. import type ;
  19. import virtual-target ;
  20. path-constant SELF : . ;
  21. project b2
  22. : build-dir .build
  23. : requirements
  24. <cxxstd>11
  25. <toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS=1
  26. <toolset>msvc:<define>_CRT_NONSTDC_NO_DEPRECATE=1
  27. ;
  28. #|
  29. Build the engine and its dependencies outside of the simple core build scripts.
  30. This allows us to keep the core build scripts as simple as possible. And lets
  31. us support more functionality for development of the engine core.
  32. |#
  33. #|
  34. Define custom yyacc tool.
  35. |#
  36. feature.feature yyacc : : dependency free ;
  37. toolset.flags yyacc TOOL <yyacc> ;
  38. exe yyacc
  39. : src/engine/yyacc.cpp
  40. : ;
  41. explicit yyacc ;
  42. rule yyacc-gen ( project name : property-set : sources * )
  43. {
  44. local relevant = [ toolset.relevant $(__name__).yyacc ] ;
  45. local a = [ new action $(sources[1]) : $(__name__).yyacc : [ $(property-set).add $(relevant) ] ] ;
  46. local targets ;
  47. for local n in $(name:S=).y $(name:S=)tab.h
  48. {
  49. targets += [ virtual-target.register
  50. [ new file-target $(n) exact : [ type.type $(n) ]
  51. : $(project) : $(a)
  52. ] ] ;
  53. }
  54. return $(targets) ;
  55. }
  56. actions yyacc bind TOOL
  57. {
  58. "$(TOOL)" "$(<)" "$(>)"
  59. }
  60. generate jamgram.y
  61. : src/engine/jamgram.yy
  62. : <generating-rule>@yyacc-gen
  63. <location>src/engine
  64. <yyacc>yyacc <dependency>yyacc
  65. ;
  66. explicit jamgram.y ;
  67. #|
  68. Define grammar translation with Bison.
  69. |#
  70. BISON = [ os.environ BISON ] ;
  71. BISON ?= bison ;
  72. local BISON_IN_PATH = [ path.glob [ os.executable-path ] : $(BISON[1]) $(BISON[1]).* ] ;
  73. rule grammar ( target : source : properties * )
  74. {
  75. # LOCATE on $(target) = $(source:D) ;
  76. BISON on $(target) = $(BISON) ;
  77. }
  78. actions grammar
  79. {
  80. "$(BISON)" --yacc --defines -o "$(<[1])" "$(>)"
  81. }
  82. if $(BISON_IN_PATH)
  83. {
  84. make jamgram.cpp
  85. : src/engine/jamgram.y
  86. : @grammar
  87. : <dependency>jamgram.y
  88. <location>src/engine ;
  89. }
  90. else
  91. {
  92. errors.warning "Bison generator program '$(BISON:J= )' not found. Skipping grammar build." ;
  93. alias jamgram.cpp
  94. : src/engine/jamgram.cpp ;
  95. }
  96. explicit jamgram.cpp ;
  97. #|
  98. Define the b2 executable. Sources are based on platform.
  99. TODO: Make platform specific source be no-ops when not needed.
  100. |#
  101. local python-exe = [ MATCH --with-python=(.*) : [ modules.peek : ARGV ] ] ;
  102. local python-include ;
  103. local python-ldlib ;
  104. if $(python-exe)
  105. {
  106. python-include = [ SHELL
  107. "$(python-exe) -c \"import sysconfig; print(sysconfig.get_path('include'));\""
  108. : strip-eol ] ;
  109. python-libdir = [ SHELL
  110. "$(python-exe) -c \"import sysconfig; import os.path; print(sysconfig.get_config_var('LIBDIR'));\""
  111. : strip-eol ] ;
  112. python-ldlib = [ MATCH ".*(python.*)" : [ SHELL
  113. "$(python-exe) -c \"import sysconfig; import os.path; print(sysconfig.get_config_var('LIBRARY'));\""
  114. : strip-eol ] ] ;
  115. python-ldlib = $(python-ldlib:S=) ;
  116. lib python
  117. :
  118. : <name>$(python-ldlib) <search>$(python-libdir)
  119. :
  120. : <include>$(python-include) <define>HAVE_PYTHON ;
  121. }
  122. else
  123. {
  124. alias python ;
  125. }
  126. obj jamgram.obj
  127. : jamgram.cpp
  128. : <toolset>gcc:<cxxflags>-Wno-free-nonheap-object
  129. ;
  130. explicit jamgram.obj ;
  131. local b2_src =
  132. [ glob src/engine/*.cpp src/engine/modules/*.cpp :
  133. src/engine/*nt.cpp src/engine/*unix.cpp src/engine/*vms.cpp
  134. src/engine/yyacc.cpp src/engine/mkjambase.cpp
  135. src/engine/check_*.cpp
  136. src/engine/jamgram.cpp
  137. ] ;
  138. local b2_src_nt = [ glob src/engine/*nt.cpp ] ;
  139. local b2_src_unix = [ glob src/engine/*unix.cpp ] ;
  140. local b2_src_vms = [ glob src/engine/*vms.cpp ] ;
  141. local unix_os = [ set.difference [ feature.values <target-os> ] : windows vms ] ;
  142. exe b2
  143. : $(b2_src)
  144. jamgram.obj
  145. python
  146. : <target-os>windows:<source>$(b2_src_nt)
  147. <target-os>vms:<source>$(b2_src_vms)
  148. <target-os>$(unix_os):<source>$(b2_src_unix)
  149. <toolset>msvc:<find-static-library>kernel32
  150. <toolset>msvc:<find-static-library>advapi32
  151. <toolset>msvc:<find-static-library>user32
  152. ;
  153. explicit b2 ;
  154. #|
  155. Installation of the engine, build, and example files.
  156. |#
  157. feature.feature b2-install-layout : standard portable : incidental propagated ;
  158. add-install-dir b2prefix-standard : : prefix ;
  159. add-install-dir b2bindir-standard : : bindir ;
  160. add-install-dir b2coredir-standard : boost-build/src : datarootdir ;
  161. add-install-dir b2examplesdir-standard : boost-build/examples : datarootdir ;
  162. add-install-dir b2prefix-portable : : prefix ;
  163. add-install-dir b2bindir-portable : : b2prefix-portable ;
  164. add-install-dir b2coredir-portable : .b2 : b2prefix-portable ;
  165. add-install-dir b2examplesdir-portable : .b2/examples : b2prefix-portable ;
  166. local ext = "" ;
  167. if [ os.on-windows ] || [ os.on-vms ]
  168. {
  169. ext = ".exe" ;
  170. }
  171. install b2-engine
  172. : $(SELF)/src/engine/b2$(ext)
  173. : <b2-install-layout>standard:<location>(b2bindir-standard)
  174. <b2-install-layout>portable:<location>(b2bindir-portable)
  175. ;
  176. explicit b2-engine ;
  177. local examples ;
  178. for local e in [ glob-tree-ex $(SELF)/example : * : . .svn ]
  179. {
  180. if [ CHECK_IF_FILE [ path.native $(e) ] ]
  181. {
  182. examples += $(e) ;
  183. }
  184. }
  185. install b2-examples
  186. : # What to install
  187. $(examples)
  188. : # What is the root of the directory
  189. <install-source-root>example
  190. # Which subdir of $prefix/share
  191. <b2-install-layout>standard:<location>(b2examplesdir-standard)
  192. <b2-install-layout>portable:<location>(b2examplesdir-portable)
  193. ;
  194. explicit b2-examples ;
  195. local .core-sources =
  196. $(SELF)/src/build-system.jam
  197. [ path.glob-tree $(SELF)/src/build : *.jam ]
  198. [ path.glob-tree $(SELF)/src/contrib : *.jam ]
  199. [ path.glob-tree $(SELF)/src/kernel : *.jam ]
  200. [ path.glob-tree $(SELF)/src/options : *.jam ]
  201. [ path.glob-tree $(SELF)/src/util : *.jam ]
  202. [ path.glob-tree $(SELF)/src/tools : *.jam *.xml *.xsl *.doxyfile *.hpp doxproc.py ]
  203. ;
  204. if $(python-exe)
  205. {
  206. .core-sources +=
  207. [ path.glob-tree $(SELF)/src/build : *.py ]
  208. [ path.glob-tree $(SELF)/src/contrib : *.py ]
  209. [ path.glob-tree $(SELF)/src/kernel : *.py ]
  210. [ path.glob-tree $(SELF)/src/options : *.py ]
  211. [ path.glob-tree $(SELF)/src/util : *.py ]
  212. [ path.glob-tree $(SELF)/src/tools : *.py : doxproc.py ]
  213. ;
  214. }
  215. install b2-core
  216. : # What to install
  217. $(.core-sources)
  218. : # What is the root of the directory
  219. <install-source-root>src
  220. # Which subdir of $prefix/share
  221. <b2-install-layout>standard:<location>(b2coredir-standard)
  222. <b2-install-layout>portable:<location>(b2coredir-portable)
  223. ;
  224. explicit b2-core ;
  225. #|
  226. Only install example files when requested to avoid bloating install footprint.
  227. |#
  228. if --with-examples in [ modules.peek : ARGV ]
  229. {
  230. alias install : b2-engine b2-core b2-examples ;
  231. }
  232. else
  233. {
  234. alias install : b2-engine b2-core ;
  235. }
  236. explicit install ;