bazel: win: Explicitly link libcef.lib in cc_binary (see #3757)
Using cc_import + interface_library/shared_library to link libcef.lib causes libcef.dll to be copied as a transitive dependency, leading to issues with complex Bazel configs. Instead, we explicitly link libcef.lib in the binary target (cc_binary + linkopts/additional_linker_inputs) and explicitly copy libcef.dll to the target directory.
This commit is contained in:
parent
213c0280e9
commit
980cc4b9fe
|
@ -47,10 +47,10 @@ def declare_exe(name, srcs, manifest_srcs, rc_file, resources_srcs, resources_de
|
|||
srcs = srcs,
|
||||
deps = [
|
||||
"@cef//:cef_wrapper",
|
||||
"@cef//:cef",
|
||||
"@cef//:cef_sandbox",
|
||||
] + deps,
|
||||
linkopts = [
|
||||
"$(location @cef//:cef_lib)",
|
||||
"$(location :{})".format(res_target),
|
||||
] + COMMON_LINKOPTS + linkopts,
|
||||
copts = COMMON_COPTS + select({
|
||||
|
@ -62,6 +62,7 @@ def declare_exe(name, srcs, manifest_srcs, rc_file, resources_srcs, resources_de
|
|||
"//conditions:default": COMMON_DEFINES_RELEASE,
|
||||
}) + local_defines,
|
||||
additional_linker_inputs = [
|
||||
"@cef//:cef_lib",
|
||||
":{}".format(res_target),
|
||||
] + additional_linker_inputs,
|
||||
data = [
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
# Distribution DLLs.
|
||||
#
|
||||
|
||||
# NOTE: libcef.dll is included via the //:cef dependency.
|
||||
DLLS = [
|
||||
"chrome_elf.dll",
|
||||
"d3dcompiler_47.dll",
|
||||
"libcef.dll",
|
||||
"libEGL.dll",
|
||||
"libGLESv2.dll",
|
||||
"vk_swiftshader.dll",
|
||||
|
|
|
@ -274,29 +274,19 @@ alias(
|
|||
})
|
||||
)
|
||||
|
||||
# Only available on Linux/Windows.
|
||||
# Only available on Linux.
|
||||
cc_import(
|
||||
name = "cef_dbg",
|
||||
interface_library = select({
|
||||
"@platforms//os:windows": "Debug/libcef.lib",
|
||||
"//conditions:default": None,
|
||||
}),
|
||||
shared_library = select({
|
||||
"@platforms//os:linux": "Debug/libcef.so",
|
||||
"@platforms//os:windows": "Debug/libcef.dll",
|
||||
"//conditions:default": None,
|
||||
}),
|
||||
)
|
||||
|
||||
cc_import(
|
||||
name = "cef_opt",
|
||||
interface_library = select({
|
||||
"@platforms//os:windows": "Release/libcef.lib",
|
||||
"//conditions:default": None,
|
||||
}),
|
||||
shared_library = select({
|
||||
"@platforms//os:linux": "Release/libcef.so",
|
||||
"@platforms//os:windows": "Release/libcef.dll",
|
||||
"//conditions:default": None,
|
||||
}),
|
||||
)
|
||||
|
@ -309,6 +299,36 @@ alias(
|
|||
}),
|
||||
)
|
||||
|
||||
# Only available on Windows.
|
||||
# Using cc_import + interface_library/shared_library to link libcef.lib causes
|
||||
# libcef.dll to be copied as a transitive dependency, leading to issues with
|
||||
# complex Bazel configs. Instead, we explicitly link libcef.lib in the binary
|
||||
# target (cc_binary + linkopts/additional_linker_inputs) and explicitly copy
|
||||
# libcef.dll to the target directory.
|
||||
alias(
|
||||
name = "cef_lib_dbg",
|
||||
actual = select({
|
||||
"@platforms//os:windows": "Debug/libcef.lib",
|
||||
"//conditions:default": None,
|
||||
}),
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "cef_lib_opt",
|
||||
actual = select({
|
||||
"@platforms//os:windows": "Release/libcef.lib",
|
||||
"//conditions:default": None,
|
||||
}),
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "cef_lib",
|
||||
actual = select({
|
||||
"@cef//:dbg": "@cef//:cef_lib_dbg",
|
||||
"//conditions:default": "@cef//:cef_lib_opt",
|
||||
}),
|
||||
)
|
||||
|
||||
# Copy the CEF framework into the app bundle but do not link it. See
|
||||
# https://groups.google.com/g/cef-announce/c/Fith0A3kWtw/m/6ds_mJVMCQAJ
|
||||
# for background. Use `copy_directory` instead of `filegroup` to remove
|
||||
|
|
Loading…
Reference in New Issue