SERVER-96686 Convert the last targets from SCons to Bazel (#30634)

GitOrigin-RevId: 9c5fe4dce066b3ebd7b95b59e8623e140e43f9f8
This commit is contained in:
Zack Winter 2024-12-23 15:20:09 -08:00 committed by MongoDB Bot
parent 4834689012
commit ee4f838a2b
5 changed files with 60 additions and 38 deletions

View File

@ -6907,7 +6907,7 @@ if env.get("__NINJA_NO") != "1":
"aib_additional_directory",
"{}/Contents/Resources/DWARF".format(dsym_dir_name),
)
setattr(dwarf_file.attributes, "aib_new_name", dwarf_sym_name.name)
setattr(dwarf_file.attributes, "aib_new_name", dwarf_sym_name)
debug_files.extend([plist_file, dwarf_file])
debug_suffix = ".dSYM"

View File

@ -232,7 +232,6 @@ WINDOWS_COPTS = (
WINDOWS_GENERAL_COPTS +
WINDOWS_DEBUG_COPTS +
WINDOWS_OPT_COPTS +
WINDOWS_MULTITHREAD_RUNTIME_COPTS +
WINDOWS_RUNTIME_ERROR_CHECK_COPTS +
WINDOWS_SUPRESSED_WARNINGS_COPTS +
WINDOWS_WARNINGS_AS_ERRORS_COPTS +
@ -1535,6 +1534,7 @@ def mongo_cc_library(
exec_properties = {},
no_undefined_ref_DO_NOT_USE = True,
linkshared = False,
skip_windows_crt_flags = False,
**kwargs):
"""Wrapper around cc_library.
@ -1593,7 +1593,7 @@ def mongo_cc_library(
if native.package_name().startswith("src/mongo"):
hdrs = hdrs + ["//src/mongo:mongo_config_header"]
if name != "boost_assert_shim":
if name != "boost_assert_shim" and name != "mongoca" and name != "cyrus_sasl_windows_test_plugin":
deps += MONGO_GLOBAL_SRC_DEPS
if name != "_global_header_bypass":
deps += ["//src/mongo:_global_header_bypass"]
@ -1636,6 +1636,9 @@ def mongo_cc_library(
package_specific_copts = package_specific_copt(native.package_name())
package_specific_linkflags = package_specific_linkflag(native.package_name())
if not skip_windows_crt_flags:
package_specific_copts += WINDOWS_MULTITHREAD_RUNTIME_COPTS
if mongo_api_name:
visibility_support_defines_list = ["MONGO_USE_VISIBILITY", "MONGO_API_" + mongo_api_name]
visibility_support_shared_lib_flags_list = ["-fvisibility=hidden"]
@ -1865,6 +1868,7 @@ def _mongo_cc_binary_and_program(
exec_properties = {},
skip_global_deps = [],
_program_type = "",
skip_windows_crt_flags = False,
**kwargs):
if linkstatic == True:
fail("""Linking specific targets statically is not supported.
@ -1916,6 +1920,8 @@ def _mongo_cc_binary_and_program(
fincludes_hdr = force_includes_hdr(native.package_name(), name)
package_specific_copts = package_specific_copt(native.package_name())
package_specific_linkflags = package_specific_linkflag(native.package_name())
if not skip_windows_crt_flags:
package_specific_copts += WINDOWS_MULTITHREAD_RUNTIME_COPTS
all_deps = deps

View File

@ -1174,7 +1174,11 @@ def exists(env: SCons.Environment.Environment) -> bool:
def handle_bazel_program_exception(env, target, outputs):
if sys.platform == "win32" and env.GetOption("link-model") == "dynamic-sdk":
if sys.platform == "win32" and (
env.GetOption("link-model") == "dynamic-sdk"
or "cyrus_sasl_windows_test_plugin" in target
or "mongoca" in target
):
is_shared_library = False
for bazel_output_file in outputs:
if os.path.splitext(bazel_output_file)[1] in set([".dll", ".pdb"]):

View File

@ -8,3 +8,47 @@ exports_files(
"*.cpp",
]),
)
mongo_cc_library(
name = "mongoca",
srcs = [
"CustomAction.cpp",
"targetver.h",
"//src/mongo/platform:compiler.h",
"//src/mongo/util:scopeguard.h",
],
additional_linker_inputs = [
":CustomAction.def",
],
copts = select({
"//bazel/config:dbg_enabled": [
"/MTd",
],
"//conditions:default": [
"/MT",
],
}),
linkopts = [
"msi.lib",
"user32.lib",
"Advapi32.lib",
],
linkshared = True,
non_transitive_dyn_linkopts = [
"/DEF:$(location :CustomAction.def)",
],
# We don't want any special allocator here either.
skip_global_deps = [
"allocator",
"libunwind",
],
# Do not link with DLL version of the CRT.
# As part of install, we may need to install the CRT DLL but if it is not installed, we cannot run
# the installer if we dynamically linked against it.
skip_windows_crt_flags = True,
target_compatible_with = select({
"@platforms//os:windows": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
deps = [],
)

View File

@ -1,43 +1,11 @@
# -*- mode: python -*-
Import("env")
Import("debugBuild")
Import("use_libunwind")
env = env.Clone()
# Do not link with DLL version of the CRT.
# As part of install, we may need to install the CRT DLL but if it is not installed, we cannot run
# the installer if we dynamically linked against it.
#
bad_flags = [a for a in env["CCFLAGS"] if a.startswith("/M")]
for flag in bad_flags:
env["CCFLAGS"].remove(flag)
if debugBuild:
env["CCFLAGS"].append("/MTd")
else:
env["CCFLAGS"].append("/MT")
env.Append(
LIBS=[
"msi",
"user32",
]
)
ca = env.SharedLibrary(
env.BazelSharedLibrary(
target="mongoca",
source=[
"customaction.cpp",
"customaction.def",
],
# We don't want any special allocator here either.
LIBDEPS_NO_INHERIT=[
"$BUILD_DIR/third_party/gperftools/tcmalloc_minimal",
"$BUILD_DIR/third_party/tcmalloc/tcmalloc",
"$BUILD_DIR/third_party/unwind/unwind",
],
source=[],
AIB_COMPONENT="msi-util",
AIB_ROLE="runtime",
)