summaryrefslogtreecommitdiff
path: root/src/third_party/SConscript
blob: 3a820399677849a3809e28cd22097c58ca3d9c70 (plain)
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# -*- mode: python -*-

Import("env use_system_version_of_library usemozjs get_option")
Import("wiredtiger")

boostSuffix = "-1.60.0"
snappySuffix = '-1.1.3'
zlibSuffix = '-1.2.8'
pcreSuffix = "-8.39"
mozjsSuffix = '-45'
yamlSuffix = '-0.5.3'
icuSuffix = '-57.1'
gperftoolsSuffix = '-2.5'

thirdPartyIncludePathList = [
    ('s2', '#/src/third_party/s2'),
    ('tz', '#/src/third_party/tz'),
]

if not use_system_version_of_library('tcmalloc'):
    thirdPartyIncludePathList.append(
        ('gperftools', '#/src/third_party/gperftools' + gperftoolsSuffix + '/src'))

if not use_system_version_of_library('pcre'):
    thirdPartyIncludePathList.append(
        ('pcre', '#/src/third_party/pcre' + pcreSuffix))

if not use_system_version_of_library('boost'):
    thirdPartyIncludePathList.append(
        ('boost', '#/src/third_party/boost' + boostSuffix))

if not use_system_version_of_library('snappy'):
    thirdPartyIncludePathList.append(
        ('snappy', '#/src/third_party/snappy' + snappySuffix))

# Valgrind is a header only include as valgrind.h includes everything we need
if not use_system_version_of_library('valgrind'):
    thirdPartyIncludePathList.append(
        ('valgrind', '#/src/third_party/valgrind-3.11.0/include'))

if not use_system_version_of_library('zlib'):
    thirdPartyIncludePathList.append(
        ('zlib', '#/src/third_party/zlib' + zlibSuffix))

# TODO: figure out if we want to offer system versions of mozjs.  Mozilla
# hasn't offered a source tarball since 24, but in theory they could.
#
#if not use_system_version_of_library('mozjs'):
if True:
    thirdPartyIncludePathList.append(
        ('mozjs', ['#/src/third_party/mozjs' + mozjsSuffix + '/include',
                   '#/src/third_party/mozjs' + mozjsSuffix + '/mongo_sources',
                   '#/src/third_party/mozjs' + mozjsSuffix + '/platform/' + env["TARGET_ARCH"] + "/" + env["TARGET_OS"] + "/include",
        ]))

if not use_system_version_of_library('stemmer'):
    thirdPartyIncludePathList.append(
        ('stemmer', '#/src/third_party/libstemmer_c/include'))

# Note that the wiredtiger.h header is generated, so
# we want to look for it in the build directory not
# the source directory.
# The wiredtiger_ext.h is a static file in the source tree
# In the system installs, wiredtiger.h and wiredtiger_ext.h are in the same directory
if wiredtiger and not use_system_version_of_library('wiredtiger'):
    thirdPartyIncludePathList.append(
        ('wiredtiger', '$BUILD_DIR/third_party/wiredtiger'))
    thirdPartyIncludePathList.append(
        ('wiredtiger_ext', '#/src/third_party/wiredtiger/src/include'))

if not use_system_version_of_library('yaml'):
    thirdPartyIncludePathList.append(
        ('yaml', '#/src/third_party/yaml-cpp' + yamlSuffix + '/include'))

if not use_system_version_of_library('asio'):
    thirdPartyIncludePathList.append(
        ('asio', '#/src/third_party/asio-asio-1-11-0/asio/include'))

if not use_system_version_of_library('intel_decimal128'):
    thirdPartyIncludePathList.append(
        ('intel_decimal128', '#/src/third_party/IntelRDFPMathLib20U1/LIBRARY'))

if not use_system_version_of_library('icu'):
    thirdPartyIncludePathList.append(
        ('icu', '#/src/third_party/icu4c' + icuSuffix + '/source/common'))
    thirdPartyIncludePathList.append(
        ('icu', '#/src/third_party/icu4c' + icuSuffix + '/source/i18n'))

def injectAllThirdPartyIncludePaths(thisEnv):
    thisEnv.PrependUnique(CPPPATH=[entry[1] for entry in thirdPartyIncludePathList])

def injectThirdPartyIncludePaths(thisEnv, libraries):
    thisEnv.PrependUnique(CPPPATH=[
        entry[1] for entry in thirdPartyIncludePathList if entry[0] in libraries])

env.AddMethod(injectAllThirdPartyIncludePaths, 'InjectAllThirdPartyIncludePaths')
env.AddMethod(injectThirdPartyIncludePaths, 'InjectThirdPartyIncludePaths')


murmurEnv = env.Clone()
murmurEnv.SConscript('murmurhash3/SConscript', exports={ 'env' : murmurEnv })


s2Env = env.Clone()
s2Env.InjectThirdPartyIncludePaths(libraries=['s2', 'boost'])
s2Env.InjectMongoIncludePaths()
s2Env.SConscript('s2/SConscript', exports={'env' : s2Env})


if use_system_version_of_library("pcre"):
    pcreEnv = env.Clone(
        SYSLIBDEPS=[
            env['LIBDEPS_PCRE_SYSLIBDEP'],
            env['LIBDEPS_PCRECPP_SYSLIBDEP'],
        ])
else:
    pcreEnv = env.Clone()
    pcreEnv.InjectThirdPartyIncludePaths(libraries=['pcre'])
    pcreEnv.SConscript('pcre' + pcreSuffix + '/SConscript', exports={ 'env' : pcreEnv })
    pcreEnv = pcreEnv.Clone(
        LIBDEPS=[
            'pcre' + pcreSuffix + '/pcrecpp',
        ])

pcreEnv.Library(
    target="shim_pcrecpp",
    source=[
        'shim_pcrecpp.cc',
    ])


boostEnv = env
if use_system_version_of_library("boost"):
    # On windows, we don't need the syslibdeps because autolib will select the right libraries
    # for us automatically.
    if not env.TargetOSIs('windows'):
        boostEnv = env.Clone(
            SYSLIBDEPS=[
                env['LIBDEPS_BOOST_PROGRAM_OPTIONS_SYSLIBDEP'],
                env['LIBDEPS_BOOST_FILESYSTEM_SYSLIBDEP'],
                env['LIBDEPS_BOOST_THREAD_SYSLIBDEP'],
                env['LIBDEPS_BOOST_SYSTEM_SYSLIBDEP'],
                env['LIBDEPS_BOOST_IOSTREAMS_SYSLIBDEP'],
                env['LIBDEPS_BOOST_CHRONO_SYSLIBDEP'],
                env['LIBDEPS_BOOST_REGEX_SYSLIBDEP'],
            ])
else:
    boostDirectory = 'boost' + boostSuffix
    boostEnv = env.Clone()
    boostEnv.InjectThirdPartyIncludePaths(libraries=['boost'])
    boostEnv.SConscript(boostDirectory + '/SConscript', exports={ 'env' : boostEnv })
    boostEnv = boostEnv.Clone(
        LIBDEPS=[
            boostDirectory + '/boost_program_options',
            boostDirectory + '/boost_filesystem',
            boostDirectory + '/boost_thread',
            boostDirectory + '/boost_system',
            boostDirectory + '/boost_chrono',
            boostDirectory + '/boost_iostreams',
            boostDirectory + '/boost_regex',
        ])

boostEnv.Library(
    target="shim_boost",
    source=[
        'shim_boost.cpp',
    ])


if use_system_version_of_library("snappy"):
    snappyEnv = env.Clone(
        SYSLIBDEPS=[
            env['LIBDEPS_SNAPPY_SYSLIBDEP'],
        ])
else:
    snappyEnv = env.Clone()
    snappyEnv.InjectThirdPartyIncludePaths(libraries=['snappy'])
    snappyEnv.InjectMongoIncludePaths()
    snappyEnv.SConscript('snappy' + snappySuffix + '/SConscript', exports={ 'env' : snappyEnv })
    snappyEnv = snappyEnv.Clone(
        LIBDEPS=[
            'snappy' + snappySuffix + '/snappy',
        ])

snappyEnv.Library(
    target="shim_snappy",
    source=[
        'shim_snappy.cpp',
    ])

if use_system_version_of_library("zlib"):
    zlibEnv = env.Clone(
        SYSLIBDEPS=[
            env['LIBDEPS_ZLIB_SYSLIBDEP'],
        ])
else:
    zlibEnv = env.Clone()
    zlibEnv.InjectThirdPartyIncludePaths(libraries=['zlib'])
    zlibEnv.InjectMongoIncludePaths()
    zlibEnv.SConscript('zlib' + zlibSuffix + '/SConscript', exports={ 'env' : zlibEnv })
    zlibEnv = zlibEnv.Clone(
        LIBDEPS=[
            'zlib' + zlibSuffix + '/zlib',
        ])

zlibEnv.Library(
    target="shim_zlib",
    source=[
        'shim_zlib.cpp',
    ])

if usemozjs:
    mozjsEnv = env.Clone()
    mozjsEnv.SConscript('mozjs' + mozjsSuffix + '/SConscript', exports={'env' : mozjsEnv })
    mozjsEnv = mozjsEnv.Clone(
        LIBDEPS=[
            'mozjs' + mozjsSuffix + '/mozjs',
            'shim_zlib',
        ])

    mozjsEnv.Library(
        target="shim_mozjs",
        source=[
            'shim_mozjs.cpp',
        ])

gperftoolsEnv = env
if (gperftoolsEnv['MONGO_ALLOCATOR'] == "tcmalloc"):
    if use_system_version_of_library("tcmalloc"):
        gperftoolsEnv = env.Clone(
            SYSLIBDEPS=[
                env['LIBDEPS_TCMALLOC_SYSLIBDEP'],
            ])
    else:
        gperftoolsEnv = env.Clone()
        gperftoolsEnv.InjectThirdPartyIncludePaths(libraries=['gperftools'])
        gperftoolsEnv.InjectMongoIncludePaths()
        gperftoolsEnv.SConscript('gperftools' + gperftoolsSuffix + '/SConscript', exports={ 'env' : gperftoolsEnv })
        gperftoolsEnv = gperftoolsEnv.Clone(
            LIBDEPS=[
                'gperftools' + gperftoolsSuffix + '/tcmalloc_minimal',
            ])

gperftoolsEnv.Library(
    target="shim_allocator",
    source=[
        "shim_allocator.cpp",
    ])


if use_system_version_of_library("stemmer"):
    stemmerEnv = env.Clone(
        SYSLIBDEPS=[
            env['LIBDEPS_STEMMER_SYSLIBDEP'],
        ])
else:
    stemmerEnv = env.Clone()
    stemmerEnv.InjectThirdPartyIncludePaths(libraries=['stemmer'])
    stemmerEnv.SConscript('libstemmer_c/SConscript', exports={ 'env' : stemmerEnv })
    stemmerEnv = stemmerEnv.Clone(
        LIBDEPS=[
            'libstemmer_c/stemmer',
        ])

stemmerEnv.Library(
    target="shim_stemmer",
    source=[
        'shim_stemmer.cpp'
    ])


if use_system_version_of_library("yaml"):
    yamlEnv = env.Clone(
        SYSLIBDEPS=[
            env['LIBDEPS_YAML_SYSLIBDEP'],
        ])
else:
    yamlEnv = env.Clone()
    yamlEnv.InjectThirdPartyIncludePaths(libraries=['yaml', 'boost'])
    yamlEnv.SConscript('yaml-cpp' + yamlSuffix + '/SConscript', exports={ 'env' : yamlEnv })
    yamlEnv = yamlEnv.Clone(
        LIBDEPS=[
            'yaml-cpp' + yamlSuffix + '/yaml',
        ])

yamlEnv.Library(
    target="shim_yaml",
    source=[
        'shim_yaml.cpp',
    ])


tzEnv = env.Clone()
if env.TargetOSIs('solaris'):
    tzEnv.InjectThirdPartyIncludePaths(libraries=['tz'])
    tzEnv.SConscript('tz/SConscript', exports={ 'env' : tzEnv })
    tzEnv = tzEnv.Clone(
        LIBDEPS=[
            'tz/tz',
        ])

tzEnv.Library(
    target='shim_tz',
    source=[
        'shim_tz.cpp',
    ])


if wiredtiger:
    if use_system_version_of_library("wiredtiger"):
        wiredtigerEnv = env.Clone(
            SYSLIBDEPS=[
                env['LIBDEPS_WIREDTIGER_SYSLIBDEP'],
            ])
    else:
        wiredtigerEnv = env.Clone()
        wiredtigerEnv.InjectThirdPartyIncludePaths(libraries=['wiredtiger'])
        wiredtigerEnv.SConscript('wiredtiger/SConscript', exports={ 'env' : wiredtigerEnv })
        wiredtigerEnv = wiredtigerEnv.Clone(
            LIBDEPS=[
                'wiredtiger/wiredtiger',
            ])

    wiredtigerEnv.Library(
        target="shim_wiredtiger",
        source=[
            'shim_wiredtiger.cpp'
        ])

if use_system_version_of_library("asio"):
    # Normally, we would request LIBDEPS_ASIO_SYSLIBDEP here, but on most systems, the system asio
    # will be header only so there is no library required. In the rare case where one is, it can be
    # injected via LIBS= on the command line.
    asioEnv = env.Clone()
else:
    asioEnv = env.Clone()
    asioEnv.InjectThirdPartyIncludePaths(libraries=['asio'])
    asioEnv.SConscript('asio-asio-1-11-0/SConscript', exports={ 'env' : asioEnv })
    asioEnv = asioEnv.Clone(
        LIBDEPS=[
            'asio-asio-1-11-0/asio',
        ])

asioEnv.Library(
    target="shim_asio",
    source=[
        'shim_asio.cpp'
    ])

if use_system_version_of_library("intel_decimal128"):
    intelDecimal128Env = env.Clone(
	SYSLIBDEPS=[
	    env['LIBDEPS_INTEL_DECIMAL128_SYSLIBDEP'],
	])
else:
    intelDecimal128Env = env.Clone()
    intelDecimal128Env.InjectThirdPartyIncludePaths(libraries=['intel_decimal128'])
    intelDecimal128Env.SConscript('IntelRDFPMathLib20U1/SConscript', exports={ 'env' : intelDecimal128Env })
    intelDecimal128Env = intelDecimal128Env.Clone(
	LIBDEPS=[
	    'IntelRDFPMathLib20U1/intel_decimal128',
	])

intelDecimal128Env.Library(
    target="shim_intel_decimal128",
    source=[
	'shim_intel_decimal128.cpp'
    ])

if use_system_version_of_library("icu"):
    icuEnv = env.Clone(
        SYSLIBDEPS=[
            env['LIBDEPS_ICUDATA_SYSLIBDEP'],
            env['LIBDEPS_ICUI18N_SYSLIBDEP'],
            env['LIBDEPS_ICUUC_SYSLIBDEP'],
        ])
else:
    icuEnv = env.Clone()
    icuEnv.InjectThirdPartyIncludePaths(libraries=['icu'])
    icuEnv.SConscript('icu4c' + icuSuffix + '/source/SConscript', exports={ 'env' : icuEnv })
    icuEnv = icuEnv.Clone(
        LIBDEPS=[
            'icu4c' + icuSuffix + '/source/icu_i18n',
        ])

icuEnv.Library(
    target='shim_icu',
    source=[
        'shim_icu.cpp',
    ])