• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1load("//bazel:macros.bzl", "py_binary")
2load("//bazel:skia_rules.bzl", "exports_files_legacy", "skia_cc_library", "skia_objc_library")
3
4package(
5    default_applicable_licenses = ["//:license"],
6)
7
8licenses(["notice"])
9
10exports_files_legacy(label_list = [
11    "ToolUtils.h",
12    "ToolUtils.cpp",
13    "SkMetaData.h",
14    "SkMetaData.cpp",
15    "Registry.h",
16    "Resources.h",
17    "Resources.cpp",
18    "ResourceFactory.h",
19])
20
21skia_cc_library(
22    name = "legacy_tool_utils",
23    testonly = True,
24    srcs = [
25        "EncodeUtils.cpp",
26        "DecodeUtils.cpp",
27        "GpuToolUtils.cpp",
28        "Resources.cpp",
29        "ToolUtils.cpp",
30        "ResourceFactory.h",
31        "//tools/flags",
32        # TODO(kjlubick, bungeman): We should split out the font stuff into its own set of files
33        "//tools/fonts:test_font_manager_srcs",
34        "SkMetaData.cpp",
35    ],
36    hdrs = [
37        "CodecUtils.h",
38        "DecodeUtils.h",
39        "EncodeUtils.h",
40        "GpuToolUtils.h",
41        "Resources.h",
42        "SkMetaData.h",
43        "ToolUtils.h",
44    ],
45    textual_hdrs = [
46        "//tools/fonts:test_fonts",
47    ],
48    visibility = ["//:__subpackages__"],
49    deps = [
50        "//:skia_internal",
51    ],
52)
53
54skia_cc_library(
55    name = "registry",
56    hdrs = ["Registry.h"],
57    visibility = [
58        "//bench:__pkg__",
59        "//gm:__pkg__",
60        "//tests:__subpackages__",
61        "//tools/testrunners/benchmark:__pkg__",
62        "//tools/viewer:__pkg__",
63    ],
64    deps = ["//:core"],
65)
66
67skia_cc_library(
68    name = "hash_and_encode",
69    testonly = True,
70    srcs = ["HashAndEncode.cpp"],
71    hdrs = ["HashAndEncode.h"],
72    visibility = ["//gm:__pkg__"],
73    deps = [
74        "//:core",
75        "//:png_encode_codec",
76        "//tools/flags:cmd_flags",
77    ],
78)
79
80py_binary(
81    name = "embed_resources",
82    srcs = ["embed_resources.py"],
83    visibility = ["//:__subpackages__"],
84)
85
86skia_cc_library(
87    name = "autorelease_pool",
88    hdrs = ["AutoreleasePool.h"],
89    visibility = [
90        "//bench:__pkg__",
91        "//tools/gpu:__pkg__",
92        "//tools/testrunners/benchmark:__pkg__",
93    ],
94)
95
96skia_objc_library(
97    name = "autorelease_pool_objc",
98    srcs = ["AutoreleasePool.mm"],
99    hdrs = ["AutoreleasePool.h"],
100    visibility = ["//tools/gpu:__pkg__"],
101)
102
103skia_cc_library(
104    name = "url_data_manager",
105    srcs = ["UrlDataManager.cpp"],
106    hdrs = ["UrlDataManager.h"],
107    visibility = ["//tools/debugger:__pkg__"],
108    deps = ["//:core"],
109)
110
111skia_cc_library(
112    name = "sk_sharing_proc",
113    srcs = ["SkSharingProc.cpp"],
114    hdrs = ["SkSharingProc.h"],
115    visibility = ["//tools/debugger:__pkg__"],
116    deps = [
117        "//:core",
118        "//:png_decode_codec",
119        "//:png_encode_codec",
120    ],
121)
122
123skia_cc_library(
124    name = "mskp_player",
125    srcs = ["MSKPPlayer.cpp"],
126    hdrs = ["MSKPPlayer.h"],
127    visibility = ["//tools/viewer:__pkg__"],
128    deps = [
129        ":sk_sharing_proc",
130        "//:skia_internal",
131    ],
132)
133
134skia_cc_library(
135    name = "runtime_blend_utils",
136    srcs = ["RuntimeBlendUtils.cpp"],
137    hdrs = ["RuntimeBlendUtils.h"],
138    visibility = [
139        "//tests:__pkg__",
140        "//tools/viewer:__pkg__",
141    ],
142    deps = ["//:skia_internal"],
143)
144
145skia_cc_library(
146    name = "get_executable_path",
147    srcs = select({
148        "@platforms//os:windows": ["SkGetExecutablePath_win.cpp"],
149        "@platforms//os:macos": ["SkGetExecutablePath_mac.cpp"],
150        "@platforms//os:linux": ["SkGetExecutablePath_linux.cpp"],
151    }),
152    hdrs = ["SkGetExecutablePath.h"],
153    visibility = [
154        "//src/sksl:__pkg__",
155        "//tools/sksl-minify:__pkg__",
156    ],
157)
158
159skia_cc_library(
160    name = "stats",
161    srcs = ["ProcStats.cpp"],
162    hdrs = [
163        "ProcStats.h",
164        "Stats.h",
165    ],
166    visibility = [
167        "//bench:__pkg__",
168        "//tools/testrunners/benchmark:__pkg__",
169    ],
170    deps = ["//:core"],
171)
172
173skia_cc_library(
174    name = "tool_utils",
175    testonly = True,
176    srcs = [
177        "SkMetaData.cpp",
178        "ToolUtils.cpp",
179    ],
180    hdrs = [
181        "SkMetaData.h",
182        "ToolUtils.h",
183    ],
184    visibility = [
185        "//bench:__subpackages__",
186        "//gm:__subpackages__",
187        "//tools:__subpackages__",
188    ],
189    deps = [
190        "//:core",
191        "//src/base",
192        "//src/core:core_priv",
193    ],
194)
195
196skia_cc_library(
197    name = "codec_utils",
198    testonly = True,
199    srcs = [
200        "DecodeUtils.cpp",
201        "EncodeUtils.cpp",
202    ],
203    hdrs = [
204        "DecodeUtils.h",
205        "EncodeUtils.h",
206    ],
207    visibility = [
208        "//gm:__subpackages__",
209    ],
210    deps = [
211        "//:core",
212        "//:png_decode_codec",
213        "//:png_encode_codec",
214        "//src/base",
215        "//src/core:core_priv",
216        "//tools:resources",
217    ],
218)
219
220skia_cc_library(
221    name = "resources",
222    testonly = True,
223    srcs = [
224        "Resources.cpp",
225    ],
226    hdrs = [
227        "Resources.h",
228    ],
229    visibility = [
230        "//bench:__subpackages__",
231        "//tools:__subpackages__",
232    ],
233    deps = [
234        "//:core",
235        "//src/base",
236        "//src/core:core_priv",
237        "//tools/flags:cmd_flags",
238    ],
239)
240
241# Regenerate workarounds with `bazel run //tools:generate_workarounds`
242py_binary(
243    name = "generate_workarounds",
244    srcs = [":generate_workarounds.py"],
245    args = [
246        "--output-file",
247        "include/gpu/GrDriverBugWorkaroundsAutogen.h",
248        "src/gpu/gpu_workaround_list.txt",
249    ],
250    data = [
251        ":build_workaround_header",
252    ],
253    tags = ["no-remote"],
254)
255
256py_binary(
257    name = "build_workaround_header",
258    srcs = ["build_workaround_header.py"],
259)
260
261_GENERATE_WORKAROUNDS = """
262import os
263import subprocess
264import sys
265
266# https://bazel.build/docs/user-manual#running-executables
267# Note: Bazel eats single quotes, so we must use double quotes.
268os.chdir(os.environ["BUILD_WORKSPACE_DIRECTORY"])
269
270# execpath returns the path to the given label relative to the Skia root.
271# This will be something like:
272#   bazel-out/k8-opt-exec-81C6BA4F/bin/tools/build_workaround_header
273# https://bazel.build/reference/be/make-variables#predefined_label_variables
274generate_script = os.path.abspath("$(execpath :build_workaround_header)")
275
276result = subprocess.run(
277    [generate_script] + sys.argv[1:], capture_output=True, encoding="utf-8")
278if result.returncode != 0:
279    print(result.stdout)
280    print(result.stderr)
281    sys.exit(result.returncode)
282"""
283
284genrule(
285    name = "create_generate_workarounds_script",
286    outs = ["generate_workarounds.py"],
287    cmd = "echo '%s' > $@" % _GENERATE_WORKAROUNDS,
288    tools = [":build_workaround_header"],
289)
290
291skia_cc_library(
292    name = "full_build",
293    testonly = True,
294    srcs = [
295        # These are *not* skia_cc_library targets because we'd have to set the deps
296        # for them, which is redundent. Thus we just compile them as a list of files
297        # and the deps specified below should be sufficient for them.
298        "//include/core:headers_to_compile",
299        "//include/effects:headers_to_compile",
300        "//include/encode:headers_to_compile",
301        "//include/gpu/ganesh:headers_to_compile",
302        "//include/gpu:headers_to_compile",
303        "//include/gpu/vk:headers_to_compile",
304        "//include/private/base:headers_to_compile",
305        "//include/private/chromium:headers_to_compile",
306        "//include/private/gpu/ganesh:headers_to_compile",
307        "//include/private:headers_to_compile",
308        "//src/base:headers_to_compile",
309        "//src/codec:headers_to_compile",
310        "//src/core:headers_to_compile",
311        "//src/encode:headers_to_compile",
312        "//src/gpu/ganesh/geometry:headers_to_compile",
313        "//src/gpu/ganesh/mock:headers_to_compile",
314        "//src/gpu/ganesh:headers_to_compile",
315        "//src/gpu/tessellate:headers_to_compile",
316        "//src/gpu/vk:headers_to_compile",
317        "//src/gpu:headers_to_compile",
318        "//src/pdf:headers_to_compile",
319    ],
320    copts = [
321        # Since we are generating .cpp files for headers, some variables/functions which
322        # were properly declared static could be mis-interpreted to be unused. We don't
323        # want to fail on that. Therefore, we do not want warnings about those unused
324        # things to be flagged.
325        "-Wno-unused-function",
326        "-Wno-unused-template",
327        "-Wno-unused-const-variable",
328    ],
329    # This is not intended to be used for tests or anything, just for IWYU
330    visibility = ["//visibility:private"],
331    deps = [
332        "//:bmp_decode_codec",
333        "//:core",
334        "//:fontmgr_data_freetype",
335        "//:fontmgr_directory_freetype",
336        "//:fontmgr_empty_freetype",
337        "//:gif_decode_codec",
338        "//:ico_decode_codec",
339        "//:jpeg_decode_codec",
340        "//:jpeg_encode_codec",
341        "//:jpegxl_decode_codec",
342        "//:pathops",
343        "//:pdf_writer",
344        "//:png_decode_codec",
345        "//:png_encode_codec",
346        "//:skparagraph_harfbuzz_skunicode",
347        "//:skresources",
348        "//:skshaper_core",
349        "//:skshaper_harfbuzz",
350        "//:skshaper_unicode",
351        "//:skunicode_core",
352        "//:skunicode_icu",
353        "//:svg_renderer",
354        "//:svg_writer",
355        "//:wbmp_decode_codec",
356        "//:webp_decode_codec",
357        "//:webp_encode_codec",
358        "//src/gpu/ganesh/gl:ganesh_gl_TEST_UTIL",
359        "//src/gpu/ganesh/vk:ganesh_vulkan_TEST_UTIL",
360    ],
361)
362