summaryrefslogtreecommitdiff
path: root/src/third_party/SConscript
blob: 178dcf1d9ded4488c1c936ca13437d78e8f25c81 (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
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
# -*- mode: python -*-

import json

Import([
    'env',
    'get_option',
    'jsEngine',
    'use_libunwind',
    'use_system_libunwind',
    'use_system_version_of_library',
    'use_vendored_libunwind',
    'wiredtiger',
])

snappySuffix = '-1.1.7'
icuSuffix = '-57.1'
timelibSuffix = '-2021.06'
tomcryptSuffix = '-1.18.2'
variantSuffix = '-1.4.0'

thirdPartyEnvironmentModifications = {
    'abseil-cpp': {'CPPPATH': ['#/src/third_party/abseil-cpp-master/abseil-cpp'], },
    'fmt': {'CPPPATH': ['#src/third_party/fmt/dist/include'], },
    's2': {'CPPPATH': ['#src/third_party/s2'], },
    'safeint': {
        'CPPPATH': ['#src/third_party/SafeInt'],
        # SAFEINT_USE_INTRINSICS=0 for overflow-safe constexpr multiply. See comment in SafeInt.hpp.
        'CPPDEFINES': [('SAFEINT_USE_INTRINSICS', 0)],
    },
    'timelib': {'CPPPATH': ['#/src/third_party/timelib' + timelibSuffix], },
    'unwind': {},
    'variant': {'CPPPATH': ['#src/third_party/variant' + variantSuffix + '/include'], },
    'mozjs': {
        'CPPPATH': [
            '#/src/third_party/mozjs/include',
            '#/src/third_party/mozjs/mongo_sources',
            '#/src/third_party/mozjs/platform/' + env["TARGET_ARCH"] + "/" + env["TARGET_OS"] +
            "/include",
        ],
        'FORCEINCLUDES': ['js-config.h', ],
    }
}


def injectMozJS(thisEnv):
    thisEnv.InjectThirdParty(libraries=['mozjs'])

    if thisEnv.TargetOSIs('windows'):
        thisEnv.Append(CPPDEFINES=[
            '_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING',
        ], )
    else:
        thisEnv.Append(CXXFLAGS=[
            '-Wno-non-virtual-dtor',
            '-Wno-invalid-offsetof',
        ], )

    thisEnv.Prepend(CPPDEFINES=[
        'JS_USE_CUSTOM_ALLOCATOR',
        'STATIC_JS_API=1',
    ])

    if get_option('spider-monkey-dbg') == "on":
        thisEnv.Prepend(CPPDEFINES=[
            'DEBUG',
            'JS_DEBUG',
        ])


env.AddMethod(injectMozJS, 'InjectMozJS')

if not use_system_version_of_library('tcmalloc'):
    # GPerftools does this slightly differently than the others.
    thirdPartyEnvironmentModifications['gperftools'] = {}

if not use_system_version_of_library('pcre2'):
    thirdPartyEnvironmentModifications['pcre2'] = {
        'CPPPATH': ['#/src/third_party/pcre2/src'],
    }

if not use_system_version_of_library('boost'):

    # On at least Apple clang, proto throws this error.
    #
    # See https://github.com/boostorg/proto/issues/30.
    #
    # We use a generator so we can filter out conf tests, where applying this
    # flag could change their meaning.
    def NoErrorForUnknownWarningOptionGenerator(target, source, env, for_signature):
        if 'conftest' in str(target[0]):
            return str()
        return '-Wno-error=unknown-warning-option'

    thirdPartyEnvironmentModifications['boost'] = {
        'CPPPATH': ['#/src/third_party/boost'],

        # We could narror further to just clang on Darwin, but there is
        # little harm in applying for all clang.
        'NOERROR_FOR_UNKNOWN_WARNING_OPTION_GEN': NoErrorForUnknownWarningOptionGenerator,
        'CCFLAGS': ['$NOERROR_FOR_UNKNOWN_WARNING_OPTION_GEN'] if env.ToolchainIs('clang') else []
    }

if not use_system_version_of_library('snappy'):
    thirdPartyEnvironmentModifications['snappy'] = {
        'CPPPATH': ['#/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'):
    thirdPartyEnvironmentModifications['valgrind'] = {
        'CPPPATH': ['#/src/third_party/valgrind/include'],
    }

if not use_system_version_of_library('zlib'):
    thirdPartyEnvironmentModifications['zlib'] = {
        'CPPPATH': ['#/src/third_party/zlib'],
    }

if not use_system_version_of_library('zstd'):
    thirdPartyEnvironmentModifications['zstd'] = {
        'CPPPATH': ['#/src/third_party/zstandard/zstd/lib'],
    }

if not use_system_version_of_library('google-benchmark'):
    thirdPartyEnvironmentModifications['benchmark'] = {
        'CPPPATH': ['#/src/third_party/benchmark/dist/include'],
    }

if "tom" in env["MONGO_CRYPTO"]:
    thirdPartyEnvironmentModifications['tomcrypt'] = {
        'CPPPATH': ['#/src/third_party/tomcrypt' + tomcryptSuffix + '/src/headers'],
    }

if not use_system_version_of_library('stemmer'):
    thirdPartyEnvironmentModifications['stemmer'] = {
        'CPPPATH': ['#/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.
if wiredtiger and not use_system_version_of_library('wiredtiger'):
    thirdPartyEnvironmentModifications['wiredtiger'] = {
        'CPPPATH': ['$BUILD_DIR/third_party/wiredtiger'],
    }

if not use_system_version_of_library('yaml'):
    thirdPartyEnvironmentModifications['yaml'] = {
        'CPPPATH': ['#/src/third_party/yaml-cpp/yaml-cpp/include'],
        'CPPDEFINES': ['_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING']
                      if env.ToolchainIs('msvc') else [],
    }

if not use_system_version_of_library('asio'):
    thirdPartyEnvironmentModifications['asio'] = {
        'CPPPATH': ['#/src/third_party/asio-master/asio/include'],
    }

if not use_system_version_of_library('intel_decimal128'):
    thirdPartyEnvironmentModifications['intel_decimal128'] = {
        'CPPPATH': ['#/src/third_party/IntelRDFPMathLib20U1/LIBRARY'],
    }

if not use_system_version_of_library('icu'):
    thirdPartyEnvironmentModifications['icu'] = {
        'CPPPATH': [
            '#/src/third_party/icu4c' + icuSuffix + '/source/common',
            '#/src/third_party/icu4c' + icuSuffix + '/source/i18n',
        ],
    }

if not use_system_version_of_library('kms-message'):
    thirdPartyEnvironmentModifications['kms-message'] = {
        'CPPPATH': ['#/src/third_party/kms-message/src'],
        'CPPDEFINES': ['KMS_MSG_STATIC'],
    }

if use_system_libunwind:
    thirdPartyEnvironmentModifications['unwind'] = {
        'SYSLIBDEPS_PRIVATE': [env['LIBDEPS_UNWIND_SYSLIBDEP'], env['LIBDEPS_LZMA_SYSLIBDEP']],
    }
elif use_vendored_libunwind:
    thirdPartyEnvironmentModifications['unwind'] = {
        'SYSLIBDEPS_PRIVATE': [env['LIBDEPS_LZMA_SYSLIBDEP']],
    }


def injectThirdParty(thisEnv, libraries=[], parts=[]):
    libraries = thisEnv.Flatten([libraries])
    parts = thisEnv.Flatten([parts])
    for lib in libraries:
        mods = thirdPartyEnvironmentModifications.get(lib, None)
        if mods is None:
            continue
        if not parts:
            thisEnv.PrependUnique(**mods)
        else:
            for part in parts:
                thisEnv.PrependUnique({part: mods[part]})


env.AddMethod(injectThirdParty, 'InjectThirdParty')

env = env.Clone()

# Construct an empty object file that we can use to produce the
# library for every shim. This avoids the need to create and name a
# different empty source file for every third-party library, as we did
# in the past.

empty_source = env.Textfile(
    target='third_party_shim.cpp',
    source=str(),
)
env.Alias('generated-sources', empty_source)

empty_object = env.LibraryObject(
    target='third_party_shim',
    source=empty_source,
)


def shim_library(env, name, **kwargs):
    # Add the 'virtual-libdep' tag, which will prevent shim libraries
    # from actually being linked to. They don't provide any symbols,
    # so there is no need to do so. Instead, they just act as a node
    # in the library dependency graph to reach other libraries.
    libdeps_tags = kwargs.get('LIBDEPS_TAGS', env.get('LIBDEPS_TAGS', [])).copy()
    libdeps_tags.append('virtual-libdep')
    kwargs['LIBDEPS_TAGS'] = libdeps_tags
    return env.Library(
        target=f'shim_{name}',
        source=empty_object[0],
        # Since nothing will link to this library per the
        # `virtual-libdep` tag above, we can also skip installing it.
        AIB_IGNORE=True,
        **kwargs,
    )


env.AddMethod(shim_library, 'ShimLibrary')

murmurEnv = env.Clone()
murmurEnv.InjectThirdParty(libraries=['fmt'])
murmurEnv.SConscript('murmurhash3/SConscript', exports={'env': murmurEnv})

s2Env = env.Clone()
s2Env.InjectThirdParty(libraries=[
    's2',
    'boost',
    'abseil-cpp',
    'fmt',
    'safeint',
    'variant',
])
s2Env.InjectMongoIncludePaths()
s2Env.SConscript('s2/SConscript', exports={'env': s2Env})

if jsEngine:
    mozjsEnv = env.Clone()
    mozjsEnv.SConscript('mozjs/SConscript', exports={'env': mozjsEnv})

if use_libunwind:
    unwindEnv = env.Clone(LIBDEPS_NO_INHERIT=[
        '$BUILD_DIR/third_party/shim_allocator',
    ], )
    if use_system_libunwind:
        unwindEnv = unwindEnv.Clone(SYSLIBDEPS=[
            env['LIBDEPS_UNWIND_SYSLIBDEP'],
        ])
    else:
        unwindEnv = unwindEnv.Clone()

        # SCons uses the "$CC" tool for both C and assembler files. Distinguish them for the sake of
        # later tools like our Ninja SCons module.
        unwindEnv['ASPP'] = '$CC'
        unwindEnv['ASPPCOM'] = unwindEnv['ASPPCOM'].replace('$CC ', '$ASPP ')

        def registerConsumerModifications(env, **kwargs):
            for k, v in kwargs.items():
                thirdPartyEnvironmentModifications['unwind'][k] = v

        unwindEnv.AddMethod(registerConsumerModifications, 'RegisterConsumerModifications')
        unwindEnv.SConscript('unwind/SConscript', exports={'env': unwindEnv})
        unwindEnv.Append(LIBDEPS_INTERFACE=[
            'unwind/unwind',
        ])

    unwindEnv.ShimLibrary(name="unwind", )

fmtEnv = env.Clone()
if use_system_version_of_library("fmt"):
    fmtEnv = fmtEnv.Clone(SYSLIBDEPS=[
        env['LIBDEPS_FMT_SYSLIBDEP'],
    ])
else:
    fmtEnv = fmtEnv.Clone()
    fmtEnv.InjectThirdParty(libraries=['fmt'])
    fmtEnv.InjectMongoIncludePaths()
    fmtEnv.SConscript('fmt/SConscript', exports={'env': fmtEnv})
    fmtEnv = fmtEnv.Clone(LIBDEPS_INTERFACE=[
        'fmt/fmt',
    ])

fmtEnv.ShimLibrary(name="fmt")

pcre2Env = env.Clone()
if use_system_version_of_library("pcre2"):
    pcre2Env = pcre2Env.Clone(SYSLIBDEPS=[
        env['LIBDEPS_PCRE2_SYSLIBDEP'],
    ])
else:
    pcre2Env = pcre2Env.Clone()
    pcre2Env.InjectThirdParty(libraries=['pcre2'])
    pcre2Env.SConscript('pcre2' + '/SConscript', exports={'env': pcre2Env})
    pcre2Env = pcre2Env.Clone(LIBDEPS_INTERFACE=[
        'pcre2/pcre2',
    ])

pcre2Env.ShimLibrary(name="pcre2")

boostEnv = env.Clone()
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 = boostEnv.Clone(SYSLIBDEPS=[
            env['LIBDEPS_BOOST_PROGRAM_OPTIONS_SYSLIBDEP'],
            env['LIBDEPS_BOOST_FILESYSTEM_SYSLIBDEP'],
            env['LIBDEPS_BOOST_SYSTEM_SYSLIBDEP'],
            env['LIBDEPS_BOOST_IOSTREAMS_SYSLIBDEP'],
            env['LIBDEPS_BOOST_THREAD_SYSLIBDEP'],
            env['LIBDEPS_BOOST_LOG_SYSLIBDEP'],
        ])
else:
    boostDirectory = 'boost'
    boostEnv = boostEnv.Clone()
    boostEnv.InjectThirdParty(libraries=['boost'])
    boostEnv.SConscript(boostDirectory + '/SConscript', exports={'env': boostEnv})
    boostEnv = boostEnv.Clone(LIBDEPS_INTERFACE=[
        boostDirectory + '/boost_filesystem',
        boostDirectory + '/boost_iostreams',
        boostDirectory + '/boost_log',
        boostDirectory + '/boost_program_options',
        boostDirectory + '/boost_system',
    ])

boostEnv.ShimLibrary(name="boost")

abseilDirectory = 'abseil-cpp-master'
abseilEnv = env.Clone()
abseilEnv.InjectThirdParty(libraries=['abseil-cpp'])
abseilEnv.SConscript(abseilDirectory + '/SConscript', exports={'env': abseilEnv})
abseilEnv = abseilEnv.Clone(LIBDEPS_INTERFACE=[
    abseilDirectory + '/absl_container',
    abseilDirectory + '/absl_hash',
    abseilDirectory + '/absl_numeric',
])

abseilEnv.ShimLibrary(name="abseil")

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

snappyEnv.ShimLibrary(name="snappy")

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

zlibEnv.ShimLibrary(name="zlib", )

zstdEnv = env.Clone()
if use_system_version_of_library("zstd"):
    zstdEnv = zstdEnv.Clone(SYSLIBDEPS=[
        env['LIBDEPS_ZSTD_SYSLIBDEP'],
    ])
else:
    zstdEnv = zstdEnv.Clone()
    zstdEnv.InjectThirdParty(libraries=['zstd'])
    zstdEnv.SConscript('zstandard/SConscript', exports={'env': zstdEnv})
    zstdEnv = zstdEnv.Clone(LIBDEPS_INTERFACE=[
        'zstandard/zstd',
    ])

zstdEnv.ShimLibrary(name="zstd", )

benchmarkEnv = env.Clone()
if use_system_version_of_library("google-benchmark"):
    benchmarkEnv = benchmarkEnv.Clone(SYSLIBDEPS=[
        env['LIBDEPS_BENCHMARK_SYSLIBDEP'],
    ])
else:
    benchmarkEnv = benchmarkEnv.Clone()
    benchmarkEnv.InjectThirdParty(libraries=['benchmark'])
    benchmarkEnv.SConscript(
        'benchmark/SConscript',
        exports={'env': benchmarkEnv},
    )
    benchmarkEnv = benchmarkEnv.Clone(LIBDEPS_INTERFACE=[
        'benchmark/benchmark',
    ])

benchmarkEnv.ShimLibrary(name="benchmark")

if "tom" in env["MONGO_CRYPTO"]:
    tomcryptEnv = env.Clone()
    tomcryptEnv.SConscript(
        'tomcrypt' + tomcryptSuffix + '/SConscript',
        exports={'env': tomcryptEnv},
    )
    tomcryptEnv = tomcryptEnv.Clone(LIBDEPS_INTERFACE=[
        'tomcrypt' + tomcryptSuffix + '/tomcrypt',
    ])

    tomcryptEnv.ShimLibrary(name="tomcrypt", )

gperftoolsEnv = env.Clone(LIBDEPS_NO_INHERIT=[
    '$BUILD_DIR/third_party/shim_allocator',
], )
if gperftoolsEnv['MONGO_ALLOCATOR'] in ["tcmalloc", "tcmalloc-experimental"]:
    if use_system_version_of_library("tcmalloc"):
        gperftoolsEnv = gperftoolsEnv.Clone(SYSLIBDEPS=[
            env['LIBDEPS_TCMALLOC_SYSLIBDEP'],
        ])
    else:
        gperftoolsEnv = gperftoolsEnv.Clone()
        gperftoolsEnv.InjectThirdParty(libraries=['gperftools'])

        # Allow gperftools to determine its own consumer-side include/ dirs.
        # Needed because those are in a platform-specific subdirectory.
        def registerConsumerModifications(env, **kwargs):
            for k, v in kwargs.items():
                thirdPartyEnvironmentModifications['gperftools'][k] = v

        gperftoolsEnv.AddMethod(registerConsumerModifications, 'RegisterConsumerModifications')
        gperftoolsEnv.SConscript(
            'gperftools' + '/SConscript',
            exports={'env': gperftoolsEnv},
        )
        gperftoolsEnv = gperftoolsEnv.Clone(LIBDEPS_INTERFACE=[
            'gperftools/tcmalloc_minimal',
        ])

gperftoolsEnv.ShimLibrary(
    name="allocator",
    LIBDEPS_TAGS=[
        # TODO: Remove when SERVER-48291 is merged into stable build tools.
        # An inserted dependency must be linked to every node, including what would
        # be considered a leaf node to ensure that a system dependency is not linked
        # in before this one. This tag allows nodes tagged as leaf nodes to still
        # get the correct allocator.
        'lint-leaf-node-allowed-dep',
        # This tag allows this dependency to be linked to nodes marked as not
        # allowed to have public dependencies.
        'lint-public-dep-allowed'
    ],
)

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

stemmerEnv.ShimLibrary(name="stemmer")

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

yamlEnv.ShimLibrary(name="yaml")

timelibEnv = env.Clone()
timelibEnv.InjectThirdParty(libraries=['timelib'])
timelibEnv.SConscript('timelib' + timelibSuffix + '/SConscript', exports={'env': timelibEnv})
timelibEnv = timelibEnv.Clone(LIBDEPS_INTERFACE=[
    'timelib' + timelibSuffix + '/timelib',
])

timelibEnv.ShimLibrary(name='timelib', )

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

    wiredtigerEnv.ShimLibrary(name="wiredtiger")

asioEnv = env.Clone()
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 = asioEnv.Clone()
else:
    asioEnv = asioEnv.Clone()
    asioEnv.InjectThirdParty(libraries=['asio'])
    asioEnv.SConscript('asio-master/SConscript', exports={'env': asioEnv})
    asioEnv = asioEnv.Clone(LIBDEPS_INTERFACE=[
        'asio-master/asio',
    ])

asioEnv.ShimLibrary(name="asio")

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

intelDecimal128Env.ShimLibrary(name="intel_decimal128", )

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

icuEnv.ShimLibrary(name="icu", )

kmsEnv = env.Clone()
if get_option('ssl') == 'on':
    if use_system_version_of_library("kms-message"):
        kmsEnv = kmsEnv.Clone(SYSLIBDEPS=[
            env['LIBDEPS_KMS-MESSAGE_SYSLIBDEP'],
        ])
    else:
        kmsEnv = kmsEnv.Clone()
        kmsEnv.InjectThirdParty(libraries=['kms-message'])
        kmsEnv.SConscript('kms-message/SConscript', exports={'env': kmsEnv})
        kmsEnv = kmsEnv.Clone(LIBDEPS_INTERFACE=[
            'kms-message/kms-message',
        ])

    kmsEnv.ShimLibrary(name="kms_message", )