8ed49ea6e3
This ports the third_party BUILD.gn files related to codecs (with a best-effort on arm/SIMD stuff). This includes: - libpng - libjpeg-turbo - libwebp - wuffs (gif) - libgifcodec - dng_sdk and piex (raw codec) This expands the string_flag_with_values macro to allow multiple values to be set at once. This was added in Bazel 5.0.0, however the latest pre-release version of that has a bug [1] which slows down compilation dramatically. This was fixed at ToT, but not released. As a result, I started using the Bazel 6 pre-release (via bazelisk). The macro select_multi makes writing select() where multiple elements could be on possible/easier. One can try compiling certain codecs by running: bazel build :skia-core --config clang --include_codec=raw_codec --include_codec=png_codec Suggested Review Order: - bazel/macros.bzl - bazel/common_config_settings/defs.bzl and its BUILD.bazel to see how the codec options are defined. - BUILD.bazel to see how the codec settings are used. - src/codec/BUILD.bazel to see the inclusion of Skia files to deal with specific codecs. - third_party/BUILD.bazel (while referencing the corresponding BUILD.gn files, such as third_party/libwebp/BUILD.gn) - Everything else. Change-Id: I797375a35fa345d9835e7b2a2ab23371c45953c3 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/469456 Reviewed-by: Leandro Lovisolo <lovisolo@google.com> Reviewed-by: Ben Wagner <bungeman@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com>
82 lines
2.3 KiB
Python
82 lines
2.3 KiB
Python
load("@rules_cc//cc:defs.bzl", "cc_binary")
|
|
load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary")
|
|
|
|
package(default_visibility = ["//:__subpackages__"])
|
|
|
|
BASE_LINKOPTS = [
|
|
#"-flto", # https://github.com/emscripten-core/emsdk/issues/807
|
|
"--bind", # Compiles the source code using the Embind bindings to connect C/C++ and JavaScript
|
|
"-sALLOW_MEMORY_GROWTH",
|
|
"-sUSE_PTHREADS=0", # Disable pthreads
|
|
"-sMODULARIZE",
|
|
"-sDISABLE_EXCEPTION_CATCHING", # Disable all exception catching
|
|
"-sNODEJS_CATCH_EXIT=0", # We don't have a 'main' so disable exit() catching
|
|
"-sWASM",
|
|
"-sMAX_WEBGL_VERSION=2",
|
|
]
|
|
|
|
RELEASE_OPTS = [
|
|
# We disable closure for now, because we need a way to pass in the externs file,
|
|
# which does not appear to be exposed on the emscripten toolchain.
|
|
# "--closure 1", # Run the closure compiler
|
|
"-sASSERTIONS=0", # Turn off assertions
|
|
]
|
|
|
|
DEBUG_OPTS = [
|
|
"--closure 0", # Do not use closure
|
|
"-sASSERTIONS", # Turn on assertions
|
|
"-sGL_ASSERTIONS",
|
|
]
|
|
|
|
GM_OPTS = [
|
|
"-sEXPORT_NAME=InitWasmGMTests",
|
|
"--pre-js",
|
|
"modules/canvaskit/gm.js",
|
|
]
|
|
|
|
filegroup(
|
|
name = "hdrs",
|
|
srcs = [
|
|
"WasmCommon.h",
|
|
],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "gm-bindings",
|
|
testonly = True,
|
|
srcs = [
|
|
"gm_bindings.cpp",
|
|
":hdrs",
|
|
"//gm:gms", # Required for the registry to work
|
|
"//src/ports:default_global_init",
|
|
"//src/ports:fontmgr",
|
|
"//src/ports:malloc",
|
|
"//src/ports:skdebug",
|
|
"//src/ports:skia_image_generator",
|
|
],
|
|
additional_linker_inputs = ["gm.js"],
|
|
linkopts = select({
|
|
"//bazel/common_config_settings:debug_build": BASE_LINKOPTS + GM_OPTS + DEBUG_OPTS,
|
|
"//bazel/common_config_settings:release_build": BASE_LINKOPTS + GM_OPTS + RELEASE_OPTS,
|
|
"//conditions:default": BASE_LINKOPTS + GM_OPTS + RELEASE_OPTS,
|
|
}),
|
|
local_defines = [
|
|
"SK_GL",
|
|
"SK_USE_WEBGL",
|
|
],
|
|
# This target won't build successfully on its own because of missing emscripten
|
|
# headers etc. Therefore, we hide it from wildcards.
|
|
tags = ["manual"],
|
|
deps = [
|
|
"//:gms",
|
|
"//:hash_and_encode",
|
|
"//:tests",
|
|
],
|
|
)
|
|
|
|
wasm_cc_binary(
|
|
name = "gm-bindings-wasm",
|
|
testonly = True,
|
|
cc_target = ":gm-bindings",
|
|
)
|