summaryrefslogtreecommitdiff
path: root/src/mongo/embedded/SConscript
blob: d5e00437117f8b7d7df37658abd2b98479b98abd (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
# -*- mode: python; -*-

import re

Import("env")
Import("get_option")
Import("wiredtiger")

env = env.Clone()

env.AppendUnique(
    CPPPATH=["$BUILD_DIR/mongo/embedded"],
)

# Inject this before we call the SDK directory SConscripts so that
# they can both use it.

sdkEnv = env.Clone()


def mongo_export_file_generator(target, source, env, for_signature):
    if env.ToolchainIs("msvc"):
        script = env.File(env.subst("${TARGET.base}.def", target=target))
        return script.get_csig() if for_signature else "/DEF:" + str(script)
    elif env.TargetOSIs("darwin"):
        script = env.File(env.subst("${TARGET.base}.exported_symbols_list", target=target))
        return script.get_csig() if for_signature else "-Wl,-exported_symbols_list," + str(script)
    elif env.TargetOSIs("posix"):
        script = env.File(env.subst("${TARGET.base}.version_script", target=target))
        return script.get_csig() if for_signature else "-Wl,--version-script," + str(script)
    else:
        pass


# We really only want to use the mapfile if we are doing an SDK build. In an ordinary
# dynamic build, we would end up building the normal library with an export map
# but many of its symbols should in fact be coming from other libraries, and we
# get odd ODR-esque violations. UBSAN caught this. Thanks UBSAN!
if get_option("link-model") == "dynamic-sdk":
    sdkEnv["MONGO_EXPORT_FILE_SHLINKFLAGS"] = mongo_export_file_generator

env.SConscript(
    must_exist=1,
    dirs=[
        "stitch_support",
    ],
    exports={
        "env": sdkEnv,
    },
)

yamlEnv = env.Clone()
yamlEnv.InjectThirdParty(libraries=["yaml"])