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
|
# -*- mode: python; -*-
import re
Import([
"env",
"has_option",
"get_option",
"use_libunwind",
])
env = env.Clone()
env.InjectMongoIncludePaths()
# This generates a numeric representation of the version string so that
# you can easily compare versions of MongoDB without having to parse
# the version string.
#
# The rules for this are
# {major}{minor}{release}{pre/rc/final}
# If the version is pre-release and not an rc, the final number is 0
# If the version is an RC, the final number of 1 + rc number
# If the version is pre-release between RC's, the final number is 1 + rc number
# If the version is a final release, the final number is 99
#
# Examples:
# 3.1.1-123 = 3010100
# 3.1.1-rc2 = 3010103
# 3.1.1-rc2-123 = 3010103
# 3.1.1 = 3010199
#
version_parts = [ x for x in re.match(r'^(\d+)\.(\d+)\.(\d+)-?((?:(rc)(\d+))?.*)?',
env['MONGO_VERSION']).groups() ]
version_extra = version_parts[3] if version_parts[3] else ""
if version_parts[4] == 'rc':
version_parts[3] = int(version_parts[5]) + -50
elif version_parts[3]:
version_parts[2] = int(version_parts[2]) + 1
version_parts[3] = -100
else:
version_parts[3] = 0
version_parts = [ int(x) for x in version_parts[:4]]
env.AppendUnique(
FORCEINCLUDES=[
'mongo/platform/basic.h',
],
)
env.SConscript(
dirs=[
'base',
'bson',
'client',
'crypto',
'db',
'dbtests',
'embedded',
'executor',
'idl',
'installer',
'logv2',
'platform',
'rpc',
's',
'scripting',
'shell',
'stdx',
'tools',
'transport',
'unittest',
'util',
'watchdog',
],
exports=[
'env',
'version_extra',
'version_parts',
],
)
config_header_substs = (
('@mongo_config_altivec_vec_vbpermq_output_index@', 'MONGO_CONFIG_ALTIVEC_VEC_VBPERMQ_OUTPUT_INDEX'),
('@mongo_config_debug_build@', 'MONGO_CONFIG_DEBUG_BUILD'),
('@mongo_config_have_execinfo_backtrace@', 'MONGO_CONFIG_HAVE_EXECINFO_BACKTRACE'),
('@mongo_config_have_explicit_bzero@', 'MONGO_CONFIG_HAVE_EXPLICIT_BZERO'),
('@mongo_config_have_fips_mode_set@', 'MONGO_CONFIG_HAVE_FIPS_MODE_SET'),
('@mongo_config_have_header_unistd_h@', 'MONGO_CONFIG_HAVE_HEADER_UNISTD_H'),
('@mongo_config_have_memset_s@', 'MONGO_CONFIG_HAVE_MEMSET_S'),
('@mongo_config_have_posix_monotonic_clock@', 'MONGO_CONFIG_HAVE_POSIX_MONOTONIC_CLOCK'),
('@mongo_config_have_pthread_setname_np@', 'MONGO_CONFIG_HAVE_PTHREAD_SETNAME_NP'),
('@mongo_config_have_ssl_ec_key_new@', 'MONGO_CONFIG_HAVE_SSL_EC_KEY_NEW'),
('@mongo_config_have_ssl_set_ecdh_auto@', 'MONGO_CONFIG_HAVE_SSL_SET_ECDH_AUTO'),
('@mongo_config_have_strnlen@', 'MONGO_CONFIG_HAVE_STRNLEN'),
('@mongo_config_max_extended_alignment@', 'MONGO_CONFIG_MAX_EXTENDED_ALIGNMENT'),
('@mongo_config_ocsp_stapling_enabled@', 'MONGO_CONFIG_OCSP_STAPLING_ENABLED'),
('@mongo_config_optimized_build@', 'MONGO_CONFIG_OPTIMIZED_BUILD'),
('@mongo_config_ssl_has_asn1_any_definitions@', 'MONGO_CONFIG_HAVE_ASN1_ANY_DEFINITIONS'),
('@mongo_config_ssl_provider@', 'MONGO_CONFIG_SSL_PROVIDER'),
('@mongo_config_ssl@', 'MONGO_CONFIG_SSL'),
('@mongo_config_usdt_enabled@', 'MONGO_CONFIG_USDT_ENABLED'),
('@mongo_config_usdt_provider@', 'MONGO_CONFIG_USDT_PROVIDER'),
('@mongo_config_use_libunwind@', 'MONGO_CONFIG_USE_LIBUNWIND'),
('@mongo_config_use_raw_latches@', 'MONGO_CONFIG_USE_RAW_LATCHES'),
('@mongo_config_wiredtiger_enabled@', 'MONGO_CONFIG_WIREDTIGER_ENABLED'),
)
def makeConfigHeaderDefine(self, key):
val = "// #undef {0}".format(key)
if key in self['CONFIG_HEADER_DEFINES']:
val = "#define {0} {1}".format(key, self['CONFIG_HEADER_DEFINES'][key])
return val
env.AddMethod(makeConfigHeaderDefine)
generateConfigHeaderFile = env.Substfile(
'config.h.in',
SUBST_DICT=[(k, env.makeConfigHeaderDefine(v)) for (k, v) in config_header_substs]
)
env.Alias('generated-sources', generateConfigHeaderFile)
# NOTE: The 'base' library does not really belong here. Its presence
# here is temporary. Do not add to this library, do not remove from
# it, and do not declare other libraries in this file.
baseEnv = env.Clone()
if use_libunwind == True:
baseEnv.InjectThirdParty('unwind')
quick_exit_env = baseEnv.Clone()
if has_option('gcov'):
quick_exit_env.Append(
CPPDEFINES=[
'MONGO_GCOV',
],
)
quick_exit_obj = baseEnv.LibraryObject(
target='quick_exit',
source=[
'util/quick_exit.cpp',
],
)[0]
debugger_env = baseEnv.Clone()
if has_option("gdbserver"):
debugger_env.Append(CPPDEFINES=["USE_GDBSERVER"])
elif has_option("lldb-server"):
debugger_env.Append(CPPDEFINES=["USE_LLDB_SERVER"])
debugger_obj = debugger_env.LibraryObject(
target='debugger',
source=[
'util/debugger.cpp',
],
)[0]
baseEnv.Library(
target='base',
source=[
'base/data_range.cpp',
'base/data_range_cursor.cpp',
'base/data_type.cpp',
'base/data_type_string_data.cpp',
'base/data_type_terminated.cpp',
'base/dependency_graph.cpp',
'base/error_codes.cpp',
'base/error_extra_info.cpp',
'base/init.cpp',
'base/initializer.cpp',
'base/parse_number.cpp',
'base/shim.cpp',
'base/simple_string_data_comparator.cpp',
'base/status.cpp',
'base/string_data.cpp',
'base/validate_locale.cpp',
'bson/bson_comparator_interface_base.cpp',
'bson/bson_depth.cpp',
'bson/bson_validate.cpp',
'bson/bsonelement.cpp',
'bson/bsonmisc.cpp',
'bson/bsonobj.cpp',
'bson/bsonobjbuilder.cpp',
'bson/bsontypes.cpp',
'bson/json.cpp',
'bson/oid.cpp',
'bson/simple_bsonelement_comparator.cpp',
'bson/simple_bsonobj_comparator.cpp',
'bson/timestamp.cpp',
'logv2/attributes.cpp',
'logv2/bson_formatter.cpp',
'logv2/console.cpp',
'logv2/file_rotate_sink.cpp',
'logv2/json_formatter.cpp',
'logv2/log_component.cpp',
'logv2/log_component_settings.cpp',
'logv2/log_detail.cpp',
'logv2/log_domain.cpp',
'logv2/log_domain_global.cpp',
'logv2/log_domain_internal.cpp',
'logv2/log_manager.cpp',
'logv2/log_severity.cpp',
'logv2/log_tag.cpp',
'logv2/log_util.cpp',
'logv2/plain_formatter.cpp',
'logv2/ramlog.cpp',
'logv2/redaction.cpp',
'logv2/shared_access_fstream.cpp',
'logv2/text_formatter.cpp',
'platform/decimal128.cpp',
'platform/mutex.cpp',
'platform/posix_fadvise.cpp',
'platform/process_id.cpp',
'platform/random.cpp',
'platform/shared_library.cpp',
'platform/shared_library_${TARGET_OS_FAMILY}.cpp',
'platform/stack_locator.cpp',
'platform/stack_locator_${TARGET_OS}.cpp',
'platform/strcasestr.cpp',
'platform/strnlen.cpp',
'util/allocator.cpp',
'util/assert_util.cpp',
'util/base64.cpp',
'util/boost_assert_impl.cpp',
'util/concurrency/idle_thread_block.cpp',
'util/concurrency/thread_name.cpp',
'util/duration.cpp',
'util/errno_util.cpp',
'util/exception_filter_win32.cpp',
'util/exit.cpp',
'util/file.cpp',
'util/hex.cpp',
'util/itoa.cpp',
'util/platform_init.cpp',
'util/shell_exec.cpp',
'util/signal_handlers_synchronous.cpp',
'util/stacktrace.cpp',
'util/stacktrace_${TARGET_OS_FAMILY}.cpp',
'util/stacktrace_somap.cpp',
'util/stacktrace_threads.cpp',
'util/str.cpp',
'util/str_escape.cpp',
'util/system_clock_source.cpp',
'util/system_tick_source.cpp',
'util/testing_proctor.cpp',
'util/text.cpp',
'util/thread_safety_context.cpp',
'util/thread_context.cpp',
'util/time_support.cpp',
'util/timer.cpp',
'util/uuid.cpp',
'util/version.cpp',
debugger_obj,
quick_exit_obj,
],
# NOTE: This library *must not* depend on any libraries than
# the ones declared here. Do not add to this list.
LIBDEPS=[
'$BUILD_DIR/third_party/murmurhash3/murmurhash3',
'$BUILD_DIR/third_party/shim_abseil',
'$BUILD_DIR/third_party/shim_boost',
'$BUILD_DIR/third_party/shim_fmt',
],
LIBDEPS_PRIVATE=[
'$BUILD_DIR/third_party/shim_intel_decimal128',
'$BUILD_DIR/third_party/shim_pcrecpp',
'$BUILD_DIR/third_party/shim_unwind' if use_libunwind else [],
'stdx/stdx',
'util/shim_boost_assert',
],
AIB_COMPONENT='platform',
)
# Stage the top-level mongodb banners
distsrc = env.Dir('#distsrc')
env.AutoInstall(
target='$PREFIX',
source=[
distsrc.File('README'),
# TODO: we need figure out what to do when we use a different
# THIRD-PARTY-NOTICES for example, with Embedded
distsrc.File('THIRD-PARTY-NOTICES'),
distsrc.File('MPL-2'),
],
AIB_COMPONENT='common',
AIB_ROLE='base',
)
# If no module has introduced a file named LICENSE-Enterprise.txt then this
# is a Community build, so inject the AGPL and the Community license
enterprise_license = [banner for banner in env["MODULE_BANNERS"] if banner.name == "LICENSE-Enterprise.txt"]
if not enterprise_license:
env.Append(MODULE_BANNERS = [distsrc.File('LICENSE-Community.txt')])
# All module banners get staged to the top level of the tarfile, so we
# need to fail if we are going to have a name collision.
module_banner_filenames = set([f.name for f in env['MODULE_BANNERS']])
if not len(module_banner_filenames) == len(env['MODULE_BANNERS']):
# TODO: Be nice and identify conflicts in error.
env.FatalError("ERROR: Filename conflicts exist in module banners.")
env.AutoInstall(
target='$PREFIX',
source=env.get('MODULE_BANNERS', []),
AIB_COMPONENT='common',
AIB_COMPONENTS_EXTRA=['dist', 'dist-test'],
AIB_ROLE='base',
)
|