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

Import(
    [
        "env",
        "get_option",
        "has_option",
        "jsEngine",
        "version_parts",
        "version_extra",
    ]
)

env = env.Clone()


def shouldBuildGRPC(myEnv):
    return myEnv.TargetOSIs("linux") and myEnv["ENABLE_GRPC_BUILD"]


if shouldBuildGRPC(env):
    env.InjectThirdParty(libraries=["grpc"])


env.Library(
    target="shell_utils",
    source=[
        "mongo-server.cpp",
        "named_pipe_test_helper.cpp",
        "shell_options.cpp",
        "shell_utils.cpp",
        "shell_utils_extended.cpp",
        "shell_utils_launcher.cpp",
    ],
    LIBDEPS=[
        "$BUILD_DIR/mongo/base/environment_buffer",
        "$BUILD_DIR/mongo/client/clientdriver_network",
        "$BUILD_DIR/mongo/db/mongohasher",
        "$BUILD_DIR/mongo/db/traffic_reader",
        "$BUILD_DIR/mongo/scripting/scripting",
        "$BUILD_DIR/mongo/transport/message_compressor",
        "$BUILD_DIR/mongo/unittest/golden_test_base",
        "$BUILD_DIR/mongo/util/password",
        "benchrun",
        "shell_options_storage",
    ],
    LIBDEPS_PRIVATE=[
        "$BUILD_DIR/mongo/bson/util/bson_column",
        "$BUILD_DIR/mongo/db/auth/security_token_auth",
        "$BUILD_DIR/mongo/db/query/collation/collator_icu",
        "$BUILD_DIR/mongo/db/storage/record_store_base",
        "$BUILD_DIR/mongo/util/icu",
        "program_runner",
    ],
)

if get_option("ssl") == "on":
    kmsEnv = env.Clone()

    env.Library(
        target="kms_shell",
        source=[
            "kms_shell.cpp",
        ],
        LIBDEPS_PRIVATE=[
            "kms",
            "shell_utils",
        ],
    )

    if get_option("js-engine") != "none":
        scriptingEnv = env.Clone()

        scriptingEnv.Append(
            CXXFLAGS=[
                "/Zc:preprocessor",
                "/wd5104",
                "/wd5105",
            ]
            if scriptingEnv.TargetOSIs("windows")
            else [
                # TODO(SERVER-59992): Remove -Wno-class-memacces where possible.
                "-Wno-unknown-warning-option",
                "-Wno-class-memaccess",
                # TODO(SERVER-77205): Review and Possibly Remove '-Wno-deprecated' After Mozjs Update
                "-Wno-deprecated",
            ],
        )
        scriptingEnv.InjectMozJS()

        scriptingEnv.Library(
            target="encrypted_dbclient",
            source=[
                "encrypted_dbclient_base.cpp",
            ],
            LIBDEPS_PRIVATE=[
                "$BUILD_DIR/mongo/client/clientdriver_minimal",
                "$BUILD_DIR/mongo/crypto/aead_encryption",
                "$BUILD_DIR/mongo/crypto/encrypted_field_config",
                "$BUILD_DIR/mongo/crypto/fle_crypto",
                "$BUILD_DIR/mongo/crypto/fle_fields",
                "$BUILD_DIR/mongo/crypto/symmetric_crypto",
                "$BUILD_DIR/mongo/db/query_expressions",
                "$BUILD_DIR/mongo/scripting/scripting",
                "$BUILD_DIR/mongo/shell/shell_options_register",
                "$BUILD_DIR/third_party/mozjs/mozjs",
                "kms",
            ],
        )

if not has_option("noshell") and jsEngine:
    env.Library(
        target="mongo_initializers",
        source=[
            "shell_options_init.cpp",
        ],
        LIBDEPS_PRIVATE=[
            # NOTE: If you need to add a static or mongo initializer to mongo startup,
            # please add that library here, as a private library dependency.
            "$BUILD_DIR/mongo/client/clientdriver_network",
            "$BUILD_DIR/mongo/client/connection_string",
            "$BUILD_DIR/mongo/client/cyrus_sasl_client" if env["MONGO_BUILD_SASL_CLIENT"] else "",
            "$BUILD_DIR/mongo/db/catalog/index_key_validate",
            "$BUILD_DIR/mongo/db/modules/enterprise/src/fips/fips_mode_client"
            if "fle" in env.get("MONGO_ENTERPRISE_FEATURES", [])
            and get_option("js-engine") != "none"
            else "",
            "$BUILD_DIR/mongo/db/modules/enterprise/src/fle/shell/implicit_encrypted_dbclient"
            if "fle" in env.get("MONGO_ENTERPRISE_FEATURES", [])
            and get_option("js-engine") != "none"
            else "",
            "$BUILD_DIR/mongo/db/mongohasher",
            "$BUILD_DIR/mongo/db/pipeline/change_stream_error_extra_info",
            "$BUILD_DIR/mongo/db/query/command_request_response",
            "$BUILD_DIR/mongo/db/query/query_request",
            "$BUILD_DIR/mongo/db/server_base",
            "$BUILD_DIR/mongo/db/service_context_non_d",
            "$BUILD_DIR/mongo/db/session/logical_session_id_helpers",
            "$BUILD_DIR/mongo/db/storage/duplicate_key_error_info",
            "$BUILD_DIR/mongo/db/timeseries/bucket_compression_failure",
            "$BUILD_DIR/mongo/db/traffic_reader",
            "$BUILD_DIR/mongo/db/views/resolved_view",
            "$BUILD_DIR/mongo/executor/async_rpc_error_info",
            "$BUILD_DIR/mongo/executor/network_interface_factory",
            "$BUILD_DIR/mongo/executor/network_interface_thread_pool",
            "$BUILD_DIR/mongo/executor/thread_pool_task_executor",
            "$BUILD_DIR/mongo/rpc/message",
            "$BUILD_DIR/mongo/scripting/scripting",
            "$BUILD_DIR/mongo/transport/message_compressor",
            "$BUILD_DIR/mongo/transport/message_compressor_options_client",
            "$BUILD_DIR/mongo/transport/transport_layer_manager",
            "$BUILD_DIR/mongo/util/net/http_client_impl",
            "$BUILD_DIR/mongo/util/net/network",
            "$BUILD_DIR/mongo/util/net/ssl_options_client" if get_option("ssl") == "on" else "",
            "$BUILD_DIR/mongo/util/options_parser/options_parser_init",
            "$BUILD_DIR/mongo/util/password",
            "$BUILD_DIR/mongo/util/processinfo",
            "$BUILD_DIR/mongo/util/signal_handlers",
            "$BUILD_DIR/mongo/util/version_impl",
            "benchrun",
            "encrypted_dbclient" if get_option("ssl") == "on" else "",
            "kms_shell" if get_option("ssl") == "on" else "",
            "mongojs",
            "shell_options_register",
            "shell_utils",
        ],
        LIBDEPS=[
            # NOTE: This list must remain empty. Please only add to LIBDEPS_PRIVATE
        ],
    )

    env.Library(
        target="mongo_main",
        source=[
            "mongo_main.cpp",
        ],
        LIBDEPS_PRIVATE=[
            # NOTE: Do not add new libdeps (public or private) here unless
            # required by the linker to satisfy symbol dependencies from
            # the files listed above in `sources`. If you need to add a
            # library to inject a static or mongo initializer to mongo,
            # please add that library as a private libdep of
            # mongo_initializers.
            "$BUILD_DIR/mongo/s/grid",
            "$BUILD_DIR/mongo/s/write_ops/batch_write_types",
            "$BUILD_DIR/mongo/transport/transport_layer_manager",
            "$BUILD_DIR/mongo/util/allocator_thread",
            "$BUILD_DIR/mongo/util/net/ssl_manager",
            "$BUILD_DIR/mongo/util/pcre_wrapper",
            "$BUILD_DIR/mongo/util/periodic_runner_factory",
            "$BUILD_DIR/mongo/util/signal_handlers",
            "linenoise",
            "mongo_initializers",
            "program_runner",
            "shell_utils",
        ],
        LIBDEPS=[
            # NOTE: This list must remain empty. Please only add to LIBDEPS_PRIVATE
        ],
    )

    shellEnv = env.Clone()
    if env.TargetOSIs("windows"):
        shellEnv.Append(LIBS=["winmm"])

        generatedMongoManifest = shellEnv.Substfile(
            "mongo.manifest.in",
            SUBST_DICT=[
                ("@mongo_version_major@", version_parts[0]),
                ("@mongo_version_minor@", version_parts[1]),
                ("@mongo_version_patch@", version_parts[2]),
                ("@mongo_version_extra@", version_parts[3]),
                ("@mongo_version_extra_str@", version_extra),
            ],
        )
        shellEnv.Alias("generated-sources", generatedMongoManifest)
        shellEnv.Depends("mongo.res", generatedMongoManifest)

    mongo_shell = shellEnv.Program(
        target="mongo",
        source=[
            "mongo.cpp",
        ]
        + env.WindowsResourceFile("mongo.rc"),
        LIBDEPS=[
            # NOTE: Do not add new libdeps (public or private) here unless
            # required by the linker to satisfy symbol dependencies from
            # the files listed above in `sources`. If you need to add a
            # library to inject a static or mongo initializer to mongo,
            # please add that library as a private libdep of
            # mongo_initializers.
            "$BUILD_DIR/mongo/db/server_base",
            "mongo_main",
        ],
        AIB_COMPONENT="jstestshell",
        AIB_COMPONENTS_EXTRA=[
            "devcore",
            "dist-test",
            "integration-tests",
            "mongo",
            "serverless-test",
        ],
    )

env.CppUnitTest(
    target="shell_test",
    source=[
        "kms_test.cpp" if get_option("ssl") == "on" else [],
        "shell_options_test.cpp",
        "shell_utils_test.cpp",
    ],
    LIBDEPS=[
        "$BUILD_DIR/mongo/util/signal_handlers",
        "kms" if get_option("ssl") == "on" else [],
        "shell_options_register",
        "shell_utils",
    ],
)