This makes use of Bazel's pre-defined platforms
https://github.com/bazelbuild/platforms
and some of our own defined values (see
//bazel/common_config_settings/BUILD.bazel) to customize
the build rules.
I verified this by building bazel_test locally for
linux x64 as well as using the third_party deps for
a WASM build (using build files not seen in this CL).
Suggested Review Order:
- https://docs.bazel.build/versions/main/platforms.html if not
already familiar with Bazel Platforms
- third_party/BUILD.bazel to see that 1) all globs have
been removed and 2) select() targets various
platform constants or groups of constants to control
sources, headers, and local_defines.
- common_config_settings/ to see the groups of constraints
created, as well as new constraint_settings defined
(skdebug_impl)
- supported_combinations/ to see how we can define supported
sets of the constraint values (aka Bazel platforms).
I imagine expanding this more, so we might have platforms
named "linux_x64_emptyfontmgr_vulkan" or such.
- //BUILD.bazel and bazel_test.cpp to see use of SkDebugf.
- Everything else.
Change-Id: I49e4abdbcf7b76f0674efdbb1f53dc8823d110ee
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/463517
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
Owners-Override: Kevin Lubick <kjlubick@google.com>
This can successfully build a C library:
bazel build --config=clang //third_party:libpng
This can build and run a statically-linked executable:
bazel test --config=clang //:bazel_test
For more verbose compile and linking output, add the
`--features diagnostic`
flag to a Bazel command (see _make_diagnostic_flags() in
toolchain/clang_toolchain_config.bzl. Similarly, a
`--features print_search_dirs` can be used to show where
clang is looking for libraries etc to link against.
These features are made available for easier debugging.
Suggested review order:
- Read https://docs.bazel.build/versions/4.2.1/tutorial/cc-toolchain-config.html
if unfamiliar with setting up C++ toolchains in Bazel
- .bazelrc and WORKSPACE.bazel that configure use and download
of the toolchain (Clang 13, musl 1.2.2)
- toolchain/build_toolchain.bzl which downloads and assembles
the toolchain (w/o installing anything on the host machine)
- toolchain/BUILD.bazel and toolchain/*trampoline.sh to see
the setup of the toolchain rules.
- toolchain/clang_toolchain_config.bzl to see the configuration
of the toolchain. Pay special attention to the various
command line flags that are set.
- See that tools/bazel_test.cc has made a new home in
experimental/bazel_test/bazel_test.cpp, with a companion
BUILD.bazel. Note the addition of some function calls
that test use of the C++ standard library.
The number being used to test the PNG library is the latest
and greatest that verifies we are compiling the one brought
in via DEPS (and not a local one).
- third_party/* to see how png (and its dependent zlib) have
been built. Pay special attention to the musl_compat hack
to fix static linking (any idea what the real cause is?)
- //BUILD.bazel to see definition of the bazel_test executable.
Change-Id: I7b0922d0d45cb9be8df2fd5fa5a1f48492654d5f
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/461178
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Leandro Lovisolo <lovisolo@google.com>