• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# https://github.com/bazelbuild/bazel-skylib
2load("@bazel_skylib//lib:selects.bzl", "selects")
3load("//bazel:macros.bzl", "select_multi")
4
5package(default_visibility = ["//:__subpackages__"])
6
7cc_test(
8    name = "bazel_test",
9    size = "small",
10    srcs = [
11        "//experimental/bazel_test:srcs",
12        "//include/config:hdrs",
13        "//include/core:hdrs",
14        "//src/ports:skdebug",
15    ],
16    deps = [
17        "//third_party:libpng",
18        "//third_party:musl_compat",
19    ],
20)
21
22CORE_SRCS = [
23    "//include/private:hdrs",
24    "//include/third_party:skcms-hdrs",
25    "//src/android:srcs",
26    "//src/codec:srcs",
27    "//src/core:srcs",
28    "//src/image:srcs",
29    "//src/images:srcs",
30    "//src/effects:srcs",
31    "//src/opts:srcs",
32    "//src/pathops:srcs",
33    "//src/sfnt:srcs",
34    "//src/shaders:srcs",
35    "//src/utils:srcs",
36    "//third_party:skcms",
37] + selects.with_or({
38    # https://github.com/bazelbuild/bazel-skylib/blob/main/docs/selects_doc.md#selectswith_or
39    ("//bazel/common_config_settings:gl_backend", "//bazel/common_config_settings:vulkan_backend"): [
40        "//src/gpu:srcs",
41        "//src/sksl:srcs",
42        # TODO(kjlubick) should mock be test only?
43        "//include/private:mock-hdrs",
44        "//src/gpu:mock-srcs",
45    ],
46    "//conditions:default": [],
47})
48
49CORE_HDRS = [
50    "//include/android:hdrs",
51    "//include/codec:hdrs",
52    "//include/config:hdrs",
53    "//include/core:hdrs",
54    "//include/effects:hdrs",
55    "//include/encode:hdrs",
56    "//include/pathops:hdrs",
57    "//include/ports:hdrs",
58    "//include/utils:base-hdrs",
59] + selects.with_or({
60    # https://github.com/bazelbuild/bazel-skylib/blob/main/docs/selects_doc.md#selectswith_or
61    ("//bazel/common_config_settings:gl_backend", "//bazel/common_config_settings:vulkan_backend"): [
62        "//include/sksl:hdrs",
63        "//include/gpu:hdrs",
64        # TODO(kjlubick) should mock be test only?
65        "//include/gpu:mock-hdrs",
66    ],
67    "//conditions:default": [],
68})
69
70# Some of these are documented in SkUserConfig.h
71CORE_DEFINES = ["SK_HAS_ANDROID_CODEC"] + select({
72    "//bazel/common_config_settings:debug_build": [
73        "SK_DEBUG",
74    ],
75    "//bazel/common_config_settings:release_build": [
76        "SK_RELEASE",
77    ],
78    "//conditions:default": [
79        "SK_RELEASE",
80    ],
81}) + select({
82    "//bazel/common_config_settings:gl_backend": [
83        "SK_GL",
84        "SK_SUPPORT_GPU=1",
85    ],
86    "//bazel/common_config_settings:vulkan_backend": [
87        "SK_VULKAN",
88        "SK_SUPPORT_GPU=1",
89    ],
90    "//conditions:default": [
91        "SK_SUPPORT_GPU=0",
92    ],
93}) + select({
94    "//bazel/common_config_settings:gl_standard": [
95        "SK_ASSUME_GL=1",
96    ],
97    "//bazel/common_config_settings:gles_standard": [
98        "SK_ASSUME_GL_ES=1",
99    ],
100    "//bazel/common_config_settings:webgl_standard": [
101        "SK_ASSUME_WEBGL=1",
102        "SK_USE_WEBGL",
103    ],
104    "//conditions:default": [],
105}) + select_multi(
106    {
107        "//bazel/common_config_settings:gif_codec": ["SK_HAS_WUFFS_LIBRARY"],
108        "//bazel/common_config_settings:jpeg_codec": ["SK_CODEC_DECODES_JPEG"],
109        "//bazel/common_config_settings:png_codec": ["SK_CODEC_DECODES_PNG"],
110        "//bazel/common_config_settings:raw_codec": [
111            "SK_CODEC_DECODES_RAW",
112            "SK_CODEC_DECODES_JPEG",
113        ],
114        "//bazel/common_config_settings:webp_codec": ["SK_CODEC_DECODES_WEBP"],
115    },
116    default = [],
117)
118
119CORE_DEPS = [] + select_multi(
120    {
121        "//bazel/common_config_settings:gif_codec": ["//third_party:wuffs"],
122        "//bazel/common_config_settings:png_codec": ["//third_party:libpng"],
123        "//bazel/common_config_settings:raw_codec": [
124            "//third_party:piex",
125            "//third_party:dng_sdk",
126        ],
127        "//bazel/common_config_settings:webp_codec": ["//third_party:libwebp"],
128    },
129    default = [],
130) + selects.with_or({
131    # The RAW codec require JPEG, but we cannot list libjpeg-turbo twice in the above list, or
132    # Bazel gets sad.
133    ("//bazel/common_config_settings:jpeg_codec", "//bazel/common_config_settings:raw_codec"): ["//third_party:libjpeg-turbo"],
134    "//conditions:default": [],
135})
136
137CORE_COPTS = []
138
139cc_library(
140    name = "skia-core",
141    srcs = CORE_SRCS,
142    hdrs = CORE_HDRS,
143    copts = CORE_COPTS,
144    local_defines = CORE_DEFINES,
145    textual_hdrs = ["//src/sksl:txts"],
146    deps = CORE_DEPS,
147)
148
149cc_library(
150    name = "hash_and_encode",
151    testonly = True,
152    srcs = [
153        "//tools:cmdline",
154        "//tools:hash_and_encode",
155    ],
156    deps = [
157        ":skia-core",
158        "//third_party:libpng",
159    ],
160)
161
162cc_library(
163    name = "gms",
164    testonly = True,
165    srcs = [
166        "//gm:gms",
167        "//gm:srcs",
168        "//tools:srcs",
169    ],
170    hdrs = [
171        "//gm:hdrs",
172    ],
173    textual_hdrs = ["//tools:txts"],
174    deps = [":skia-core"],
175)
176
177cc_library(
178    name = "tests",
179    testonly = True,
180    srcs = [
181        "//tests:srcs",
182        "//tools:srcs",
183    ],
184    hdrs = [
185        "//tests:hdrs",
186    ],
187    local_defines = [
188        "GR_TEST_UTILS",
189    ],
190    textual_hdrs = ["//tools:txts"],
191    deps = [":skia-core"],
192)
193