From 12a3336151ada75d988ccad710923b6d56b0d0c4 Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Wed, 5 Oct 2022 16:47:13 -0400 Subject: [PATCH] Reland "[bazel] Add individual test targets, broken up by CPU and GPU" This is a reland of commit e034091e5451b3dc879357c3fa48d00a8bed4f8b Original change's description: > [bazel] Add individual test targets, broken up by CPU and GPU > > Trimmed down testing output: > > $ bazel test //tests/... --config=gl > //tests:GPUDrawPathTest PASSED in 0.6s > //tests:MatrixProcsTest PASSED in 0.1s > > $ bazel test //tests/... --config=cpu > //tests:GPUDrawPathTest PASSED in 0.0s > //tests:MatrixProcsTest PASSED in 0.1s > > # Make small change to tests/MatrixProcsTest.cpp > > $ bazel test //tests/... --config=cpu > //tests:GPUDrawPathTest (cached) PASSED in 0.0s > //tests:MatrixProcsTest PASSED in 0.1s > > # Compile and run CPU tests remotely on Linux RBE instances; > bazel test //tests/... --config=linux_rbe --config=cpu --remote_download_minimal > INFO: Elapsed time: 54.482s, Critical Path: 45.77s > INFO: 1320 processes: 112 remote cache hit, 1583 remote. > INFO: Build completed, 1 test FAILED, 1320 total actions > //tests:TypefaceMacTest SKIPPED > //tests:AAClipTest PASSED in 2.2s > ... > //tests:YUVTest PASSED in 1.7s > //tests:TypefaceTest FAILED in 1.7s > > (I think the TypefaceTest is failing remotely because the > RBE instances might not have any fonts installed in the > Docker container). > > All test files in the tests subfolder (but not //tests/graphite > or //tests/sksl) are categorized as Ganesh GPU tests or CPU tests. > This categorization is based on the question "Do we need a Ganesh > GPU backend to compile the test file or not?". > > These are further grouped into tests that need similar features > enabled, for example CODEC_TESTS and PDF_TESTS. Features are > enabled via a new transition rule cc_test_with_flags, which is > very similar to cc_binary_with_flags. > > These groups are turned into Bazel targets using macros defined > in //tests/test.bzl (basically just a for loop and some select > statements). > > Bazel does not let us define some tests when certain --config > options are made (at least, not with macros), so we always > define every test target. We do use select() statements to > decide if this test should do something (that is, run Skia and > do assertions) or not (just return 0). This is based off one of > the options passed into --config. For example --config=cpu > only *really* runs the tests which do not need a GPU backend > (e.g. CODEC_TESTS, PDF_TESTS, and more). --config=gl compiles > in the Ganesh GL backend and runs the tests that require a > GPU backend. > > bazel/buildrc has some configs for testing one GPU backend > at a time, as this is how we currently have our CI jobs > organized. Local developers could define their own settings > with multiple backends as necessary and use that for a > --config instead. > > Known Limitations: > - CPU tests all pass for me locally. One fails remotely. > - Some (~12) GPU tests fail locally. Have not delved into why yet. > - We do not (yet) enforce IWYU on all the tests. I would like to, > but that's for another time due to the large amount of files > that would need changing. > - Have only run the tests on a Linux box so far. > > Suggested Review Order: > - //tests/test.bzl, noting the select() statements that > compile BazelTestRunner.cpp etc or BazelNoopRunner.cpp > - //tests/BUILD.bazel to see the breakdown and usages of > the macros. > - //tests/Bazel*Runner.cpp, noting some similarities to how > dm/DM.cpp works (it was what I looked at when building this). > - //bazel/cc_test_with_flags.bzl, noting how it uses the same > list from cc_binary_with_flags.bzl. > - .bazelproject, which makes integration with Intellij a little > bit easier (but this could use some tweaks). > - All the other BUILD.bazel files, noting how we needed a few > more settings to make all the tests compile correctly > (e.g. //src/lazy:enable_discardable_memory and the fontmgrs). > - All other files. > > Change-Id: I39d4dcbf03e45d31c3d9bea3a4eb04cd08cb0b05 > Bug: skia:13758 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/583247 > Reviewed-by: Ben Wagner > Reviewed-by: Leandro Lovisolo Bug: skia:13758 Change-Id: Ib705dd1b6b411209628503b371b5c3b7ad24d2a4 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/588040 Reviewed-by: Leandro Lovisolo Reviewed-by: Ben Wagner --- .bazelproject | 19 + .bazelrc | 4 + BUILD.gn | 2 + PRESUBMIT.py | 3 +- bazel/BUILD.bazel | 3 + bazel/Makefile | 4 + bazel/buildrc | 26 + bazel/cc_binary_with_flags.bzl | 9 +- bazel/cc_test_with_flags.bzl | 86 +++ bazel/common_config_settings/BUILD.bazel | 58 +- include/ports/BUILD.bazel | 43 +- modules/canvaskit/compile_gm.sh | 4 + resources/BUILD.bazel | 5 + src/BUILD.bazel | 22 +- src/lazy/BUILD.bazel | 28 +- src/ports/BUILD.bazel | 91 +++- src/utils/BUILD.bazel | 2 + tests/BUILD.bazel | 643 +++++++++++++++++++++++ tests/BazelNoopRunner.cpp | 13 + tests/BazelTestRunner.cpp | 156 ++++++ tests/Test.h | 18 +- tests/TestHarness.h | 1 + tests/tests.bzl | 156 ++++++ tools/BUILD.bazel | 46 +- tools/debugger/BUILD.bazel | 29 + tools/flags/BUILD.bazel | 1 + tools/fonts/BUILD.bazel | 17 +- tools/gpu/BUILD.bazel | 21 +- tools/gpu/dawn/BUILD.bazel | 30 ++ tools/gpu/vk/BUILD.bazel | 19 + 30 files changed, 1511 insertions(+), 48 deletions(-) create mode 100644 .bazelproject create mode 100644 bazel/cc_test_with_flags.bzl create mode 100644 resources/BUILD.bazel create mode 100644 tests/BUILD.bazel create mode 100644 tests/BazelNoopRunner.cpp create mode 100644 tests/BazelTestRunner.cpp create mode 100644 tests/tests.bzl create mode 100644 tools/debugger/BUILD.bazel create mode 100644 tools/gpu/dawn/BUILD.bazel diff --git a/.bazelproject b/.bazelproject new file mode 100644 index 000000000000..79c40fb8d4a5 --- /dev/null +++ b/.bazelproject @@ -0,0 +1,19 @@ +directories: + . + -bin + -out + -node_modules + -third_party/externals + +# Automatically includes all relevant targets under the 'directories' above +derive_targets_from_directories: false + +targets: + # If source code isn't resolving, add additional targets that compile it here + //example:hello_world_vulkan + //example:hello_world_gl +additional_languages: + # Uncomment any additional languages you want supported + javascript + python + typescript diff --git a/.bazelrc b/.bazelrc index 1d943d70a933..86e2f684e65d 100644 --- a/.bazelrc +++ b/.bazelrc @@ -43,6 +43,8 @@ build --flag_alias=include_encoder=//src/images:include_encoder build --flag_alias=include_fontmgr=//bazel/common_config_settings:include_fontmgr build --flag_alias=with_gl_standard=//src/gpu:with_gl_standard +build --flag_alias=disable_discardable_memory=no//src/lazy:enable_discardable_memory +build --flag_alias=enable_discardable_memory=//src/lazy:enable_discardable_memory build --flag_alias=disable_effect_serialization=no//bazel/common_config_settings:enable_effect_serialization build --flag_alias=enable_effect_serialization=//bazel/common_config_settings:enable_effect_serialization build --flag_alias=disable_gpu_test_utils=no//src/gpu:enable_gpu_test_utils @@ -65,6 +67,8 @@ build --flag_alias=disable_tracing=no//bazel/common_config_settings:enable_traci build --flag_alias=enable_tracing=//bazel/common_config_settings:enable_tracing build --flag_alias=disable_vma=no//src/gpu:use_vulkan_memory_allocator build --flag_alias=enable_vma=//src/gpu:use_vulkan_memory_allocator +build --flag_alias=with_default_global_memory_pool=//src/lazy:use_default_global_memory_pool +build --flag_alias=with_no_global_memory_pool=no//src/lazy:use_default_global_memory_pool build --flag_alias=with_harfbuzz=//bazel/common_config_settings:use_harfbuzz build --flag_alias=with_no_harfbuzz=no//bazel/common_config_settings:use_harfbuzz build --flag_alias=with_icu=//bazel/common_config_settings:use_icu diff --git a/BUILD.gn b/BUILD.gn index 2020a3531586..a8bd25820b8d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -536,6 +536,8 @@ optional("fontmgr_win") { public = [ "include/ports/SkTypeface_win.h" ] sources = [ + "include/ports/SkFontMgr_indirect.h", + "include/ports/SkRemotableFontMgr.h", "src/fonts/SkFontMgr_indirect.cpp", "src/ports/SkFontMgr_win_dw.cpp", "src/ports/SkScalerContext_win_dw.cpp", diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 2a4d16c065e4..457f22a7a817 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -250,7 +250,8 @@ def _CheckBazelBUILDFiles(input_api, output_api): is_bazel = affected_file_path.endswith('BUILD.bazel') # This list lines up with the one in autoroller_lib.py (see G3). excluded_paths = ["infra/", "bazel/rbe/", "bazel/external/", "bazel/common_config_settings/", - "modules/canvaskit/go/", "experimental/", "bazel/platform", "third_party/"] + "modules/canvaskit/go/", "experimental/", "bazel/platform", "third_party/", + "tests/", "resources/"] is_excluded = any(affected_file_path.startswith(n) for n in excluded_paths) if is_bazel and not is_excluded: with open(affected_file_path, 'r') as file: diff --git a/bazel/BUILD.bazel b/bazel/BUILD.bazel index 23e821874db2..bb7fb83430ad 100644 --- a/bazel/BUILD.bazel +++ b/bazel/BUILD.bazel @@ -52,6 +52,9 @@ GENERAL_DEFINES = [ }) + select({ "//src/shaders:legacy_shader_context_true": [], # This is the default in SkTypes.h "//src/shaders:legacy_shader_context_false": ["SK_DISABLE_LEGACY_SHADERCONTEXT"], +}) + select({ + "//src/lazy:enable_discardable_memory_true": ["SK_USE_DISCARDABLE_SCALEDIMAGECACHE"], + "//src/lazy:enable_discardable_memory_false": [], }) GPU_DEFINES = select_multi({ diff --git a/bazel/Makefile b/bazel/Makefile index d485b7f71adb..738c0ff3a3d4 100644 --- a/bazel/Makefile +++ b/bazel/Makefile @@ -71,9 +71,13 @@ iwyu_rbe: --config=enforce_iwyu --remote_download_minimal --nobuild_runfile_manifests bazelisk build //modules/skottie:skottie_tool_gpu --config=for_linux_x64_with_rbe \ --config=enforce_iwyu --remote_download_minimal --nobuild_runfile_manifests + bazelisk build //tests/... --config=for_linux_x64_with_rbe \ + --config=enforce_iwyu --remote_download_minimal --nobuild_runfile_manifests iwyu: bazelisk build //:skia_public --config=enforce_iwyu \ --nobuild_runfile_manifests bazelisk build //modules/skottie:skottie_tool_gpu --config=enforce_iwyu \ --nobuild_runfile_manifests + bazelisk build //tests/... --config=enforce_iwyu \ + --nobuild_runfile_manifests \ No newline at end of file diff --git a/bazel/buildrc b/bazel/buildrc index ea5e81dbfe1e..68a8a59bacfd 100644 --- a/bazel/buildrc +++ b/bazel/buildrc @@ -10,6 +10,10 @@ # For example, a default output directory might look like "k8-fastbuild-ST-6a54c1377847". # Inside this output directory is a subfolder for the target (e.g. executable) name. # +# Note that multiple definitions of a config are allowed - in this event, they are added together. +# This is handy if we need to comment on why certain settings are necessary. Otherwise, escaping +# the trailing newline (and thus having a multi-line definition) is preferred for brevity. +# # Notably, the flags that we turn on and off via //bazel/common_config_settings do not affect # the output directory. The output directory is used to store compiled object files (.o files) # and generated dependency files (e.g. the output of clang --write-dependencies [5]), so having @@ -86,6 +90,7 @@ build:enforce_iwyu --features=skia_enforce_iwyu --cc_output_directory_tag=iwyu \ --compilation_mode=dbg --keep_going \ --with_gl_standard=gl_standard --gpu_backend=gl_backend \ --gpu_backend=vulkan_backend --gpu_backend=dawn_backend \ + --enable_gpu_test_utils \ --include_fontmgr=custom_directory_fontmgr --include_fontmgr=custom_embedded_fontmgr \ --include_fontmgr=custom_empty_fontmgr --fontmgr_factory=custom_directory_fontmgr_factory \ --include_decoder=avif_decode_codec --include_decoder=gif_decode_codec \ @@ -97,3 +102,24 @@ build:enforce_iwyu --features=skia_enforce_iwyu --cc_output_directory_tag=iwyu \ --with_harfbuzz --with_icu \ --enable_sksl_tracing \ --enable_svg_canvas --enable_pdf_backend + + +build:cpu_only --cc_output_directory_tag=cpu_tests + +build:gl_ganesh --enable_gpu_test_utils --gpu_backend=gl_backend \ + --cc_output_directory_tag=gl_ganesh +# We need to have this environment variable set when testing our Ganesh GL backend on Unix, +# otherwise, we get "Failed to open X display." and connect make a GL context for testing. +build:gl_ganesh --action_env=DISPLAY=:1 + +build:vulkan_ganesh --enable_gpu_test_utils --gpu_backend=vulkan_backend \ + --cc_output_directory_tag=vulkan_ganesh + +build:dawn_ganesh --enable_gpu_test_utils --gpu_backend=dawn_backend \ + --cc_output_directory_tag=dawn_ganesh + +# Short-hand aliases +build:cpu --config=cpu_only +build:gl --config=gl_ganesh +build:vk --config=vulkan_ganesh +build:dawn --config=dawn_ganesh diff --git a/bazel/cc_binary_with_flags.bzl b/bazel/cc_binary_with_flags.bzl index b2238fa49e0f..fffda106fe57 100644 --- a/bazel/cc_binary_with_flags.bzl +++ b/bazel/cc_binary_with_flags.bzl @@ -13,6 +13,8 @@ load("//bazel:copts.bzl", "DEFAULT_COPTS") _bool_flags = [ "//bazel/common_config_settings:use_harfbuzz", "//bazel/common_config_settings:use_icu", + "//src/lazy:enable_discardable_memory", + "//src/lazy:use_default_global_memory_pool", "//src/gpu:enable_gpu_test_utils", "//src/pdf:enable_pdf_backend", "//src/sksl:enable_sksl", @@ -35,9 +37,14 @@ _string_list_flags = [ # These are the flags that we support setting via set_flags _flags = _bool_flags + _string_flags + _string_list_flags +_short_flags = [long_flag.split(":")[1] for long_flag in _flags] def _flag_transition_impl(settings, attr): rv = {} + for flag in attr.set_flags: + if flag not in _short_flags: + fail("unknown flag " + flag) + for key in settings: # Get the short form of the name. This the short form used as the keys in the # set_flags dictionary. @@ -58,7 +65,7 @@ def _flag_transition_impl(settings, attr): rv[key] = flag_setting # we know flag_setting is a string (e.g. the default). elif key in _bool_flags: if type(flag_setting) == "list": - rv[key] = flag_setting[0] == "True" + rv[key] = flag_setting[0].lower() == "true" else: rv[key] = flag_setting # flag_setting will be a boolean, the default return rv diff --git a/bazel/cc_test_with_flags.bzl b/bazel/cc_test_with_flags.bzl new file mode 100644 index 000000000000..f9741fbff3c7 --- /dev/null +++ b/bazel/cc_test_with_flags.bzl @@ -0,0 +1,86 @@ +""" +THIS IS THE EXTERNAL-ONLY VERSION OF THIS FILE. G3 HAS ITS OWN. + +This file contains a way to set flags from BUILD.bazel instead of requiring users to set them from +the CLI. This allows us to have tests that build with a specific set of features (e.g. the pdf +backend or the codecs) without having a large number of flags to set (easier to forget). + +It uses the same core implementation as cc_binary_with_flags. + +It is based off of: +https://github.com/bazelbuild/examples/blob/7fc3f8b587ee415ff02ce358caa960f9533a912c/configurations/cc_test/defs.bzl + +""" + +load("//bazel:copts.bzl", "DEFAULT_COPTS") +load("//bazel:cc_binary_with_flags.bzl", "with_flags_transition") + +def _transition_rule_impl(ctx): + executable_src = ctx.executable.actual_test + executable_dst = ctx.actions.declare_file(ctx.label.name) + ctx.actions.run_shell( + tools = [executable_src], + outputs = [executable_dst], + command = "cp %s %s" % (executable_src.path, executable_dst.path), + ) + runfiles = ctx.attr.actual_test[0][DefaultInfo].default_runfiles + return [DefaultInfo(runfiles = runfiles, executable = executable_dst)] + +# This rule must end with a _test suffix or Bazel doesn't allow the test attribute to be true. +transition_test = rule( + implementation = _transition_rule_impl, + attrs = { + # set_flags is a dictionary with the keys being the short-form of a flag name + # (e.g. the part that comes after the colon) and the value being a list of values + # that the flag should be set to, regardless of the relevant CLI flags. + # https://bazel.build/rules/lib/attr#string_list_dict + "set_flags": attr.string_list_dict(), + # This is the cc_test that should be made with the flags being set. + # Note specifically how it is modified using with_flags_transition, which + # ensures that the flags propagates down the graph. Must be executable + # so the _transition_rule_impl can use it as an executable. + # https://bazel.build/rules/lib/attr#label + "actual_test": attr.label(cfg = with_flags_transition, executable = True), + # This is a stock Bazel requirement for any rule that uses Starlark + # transitions. It's okay to copy the below verbatim for all such rules. + # + # The purpose of this requirement is to give the ability to restrict + # which packages can invoke these rules, since Starlark transitions + # make much larger graphs possible that can have memory and performance + # consequences for your build. The allowlist defaults to "everything". + # But you can redefine it more strictly if you feel that's prudent. + "_allowlist_function_transition": attr.label( + default = "@bazel_tools//tools/allowlists/function_transition_allowlist", + ), + }, + # Means it works with "$ bazel test". https://bazel.build/rules/lib/globals#rule.test + test = True, +) + +def cc_test_with_flags(name, set_flags = {}, copts = DEFAULT_COPTS, **kwargs): + """Builds a cc_test as if set_flags were set on the CLI. + + Args: + name: string, the name for the rule that is the binary, but with the flags changed via + a transition. Any dependents should use this name. + set_flags: dictionary of string to list of strings. The keys should be the name of the + flag, and the values should be the desired valid settings for that flag. + copts: a list of strings or select statements that control the compiler flags. + It has a sensible list of defaults. + **kwargs: Any flags that a cc_binary normally takes. + """ + cc_test_name = name + "_native_test" + transition_test( + name = name, + actual_test = ":%s" % cc_test_name, + set_flags = set_flags, + testonly = True, + ) + tags = kwargs.get("tags", []) + tags.append("manual") # We want to exclude this helper test from bazel test foo/... + kwargs["tags"] = tags + native.cc_test( + name = cc_test_name, + copts = copts, + **kwargs + ) diff --git a/bazel/common_config_settings/BUILD.bazel b/bazel/common_config_settings/BUILD.bazel index 8dc4120a7a70..b97cd758779c 100644 --- a/bazel/common_config_settings/BUILD.bazel +++ b/bazel/common_config_settings/BUILD.bazel @@ -1,4 +1,4 @@ -load("//bazel:macros.bzl", "bool_flag", "string_flag_with_values") +load("//bazel:macros.bzl", "bool_flag", "selects", "string_flag_with_values") licenses(["notice"]) @@ -109,6 +109,7 @@ string_flag_with_values( name = "fontmgr_factory", default = "empty_fontmgr_factory", values = [ + "android_fontmgr_factory", # Makes the default SkFontMgr load fonts from a hard-coded directory on disk. "custom_directory_fontmgr_factory", # Makes the default SkFontMgr load fonts from an SkEmbeddedResource that has been compiled @@ -121,6 +122,8 @@ string_flag_with_values( # Makes the default SkFontMgr return null. Typically used when font support is not desired. "empty_fontmgr_factory", "fontconfig_fontmgr_factory", + # Deprecated, do not use. + "fci_fontmgr_factory", ], ) @@ -132,6 +135,7 @@ string_flag_with_values( name = "include_fontmgr", multiple = True, values = [ + "android_fontmgr", # Allows the construction of an SkFontMgr that loads files from a programmatically # defined directory on disk. "custom_directory_fontmgr", @@ -141,6 +145,8 @@ string_flag_with_values( # Allows the construction of an SkFontMgr which returns empty fonts. "custom_empty_fontmgr", "fontconfig_fontmgr", + # Deprecated, do not use. + "fci_fontmgr", ], ) @@ -164,3 +170,53 @@ bool_flag( name = "use_icu", default = False, ) + +# These are some helpers to mean "either the fontmgr was enabled or its factory was" + +selects.config_setting_group( + name = "uses_android_fontmgr", + match_any = [ + ":android_fontmgr", + ":android_fontmgr_factory", + ], +) + +selects.config_setting_group( + name = "uses_custom_directory_fontmgr", + match_any = [ + ":custom_directory_fontmgr", + ":custom_directory_fontmgr_factory", + ], +) + +selects.config_setting_group( + name = "uses_custom_embedded_fontmgr", + match_any = [ + ":custom_embedded_fontmgr", + ":custom_embedded_fontmgr_factory", + ], +) + +selects.config_setting_group( + name = "uses_custom_empty_fontmgr", + match_any = [ + ":custom_empty_fontmgr", + ":custom_empty_fontmgr_factory", + ], +) + +selects.config_setting_group( + name = "uses_fontconfig_fontmgr", + match_any = [ + ":fontconfig_fontmgr", + ":fontconfig_fontmgr_factory", + ], +) + +selects.config_setting_group( + name = "uses_fci_fontmgr", + match_any = [ + ":fci_fontmgr", + ":fci_fontmgr_factory", + ], +) diff --git a/include/ports/BUILD.bazel b/include/ports/BUILD.bazel index 7363073d6d62..bc6036126266 100644 --- a/include/ports/BUILD.bazel +++ b/include/ports/BUILD.bazel @@ -1,28 +1,41 @@ -load("//bazel:macros.bzl", "exports_files_legacy") +load("//bazel:macros.bzl", "exports_files_legacy", "select_multi") licenses(["notice"]) exports_files_legacy() +filegroup( + name = "fontmgr", + srcs = select_multi( + { + "//bazel/common_config_settings:uses_android_fontmgr": ["SkFontMgr_android.h"], + "//bazel/common_config_settings:uses_custom_directory_fontmgr": ["SkFontMgr_directory.h"], + "//bazel/common_config_settings:uses_custom_empty_fontmgr": ["SkFontMgr_empty.h"], + "//bazel/common_config_settings:uses_fontconfig_fontmgr": ["SkFontMgr_fontconfig.h"], + "//bazel/common_config_settings:uses_fci_fontmgr": [ + "SkFontConfigInterface.h", + "SkFontMgr_FontConfigInterface.h", + ], + # TODO(kjlubick, bungeman) fuchsia_fontmgr, fontmgr_mac_ct, fontmgr_win + }, + ), +) + filegroup( name = "public_hdrs", srcs = [ - "SkCFObject.h", - "SkFontConfigInterface.h", - "SkFontMgr_FontConfigInterface.h", - "SkFontMgr_android.h", - "SkFontMgr_directory.h", - "SkFontMgr_empty.h", - "SkFontMgr_fontconfig.h", - "SkFontMgr_fuchsia.h", - "SkFontMgr_indirect.h", - "SkFontMgr_mac_ct.h", "SkImageGeneratorCG.h", "SkImageGeneratorNDK.h", "SkImageGeneratorWIC.h", - "SkRemotableFontMgr.h", - "SkTypeface_mac.h", - "SkTypeface_win.h", - ], + ":fontmgr", + ] + select({ + "@platforms//os:macos": ["SkCFObject.h"], + "@platforms//os:ios": ["SkCFObject.h"], + "//conditions:default": [], + }) + select({ + "@platforms//os:macos": ["SkTypeface_mac.h"], + "@platforms//os:windows": ["SkTypeface_win.h"], + "//conditions:default": [], + }), visibility = ["//include:__pkg__"], ) diff --git a/modules/canvaskit/compile_gm.sh b/modules/canvaskit/compile_gm.sh index 91b7af3af3b6..664acca9b76c 100755 --- a/modules/canvaskit/compile_gm.sh +++ b/modules/canvaskit/compile_gm.sh @@ -196,6 +196,10 @@ GLOBIGNORE+="tests/BackendAllocationTest.cpp:"\ # All the tests in these files crash. GLOBIGNORE+="tests/GrThreadSafeCacheTest.cpp" +# These are not tests +GLOBIGNORE+="tests/BazelNoopRunner.cpp:"\ +"tests/BazelTestRunner.cpp" + # Emscripten prefers that the .a files go last in order, otherwise, it # may drop symbols that it incorrectly thinks aren't used. One day, # Emscripten will use LLD, which may relax this requirement. diff --git a/resources/BUILD.bazel b/resources/BUILD.bazel new file mode 100644 index 000000000000..8adb3eac2b8a --- /dev/null +++ b/resources/BUILD.bazel @@ -0,0 +1,5 @@ +filegroup( + name = "resources", + srcs = glob(["**"]), + visibility = ["//tests:__pkg__"], +) diff --git a/src/BUILD.bazel b/src/BUILD.bazel index 7d3f43b84c04..4e49ca3e8a77 100644 --- a/src/BUILD.bazel +++ b/src/BUILD.bazel @@ -35,9 +35,10 @@ filegroup( ], "//conditions:default": [], }) + select({ - "//src/pdf:enable_pdf_backend_true": [ - "//src/pdf:srcs", - ], + "//src/pdf:enable_pdf_backend_true": ["//src/pdf:srcs"], + "//conditions:default": [], + }) + select({ + "//src/lazy:enable_discardable_memory_true": ["//src/lazy:srcs"], "//conditions:default": [], }), visibility = ["//:__pkg__"], @@ -74,9 +75,10 @@ filegroup( ], "//conditions:default": [], }) + select({ - "//src/pdf:enable_pdf_backend_true": [ - "//src/pdf:private_hdrs", - ], + "//src/pdf:enable_pdf_backend_true": ["//src/pdf:private_hdrs"], + "//conditions:default": [], + }) + select({ + "//src/lazy:enable_discardable_memory_true": ["//src/lazy:private_hdrs"], "//conditions:default": [], }), visibility = [ @@ -101,14 +103,10 @@ skia_cc_deps( "//src/sksl:needs_sksl": ["//src/sksl:deps"], "//conditions:default": [], }) + select({ - "//src/svg:enable_svg_canvas_true": [ - "//src/xml:deps", - ], + "//src/svg:enable_svg_canvas_true": ["//src/xml:deps"], "//conditions:default": [], }) + select({ - "//src/pdf:enable_pdf_backend_true": [ - "//src/pdf:deps", - ], + "//src/pdf:enable_pdf_backend_true": ["//src/pdf:deps"], "//conditions:default": [], }), ) diff --git a/src/lazy/BUILD.bazel b/src/lazy/BUILD.bazel index c7b3ff1ea6f5..0f740832f7e7 100644 --- a/src/lazy/BUILD.bazel +++ b/src/lazy/BUILD.bazel @@ -1,9 +1,19 @@ -load("//bazel:macros.bzl", "exports_files_legacy", "split_srcs_and_hdrs") +load("//bazel:macros.bzl", "bool_flag", "exports_files_legacy", "split_srcs_and_hdrs") licenses(["notice"]) exports_files_legacy() +bool_flag( + name = "enable_discardable_memory", + default = False, +) + +bool_flag( + name = "use_default_global_memory_pool", + default = False, +) + LAZY_FILES = [ "SkDiscardableMemoryPool.cpp", "SkDiscardableMemoryPool.h", @@ -13,3 +23,19 @@ split_srcs_and_hdrs( name = "lazy", files = LAZY_FILES, ) + +filegroup( + name = "srcs", + srcs = [ + ":lazy_srcs", + ], + visibility = ["//src:__pkg__"], +) + +filegroup( + name = "private_hdrs", + srcs = [ + ":lazy_hdrs", + ], + visibility = ["//src:__pkg__"], +) diff --git a/src/ports/BUILD.bazel b/src/ports/BUILD.bazel index f9ab0d9718ba..1b98154f3d01 100644 --- a/src/ports/BUILD.bazel +++ b/src/ports/BUILD.bazel @@ -4,6 +4,16 @@ licenses(["notice"]) exports_files_legacy() +filegroup( + name = "discardable_memory_pool", + srcs = select({ + "//src/lazy:use_default_global_memory_pool_true": ["SkDiscardableMemory_none.cpp"], + "//conditions:default": [], + }), +) + +# Any setting that causes this filegroup to be included also needs to have a dependency on freetype. +# See "deps" and "uses_freetype" at the bottom of this file. filegroup( name = "typeface_freetype", srcs = [ @@ -17,6 +27,9 @@ filegroup( filegroup( name = "fontmgr_factory", srcs = selects.with_or({ + "//bazel/common_config_settings:android_fontmgr_factory": [ + ":fontmgr_android_factory", + ], "//bazel/common_config_settings:custom_directory_fontmgr_factory": [ ":fontmgr_custom_directory_factory", ], @@ -29,6 +42,9 @@ filegroup( "//bazel/common_config_settings:fontconfig_fontmgr_factory": [ ":fontmgr_fontconfig_factory", ], + "//bazel/common_config_settings:fci_fontmgr_factory": [ + ":fontmgr_fci_factory", + ], ("//bazel/common_config_settings:empty_fontmgr_factory", "//conditions:default"): [ ":fontmgr_empty_factory", ], @@ -39,14 +55,33 @@ filegroup( name = "fontmgr", srcs = select_multi( { + "//bazel/common_config_settings:android_fontmgr": [":fontmgr_android"], "//bazel/common_config_settings:custom_directory_fontmgr": [":fontmgr_custom_directory"], "//bazel/common_config_settings:custom_embedded_fontmgr": [":fontmgr_custom_embedded"], "//bazel/common_config_settings:custom_empty_fontmgr": [":fontmgr_custom_empty"], "//bazel/common_config_settings:fontconfig_fontmgr": [":fontmgr_fontconfig"], + "//bazel/common_config_settings:fci_fontmgr": [":fontmgr_fci"], }, ), ) +filegroup( + name = "fontmgr_android", + srcs = [ + "SkFontMgr_android.cpp", + "SkFontMgr_android_parser.cpp", + ":typeface_freetype", + ], +) + +filegroup( + name = "fontmgr_android_factory", + srcs = [ + "SkFontMgr_android_factory.cpp", + ":fontmgr_android", + ], +) + filegroup( name = "fontmgr_custom", srcs = [ @@ -110,6 +145,8 @@ filegroup( ], ) +# Any setting that causes this filegroup to be included also needs to have a dependency on +# fontconfig. See "deps" and "uses_fontconfig" at the bottom of this file. filegroup( name = "fontmgr_fontconfig", srcs = [ @@ -126,6 +163,29 @@ filegroup( ], ) +# TODO(bungeman, kjlubick) break this up into the direct and Interface part. +# Alternatively, delete it. +# Any setting that causes this filegroup to be included also needs to have a dependency on +# fontconfig. See "deps" and "uses_fontconfig" at the bottom of this file. +filegroup( + name = "fontmgr_fci", + srcs = [ + "SkFontConfigInterface.cpp", + "SkFontConfigInterface_direct.cpp", + "SkFontConfigInterface_direct_factory.cpp", + "SkFontMgr_FontConfigInterface.cpp", + ":typeface_freetype", + ], +) + +filegroup( + name = "fontmgr_fci_factory", + srcs = [ + "SkFontMgr_FontConfigInterface_factory.cpp", + ":fontmgr_fci", + ], +) + filegroup( name = "global_init", srcs = ["SkGlobalInitialization_default.cpp"], @@ -180,6 +240,7 @@ filegroup( filegroup( name = "srcs", srcs = [ + ":discardable_memory_pool", ":fontmgr", ":fontmgr_factory", ":global_init", @@ -203,6 +264,15 @@ filegroup( }) + select({ "@platforms//os:ios": ["SkOSFile_ios.h"], "//conditions:default": [], + }) + select({ + "//bazel/common_config_settings:uses_android_fontmgr": ["SkFontMgr_android_parser.h"], + "//conditions:default": [], + }) + select({ + "//bazel/common_config_settings:uses_fci_fontmgr": [ + "SkFontConfigInterface_direct.h", + "SkFontConfigTypeface.h", + ], + "//conditions:default": [], }), visibility = ["//src:__pkg__"], ) @@ -210,22 +280,20 @@ filegroup( selects.config_setting_group( name = "uses_freetype", match_any = [ - "//bazel/common_config_settings:custom_directory_fontmgr", - "//bazel/common_config_settings:custom_directory_fontmgr_factory", - "//bazel/common_config_settings:custom_embedded_fontmgr", - "//bazel/common_config_settings:custom_embedded_fontmgr_factory", - "//bazel/common_config_settings:custom_empty_fontmgr", - "//bazel/common_config_settings:custom_empty_fontmgr_factory", - "//bazel/common_config_settings:fontconfig_fontmgr", - "//bazel/common_config_settings:fontconfig_fontmgr_factory", + "//bazel/common_config_settings:uses_android_fontmgr", + "//bazel/common_config_settings:uses_custom_directory_fontmgr", + "//bazel/common_config_settings:uses_custom_embedded_fontmgr", + "//bazel/common_config_settings:uses_custom_empty_fontmgr", + "//bazel/common_config_settings:uses_fontconfig_fontmgr", + "//bazel/common_config_settings:uses_fci_fontmgr", ], ) selects.config_setting_group( name = "uses_fontconfig", match_any = [ - "//bazel/common_config_settings:fontconfig_fontmgr", - "//bazel/common_config_settings:fontconfig_fontmgr_factory", + "//bazel/common_config_settings:uses_fontconfig_fontmgr", + "//bazel/common_config_settings:uses_fci_fontmgr", ], ) @@ -242,5 +310,8 @@ skia_cc_deps( }) + select({ ":uses_fontconfig": ["//bazel/external/fontconfig:fontconfig"], "//conditions:default": [], + }) + select({ + "//bazel/common_config_settings:uses_android_fontmgr": ["@expat"], + "//conditions:default": [], }), ) diff --git a/src/utils/BUILD.bazel b/src/utils/BUILD.bazel index f02db702a1c0..229594d06161 100644 --- a/src/utils/BUILD.bazel +++ b/src/utils/BUILD.bazel @@ -79,6 +79,7 @@ filegroup( ], visibility = [ "//modules/skottie:__pkg__", + "//tools/debugger:__pkg__", ], ) @@ -90,6 +91,7 @@ filegroup( ], visibility = [ "//modules/skottie:__pkg__", + "//tools/debugger:__pkg__", ], ) diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel new file mode 100644 index 000000000000..077950dd300f --- /dev/null +++ b/tests/BUILD.bazel @@ -0,0 +1,643 @@ +load("//bazel:macros.bzl", "skia_cc_library") +load(":tests.bzl", "skia_cpu_tests", "skia_ganesh_tests") + +CODEC_TESTS = [ + "AndroidCodecTest.cpp", + "AnimatedImageTest.cpp", + "CodecAnimTest.cpp", + "CodecExactReadTest.cpp", + "CodecPartialTest.cpp", + "CodecRecommendedTypeTest.cpp", + "CodecTest.cpp", + "ColorSpaceTest.cpp", + "EncodeTest.cpp", + "EncodedInfoTest.cpp", + "ExifTest.cpp", + "GifTest.cpp", + "IndexedPngOverflowTest.cpp", + "WebpTest.cpp", + "YUVTest.cpp", +] + +CPU_ONLY_TESTS = [ + "AAClipTest.cpp", + "ArenaAllocTest.cpp", + "AsADashTest.cpp", + "AvifTest.cpp", + "BadIcoTest.cpp", + "BitmapCopyTest.cpp", + "BitmapGetColorTest.cpp", + "BitmapTest.cpp", + "BitSetTest.cpp", + "BlitMaskClip.cpp", + "BRDTest.cpp", + "CachedDecodingPixelRefTest.cpp", + "CanvasStateTest.cpp", + "CanvasTest.cpp", + "ChecksumTest.cpp", + "ClipCubicTest.cpp", + "ClipperTest.cpp", + "ClipStackTest.cpp", + "ColorMatrixTest.cpp", + "ColorPrivTest.cpp", + "ColorTest.cpp", + "CtsEnforcement.cpp", + "CubicMapTest.cpp", + "DashPathEffectTest.cpp", + "DataRefTest.cpp", + "DequeTest.cpp", + "DescriptorTest.cpp", + "DrawBitmapRectTest.cpp", + "DrawPathTest.cpp", + "DrawTextTest.cpp", + "EmptyPathTest.cpp", + "F16StagesTest.cpp", + "FillPathTest.cpp", + "FitsInTest.cpp", + "FlattenableFactoryToName.cpp", + "FlattenableNameToFactory.cpp", + "FlattenDrawableTest.cpp", + "Float16Test.cpp", + "FontHostStreamTest.cpp", + "FontHostTest.cpp", + "FontNamesTest.cpp", + "FontTest.cpp", + "FrontBufferedStreamTest.cpp", + "GeometryTest.cpp", + "GLBackendSurfaceTest.cpp", + "GlyphRunTest.cpp", + "HashTest.cpp", + "HighContrastFilterTest.cpp", + "HSVRoundTripTest.cpp", + "ICCTest.cpp", + "ImageBitmapTest.cpp", + "ImageFrom565Bitmap.cpp", + "ImageGeneratorTest.cpp", + "IncrTopoSortTest.cpp", + "InfRectTest.cpp", + "InsetConvexPolyTest.cpp", + "InvalidIndexedPngTest.cpp", + "IsClosedSingleContourTest.cpp", + "JSONTest.cpp", + "LListTest.cpp", + "LRUCacheTest.cpp", + "M44Test.cpp", + "MallocPixelRefTest.cpp", + "MaskCacheTest.cpp", + "MathTest.cpp", + "MatrixProcsTest.cpp", + "MatrixTest.cpp", + "MD5Test.cpp", + "MemoryTest.cpp", + "MemsetTest.cpp", + "MeshTest.cpp", + "MetaDataTest.cpp", + "MipMapTest.cpp", + "NdkDecodeTest.cpp", + "NdkEncodeTest.cpp", + "NonlinearBlendingTest.cpp", + "OffsetSimplePolyTest.cpp", + "OnceTest.cpp", + "OSPathTest.cpp", + "OverAlignedTest.cpp", + "PaintTest.cpp", + "ParametricStageTest.cpp", + "ParseColorTest.cpp", + "ParsePathTest.cpp", + "PathBuilderTest.cpp", + "PathCoverageTest.cpp", + "PathMeasureTest.cpp", + "PathTest.cpp", + "PictureBBHTest.cpp", + "PictureShaderTest.cpp", + "PictureTest.cpp", + "PixelRefTest.cpp", + "Point3Test.cpp", + "PointTest.cpp", + "PolyUtilsTest.cpp", + "QuickRejectTest.cpp", + "RandomTest.cpp", + "ReadPixelsTest.cpp", + "RecorderTest.cpp", + "RecordingXfermodeTest.cpp", + "RecordOptsTest.cpp", + "RecordPatternTest.cpp", + "RecordTest.cpp", + "RectTest.cpp", + "RefCntTest.cpp", + "RegionTest.cpp", + "RoundRectTest.cpp", + "RRectInPathTest.cpp", + "RTreeTest.cpp", + "SafeMathTest.cpp", + "SamplingTest.cpp", + "ScalarTest.cpp", + "ScaleToSidesTest.cpp", + "SerialProcsTest.cpp", + "SerializationTest.cpp", + "ShaderOpacityTest.cpp", + "ShaderTest.cpp", + "ShadowTest.cpp", + "ShaperTest.cpp", + "SizeTest.cpp", + "SkBase64Test.cpp", + "SkBlockAllocatorTest.cpp", + "SkColor4fTest.cpp", + "SkColorSpaceXformStepsTest.cpp", + "Skbug6389.cpp", + "SkDOMTest.cpp", + "SkEnumBitMaskTest.cpp", + "SkGaussFilterTest.cpp", + "SkGlyphBufferTest.cpp", + "SkGlyphTest.cpp", + "SkImageTest.cpp", + "SkPathRangeIterTest.cpp", + "SkScalerCacheTest.cpp", + "SkSharedMutexTest.cpp", + "SkSLErrorTest.cpp", + "SkSLInterpreterTest.cpp", + "SkSLMemoryLayoutTest.cpp", + "SkSLTypeTest.cpp", + "SkSpanTest.cpp", + "SkStrikeCacheTest.cpp", + "SkStringViewTest.cpp", + "SkTBlockListTest.cpp", + "SkUTFTest.cpp", + "SkVMDebugTracePlayerTest.cpp", + "SkVMDebugTraceTest.cpp", + "SkVMTest.cpp", + "SkVxTest.cpp", + "SortTest.cpp", + "SrcOverTest.cpp", + "SRGBTest.cpp", + "StreamTest.cpp", + "StrikeForGPUTest.cpp", + "StringTest.cpp", + "StrokeTest.cpp", + "SwizzlerTest.cpp", + "TArrayTest.cpp", + "TDPQueueTest.cpp", + "TemplatesTest.cpp", + "TextBlobTest.cpp", + "TLazyTest.cpp", + "TracingTest.cpp", + "TypefaceTest.cpp", + "UnicodeTest.cpp", + "UtilsTest.cpp", + "VerticesTest.cpp", + "VkBackendSurfaceTest.cpp", + "VkDrawableTest.cpp", + "VkHardwareBufferTest.cpp", + "VkPriorityExtensionTest.cpp", + "VkProtectedContextTest.cpp", + "VkWrapTests.cpp", + "VkYcbcrSamplerTest.cpp", + "Writer32Test.cpp", + "YUVCacheTest.cpp", +] + +DEBUGGER_TESTS = [ + "MatrixClipCollapseTest.cpp", + "MultiPictureDocumentTest.cpp", + "DebugLayerManagerTest.cpp", + "RecordDrawTest.cpp", +] + +DISCARDABLE_MEMORY_POOL_TESTS = [ + "CachedDataTest.cpp", + "DiscardableMemoryPoolTest.cpp", + "DiscardableMemoryTest.cpp", + "ImageCacheTest.cpp", + "SkResourceCacheTest.cpp", +] + +# These files have tests requiring a Ganesh backend, and optionally, tests only for the CPU. +# The mock Ganesh backend is always available; the other ones depend on the compile flags used +# to invoke the tests see //bazel/buildrc for these configurations. +GANESH_TESTS = [ + "AdvancedBlendTest.cpp", + "ApplyGammaTest.cpp", + "BackendAllocationTest.cpp", + "BackendSurfaceMutableStateTest.cpp", + "BlendTest.cpp", + "BulkRectTest.cpp", + "ClearTest.cpp", + "ColorFilterTest.cpp", + "CompressedBackendAllocationTest.cpp", + "CopySurfaceTest.cpp", + "CullTestTest.cpp", + "DMSAATest.cpp", + "DeferredDisplayListTest.cpp", + "DeviceTest.cpp", + "DrawOpAtlasTest.cpp", + "EGLImageTest.cpp", + "ExtendedSkColorTypeTests.cpp", + "FindCubicConvex180ChopsTest.cpp", + "FloatingPointTextureTest.cpp", + "GpuDrawPathTest.cpp", + "GpuRectanizerTest.cpp", + "GrAHardwareBufferTest.cpp", + "GrClipStackTest.cpp", + "GrContextAbandonTest.cpp", + "GrContextFactoryTest.cpp", + "GrContextOOM.cpp", + "GrDDLImageTest.cpp", + "GrFinishedFlushTest.cpp", + "GrGLExtensionsTest.cpp", + "GrGlyphVectorTest.cpp", + "GrGpuBufferTest.cpp", + "GrMemoryPoolTest.cpp", + "GrMeshTest.cpp", + "GrMipMappedTest.cpp", + "GrOpListFlushTest.cpp", + "GrPipelineDynamicStateTest.cpp", + "GrPorterDuffTest.cpp", + "GrQuadBufferTest.cpp", + "GrQuadCropTest.cpp", + "GrRenderTaskClusterTest.cpp", + "GrSlugTest.cpp", + "GrStyledShapeTest.cpp", + "GrSubmittedFlushTest.cpp", + "GrSurfaceResolveTest.cpp", + "GrSurfaceTest.cpp", + "GrTextBlobTest.cpp", + "GrTextureMipMapInvalidationTest.cpp", + "GrThreadSafeCacheTest.cpp", + "GradientTest.cpp", + "ImageFilterCacheTest.cpp", + "ImageIsOpaqueTest.cpp", + "ImageNewShaderTest.cpp", + "ImageTest.cpp", + "LazyProxyTest.cpp", + "LazyStencilAttachmentTest.cpp", + "MatrixColorFilterTest.cpp", + "MessageBusTest.cpp", + "OpChainTest.cpp", + "PathRendererCacheTests.cpp", + "PinnedImageTest.cpp", + "PreChopPathCurvesTest.cpp", + "PremulAlphaRoundTripTest.cpp", + "PrimitiveProcessorTest.cpp", + "ProcessorTest.cpp", + "ProgramsTest.cpp", + "PromiseImageTest.cpp", + "ProxyConversionTest.cpp", + "ProxyRefTest.cpp", + "ProxyTest.cpp", + "ReadWritePixelsGpuTest.cpp", + "RectangleTextureTest.cpp", + "RepeatedClippedBlurTest.cpp", + "ResourceAllocatorTest.cpp", + "ResourceCacheTest.cpp", + "RuntimeBlendTest.cpp", + "SRGBReadWritePixelsTest.cpp", + "SaveLayerOriginTest.cpp", + "ShaderImageFilterTest.cpp", + "SkRemoteGlyphCacheTest.cpp", + "SkRuntimeEffectTest.cpp", + "SkSLCross.cpp", + "SkSLES2ConformanceTest.cpp", + "Skbug12214.cpp", + "Skbug5221.cpp", + "Skbug6653.cpp", + "SpecialImageTest.cpp", + "SpecialSurfaceTest.cpp", + "SrcSrcOverBatchTest.cpp", + "SurfaceDrawContextTest.cpp", + "SurfaceSemaphoreTest.cpp", + "SurfaceTest.cpp", + "TestTest.cpp", + "TextureBindingsResetTest.cpp", + "TextureOpTest.cpp", + "TextureProxyTest.cpp", + "TextureStripAtlasManagerTest.cpp", + "TopoSortTest.cpp", + "TraceMemoryDumpTest.cpp", + "TransferPixelsTest.cpp", + "TriangulatingPathRendererTests.cpp", + "WangsFormulaTest.cpp", + "WindowRectanglesTest.cpp", + "WrappedSurfaceCopyOnWriteTest.cpp", + "WritePixelsTest.cpp", + "SkSLDSLTest.cpp", + "BlurTest.cpp", + "DefaultPathRendererTest.cpp", + "ImageFilterTest.cpp", + "SkSLTest.cpp", +] + +PATHOPS_TESTS = [ + "PathOpsAngleIdeas.cpp", + "PathOpsAngleTest.cpp", + "PathOpsAsWindingTest.cpp", + "PathOpsBattles.cpp", + "PathOpsBoundsTest.cpp", + "PathOpsBuilderConicTest.cpp", + "PathOpsBuilderTest.cpp", + "PathOpsBuildUseTest.cpp", + "PathOpsChalkboardTest.cpp", + "PathOpsConicIntersectionTest.cpp", + "PathOpsConicLineIntersectionTest.cpp", + "PathOpsConicQuadIntersectionTest.cpp", + "PathOpsCubicConicIntersectionTest.cpp", + "PathOpsCubicIntersectionTest.cpp", + "PathOpsCubicLineIntersectionIdeas.cpp", + "PathOpsCubicLineIntersectionTest.cpp", + "PathOpsCubicQuadIntersectionTest.cpp", + "PathOpsCubicReduceOrderTest.cpp", + "PathOpsDCubicTest.cpp", + "PathOpsDLineTest.cpp", + "PathOpsDPointTest.cpp", + "PathOpsDRectTest.cpp", + "PathOpsDVectorTest.cpp", + "PathOpsExtendedTest.cpp", + "PathOpsFuzz763Test.cpp", + "PathOpsInverseTest.cpp", + "PathOpsIssue3651.cpp", + "PathOpsLineIntersectionTest.cpp", + "PathOpsLineParametetersTest.cpp", + "PathOpsOpCircleThreadedTest.cpp", + "PathOpsOpCubicThreadedTest.cpp", + "PathOpsOpLoopThreadedTest.cpp", + "PathOpsOpRectThreadedTest.cpp", + "PathOpsOpTest.cpp", + "PathOpsQuadIntersectionTest.cpp", + "PathOpsQuadLineIntersectionTest.cpp", + "PathOpsQuadLineIntersectionThreadedTest.cpp", + "PathOpsQuadReduceOrderTest.cpp", + "PathOpsSimplifyDegenerateThreadedTest.cpp", + "PathOpsSimplifyFailTest.cpp", + "PathOpsSimplifyQuadralateralsThreadedTest.cpp", + "PathOpsSimplifyQuadThreadedTest.cpp", + "PathOpsSimplifyRectThreadedTest.cpp", + "PathOpsSimplifyTest.cpp", + "PathOpsSimplifyTrianglesThreadedTest.cpp", + "PathOpsSkpTest.cpp", + "PathOpsThreeWayTest.cpp", + "PathOpsTigerTest.cpp", + "PathOpsTightBoundsTest.cpp", + "PathOpsTypesTest.cpp", + "StrokerTest.cpp", +] + +PDF_TESTS = [ + "AnnotationTest.cpp", + "PDFDeflateWStreamTest.cpp", + "PDFDocumentTest.cpp", + "PDFGlyphsToUnicodeTest.cpp", + "PDFJpegEmbedTest.cpp", + "PDFMetadataAttributeTest.cpp", + "PDFOpaqueSrcModeToSrcOverTest.cpp", + "PDFPrimitivesTest.cpp", + "PDFTaggedLinkTest.cpp", + "PDFTaggedPruningTest.cpp", + "PDFTaggedTableTest.cpp", + "PDFTaggedTest.cpp", +] + +skia_cc_library( + name = "tests_base", + testonly = True, + srcs = [ + "CanvasStateHelpers.cpp", + "CtsEnforcement.cpp", + "Test.cpp", + "TestHarness.cpp", + "//tools/flags", + ] + select({ + "//src/gpu:has_gpu_backend": ["TestUtils.cpp"], + "//conditions:default": [], + }), + hdrs = [ + "CanvasStateHelpers.h", + "CodecPriv.h", + "CtsEnforcement.h", + "FakeStreams.h", + "RecordTestUtils.h", + "Test.h", + "TestHarness.h", + "//tools/fonts:test_empty_typeface", + ] + select({ + "//src/gpu:has_gpu_backend": ["TestUtils.h"], + "//conditions:default": [], + }), + deps = [ + "//:skia_internal", + "//tools:registry", + "//tools:tool_utils", + ] + select({ + "//src/gpu:has_gpu_backend": ["//tools/gpu:utils"], + "//conditions:default": [], + }) + select({ + "//src/sksl:needs_sksl": ["//tools:runtime_blend_utils"], + "//conditions:default": [], + }), +) + +skia_cc_library( + name = "fontmgr_tests_base", + testonly = True, + srcs = [ + "FontMgrFlags.cpp", + ], + deps = [":tests_base"], +) + +skia_cc_library( + name = "pathops_tests_base", + testonly = True, + srcs = [ + "PathOpsCubicIntersectionTestData.cpp", + "PathOpsDebug.cpp", + "PathOpsExtendedTest.cpp", + "PathOpsQuadIntersectionTestData.cpp", + "PathOpsTestCommon.cpp", + "PathOpsThreadedCommon.cpp", + "SubsetPath.cpp", + ], + hdrs = [ + "PathOpsCubicIntersectionTestData.h", + "PathOpsDebug.h", + "PathOpsExtendedTest.h", + "PathOpsQuadIntersectionTestData.h", + "PathOpsTSectDebug.h", + "PathOpsTestCommon.h", + "PathOpsThreadedCommon.h", + "SubsetPath.h", + "Test.h", + ], + deps = [":tests_base"], +) + +skia_cc_library( + name = "dsl_only_test_base", + testonly = True, + srcs = [ + "SkSLDSLUtil.cpp", + ], + deps = [":tests_base"], +) + +# These macros generates one test target per file listed in the passed in list. The test target +# has the name of the file, with the .cpp extension removed. +skia_cpu_tests( + name = "codec_tests", + flags = { + "include_decoder": [ + "avif_decode_codec", + "gif_decode_codec", + "jpeg_decode_codec", + "jxl_decode_codec", + "png_decode_codec", + "raw_decode_codec", + "webp_decode_codec", + ], + "include_encoder": [ + "jpeg_encode_codec", + "png_encode_codec", + "webp_encode_codec", + ], + }, + harness = ":tests_base", + resources = ["//resources"], + tests = CODEC_TESTS, +) + +skia_cpu_tests( + name = "cpu_only_tests", + flags = { + "fontmgr_factory": ["custom_directory_fontmgr_factory"], + "enable_sksl": ["True"], + "enable_sksl_tracing": ["True"], + "include_decoder": [ + "jpeg_decode_codec", + "png_decode_codec", + ], + "include_encoder": [ + "png_encode_codec", + ], + }, + harness = ":tests_base", + resources = ["//resources"], + tests = CPU_ONLY_TESTS, +) + +skia_cpu_tests( + name = "discardable_memory_tests", + flags = { + "enable_discardable_memory": ["True"], + "use_default_global_memory_pool": ["True"], + }, + harness = ":tests_base", + resources = ["//resources"], + tests = DISCARDABLE_MEMORY_POOL_TESTS, +) + +skia_ganesh_tests( + name = "debugger_tests", + extra_deps = ["//tools/debugger"], + harness = ":tests_base", + tests = DEBUGGER_TESTS, +) + +skia_ganesh_tests( + name = "dsl_only_tests", + harness = ":dsl_only_test_base", + resources = ["//resources"], + tests = ["SkSLDSLOnlyTest.cpp"], +) + +skia_ganesh_tests( + name = "ganesh_tests", + harness = ":tests_base", + resources = ["//resources"], + tests = GANESH_TESTS, +) + +skia_cpu_tests( + name = "fontmgr_android_test", + flags = { + "fontmgr_factory": ["android_fontmgr_factory"], + }, + harness = ":fontmgr_tests_base", + resources = ["//resources"], + tests = ["FontMgrAndroidParserTest.cpp"], +) + +skia_cpu_tests( + name = "fontmgr_test", + flags = { + "fontmgr_factory": ["custom_directory_fontmgr_factory"], + }, + harness = ":fontmgr_tests_base", + resources = ["//resources"], + tests = ["FontMgrTest.cpp"], +) + +skia_cpu_tests( + name = "fontmgr_fci_test", + flags = { + "fontmgr_factory": ["fci_fontmgr_factory"], + }, + harness = ":fontmgr_tests_base", + resources = ["//resources"], + tests = ["FCITest.cpp"], +) + +# TODO(kjlubick, bungeman) This test probably won't pass on Windows. We'll need a mechanism for +# running tests only on certain platforms. This probably can be achieved by expanding limit_to +# to generate a test that is configured to run only on linux and one that will only run on Mac +# and Windows will ignore both of those tests. +skia_cpu_tests( + name = "fontmgr_fontconfig_test", + flags = { + "fontmgr_factory": ["fontconfig_fontmgr_factory"], + }, + harness = ":fontmgr_tests_base", + resources = ["//resources"], + tests = ["FontMgrFontConfigTest.cpp"], +) + +skia_cpu_tests( + name = "mac_only_tests", + harness = ":tests_base", + limit_to = ["@platforms//os:macos"], + tests = ["TypefaceMacTest.cpp"], +) + +skia_cpu_tests( + name = "pathops_tests", + harness = ":pathops_tests_base", + tests = PATHOPS_TESTS, +) + +skia_cpu_tests( + name = "pdf_tests", + flags = { + "fontmgr_factory": ["custom_directory_fontmgr_factory"], + "enable_pdf_backend": ["True"], + "include_decoder": ["jpeg_decode_codec"], + "include_encoder": ["jpeg_encode_codec"], + }, + harness = ":tests_base", + resources = ["//resources"], + tests = PDF_TESTS, +) + +skia_cpu_tests( + name = "svg_tests", + flags = { + "enable_svg_canvas": ["True"], + }, + harness = ":tests_base", + resources = ["//resources"], + tests = ["SVGDeviceTest.cpp"], +) + +skia_ganesh_tests( + name = "text_blob_cache_test", + extra_deps = ["//tools/fonts:random_scaler_context"], + harness = ":tests_base", + resources = ["//resources"], + tests = ["TextBlobCacheTest.cpp"], +) diff --git a/tests/BazelNoopRunner.cpp b/tests/BazelNoopRunner.cpp new file mode 100644 index 000000000000..33c2ef4f2892 --- /dev/null +++ b/tests/BazelNoopRunner.cpp @@ -0,0 +1,13 @@ +/* + * Copyright 2022 Google LLC + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * This is meant to be an executable that simply returns 0, indicating the test passed. + * This is how we can have CPU tests be no-ops when running "GPU tests", and vice-versa. + */ + +int main() { + return 0; +} diff --git a/tests/BazelTestRunner.cpp b/tests/BazelTestRunner.cpp new file mode 100644 index 000000000000..9552712b9aa0 --- /dev/null +++ b/tests/BazelTestRunner.cpp @@ -0,0 +1,156 @@ +/* + * Copyright 2022 Google LLC + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * This runs *all* the tests registered via the Test registry in series. If one or more fail, those + * error messages will be printed out and a non-zero exit code will be returned. Otherwise, the + * exit code will be 0. + */ + +#include "include/core/SkString.h" +#include "include/core/SkTypes.h" +#include "tests/Test.h" +#include "tools/Registry.h" + +#include "tests/TestHarness.h" + +#if SK_GPU_V1 +#include "include/gpu/GrContextOptions.h" +#include "include/gpu/GrDirectContext.h" +#include "include/gpu/GrTypes.h" +#include "include/private/gpu/ganesh/GrTypesPriv.h" +#include "tools/gpu/TestContext.h" +#endif + +class BazelReporter : public skiatest::Reporter { +public: + void reportFailed(const skiatest::Failure& failure) override { + SkDebugf("FAIL: %s\n", failure.toString().c_str()); + fFailed = true; + } + bool allowExtendedTest() const override { return false; } + bool verbose() const override { return false; } + bool ok() { return !fFailed; } +private: + bool fFailed = false; +}; + +#if SK_GPU_V1 +namespace skiatest { +bool IsGLContextType(sk_gpu_test::GrContextFactory::ContextType type) { + return GrBackendApi::kOpenGL == sk_gpu_test::GrContextFactory::ContextTypeBackend(type); +} +bool IsVulkanContextType(sk_gpu_test::GrContextFactory::ContextType type) { + return GrBackendApi::kVulkan == sk_gpu_test::GrContextFactory::ContextTypeBackend(type); +} +bool IsMetalContextType(sk_gpu_test::GrContextFactory::ContextType type) { + return GrBackendApi::kMetal == sk_gpu_test::GrContextFactory::ContextTypeBackend(type); +} +bool IsDirect3DContextType(sk_gpu_test::GrContextFactory::ContextType type) { + return GrBackendApi::kDirect3D == sk_gpu_test::GrContextFactory::ContextTypeBackend(type); +} +bool IsDawnContextType(sk_gpu_test::GrContextFactory::ContextType type) { + return GrBackendApi::kDawn == sk_gpu_test::GrContextFactory::ContextTypeBackend(type); +} +bool IsRenderingGLContextType(sk_gpu_test::GrContextFactory::ContextType type) { + return IsGLContextType(type) && sk_gpu_test::GrContextFactory::IsRenderingContext(type); +} +bool IsMockContextType(sk_gpu_test::GrContextFactory::ContextType type) { + return type == sk_gpu_test::GrContextFactory::kMock_ContextType; +} + +sk_gpu_test::GrContextFactory::ContextType compiledInContextTypes[] = { +#if defined(SK_GL) + // Use "native" instead of explicitly trying both OpenGL and OpenGL ES. Do not use GLES on + // desktop since tests do not account for not fixing http://skbug.com/2809 +#if defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC) + sk_gpu_test::GrContextFactory::kGL_ContextType, +#else + sk_gpu_test::GrContextFactory::kGLES_ContextType, +#endif +#endif // defined(SK_GL) +#if defined(SK_VULKAN) + sk_gpu_test::GrContextFactory::kVulkan_ContextType, +#endif +#if defined(SK_DAWN) + sk_gpu_test::GrContextFactory::kDawn_ContextType, +#endif +// TODO(kjlubick) Other Ganesh backends + sk_gpu_test::GrContextFactory::kMock_ContextType, +}; + +// The macros defined in Test.h eventually call into this function. For each GPU backend that is +// compiled in, we run the testFn with a freshly created +void RunWithGaneshTestContexts(GrContextTestFn* testFn, GrContextTypeFilterFn* filter, + Reporter* reporter, const GrContextOptions& options) { + sk_gpu_test::GrContextFactory factory(options); + + for (sk_gpu_test::GrContextFactory::ContextType ctxType : compiledInContextTypes) { + if (filter && !(*filter)(ctxType)) { + continue; + } + + sk_gpu_test::ContextInfo ctxInfo = factory.getContextInfo(ctxType); + if (ctxInfo.directContext()) { + (*testFn)(reporter, ctxInfo); + // In case the test changed the current context make sure we move it back before + // calling flush. + ctxInfo.testContext()->makeCurrent(); + // Sync so any release/finished procs get called. + ctxInfo.directContext()->flushAndSubmit(/*syncCPU=*/true); + } else { + SkDebugf("Unable to make direct context for Ganesh test.\n"); + SkASSERT(false); + return; + } + } +} + +} // namespace skiatest +#endif // #if SK_GPU_V1 + +TestHarness CurrentTestHarness() { + return TestHarness::kBazelTestRunner; +} + +int main() { + BazelReporter reporter; + for (skiatest::Test test : skiatest::TestRegistry::Range()) { + if (test.fTestType == skiatest::TestType::kCPU) { + SkDebugf("Running %s\n", test.fName); + test.cpu(&reporter); + SkDebugf("\tDone\n"); + } + } + +#if SK_GPU_V1 + GrContextOptions grCtxOptions; + // TODO(kjlubick) DM has grContextOptions set via flags. Should this runner have that too? + grCtxOptions.fExecutor = nullptr; + grCtxOptions.fAllowPathMaskCaching = true; + grCtxOptions.fFailFlushTimeCallbacks = false; + grCtxOptions.fAllPathsVolatile = false; + grCtxOptions.fGpuPathRenderers = GpuPathRenderers::kDefault; + grCtxOptions.fDisableDriverCorrectnessWorkarounds = false; + grCtxOptions.fResourceCacheLimitOverride = -1; + grCtxOptions.fReduceOpsTaskSplitting = GrContextOptions::Enable::kNo; + for (skiatest::Test test : skiatest::TestRegistry::Range()) { + if (test.fTestType == skiatest::TestType::kGanesh) { + SkDebugf("Running %s\n", test.fName); + test.ganesh(&reporter, grCtxOptions); + SkDebugf("\tDone\n"); + } + } +#endif + + // TODO(kjlubick) Graphite support + + if (reporter.ok()) { + SkDebugf("PASS\n"); + return 0; + } + SkDebugf("FAIL\n"); + return 1; +} diff --git a/tests/Test.h b/tests/Test.h index 20f09b63e3c6..6db3cc6e9b7b 100644 --- a/tests/Test.h +++ b/tests/Test.h @@ -9,10 +9,22 @@ #include "include/core/SkString.h" #include "include/core/SkTypes.h" +#include "include/private/SkNoncopyable.h" +#include "include/private/SkTArray.h" #include "src/core/SkTraceEvent.h" #include "tests/CtsEnforcement.h" #include "tools/Registry.h" -#include "tools/gpu/GrContextFactory.h" + +#if SK_GPU_V1 +#include "tools/gpu/GrContextFactory.h" // IWYU pragma: export (because it is used by a macro) +#else +namespace sk_gpu_test { class ContextInfo; } +#endif + +#include +#include + +struct GrContextOptions; namespace skgpu::graphite { class Context; } @@ -144,7 +156,11 @@ struct Test { using TestRegistry = sk_tools::Registry; +#if SK_GPU_V1 using GrContextFactoryContextType = sk_gpu_test::GrContextFactory::ContextType; +#else +using GrContextFactoryContextType = nullptr_t; +#endif typedef void GrContextTestFn(Reporter*, const sk_gpu_test::ContextInfo&); typedef bool GrContextTypeFilterFn(GrContextFactoryContextType); diff --git a/tests/TestHarness.h b/tests/TestHarness.h index 349ef7e4bdda..9857d9d34812 100644 --- a/tests/TestHarness.h +++ b/tests/TestHarness.h @@ -17,6 +17,7 @@ enum class TestHarness { kListGpuUnitTests, kSkQP, kWasmGMTests, + kBazelTestRunner, }; TestHarness CurrentTestHarness(); bool CurrentTestHarnessIsSkQP(); diff --git a/tests/tests.bzl b/tests/tests.bzl new file mode 100644 index 000000000000..7bc352d36fa9 --- /dev/null +++ b/tests/tests.bzl @@ -0,0 +1,156 @@ +""" +This file contains macros that generate multiple test targets, one per file. +""" + +load("//bazel:cc_test_with_flags.bzl", "cc_test_with_flags") + +# buildifier: disable=unused-variable +def skia_cpu_tests( + name, + tests, + harness, + resources = [], + flags = {}, + extra_deps = [], + limit_to = []): + """Defines tests that should run only with --config=cpu + + This macro will create one cc_test_with_flags rule for each file in tests. + These tests are configured to use the BazelTestRunner and actually run all tests + (e.g. those defined with DEF_TEST) in the file if no GPU backend has been specified, + that is, the bazel test command was invoked with --config=cpu (see buildrc for this + definition). + + This macro cannot un-define those targets completely if a GPU backend has been specified + because the macro runs before the config flags are available for use. An analogy is a + C++ macro cannot do a #if on the value of a C++ variable. + + Instead, if a GPU backend has been specified (e.g. --config=gl), we only compile the + BazelNoopRunner.cpp and nothing else (e.g. no deps, not even Skia). This makes any CPU tests + a trivially passing executable, which can easily be cached and effectively skipped. + + Args: + name: Gives a human readable description of a group of tests; not actually used by Bazel. + tests: A list of strings, corresponding to C++ files with one or more DEF_TEST (see Test.h). + harness: A label (string) corresponding to a skia_cc_library which all the supplementary + test helpers, utils, etc. (e.g. Test.h and Test.cpp). Ideally, this is as small + as feasible, to avoid unnecessary bloat or recompilation if something unrelated + changes. + resources: A label corresponding to a file_group target that has any skia resource files + (e.g. images, fonts) needed to run these tests. Resources change infrequently, + so it's not super important that this be a precise list. + flags: A map of strings to lists of strings to specify features that must be compiled in + for these tests to work. For example, tests targeting our codec logic will want the + various codecs included, but most tests won't need that. + extra_deps: A list of labels corresponding to skia_cc_library targets which this test needs + to work, typically some utility located under //tools + limit_to: A list of platform labels (e.g. @platform//os:foo; @platform//cpu:bar) which + restrict where this test will be compiled and ran. If the list is empty, it will + run anywhere. If it is non-empty, it will only run on platforms which match the + entire set of constraints. See https://github.com/bazelbuild/platforms for these. + """ + for filename in tests: + cc_test_with_flags( + name = filename[:-4], # trim .cpp + size = "small", + srcs = select({ + # Make this a no-op test if compiling with a GPU backend. + "//src/gpu:has_gpu_backend": ["BazelNoopRunner.cpp"], + "//conditions:default": [ + "BazelTestRunner.cpp", + filename, + ], + }), + deps = select({ + "//src/gpu:has_gpu_backend": [], + # Only build and apply deps if we have a no-op test. + "//conditions:default": [ + harness, + "//:skia_internal", + ] + extra_deps, + }), + data = resources, + set_flags = flags, + target_compatible_with = limit_to, + ) + +# buildifier: disable=unused-variable +def skia_ganesh_tests( + name, + tests, + harness, + resources = [], + flags = {}, + extra_deps = [], + limit_to = []): + """Defines tests that should run only when a Ganesh GPU backend is compiled in, e.g --config=gl + + This macro will create one cc_test_with_flags rule for each file in tests. + These tests are configured to use the BazelTestRunner and actually run all tests (e.g. those + defined with DEF_TEST or DEF_GANESH_TEST) in the file if a Ganesh GPU backend has been + specified, that is, the bazel test command was invoked with --config=gl or --config=vk + (see buildrc for this definition). + + This macro cannot un-define those targets completely if only the CPU backend is being used + because the macro runs before the config flags are available for use. An analogy is a + C++ macro cannot do a #if on the value of a C++ variable. + + Instead, if a Ganesh GPU backend has not been specified (e.g. --config=cpu), we only compile the + BazelNoopRunner.cpp and nothing else (e.g. no deps, not even Skia). This makes any Ganesh GPU + tests a trivially passing executable, which can easily be cached and effectively skipped. + + Test files may have both CPU tests (i.e. DEF_TEST) and GPU tests (e.g. DEF_GANESH_TEST). The + BazelTestRunner will always run all tests that were compiled in. The CPU tests defined in this + way will *not* be run with --config=cpu because they live in a file that can only be compiled + with at least one GPU backend; they will be run with a config like --config=gl, along side the + GPU tests defined with DEF_GANESH_TEST. + + Args: + name: Gives a human readable description of a group of tests; not actually used by Bazel. + tests: A list of strings, corresponding to C++ files with one or more DEF_GANESH_TEST + (see Test.h). + harness: A label (string) corresponding to a skia_cc_library which all the supplementary + test helpers, utils, etc. (e.g. Test.h and Test.cpp). Ideally, this is as small + as feasible, to avoid unnecessary bloat or recompilation if something unrelated + changes. + resources: A label corresponding to a file_group target that has any skia resource files + (e.g. images, fonts) needed to run these tests. Resources change infrequently, + so it's not super important that this be a precise list. + flags: A map of strings to lists of strings to specify features that must be compiled in + for these tests to work. For example, tests targeting our codec logic will want the + various codecs included, but most tests won't need that. + extra_deps: A list of labels corresponding to skia_cc_library targets which this test needs + to work, typically some utility located under //tools + limit_to: A list of platform labels (e.g. @platform//os:foo; @platform//cpu:bar) which + restrict where this test will be compiled and ran. If the list is empty, it will + run anywhere. If it is non-empty, it will only run on platforms which match the + entire set of constraints. See https://github.com/bazelbuild/platforms for these. + """ + for filename in tests: + cc_test_with_flags( + name = filename[:-4], # trim .cpp + size = "small", + srcs = select({ + "//src/gpu:has_gpu_backend": [ + "BazelTestRunner.cpp", + filename, + ], + # Make this a no-op test if not compiling with a Ganesh GPU backend. + "//conditions:default": ["BazelNoopRunner.cpp"], + }), + deps = select({ + # Only build and apply deps if we have a no-op test. + "//src/gpu:has_gpu_backend": [ + harness, + "//:skia_internal", + ] + extra_deps, + "//conditions:default": [], + }), + data = resources, + set_flags = flags, + target_compatible_with = limit_to, + tags = [ + # We currently have no RBE machines with GPUs, so we cannot run these remotely. + "no-remote", + ], + ) diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel index ea55b662b945..15846ffb796d 100644 --- a/tools/BUILD.bazel +++ b/tools/BUILD.bazel @@ -1,4 +1,4 @@ -load("//bazel:macros.bzl", "exports_files_legacy", "py_binary", "skia_cc_library") +load("//bazel:macros.bzl", "exports_files_legacy", "py_binary", "skia_cc_library", "skia_objc_library") licenses(["notice"]) @@ -30,8 +30,52 @@ skia_cc_library( ], ) +skia_cc_library( + name = "registry", + hdrs = ["Registry.h"], + visibility = ["//tests:__subpackages__"], + deps = ["//:skia_internal"], +) + py_binary( name = "embed_resources", srcs = ["embed_resources.py"], visibility = ["//:__subpackages__"], ) + +skia_cc_library( + name = "autorelease_pool", + hdrs = ["AutoreleasePool.h"], + visibility = ["//tools/gpu:__pkg__"], +) + +skia_objc_library( + name = "autorelease_pool_objc", + srcs = ["AutoreleasePool.mm"], + hdrs = ["AutoreleasePool.h"], + visibility = ["//tools/gpu:__pkg__"], +) + +skia_cc_library( + name = "url_data_manager", + srcs = ["UrlDataManager.cpp"], + hdrs = ["UrlDataManager.h"], + visibility = ["//tools/debugger:__pkg__"], + deps = ["//:skia_internal"], +) + +skia_cc_library( + name = "sk_sharing_proc", + srcs = ["SkSharingProc.cpp"], + hdrs = ["SkSharingProc.h"], + visibility = ["//tools/debugger:__pkg__"], + deps = ["//:skia_internal"], +) + +skia_cc_library( + name = "runtime_blend_utils", + srcs = ["RuntimeBlendUtils.cpp"], + hdrs = ["RuntimeBlendUtils.h"], + visibility = ["//tests:__pkg__"], + deps = ["//:skia_internal"], +) diff --git a/tools/debugger/BUILD.bazel b/tools/debugger/BUILD.bazel new file mode 100644 index 000000000000..03fecf64e81d --- /dev/null +++ b/tools/debugger/BUILD.bazel @@ -0,0 +1,29 @@ +load("//bazel:macros.bzl", "exports_files_legacy", "skia_cc_library") + +licenses(["notice"]) + +exports_files_legacy() + +skia_cc_library( + name = "debugger", + srcs = [ + "DebugCanvas.cpp", + "DebugLayerManager.cpp", + "DrawCommand.cpp", + "JsonWriteBuffer.cpp", + "//src/utils:json_hdrs", + "//src/utils:json_srcs", + ], + hdrs = [ + "DebugCanvas.h", + "DebugLayerManager.h", + "DrawCommand.h", + "JsonWriteBuffer.h", + ], + visibility = ["//tests:__subpackages__"], + deps = [ + "//:skia_internal", + "//tools:sk_sharing_proc", + "//tools:url_data_manager", + ], +) diff --git a/tools/flags/BUILD.bazel b/tools/flags/BUILD.bazel index 6ca22d1851b3..a4f261dc11ec 100644 --- a/tools/flags/BUILD.bazel +++ b/tools/flags/BUILD.bazel @@ -13,6 +13,7 @@ filegroup( ], visibility = [ "//modules/skottie:__pkg__", + "//tests:__subpackages__", "//tools:__subpackages__", ], ) diff --git a/tools/fonts/BUILD.bazel b/tools/fonts/BUILD.bazel index 692f4ed7dfdd..1ffd478b8435 100644 --- a/tools/fonts/BUILD.bazel +++ b/tools/fonts/BUILD.bazel @@ -1,4 +1,4 @@ -load("//bazel:macros.bzl", "exports_files_legacy") +load("//bazel:macros.bzl", "exports_files_legacy", "skia_cc_library") licenses(["notice"]) @@ -28,3 +28,18 @@ filegroup( ], visibility = ["//tools:__subpackages__"], ) + +filegroup( + name = "test_empty_typeface", + testonly = True, + srcs = ["TestEmptyTypeface.h"], + visibility = ["//tests:__pkg__"], +) + +skia_cc_library( + name = "random_scaler_context", + srcs = ["RandomScalerContext.cpp"], + hdrs = ["RandomScalerContext.h"], + visibility = ["//tests:__pkg__"], + deps = ["//:skia_internal"], +) diff --git a/tools/gpu/BUILD.bazel b/tools/gpu/BUILD.bazel index 14a920f4c9b2..be872741cba7 100644 --- a/tools/gpu/BUILD.bazel +++ b/tools/gpu/BUILD.bazel @@ -37,15 +37,28 @@ skia_cc_library( "//tools/gpu/gl:private_hdrs", "//tools/gpu/gl:srcs", ], + "//src/gpu:vulkan_backend": [ + "//tools/gpu/vk:private_hdrs", + "//tools/gpu/vk:srcs", + ], + "//src/gpu:dawn_backend": [ + "//tools/gpu/dawn:private_hdrs", + "//tools/gpu/dawn:srcs", + ], # TODO(kjlubick) Handle other backends }), hdrs = [ "GrContextFactory.h", ], - visibility = ["//modules/skottie:__pkg__"], + visibility = [ + "//modules/skottie:__pkg__", + "//tests:__pkg__", + ], deps = ["//:skia_internal"] + select_multi({ - "//src/gpu:gl_backend": [ - "//tools/gpu/gl:deps", - ], + "//src/gpu:gl_backend": ["//tools/gpu/gl:deps"], + "//src/gpu:dawn_backend": ["//tools/gpu/dawn:deps"], + }) + select({ + "@platforms//os:macos": ["//tools:autorelease_pool_objc"], + "//conditions:default": ["//tools:autorelease_pool"], }), ) diff --git a/tools/gpu/dawn/BUILD.bazel b/tools/gpu/dawn/BUILD.bazel new file mode 100644 index 000000000000..8466aac76e54 --- /dev/null +++ b/tools/gpu/dawn/BUILD.bazel @@ -0,0 +1,30 @@ +load("//bazel:macros.bzl", "exports_files_legacy", "skia_cc_deps") + +licenses(["notice"]) + +exports_files_legacy() + +filegroup( + name = "private_hdrs", + srcs = [ + "DawnTestContext.h", + ], + visibility = ["//tools/gpu:__pkg__"], +) + +filegroup( + name = "srcs", + srcs = [ + "DawnTestContext.cpp", + ], + visibility = ["//tools/gpu:__pkg__"], +) + +skia_cc_deps( + name = "deps", + visibility = ["//tools/gpu:__pkg__"], + deps = select({ + "@platforms//os:linux": ["//include/third_party/vulkan"], + "//conditions:default": [], + }), +) diff --git a/tools/gpu/vk/BUILD.bazel b/tools/gpu/vk/BUILD.bazel index 8e616657c65e..af0fb866f3b7 100644 --- a/tools/gpu/vk/BUILD.bazel +++ b/tools/gpu/vk/BUILD.bazel @@ -21,3 +21,22 @@ skia_cc_library( "//include/third_party/vulkan", ], ) + +filegroup( + name = "private_hdrs", + srcs = [ + "GrVulkanDefines.h", + "VkTestContext.h", + "VkTestUtils.h", + ], + visibility = ["//tools/gpu:__pkg__"], +) + +filegroup( + name = "srcs", + srcs = [ + "VkTestContext.cpp", + "VkTestUtils.cpp", + ], + visibility = ["//tools/gpu:__pkg__"], +)