-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxmodule.jam
279 lines (228 loc) · 9.9 KB
/
xmodule.jam
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# Copyright 2016 DeviantArt Inc.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
#### these docs are out of date
#### TODO: update
## This module defines the 'xm' External Module build system
#
#
# Example use:
# --------------------------------------------------------------------------------------------------------------------------------
#
# import xm ;
#
# xmodule foo.xm : foo/configure
# : <link>static:<xm-flag>--enable-static
# <link>shared:<xm-flag>--enable-shared
# <xm-flag>CXXFLAGS=\"-Wno-unused-local-typedefs -Wno-deprecated -Wno-return-type\"
# ;
#
#
# lib foo : : <xm>foo/configure
# <xpath>lib
# : :
# <xinclude>include
# ;
#
#
#
# --------------------------------------------------------------------------------------------------------------------------------
#
## todo: review/fix these docs
#
# xmodule arguments:
#
# source * path to standard build source
# - can be a bootstrap source such as: modulepath/bootstrap, modulepath/buildconf, or modulepath/autogen.sh
# - can be a configuration file such as: modulepath/configure, modulepath/CMakeLists.txt
# - inference patterns are maintained in xmodule-*.jam files
# - if a module uses non-standard/unsupported build setup, the Non-Standard Build Features can be used instead of a source
#
# xmodule properties:
#
# <xm-config> * options for building the module, exact form of options depends on the module's <xm-conf-tool> (typically infered)
#
# xmodule lib properties:
#
# <xpath> * path to directory in installation where target is to be found
#
# <xinclude> * Make dependent targets find headers in the given path
#
#
#
# Features:
#
# <xm-make-jflag> * passed to make as the -j flag.
# -- if unspecified, will default to one less than the min value of:
# - '-j' value that boost.build was involked with
# - number of local cores
#
# <xm-install-target> * name of install target
# -- if unspecified, will default to 'install'
#
# <xm-build-target> * name of build target
# -- can be specified multiple times for multiple targets
# -- if unspecified, will pass make nothing, which typically causes the default make target to build
import "class" : new ;
import generators ;
import property ;
import property-set ;
import sequence ;
import type ;
import path ;
import virtual-target ;
import feature ;
import string ;
import errors ;
import assert ;
import toolset ;
if $(__name__) != xmodule {
errors.error "xmodule toolset needs to be loaded into 'xmodule' module" ;
}
## load sibling jam modules which may not be loaded yet
{
for local sibling in [ path.glob $(__file__:D) : *.jam : xmodule.jam ] {
modules.load $(sibling:B) : $(sibling) ;
}
}
## include xmodule core files
{
local files = feature
url
type
class
virtual-targets
generator
srchash
workspace
export-name
export-generator
url-generator
xroot
xpath
xrsrc
xfile
xlib
xinclude
targets
project
rules
xtoolset
;
for local file in $(files) {
include $(__file__:D)/xmodule/core/$(file).jam ;
}
}
## import tools
{
# load tool
local rule import-tool ( tools )
{
modules.load xmodule-$(tool) : $(__file__:D)/xmodule/tools/$(tool).jam ;
}
for local tool in patch make cmake configure git dpkg curl tar b2 npm {
import-tool $(tool) ;
}
}
## register generators
register-xpath-generators ;
register-xrsrc-generators ;
register-export-generators xfile XFILE ;
register-export-generators xlib LIB : * : builtin.lib-generator ;
register-export-generators xlib XLIB : * : builtin.lib-generator ;
register-export-generators xinclude XINCLUDE ;
register-export-generators xsystem-include XSYSTEMINCLUDE ;
# must be a complete list of all non-xfile types
# could be more 'register' based..
register-xfile-passthrough-generator !XPATH+ !XRSRC+ !XCURL_URL+ : XFILE ;
## tests - activate with "--debug"
rule __test__ ( )
{
import assert ;
import property-set ;
local xmodule-tests = [ MATCH ^(__test__.+)$ : [ RULENAMES xmodule ] ] ;
# run __test__* rules
echo "found tests in xmodule: \n\t$(xmodule-tests)" ;
for local test in $(xmodule-tests) {
echo running $(test) ... ;
$(test) ;
}
# test name decoding regex
assert.result "" foo.txt "" : decode-name foo.txt ;
assert.result "" foo.txt "!" : decode-name foo.txt! ;
assert.result "!" foo.txt "!" : decode-name !foo.txt! ;
assert.result "!" foo!.txt "!" : decode-name !foo!.txt! ;
assert.result "!" foo!.txt "" : decode-name !foo!.txt ;
assert.result "" foo!.txt "!" : decode-name foo!.txt! ;
assert.result "" foo!.txt "" : decode-name foo!.txt ;
assert.result "" foo "" "#4.7.1" 4.7.1 : decode-name foo#4.7.1 ;
assert.result "" foo "" "#4.7.1" 4.7.1 : decode-name foo#4.7.1 ;
# test name decoding routine with 'version' for non-shared object
local st-ps = [ property-set.create <link>static ] ;
st-ps = [ $(st-ps).add-defaults ] ;
local sh-ps = [ property-set.create <link>shared ] ;
sh-ps = [ $(sh-ps).add-defaults ] ;
local ex = .so ;
local vex = .so.3.0 ;
if [ modules.peek : OS ] = MACOSX {
ex = .dylib ;
vex = .3.0.dylib ;
}
local f = add-prefix-and-suffix ;
assert.result foo : $(f) foo : : $(st-ps) mutable ;
assert.result foo : $(f) foo : : $(sh-ps) mutable ;
assert.result foo : $(f) foo : LIB : $(st-ps) mutable ;
assert.result foo : $(f) foo : LIB : $(sh-ps) mutable ;
assert.result foo.a : $(f) !foo : STATIC_LIB : $(st-ps) mutable ;
assert.result foo.a : $(f) !foo : STATIC_LIB : $(sh-ps) mutable ;
assert.result foo : $(f) !foo! : STATIC_LIB : $(st-ps) mutable ;
assert.result foo : $(f) !foo! : STATIC_LIB : $(sh-ps) mutable ;
assert.result libfoo.a : $(f) foo : STATIC_LIB : $(st-ps) mutable ;
assert.result libfoo.a : $(f) foo : STATIC_LIB : $(sh-ps) mutable ;
assert.result foo : $(f) foo : STATIC_LIB : $(st-ps) immutable ;
assert.result foo : $(f) foo : STATIC_LIB : $(sh-ps) immutable ;
assert.result foo$(ex) : $(f) !foo : SHARED_LIB : $(st-ps) mutable ;
assert.result foo$(ex) : $(f) !foo : SHARED_LIB : $(sh-ps) mutable ;
assert.result foo : $(f) foo : SHARED_LIB : $(st-ps) immutable ;
assert.result foo : $(f) foo : SHARED_LIB : $(sh-ps) immutable ;
# now with version
assert.result foo : $(f) foo#3.0 : : $(st-ps) mutable ;
assert.result foo : $(f) foo#3.0 : : $(sh-ps) mutable ;
assert.result foo : $(f) foo#3.0 : LIB : $(st-ps) mutable ;
assert.result foo : $(f) foo#3.0 : LIB : $(sh-ps) mutable ;
assert.result foo.a : $(f) !foo#3.0 : STATIC_LIB : $(st-ps) mutable ;
assert.result foo.a : $(f) !foo#3.0 : STATIC_LIB : $(sh-ps) mutable ;
assert.result foo : $(f) !foo!#3.0 : STATIC_LIB : $(st-ps) mutable ;
assert.result foo : $(f) !foo!#3.0 : STATIC_LIB : $(sh-ps) mutable ;
assert.result libfoo.a : $(f) foo#3.0 : STATIC_LIB : $(st-ps) mutable ;
assert.result libfoo.a : $(f) foo#3.0 : STATIC_LIB : $(sh-ps) mutable ;
assert.result foo : $(f) foo#3.0 : STATIC_LIB : $(st-ps) immutable ;
assert.result foo : $(f) foo#3.0 : STATIC_LIB : $(sh-ps) immutable ;
assert.result foo$(vex) : $(f) !foo#3.0 : SHARED_LIB : $(st-ps) mutable ;
assert.result foo$(vex) : $(f) !foo#3.0 : SHARED_LIB : $(sh-ps) mutable ;
assert.result foo : $(f) foo#3.0 : SHARED_LIB : $(st-ps) immutable ;
assert.result foo : $(f) foo#3.0 : SHARED_LIB : $(sh-ps) immutable ;
# test match-type decoding regex
assert.result "" RULE "" : match-type-decode RULE ;
assert.result "!" RULE "" : match-type-decode !RULE ;
assert.result "" RULE "+" : match-type-decode RULE+ ;
assert.result "!" RULE "+" : match-type-decode !RULE+ ;
assert.result : match-type-decode !+ ;
assert.result : match-type-decode "!" ;
assert.result : match-type-decode !RULE! ;
assert.result "!" "R ULE" "+" : match-type-decode "!R ULE+" ;
assert.result "" "R ULE" "" : match-type-decode "R ULE" ;
assert.result : match-type-decode "+" ;
### test type.type overload and register-filenames
import type ;
type.register TESTFILETYPE ;
register-filenames xm-test-file xm-test.txt : TESTFILETYPE ;
import assert ;
assert.result CPP : type.type file.cpp ;
assert.result CPP : type.type path/file.cpp ;
assert.result TESTFILETYPE : type.type xm-test-file ;
assert.result TESTFILETYPE : type.type xm-test.txt ;
assert.result TESTFILETYPE : type.type path/to/xm-test-file ;
assert.result TESTFILETYPE : type.type path/to/xm-test.txt ;
assert.result : type.type unknown-file ;
}