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