[bazel] Move link dependencies down to where they are incurred

It wasn't clear from the docs, but linkopts are passed upstack to
dependents, so we can define them where we add source files which need
them.

No-Try: true
Change-Id: I376412682320e8802c7fd2a295a65af97650541d
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/527697
Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
This commit is contained in:
Kevin Lubick 2022-04-05 18:05:05 -04:00
parent 95bcc8837f
commit ecc5d21ed0
3 changed files with 16 additions and 21 deletions

View File

@ -6,13 +6,6 @@ cc_binary_with_flags(
srcs = [
"//example:HelloWorld_src",
],
linkopts = [
"-lX11",
"-lxcb",
"-lXau",
"-lXdmcp",
"-lGL",
],
# These flags are defined in //bazel/common_config_settings/BUILD.bazel
set_flags = {
# Use the GL backend with the normal GL standard (as opposed to WebGL or GLES)
@ -40,13 +33,6 @@ cc_binary_with_flags(
srcs = [
"//example:HelloWorld_src",
],
linkopts = [
"-lX11",
"-lxcb",
"-lXau",
"-lXdmcp",
"-lX11-xcb",
],
# These flags are defined in //bazel/common_config_settings/BUILD.bazel
set_flags = {
"gpu_backend": [
@ -70,13 +56,6 @@ cc_binary_with_flags(
srcs = [
"//example:HelloWorld_src",
],
linkopts = [
"-lX11",
"-lxcb",
"-lXau",
"-lXdmcp",
"-lX11-xcb",
],
# These flags are defined in //bazel/common_config_settings/BUILD.bazel
set_flags = {
"gpu_backend": [

View File

@ -350,6 +350,10 @@ selects.config_setting_group(
cc_library(
name = "srcs",
linkopts = select({
"//bazel/common_config_settings:gl_backend": ["-lGL"],
"//conditions:default": [],
}),
visibility = ["//:__subpackages__"],
deps = [":core_srcs"] + select({
"//bazel/common_config_settings:dawn_backend": [

View File

@ -28,6 +28,18 @@ selects.config_setting_group(
cc_library(
name = "sk_app",
linkopts = select({
"@platforms//os:linux": [
"-lX11",
"-lxcb", # dep of X11
"-lXau", # dep of xcb
"-lXdmcp", # dep of xcb
],
"//conditions:default": [],
}) + selects.with_or({
(":dawn_unix", ":vulkan_unix"): ["-lX11-xcb"],
"//conditions:default": [],
}),
visibility = ["//:__subpackages__"],
deps = [
":Application_hdr",