mongo/bazel/install_rules/windows_msvc.bzl
patricearruda84 362cf626b0 SERVER-105795: Use --repo-dev instead of --action_even for pinning VC compiler. (#36786)
GitOrigin-RevId: 2882f1940aef7a9220c1a645066c91cfbd5c5d97
2025-06-02 20:51:33 +00:00

50 lines
1.3 KiB
Python

load(
"//bazel/toolchains/cc/mongo_windows:windows_cc_configure.bzl",
"find_vc_path",
"get_vc_redist_version",
)
def find_windows_msvc(ctx):
vc_path = find_vc_path(ctx)
if vc_path == None:
fail("Failed to locate Visual Studio. Make sure you are on Windows and have Visual Studio installed.")
redist_version = get_vc_redist_version(ctx)
if redist_version == None:
fail("Failed to locate a redistribution version from Visual Studio")
ctx.symlink(vc_path + "/Redist/MSVC/" + redist_version, "msvc")
ctx.file(
"BUILD.bazel",
"""
package(default_visibility = ["//visibility:public"])
filegroup(
name = "merge_modules",
srcs = select({
"@platforms//os:windows": glob(["**/*.msm"]),
"//conditions:default": [],
}),
)
filegroup(
name = "vc_redist_x64",
srcs = select({
"@platforms//os:windows": glob(["**/vc_redist.x64.exe"]),
"//conditions:default": [],
}),
)
""",
)
return None
windows_msvc = repository_rule(
environ = [
"BAZEL_VC_FULL_VERSION", # Force re-compute if the user changed the version of MS compiler.
"MONGO_VC_REDIST_FULL_VERSION", # Force re-compute if the user changed the VC Redistribution version.
],
implementation = find_windows_msvc,
configure = True,
local = True,
)