skia2/tools/skdiff/BUILD.bazel
Kevin Lubick 7a14f783bd [bazel] Sketching out HelloWorld sk_app using GL
bazel run //example:hello_world --config=clang
causes a window to open and draws a circle and a square.
Text to follow in a future CL.

To make this work, I had to get rid of musl and use glibc.
All the shared libraries (.so files) that were pre-built
and available for download (e.g. from https://packages.debian.org/bullseye/amd64/libgl1/download)
were compiled against glibc. When I tried to run a
program statically linked with musl and dynamically linked
against things using glibc, I got a segmentation fault
on things like calloc().

Initial attempts to use glibc had failed because it was thought
that the libc.so.6 file could only be referred to by absolute
path (and thus Bazel would not be happy about it). As it turns out,
that was simply a misconfiguration of the builtin_sysroot
parameter to cc_common.create_cc_toolchain_config_info
(see //toolchain/clang_toolchain_config.bzl). By setting that
to `external/clang_linux_amd64` and not
`external/clang_linux_amd64/usr`, the libc binary which had
been extracted to `external/clang_linux_amd64/lib/x86_64-linux-gnu`
was perfectly reachable from
`external/clang_linux_amd64/usr/usr/lib/x86_64-linux-gnu/libc.so`

To bring in the shared libraries to link against (e.g. X11, GL)
I made build_toolchain.bzl easier to modify in that we simply need
to add a debian download url and sha256 hash to a list (rather than
having to plumb this through via arguments).

Recommended Review Order:
 - example/BUILD.bazel (not sure if we always want to set bare
   link arguments like that or if we want to use "features" to
   pass those along to the toolchain).
 - tools/sk_app/BUILD.bazel to see initial cc_library for
   wrapping sk_app code.
 - toolchain/build_toolchain.bzl to see removal of musl and
   new list of debs.
 - toolchain/clang_toolchain_config.bzl (where use of the
   no-canonical-prefixes was key to compilation success).
   Notice also that we statically linked libc++ (I did not
   have any shared libraries for it locally, so I guessed
   a typical developer might not either).
 - Rest of toolchain/ for trivial renames.
 - bazel/Makefile to see extra docs on those targets and
   a new target that compiles all the exes so far for a
   quick way to test the build.
 - third_party/BUILD.bazel and src/gpu/BUILD.bazel which have
   non-generated changes. (all other BUILD.bazel files do).
 - go.mod, which needed to update the infra repo version in
   order to pick up http://review.skia.org/491736).

Change-Id: I8687bd227353040eca2dffa9465798d8bd395027
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/492117
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2022-01-11 13:06:19 +00:00

110 lines
2.7 KiB
Python

load("//bazel:macros.bzl", "generated_cc_atom")
cc_binary(
name = "skdiff",
visibility = ["//:__subpackages__"],
deps = [
":skdiff_html_src",
":skdiff_main_src",
":skdiff_src",
":skdiff_utils_src",
"//:skia_core",
"//third_party:skcms",
"//tools:Resources_src",
"//tools:ToolUtils_src",
"//tools/flags:CommandLineFlags_src",
"//tools/fonts:TestFontMgr_src",
"//tools/fonts:TestTypeface_src",
"//tools/fonts:ToolUtilsFont_src",
],
)
generated_cc_atom(
name = "skdiff_hdr",
hdrs = ["skdiff.h"],
visibility = ["//:__subpackages__"],
deps = [
"//include/core:SkBitmap_hdr",
"//include/core:SkColorPriv_hdr",
"//include/core:SkColor_hdr",
"//include/core:SkString_hdr",
"//include/private:SkTArray_hdr",
],
)
generated_cc_atom(
name = "skdiff_html_hdr",
hdrs = ["skdiff_html.h"],
visibility = ["//:__subpackages__"],
deps = [":skdiff_hdr"],
)
generated_cc_atom(
name = "skdiff_html_src",
srcs = ["skdiff_html.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":skdiff_hdr",
":skdiff_html_hdr",
"//include/core:SkStream_hdr",
"//include/core:SkTime_hdr",
],
)
generated_cc_atom(
name = "skdiff_main_src",
srcs = ["skdiff_main.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":skdiff_hdr",
":skdiff_html_hdr",
":skdiff_utils_hdr",
"//include/core:SkBitmap_hdr",
"//include/core:SkData_hdr",
"//include/core:SkImageEncoder_hdr",
"//include/core:SkPixelRef_hdr",
"//include/core:SkStream_hdr",
"//include/private:SkTDArray_hdr",
"//src/core:SkOSFile_hdr",
"//src/core:SkTSearch_hdr",
"//src/utils:SkOSPath_hdr",
],
)
generated_cc_atom(
name = "skdiff_src",
srcs = ["skdiff.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":skdiff_hdr",
"//include/core:SkBitmap_hdr",
"//include/core:SkColorPriv_hdr",
"//include/core:SkColor_hdr",
"//include/core:SkTypes_hdr",
],
)
generated_cc_atom(
name = "skdiff_utils_hdr",
hdrs = ["skdiff_utils.h"],
visibility = ["//:__subpackages__"],
deps = [":skdiff_hdr"],
)
generated_cc_atom(
name = "skdiff_utils_src",
srcs = ["skdiff_utils.cpp"],
visibility = ["//:__subpackages__"],
deps = [
":skdiff_hdr",
":skdiff_utils_hdr",
"//include/codec:SkCodec_hdr",
"//include/core:SkBitmap_hdr",
"//include/core:SkData_hdr",
"//include/core:SkImageEncoder_hdr",
"//include/core:SkStream_hdr",
"//include/core:SkTypes_hdr",
"//tools:ToolUtils_hdr",
],
)