blob: 7be16ef514c408569e8d6608261adb6e81e60a53 [file] [log] [blame]
mtkleinc04ff472016-06-23 10:29:30 -07001# Copyright 2016 Google Inc.
2#
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
mikejurka8c24f4f2016-09-12 16:51:58 -07006import("gn/shared_sources.gni")
brettwb9447282016-09-01 14:24:39 -07007
Forrest Reiling30229ac2017-04-17 13:36:39 -07008if (is_fuchsia) {
9 import("//build/vulkan/config.gni")
10}
11
Mike Klein3669a822017-03-03 10:55:02 -050012if (!defined(is_skia_standalone)) {
13 is_skia_standalone = false
14}
15is_skia_dev_build = is_skia_standalone && !is_official_build
16
mtkleinc04ff472016-06-23 10:29:30 -070017declare_args() {
Mike Kleinc168a3a2016-11-14 14:53:13 +000018 skia_use_angle = false
Kevin Lubick4a24e102017-03-29 11:19:01 -040019 skia_use_egl = false
mtklein63213812016-08-24 09:55:56 -070020 skia_use_expat = true
mtklein3cc22182016-08-29 13:26:14 -070021 skia_use_fontconfig = is_linux
mtkleincdedd0e2016-09-12 15:15:44 -070022 skia_use_freetype = is_android || is_fuchsia || is_linux
Mike Klein69f6ed42016-10-13 15:45:07 -040023 skia_use_gdi = false
Mike Klein7d302882016-11-03 14:06:31 -040024 skia_use_icu = !is_fuchsia && !is_ios && !is_win # TODO: Windows
mtklein63213812016-08-24 09:55:56 -070025 skia_use_libjpeg_turbo = true
26 skia_use_libpng = true
mtkleineb3c4252016-08-23 07:38:09 -070027 skia_use_libwebp = !is_fuchsia
Mike Klein38af9432016-11-11 11:39:44 -050028 skia_use_lua = false
mtkleina627b5c2016-09-20 13:36:47 -070029 skia_use_mesa = false
Mike Klein10d665d2016-11-01 11:46:10 -040030 skia_use_piex = !is_win
mtklein63213812016-08-24 09:55:56 -070031 skia_use_zlib = true
Greg Daniele5ddff52017-07-05 16:49:36 -040032 skia_use_metal = false
mtklein1bd72ba2016-09-16 07:45:52 -070033
Mike Klein7d921032017-01-05 12:20:41 -050034 skia_android_serial = ""
Brian Osman3f375d02016-12-28 11:19:22 -050035 skia_enable_discrete_gpu = true
Mike Kleina04bb452017-02-09 12:24:07 -050036 skia_enable_effects = true
mtklein06c35c02016-09-20 12:28:12 -070037 skia_enable_gpu = true
Hal Canary43fb7a02016-12-30 13:09:03 -050038 skia_enable_pdf = true
Ethan Nicholasa6ae1f72017-03-16 09:56:54 -040039 skia_enable_spirv_validation = is_skia_dev_build && is_debug
Mike Klein3669a822017-03-03 10:55:02 -050040 skia_enable_tools = is_skia_dev_build
41 skia_enable_vulkan_debug_layers = is_skia_dev_build && is_debug
Greg Daniel686bb212016-10-27 10:48:48 -040042 skia_vulkan_sdk = getenv("VULKAN_SDK")
Ethan Nicholas762466e2017-06-29 10:03:38 -040043 skia_compile_processors = false
Mike Kleinc55a6cb2017-06-28 13:21:47 -040044
45 skia_jumper_clang = ""
46 skia_jumper_objdump = ""
47 skia_jumper_ccache = ""
mtkleinc04ff472016-06-23 10:29:30 -070048}
Brian Salomon23d73ea2016-10-27 13:31:37 -040049declare_args() {
Matt Sarett189491c2017-03-20 18:09:30 -040050 skia_use_dng_sdk = !is_fuchsia && skia_use_libjpeg_turbo && skia_use_zlib
Mike Klein10d665d2016-11-01 11:46:10 -040051 skia_use_sfntly = skia_use_icu
52
Mike Klein4d598a32016-10-31 13:44:49 -040053 if (is_android) {
54 skia_use_vulkan = defined(ndk_api) && ndk_api >= 24
Forrest Reiling30229ac2017-04-17 13:36:39 -070055 } else if (is_fuchsia) {
56 skia_use_vulkan = fuchsia_use_vulkan
Mike Klein4d598a32016-10-31 13:44:49 -040057 } else {
58 skia_use_vulkan = skia_vulkan_sdk != ""
59 }
Brian Salomon23d73ea2016-10-27 13:31:37 -040060}
Greg Danielec6ae522017-04-25 13:38:26 -040061declare_args() {
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000062 skia_vulkan_headers = ""
Greg Danielec6ae522017-04-25 13:38:26 -040063 if (skia_use_vulkan) {
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000064 # When buliding on Android we get the header via the NDK so no need for any extra path.
Greg Danielec6ae522017-04-25 13:38:26 -040065 if (is_fuchsia) {
66 skia_vulkan_headers = "$fuchsia_vulkan_sdk/include"
67 } else if (is_linux || is_win) {
68 skia_vulkan_headers = "$skia_vulkan_sdk/include"
Greg Danielec6ae522017-04-25 13:38:26 -040069 }
Greg Danielec6ae522017-04-25 13:38:26 -040070 }
71}
Brian Salomon789e25e2016-09-30 13:41:03 -040072
mtklein38925aa2016-09-21 10:11:25 -070073# Our tools require static linking (they use non-exported symbols).
74skia_enable_tools = skia_enable_tools && !is_component_build
mtklein06c35c02016-09-20 12:28:12 -070075
mtkleina45be612016-08-29 15:22:10 -070076fontmgr_android_enabled = skia_use_expat && skia_use_freetype
77
mtklein1211e0c2016-07-26 13:55:45 -070078skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070079 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070080 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070081 "include/codec",
82 "include/config",
83 "include/core",
84 "include/effects",
Matt Sarett94fd06f2017-05-08 17:31:00 -040085 "include/encode",
mtklein1211e0c2016-07-26 13:55:45 -070086 "include/gpu",
87 "include/gpu/gl",
mtklein1211e0c2016-07-26 13:55:45 -070088 "include/pathops",
89 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070090 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070091 "include/utils",
92 "include/utils/mac",
mtklein1211e0c2016-07-26 13:55:45 -070093]
94
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000095if (skia_use_vulkan) {
96 skia_public_includes += [ "include/gpu/vk" ]
97}
Greg Daniele5ddff52017-07-05 16:49:36 -040098if (skia_use_metal) {
99 skia_public_includes += [ "include/gpu/mtl" ]
100}
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000101
mtkleinc04ff472016-06-23 10:29:30 -0700102# Skia public API, generally provided by :skia.
103config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -0700104 include_dirs = skia_public_includes
Greg Danielec6ae522017-04-25 13:38:26 -0400105 if (skia_vulkan_headers != "") {
106 include_dirs += [ skia_vulkan_headers ]
107 }
Mike Kleinae7e6712016-10-11 17:49:33 -0400108 defines = []
109 if (is_component_build) {
110 defines += [ "SKIA_DLL" ]
111 }
Mike Kleinc4cbd742016-09-26 21:37:09 -0400112 if (is_fuchsia || is_linux) {
jcgregorio5561e3d2016-08-25 09:25:11 -0700113 defines += [ "SK_SAMPLES_FOR_X" ]
114 }
mtklein06c35c02016-09-20 12:28:12 -0700115 if (!skia_enable_gpu) {
116 defines += [ "SK_SUPPORT_GPU=0" ]
117 }
mtkleinc04ff472016-06-23 10:29:30 -0700118}
119
120# Skia internal APIs, used by Skia itself and a few test tools.
121config("skia_private") {
122 visibility = [ ":*" ]
123
124 include_dirs = [
125 "include/private",
126 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -0700127 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -0700128 "src/core",
129 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -0700130 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -0700131 "src/image",
132 "src/images",
133 "src/lazy",
134 "src/opts",
135 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -0700136 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -0700137 "src/ports",
138 "src/sfnt",
Florin Malita5edba452017-05-30 16:39:47 -0400139 "src/shaders",
140 "src/shaders/gradients",
mtklein9e0d9dd2016-08-30 10:37:19 -0700141 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -0700142 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -0700143 "src/utils/win",
Herb Derby5a8fe972017-02-14 14:42:30 -0500144 "src/xml",
scroggo19b91532016-10-24 09:03:26 -0700145 "third_party/gif",
mtkleinc04ff472016-06-23 10:29:30 -0700146 ]
mtklein150d1132016-08-01 06:56:40 -0700147
Mike Reeda9e241d2017-05-03 10:52:00 -0400148 defines = [ "SK_GAMMA_APPLY_TO_A8" ]
mtkleinb37c0342016-09-09 11:07:45 -0700149 if (is_android) {
150 defines += [
151 "SK_GAMMA_EXPONENT=1.4",
152 "SK_GAMMA_CONTRAST=0.0",
153 ]
154 }
mtklein88a7ac02016-09-14 11:16:49 -0700155 if (is_official_build || is_android) {
156 # TODO(bsalomon): it'd be nice to make Android normal.
157 defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
158 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400159 libs = []
160 lib_dirs = []
161 if (skia_use_vulkan) {
Michael Jurkada3e5962017-04-14 17:44:09 -0700162 if (skia_vulkan_sdk != "" && !is_android && !is_fuchsia) {
Mike Klein487bfc22016-10-14 14:04:56 -0400163 if (is_win) {
Brian Salomon3b5bf352017-03-20 15:54:41 -0400164 lib_dirs += [
165 "$skia_vulkan_sdk/Bin",
166 "$skia_vulkan_sdk/Lib",
167 ]
Mike Klein487bfc22016-10-14 14:04:56 -0400168 } else {
Greg Daniel686bb212016-10-27 10:48:48 -0400169 lib_dirs += [ "$skia_vulkan_sdk/lib/" ]
Mike Klein487bfc22016-10-14 14:04:56 -0400170 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400171 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400172 }
Brian Salomon03e05842017-02-23 12:23:47 -0500173 if (skia_enable_gpu) {
174 include_dirs += [ "src/gpu" ]
175 }
Brian Osman34755e22016-12-05 09:46:02 -0500176 if (skia_use_angle) {
177 defines += [ "SK_ANGLE" ]
178 }
Brian Osman3f375d02016-12-28 11:19:22 -0500179 if (skia_enable_discrete_gpu) {
180 defines += [ "SK_ENABLE_DISCRETE_GPU" ]
181 }
Brian Salomon0c26a9d2017-07-06 10:09:38 -0400182 if (!is_official_build) {
183 defines += [ "GR_TEST_UTILS=1" ]
184 }
mtkleinc04ff472016-06-23 10:29:30 -0700185}
186
187# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
188config("skia_library") {
189 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -0700190 defines = [ "SKIA_IMPLEMENTATION=1" ]
191}
192
193skia_library_configs = [
194 ":skia_public",
195 ":skia_private",
196 ":skia_library",
197]
198
mtklein9b8583d2016-08-24 17:32:30 -0700199# Use for CPU-specific Skia code that needs particular compiler flags.
200template("opts") {
201 if (invoker.enabled) {
202 source_set(target_name) {
203 forward_variables_from(invoker, "*")
204 configs += skia_library_configs
205 }
206 } else {
207 # If not enabled, a phony empty target that swallows all otherwise unused variables.
208 source_set(target_name) {
209 forward_variables_from(invoker,
210 "*",
211 [
212 "sources",
213 "cflags",
214 ])
215 }
216 }
anmittala7eaf2e2016-08-17 13:57:26 -0700217}
218
mtklein422310d2016-08-16 18:28:43 -0700219is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700220
mtklein7d6fb2c2016-08-25 14:50:44 -0700221opts("none") {
222 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700223 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700224 cflags = []
225}
226
mtklein7d6fb2c2016-08-25 14:50:44 -0700227opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700228 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700229 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700230 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700231}
232
233opts("arm64") {
234 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700235 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700236 cflags = []
237}
238
239opts("crc32") {
240 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700241 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700242 cflags = [ "-march=armv8-a+crc" ]
243}
244
mtklein9b8583d2016-08-24 17:32:30 -0700245opts("sse2") {
246 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700247 sources = skia_opts.sse2_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400248 if (is_win) {
249 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE2" ]
250 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400251 cflags = [ "-msse2" ]
252 }
mtklein9b8583d2016-08-24 17:32:30 -0700253}
mtkleinc04ff472016-06-23 10:29:30 -0700254
mtklein9b8583d2016-08-24 17:32:30 -0700255opts("ssse3") {
256 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700257 sources = skia_opts.ssse3_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400258 if (is_win) {
259 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSSE3" ]
260 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400261 cflags = [ "-mssse3" ]
262 }
mtklein9b8583d2016-08-24 17:32:30 -0700263}
mtkleinc04ff472016-06-23 10:29:30 -0700264
mtklein9b8583d2016-08-24 17:32:30 -0700265opts("sse41") {
266 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700267 sources = skia_opts.sse41_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400268 if (is_win) {
269 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE41" ]
270 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400271 cflags = [ "-msse4.1" ]
272 }
mtklein9b8583d2016-08-24 17:32:30 -0700273}
mtklein4e976072016-08-08 09:06:27 -0700274
mtklein9b8583d2016-08-24 17:32:30 -0700275opts("sse42") {
276 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700277 sources = skia_opts.sse42_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400278 if (is_win) {
279 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE42" ]
280 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400281 cflags = [ "-msse4.2" ]
282 }
mtklein9b8583d2016-08-24 17:32:30 -0700283}
284
285opts("avx") {
286 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700287 sources = skia_opts.avx_sources
Mike Klein3eb71212016-10-11 17:08:53 -0400288 if (is_win) {
Mike Klein17b6e482016-11-18 22:11:41 +0000289 cflags = [ "/arch:AVX" ]
Mike Klein3eb71212016-10-11 17:08:53 -0400290 } else {
291 cflags = [ "-mavx" ]
292 }
mtkleinc04ff472016-06-23 10:29:30 -0700293}
294
Mike Klein78d5a3b2016-09-30 10:48:01 -0400295opts("hsw") {
296 enabled = is_x86
297 sources = skia_opts.hsw_sources
Mike Klein3eb71212016-10-11 17:08:53 -0400298 if (is_win) {
Mike Klein17b6e482016-11-18 22:11:41 +0000299 cflags = [ "/arch:AVX2" ]
Mike Klein3eb71212016-10-11 17:08:53 -0400300 } else {
301 cflags = [
302 "-mavx2",
303 "-mbmi",
304 "-mbmi2",
305 "-mf16c",
306 "-mfma",
307 ]
308 }
Mike Klein78d5a3b2016-09-30 10:48:01 -0400309}
310
mtkleinc095df52016-08-24 12:23:52 -0700311# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700312template("optional") {
313 if (invoker.enabled) {
314 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700315 if (defined(invoker.public_defines)) {
316 defines = invoker.public_defines
317 }
mtklein457b42a2016-08-23 13:56:37 -0700318 }
319 source_set(target_name) {
mtkleincd01b032016-08-31 04:58:19 -0700320 forward_variables_from(invoker,
321 "*",
322 [
323 "public_defines",
324 "sources_when_disabled",
scroggof84ad642016-10-31 09:02:57 -0700325 "configs_to_remove",
mtkleincd01b032016-08-31 04:58:19 -0700326 ])
mtklein457b42a2016-08-23 13:56:37 -0700327 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700328 configs += skia_library_configs
scroggof84ad642016-10-31 09:02:57 -0700329 if (defined(invoker.configs_to_remove)) {
330 configs -= invoker.configs_to_remove
331 }
mtklein457b42a2016-08-23 13:56:37 -0700332 }
333 } else {
mtklein457b42a2016-08-23 13:56:37 -0700334 source_set(target_name) {
335 forward_variables_from(invoker,
336 "*",
337 [
338 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700339 "deps",
mtklein6ef69992016-09-14 06:12:09 -0700340 "libs",
mtklein457b42a2016-08-23 13:56:37 -0700341 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700342 "sources_when_disabled",
scroggof84ad642016-10-31 09:02:57 -0700343 "configs_to_remove",
mtklein457b42a2016-08-23 13:56:37 -0700344 ])
mtkleincd01b032016-08-31 04:58:19 -0700345 if (defined(invoker.sources_when_disabled)) {
346 sources = invoker.sources_when_disabled
347 }
348 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700349 }
mtkleineb3c4252016-08-23 07:38:09 -0700350 }
mtklein457b42a2016-08-23 13:56:37 -0700351}
mtklein457b42a2016-08-23 13:56:37 -0700352
Mike Kleina04bb452017-02-09 12:24:07 -0500353optional("effects") {
354 enabled = skia_enable_effects
Ethan Nicholas762466e2017-06-29 10:03:38 -0400355 deps = [
356 ":compile_processors",
357 ]
Mike Kleina04bb452017-02-09 12:24:07 -0500358 sources =
359 skia_effects_sources + [ "src/ports/SkGlobalInitialization_default.cpp" ]
360 sources_when_disabled = [ "src/ports/SkGlobalInitialization_none.cpp" ]
361}
362
mtkleina45be612016-08-29 15:22:10 -0700363optional("fontmgr_android") {
364 enabled = fontmgr_android_enabled
mtkleina45be612016-08-29 15:22:10 -0700365
366 deps = [
Ben Wagnerfc497342017-02-24 11:15:26 -0500367 ":typeface_freetype",
mtkleina45be612016-08-29 15:22:10 -0700368 "//third_party/expat",
mtkleina45be612016-08-29 15:22:10 -0700369 ]
370 sources = [
371 "src/ports/SkFontMgr_android.cpp",
372 "src/ports/SkFontMgr_android_factory.cpp",
373 "src/ports/SkFontMgr_android_parser.cpp",
374 ]
375}
376
mtkleind2e39db2016-09-07 07:52:55 -0700377optional("fontmgr_custom") {
378 enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
379
380 deps = [
Ben Wagnerfc497342017-02-24 11:15:26 -0500381 ":typeface_freetype",
mtkleind2e39db2016-09-07 07:52:55 -0700382 ]
383 sources = [
384 "src/ports/SkFontMgr_custom.cpp",
Ben Wagner8ab590f2017-02-08 17:29:33 -0500385 "src/ports/SkFontMgr_custom.h",
386 "src/ports/SkFontMgr_custom_directory.cpp",
mtkleind2e39db2016-09-07 07:52:55 -0700387 "src/ports/SkFontMgr_custom_directory_factory.cpp",
Ben Wagner8ab590f2017-02-08 17:29:33 -0500388 "src/ports/SkFontMgr_custom_embedded.cpp",
389 "src/ports/SkFontMgr_custom_empty.cpp",
mtkleind2e39db2016-09-07 07:52:55 -0700390 ]
391}
392
mtklein3cc22182016-08-29 13:26:14 -0700393optional("fontmgr_fontconfig") {
394 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700395
396 deps = [
Ben Wagnerfc497342017-02-24 11:15:26 -0500397 ":typeface_freetype",
mtklein3cc22182016-08-29 13:26:14 -0700398 "//third_party:fontconfig",
mtklein3cc22182016-08-29 13:26:14 -0700399 ]
400 sources = [
bungeman1ae0e012016-09-19 12:13:16 -0700401 "src/ports/SkFontConfigInterface.cpp",
mtklein3cc22182016-08-29 13:26:14 -0700402 "src/ports/SkFontConfigInterface_direct.cpp",
403 "src/ports/SkFontConfigInterface_direct_factory.cpp",
404 "src/ports/SkFontMgr_FontConfigInterface.cpp",
405 "src/ports/SkFontMgr_fontconfig.cpp",
406 "src/ports/SkFontMgr_fontconfig_factory.cpp",
407 ]
408}
409
mtkleincdedd0e2016-09-12 15:15:44 -0700410optional("fontmgr_fuchsia") {
411 enabled = is_fuchsia && skia_use_freetype
412
413 deps = [
Ben Wagnerfc497342017-02-24 11:15:26 -0500414 ":typeface_freetype",
mtkleincdedd0e2016-09-12 15:15:44 -0700415 ]
416 sources = [
417 "src/ports/SkFontMgr_custom.cpp",
Ben Wagner8ab590f2017-02-08 17:29:33 -0500418 "src/ports/SkFontMgr_custom_empty.cpp",
mtkleincdedd0e2016-09-12 15:15:44 -0700419 "src/ports/SkFontMgr_custom_empty_factory.cpp",
420 ]
421}
422
Ethan Nicholas762466e2017-06-29 10:03:38 -0400423if (skia_compile_processors) {
424 executable("skslc") {
425 defines = [ "SKSL_STANDALONE" ]
426 sources = [
427 "src/sksl/SkSLMain.cpp",
428 ]
429 sources += skia_sksl_sources
430 include_dirs = [
431 "src/gpu",
432 "src/sksl",
433 ]
434 deps = [
435 "//third_party/spirv-tools",
436 ]
437 }
438
439 skia_gpu_processor_outputs = []
440 foreach(src, skia_gpu_processor_sources) {
441 dir = get_path_info(src, "dir")
442 name = get_path_info(src, "name")
443
444 # GN insists its outputs should go somewhere underneath target_out_dir, so we trick it with a
445 # path that starts with target_out_dir and then uses ".." to back up into the src dir.
446 skia_gpu_processor_outputs += [
447 "$target_out_dir/" + rebase_path("$dir/$name.h", target_out_dir),
448 # the script also modifies the corresponding .cpp file, but if we tell GN that it gets
449 # confused due to the same file being named by two different paths
450 ]
451 }
452
453 action("compile_processors") {
454 script = "gn/compile_processors.py"
455 deps = [
456 ":skslc(//gn/toolchain:$host_toolchain)",
457 ]
458 sources = skia_gpu_processor_sources
459 outputs = skia_gpu_processor_outputs
460 skslc_path = "$root_out_dir/"
461 if (host_toolchain != default_toolchain_name) {
462 skslc_path += "$host_toolchain/"
463 }
464 skslc_path += "skslc"
465 if (host_os == "win") {
466 skslc_path += ".exe"
467 }
468 args = [ rebase_path(skslc_path) ]
469 args += rebase_path(skia_gpu_processor_sources)
470 }
471} else {
472 skia_gpu_processor_outputs = []
473 group("compile_processors") {
474 }
475}
476
mtklein06c35c02016-09-20 12:28:12 -0700477optional("gpu") {
478 enabled = skia_enable_gpu
Ethan Nicholas762466e2017-06-29 10:03:38 -0400479 deps = [
480 ":compile_processors",
481 ]
mtkleine9fb3d52016-09-20 15:11:46 -0700482 public_defines = []
483
Mike Klein29b3e582017-02-09 11:57:32 -0500484 sources = skia_gpu_sources + skia_sksl_sources +
Ethan Nicholas762466e2017-06-29 10:03:38 -0400485 [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ] +
486 skia_gpu_processor_outputs
mtklein06c35c02016-09-20 12:28:12 -0700487
488 # These paths need to be absolute to match the ones produced by shared_sources.gni.
489 sources -= get_path_info([
490 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
491 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
492 ],
493 "abspath")
Mike Klein703cf5a2016-10-13 17:18:04 -0400494 libs = []
mtklein06c35c02016-09-20 12:28:12 -0700495 if (is_android) {
496 sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
Derek Sollenberger7a869872017-06-27 15:37:25 -0400497
498 # this lib is required to link against AHardwareBuffer
499 if (defined(ndk_api) && ndk_api >= 26) {
500 libs += [ "android" ]
501 }
Kevin Lubick4a24e102017-03-29 11:19:01 -0400502 } else if (skia_use_egl) {
503 sources += [ "src/gpu/gl/egl/GrGLCreateNativeInterface_egl.cpp" ]
504 libs += [ "EGL" ]
mtklein06c35c02016-09-20 12:28:12 -0700505 } else if (is_linux) {
506 sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
Mike Kleina979a1d2017-02-23 10:31:13 -0500507 libs += [
508 "GL",
509 "GLU",
510 ]
mtklein06c35c02016-09-20 12:28:12 -0700511 } else if (is_mac) {
512 sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
Chinmay Garde130a1182016-11-23 11:43:56 -0800513 } else if (is_ios) {
514 sources += [ "src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp" ]
Mike Klein703cf5a2016-10-13 17:18:04 -0400515 } else if (is_win) {
516 sources += [ "src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp" ]
517 libs += [ "OpenGL32.lib" ]
mtklein06c35c02016-09-20 12:28:12 -0700518 } else {
519 sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
520 }
mtkleine9fb3d52016-09-20 15:11:46 -0700521
522 if (skia_use_vulkan) {
523 public_defines += [ "SK_VULKAN" ]
524 sources += skia_vk_sources
egdaniele4a9bd72016-09-21 07:36:14 -0700525 if (skia_enable_vulkan_debug_layers) {
526 public_defines += [ "SK_ENABLE_VK_LAYERS" ]
527 }
mtkleine9fb3d52016-09-20 15:11:46 -0700528 }
Ethan Nicholasa6ae1f72017-03-16 09:56:54 -0400529 if (skia_enable_spirv_validation) {
Ethan Nicholas762466e2017-06-29 10:03:38 -0400530 deps += [ "//third_party/spirv-tools" ]
Ethan Nicholasa6ae1f72017-03-16 09:56:54 -0400531 public_defines += [ "SK_ENABLE_SPIRV_VALIDATION" ]
532 }
Greg Daniele5ddff52017-07-05 16:49:36 -0400533
534 if (skia_use_metal) {
535 public_defines += [ "SK_METAL" ]
536 sources += skia_metal_sources
537 libs += [ "Metal.framework" ]
538 }
mtklein06c35c02016-09-20 12:28:12 -0700539}
540
mtklein63213812016-08-24 09:55:56 -0700541optional("jpeg") {
542 enabled = skia_use_libjpeg_turbo
543 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
544
mtklein63213812016-08-24 09:55:56 -0700545 deps = [
546 "//third_party/libjpeg-turbo:libjpeg",
547 ]
548 sources = [
549 "src/codec/SkJpegCodec.cpp",
550 "src/codec/SkJpegDecoderMgr.cpp",
551 "src/codec/SkJpegUtility.cpp",
mtklein63213812016-08-24 09:55:56 -0700552 "src/images/SkJPEGWriteUtility.cpp",
Matt Sarett04c37312017-05-05 14:02:13 -0400553 "src/images/SkJpegEncoder.cpp",
mtklein63213812016-08-24 09:55:56 -0700554 ]
555}
556
557optional("pdf") {
Hal Canary43fb7a02016-12-30 13:09:03 -0500558 enabled = skia_use_zlib && skia_enable_pdf
559 public_defines = [ "SK_SUPPORT_PDF" ]
mtklein63213812016-08-24 09:55:56 -0700560
mtklein63213812016-08-24 09:55:56 -0700561 deps = [
562 "//third_party/zlib",
563 ]
brettwb9447282016-09-01 14:24:39 -0700564 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700565 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700566
567 if (skia_use_sfntly) {
568 deps += [ "//third_party/sfntly" ]
Hal Canary43fb7a02016-12-30 13:09:03 -0500569 public_defines += [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700570 }
571}
572
573optional("png") {
574 enabled = skia_use_libpng
575 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
576
mtklein63213812016-08-24 09:55:56 -0700577 deps = [
578 "//third_party/libpng",
579 ]
580 sources = [
581 "src/codec/SkIcoCodec.cpp",
582 "src/codec/SkPngCodec.cpp",
Matt Sarett04c37312017-05-05 14:02:13 -0400583 "src/images/SkPngEncoder.cpp",
mtklein63213812016-08-24 09:55:56 -0700584 ]
585}
586
scroggof84ad642016-10-31 09:02:57 -0700587optional("raw") {
Mike Klein10d665d2016-11-01 11:46:10 -0400588 enabled = skia_use_dng_sdk && skia_use_libjpeg_turbo && skia_use_piex
scroggof84ad642016-10-31 09:02:57 -0700589 public_defines = [ "SK_CODEC_DECODES_RAW" ]
590
591 deps = [
592 "//third_party/dng_sdk",
593 "//third_party/libjpeg-turbo:libjpeg",
594 "//third_party/piex",
595 ]
596
597 # SkRawCodec catches any exceptions thrown by dng_sdk, insulating the rest of
598 # Skia.
599 configs_to_remove = [ "//gn:no_exceptions" ]
600
601 sources = [
602 "src/codec/SkRawAdapterCodec.cpp",
603 "src/codec/SkRawCodec.cpp",
604 ]
605}
606
mtklein3cc22182016-08-29 13:26:14 -0700607optional("typeface_freetype") {
608 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700609
610 deps = [
611 "//third_party/freetype2",
612 ]
613 sources = [
614 "src/ports/SkFontHost_FreeType.cpp",
615 "src/ports/SkFontHost_FreeType_common.cpp",
616 ]
617}
618
mtklein457b42a2016-08-23 13:56:37 -0700619optional("webp") {
620 enabled = skia_use_libwebp
621 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
622
mtklein457b42a2016-08-23 13:56:37 -0700623 deps = [
624 "//third_party/libwebp",
625 ]
626 sources = [
627 "src/codec/SkWebpAdapterCodec.cpp",
628 "src/codec/SkWebpCodec.cpp",
Matt Sarett04c37312017-05-05 14:02:13 -0400629 "src/images/SkWebpEncoder.cpp",
mtklein457b42a2016-08-23 13:56:37 -0700630 ]
mtkleineb3c4252016-08-23 07:38:09 -0700631}
632
mtklein63213812016-08-24 09:55:56 -0700633optional("xml") {
634 enabled = skia_use_expat
Florin Malita442fff92016-11-08 16:07:52 +0000635 public_defines = [ "SK_XML" ]
mtklein63213812016-08-24 09:55:56 -0700636
mtklein63213812016-08-24 09:55:56 -0700637 deps = [
638 "//third_party/expat",
639 ]
640 sources = [
Mike Kleinbd41bcc2017-02-09 16:38:15 -0500641 "src/svg/SkSVGCanvas.cpp",
642 "src/svg/SkSVGDevice.cpp",
mtklein63213812016-08-24 09:55:56 -0700643 "src/xml/SkDOM.cpp",
644 "src/xml/SkXMLParser.cpp",
645 "src/xml/SkXMLWriter.cpp",
646 ]
647}
648
mtkleinc04ff472016-06-23 10:29:30 -0700649component("skia") {
650 public_configs = [ ":skia_public" ]
651 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700652
653 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700654 ":arm64",
655 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700656 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700657 ":crc32",
Mike Kleina04bb452017-02-09 12:24:07 -0500658 ":effects",
mtkleina45be612016-08-29 15:22:10 -0700659 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700660 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700661 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700662 ":fontmgr_fuchsia",
mtklein06c35c02016-09-20 12:28:12 -0700663 ":gpu",
Mike Klein78d5a3b2016-09-30 10:48:01 -0400664 ":hsw",
mtklein63213812016-08-24 09:55:56 -0700665 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700666 ":none",
mtklein63213812016-08-24 09:55:56 -0700667 ":pdf",
668 ":png",
scroggof84ad642016-10-31 09:02:57 -0700669 ":raw",
mtklein9b8583d2016-08-24 17:32:30 -0700670 ":sse2",
671 ":sse41",
672 ":sse42",
673 ":ssse3",
mtkleineb3c4252016-08-23 07:38:09 -0700674 ":webp",
mtklein63213812016-08-24 09:55:56 -0700675 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700676 ]
677
Chinmay Garde43f115c2016-11-16 15:04:12 -0800678 # This file (and all GN files in Skia) are designed to work with an
679 # empty sources assignment filter; we handle all that explicitly.
680 # We clear the filter here for clients who may have set up a global filter.
681 set_sources_assignment_filter([])
682
mtkleinc04ff472016-06-23 10:29:30 -0700683 sources = []
brettwb9447282016-09-01 14:24:39 -0700684 sources += skia_core_sources
brettwb9447282016-09-01 14:24:39 -0700685 sources += skia_utils_sources
Hal Canary6ad3d2f2016-12-20 16:15:56 -0500686 sources += skia_xps_sources
mtkleinc04ff472016-06-23 10:29:30 -0700687 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700688 "src/android/SkBitmapRegionCodec.cpp",
689 "src/android/SkBitmapRegionDecoder.cpp",
690 "src/codec/SkAndroidCodec.cpp",
Leon Scroggins IIId81fed92017-06-01 13:42:28 -0400691 "src/codec/SkBmpBaseCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700692 "src/codec/SkBmpCodec.cpp",
693 "src/codec/SkBmpMaskCodec.cpp",
694 "src/codec/SkBmpRLECodec.cpp",
695 "src/codec/SkBmpStandardCodec.cpp",
696 "src/codec/SkCodec.cpp",
697 "src/codec/SkCodecImageGenerator.cpp",
scroggo19b91532016-10-24 09:03:26 -0700698 "src/codec/SkGifCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700699 "src/codec/SkMaskSwizzler.cpp",
700 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700701 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700702 "src/codec/SkSampler.cpp",
scroggo19b91532016-10-24 09:03:26 -0700703 "src/codec/SkStreamBuffer.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700704 "src/codec/SkSwizzler.cpp",
705 "src/codec/SkWbmpCodec.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700706 "src/images/SkImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700707 "src/ports/SkDiscardableMemory_none.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700708 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700709 "src/ports/SkMemory_malloc.cpp",
710 "src/ports/SkOSFile_stdio.cpp",
711 "src/sfnt/SkOTTable_name.cpp",
712 "src/sfnt/SkOTUtils.cpp",
713 "src/utils/mac/SkStream_mac.cpp",
scroggo3d3a65c2016-10-24 12:28:30 -0700714 "third_party/gif/SkGifImageReader.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700715 ]
brettwb9447282016-09-01 14:24:39 -0700716
mtklein7d6fb2c2016-08-25 14:50:44 -0700717 libs = []
718
mtkleinc04ff472016-06-23 10:29:30 -0700719 if (is_win) {
720 sources += [
Mike Kleinae7e6712016-10-11 17:49:33 -0400721 "src/fonts/SkFontMgr_indirect.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700722 "src/ports/SkDebug_win.cpp",
723 "src/ports/SkFontHost_win.cpp",
724 "src/ports/SkFontMgr_win_dw.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700725 "src/ports/SkImageEncoder_WIC.cpp",
726 "src/ports/SkImageGeneratorWIC.cpp",
727 "src/ports/SkOSFile_win.cpp",
mtklein605d9522016-09-21 14:01:32 -0700728 "src/ports/SkOSLibrary_win.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700729 "src/ports/SkScalerContext_win_dw.cpp",
730 "src/ports/SkTLS_win.cpp",
731 "src/ports/SkTypeface_win_dw.cpp",
732 ]
Mike Klein69f6ed42016-10-13 15:45:07 -0400733 if (skia_use_gdi) {
734 sources += [ "src/ports/SkFontMgr_win_gdi_factory.cpp" ]
735 libs += [
736 "Gdi32.lib",
737 "Usp10.lib",
738 ]
739 } else {
740 sources += [ "src/ports/SkFontMgr_win_dw_factory.cpp" ]
741 }
mtkleinb9be9792016-09-16 14:44:18 -0700742 sources -=
743 [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
Mike Klein4b167fc2016-10-11 18:13:53 -0400744 libs += [
745 "FontSub.lib",
746 "Ole32.lib",
747 "OleAut32.lib",
748 "User32.lib",
749 ]
mtkleinc04ff472016-06-23 10:29:30 -0700750 } else {
751 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700752 "src/ports/SkOSFile_posix.cpp",
mtklein605d9522016-09-21 14:01:32 -0700753 "src/ports/SkOSLibrary_posix.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700754 "src/ports/SkTLS_pthread.cpp",
755 ]
756 }
757
mtklein7d6fb2c2016-08-25 14:50:44 -0700758 if (is_android) {
Mike Klein1c471872017-01-13 15:27:45 -0500759 deps += [ "//third_party/expat" ]
Mike Kleine459afd2017-03-03 09:21:30 -0500760 if (defined(ndk) && ndk != "") {
Mike Klein1c471872017-01-13 15:27:45 -0500761 deps += [ "//third_party/cpu-features" ]
762 }
mtklein06c35c02016-09-20 12:28:12 -0700763 sources += [ "src/ports/SkDebug_android.cpp" ]
mtklein7d6fb2c2016-08-25 14:50:44 -0700764 libs += [
765 "EGL",
766 "GLESv2",
767 "log",
768 ]
769 }
770
mtkleinc04ff472016-06-23 10:29:30 -0700771 if (is_linux) {
mtklein06c35c02016-09-20 12:28:12 -0700772 sources += [ "src/ports/SkDebug_stdio.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700773 }
774
775 if (is_mac) {
776 sources += [
mtklein7d6fb2c2016-08-25 14:50:44 -0700777 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700778 "src/ports/SkFontHost_mac.cpp",
779 "src/ports/SkImageEncoder_CG.cpp",
780 "src/ports/SkImageGeneratorCG.cpp",
781 ]
mtklein09e61f72016-08-23 13:35:28 -0700782 libs += [
bungeman3e306f62017-03-29 11:32:02 -0400783 # AppKit symbols NSFontWeightXXX may be dlsym'ed.
784 "AppKit.framework",
mtklein09e61f72016-08-23 13:35:28 -0700785 "ApplicationServices.framework",
786 "OpenGL.framework",
787 ]
mtkleinc04ff472016-06-23 10:29:30 -0700788 }
abarth6fc8ff02016-07-15 15:15:15 -0700789
Mike Klein7d302882016-11-03 14:06:31 -0400790 if (is_ios) {
791 sources += [
792 "src/ports/SkDebug_stdio.cpp",
793 "src/ports/SkFontHost_mac.cpp",
794 "src/ports/SkImageEncoder_CG.cpp",
795 "src/ports/SkImageGeneratorCG.cpp",
796 ]
797 libs += [
798 "CoreFoundation.framework",
799 "CoreGraphics.framework",
800 "CoreText.framework",
801 "ImageIO.framework",
802 "MobileCoreServices.framework",
bungeman3e306f62017-03-29 11:32:02 -0400803
804 # UIKit symbols UIFontWeightXXX may be dlsym'ed.
805 "UIKit.framework",
Mike Klein7d302882016-11-03 14:06:31 -0400806 ]
807 }
808
abarth6fc8ff02016-07-15 15:15:15 -0700809 if (is_fuchsia) {
mtklein06c35c02016-09-20 12:28:12 -0700810 sources += [ "src/ports/SkDebug_stdio.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700811 }
mtkleinc04ff472016-06-23 10:29:30 -0700812}
813
mtkleinc095df52016-08-24 12:23:52 -0700814# Targets guarded by skia_enable_tools may use //third_party freely.
815if (skia_enable_tools) {
Mike Klein308b5ac2016-12-06 16:03:52 -0500816 # Used by gn_to_bp.py to list our public include dirs.
817 source_set("public") {
818 configs += [ ":skia_public" ]
819 }
820
Mike Kleinc36dedf2016-11-18 09:35:28 -0500821 config("skia.h_config") {
822 include_dirs = [ "$target_gen_dir" ]
823 }
824 action("skia.h") {
825 public_configs = [ ":skia.h_config" ]
826 skia_h = "$target_gen_dir/skia.h"
827 script = "gn/find_headers.py"
Greg Danielc819e662017-04-19 16:39:45 -0400828 args = [ rebase_path(skia_h, root_build_dir) ] +
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000829 rebase_path(skia_public_includes)
Mike Kleinc36dedf2016-11-18 09:35:28 -0500830 depfile = "$skia_h.deps"
831 outputs = [
832 skia_h,
833 ]
834 }
835
836 if (skia_enable_gpu && target_cpu == "x64") {
837 # Our bots only have 64-bit libOSMesa installed.
838 # TODO: worth fixing?
839 executable("fiddle") {
840 libs = []
Mike Kleinc36dedf2016-11-18 09:35:28 -0500841 sources = [
Mike Kleinc36dedf2016-11-18 09:35:28 -0500842 "tools/fiddle/draw.cpp",
843 "tools/fiddle/fiddle_main.cpp",
844 ]
Joe Gregorioa8fabd32017-05-31 09:45:19 -0400845
846 if (skia_use_egl) {
847 sources += [ "tools/fiddle/egl_context.cpp" ]
848 } else if (skia_use_mesa) {
849 sources += [ "tools/fiddle/mesa_context.cpp" ]
850 if (is_linux) {
851 libs += [ "OSMesa" ]
852 }
853 } else {
854 sources += [ "tools/fiddle/null_context.cpp" ]
855 }
Joe Gregorio1e735c02017-04-19 14:05:14 -0400856 testonly = true
Mike Kleinc36dedf2016-11-18 09:35:28 -0500857 deps = [
Joe Gregorio1e735c02017-04-19 14:05:14 -0400858 ":flags",
Mike Kleinc36dedf2016-11-18 09:35:28 -0500859 ":skia",
860 ":skia.h",
861 ]
862 }
863 }
864
865 if (skia_enable_gpu) {
866 source_set("public_headers_warnings_check") {
867 sources = [
868 "tools/public_headers_warnings_check.cpp",
869 ]
870 configs -= [ "//gn:warnings_except_public_headers" ]
871 deps = [
872 ":skia",
873 ":skia.h",
874 ]
875 }
876 }
877
mtkleinc095df52016-08-24 12:23:52 -0700878 template("test_lib") {
879 config(target_name + "_config") {
880 include_dirs = invoker.public_include_dirs
mtkleina627b5c2016-09-20 13:36:47 -0700881 if (defined(invoker.public_defines)) {
882 defines = invoker.public_defines
883 }
mtklein25c81d42016-07-27 13:55:26 -0700884 }
mtkleinc095df52016-08-24 12:23:52 -0700885 source_set(target_name) {
886 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
887 public_configs = [
888 ":" + target_name + "_config",
889 ":skia_private",
890 ]
891
892 if (!defined(deps)) {
893 deps = []
894 }
895 deps += [ ":skia" ]
896 testonly = true
897 }
mtklein25c81d42016-07-27 13:55:26 -0700898 }
mtklein25c81d42016-07-27 13:55:26 -0700899
Mike Kleine6682eb2017-01-05 10:54:57 -0500900 template("test_app") {
901 if (defined(invoker.is_shared_library) && invoker.is_shared_library) {
902 shared_library("lib" + target_name) {
903 forward_variables_from(invoker, "*", [ "is_shared_library" ])
904 testonly = true
905 }
906 } else {
Mike Klein7d921032017-01-05 12:20:41 -0500907 _executable = target_name
908 executable(_executable) {
Mike Kleine6682eb2017-01-05 10:54:57 -0500909 forward_variables_from(invoker, "*", [ "is_shared_library" ])
910 testonly = true
911 }
912 }
Mike Klein7d921032017-01-05 12:20:41 -0500913 if (is_android && skia_android_serial != "" && defined(_executable)) {
914 action("push_" + target_name) {
915 script = "gn/push_to_android.py"
916 deps = [
917 ":" + _executable,
918 ]
919 _stamp = "$target_gen_dir/$_executable.pushed_$skia_android_serial"
920 outputs = [
921 _stamp,
922 ]
923 args = [
924 rebase_path("$root_build_dir/$_executable"),
925 skia_android_serial,
926 rebase_path(_stamp),
927 ]
928 testonly = true
929 }
930 }
Mike Kleine6682eb2017-01-05 10:54:57 -0500931 }
932
mtkleinc095df52016-08-24 12:23:52 -0700933 test_lib("gpu_tool_utils") {
mtklein38925aa2016-09-21 10:11:25 -0700934 public_include_dirs = []
935 if (skia_enable_gpu) {
936 public_defines = []
937 public_include_dirs += [ "tools/gpu" ]
mtkleind68f9b02016-09-23 13:18:41 -0700938
939 deps = []
mtklein38925aa2016-09-21 10:11:25 -0700940 sources = [
941 "tools/gpu/GrContextFactory.cpp",
942 "tools/gpu/GrTest.cpp",
943 "tools/gpu/TestContext.cpp",
944 "tools/gpu/gl/GLTestContext.cpp",
mtklein605d9522016-09-21 14:01:32 -0700945 "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
mtklein38925aa2016-09-21 10:11:25 -0700946 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
947 "tools/gpu/gl/debug/GrBufferObj.cpp",
948 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
949 "tools/gpu/gl/debug/GrProgramObj.cpp",
950 "tools/gpu/gl/debug/GrShaderObj.cpp",
951 "tools/gpu/gl/debug/GrTextureObj.cpp",
952 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
953 "tools/gpu/gl/null/NullGLTestContext.cpp",
Brian Salomoncfe910d2017-07-06 16:40:18 -0400954 "tools/gpu/mock/MockTestContext.cpp",
mtklein38925aa2016-09-21 10:11:25 -0700955 ]
956 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700957
Kevin Lubick4a24e102017-03-29 11:19:01 -0400958 if (is_android || skia_use_egl) {
mtklein38925aa2016-09-21 10:11:25 -0700959 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
Mike Klein7d302882016-11-03 14:06:31 -0400960 } else if (is_ios) {
961 sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
962 libs += [ "OpenGLES.framework" ]
mtklein38925aa2016-09-21 10:11:25 -0700963 } else if (is_linux) {
964 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
Mike Kleina979a1d2017-02-23 10:31:13 -0500965 libs += [ "X11" ]
mtklein38925aa2016-09-21 10:11:25 -0700966 } else if (is_mac) {
967 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
Mike Klein4b167fc2016-10-11 18:13:53 -0400968 } else if (is_win) {
969 sources += [ "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp" ]
970 libs += [
971 "Gdi32.lib",
972 "OpenGL32.lib",
973 ]
mtklein38925aa2016-09-21 10:11:25 -0700974 }
mtklein6ef69992016-09-14 06:12:09 -0700975
Mike Kleinc168a3a2016-11-14 14:53:13 +0000976 if (skia_use_angle) {
Mike Kleinc168a3a2016-11-14 14:53:13 +0000977 deps += [ "//third_party/angle2" ]
978 sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
979 }
mtklein38925aa2016-09-21 10:11:25 -0700980 if (skia_use_mesa) {
981 public_defines += [ "SK_MESA" ]
982 sources += [ "tools/gpu/gl/mesa/GLTestContext_mesa.cpp" ]
983 libs += [ "OSMesa" ]
984 }
mtkleind68f9b02016-09-23 13:18:41 -0700985 if (skia_use_vulkan) {
986 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
Brian Salomon5db010b2017-04-25 16:05:29 -0400987 if (is_win) {
988 libs += [ "vulkan-1.lib" ]
989 } else {
990 libs += [ "vulkan" ]
991 }
mtkleind68f9b02016-09-23 13:18:41 -0700992 }
mtkleina627b5c2016-09-20 13:36:47 -0700993 }
mtklein25c81d42016-07-27 13:55:26 -0700994 }
mtklein25c81d42016-07-27 13:55:26 -0700995
mtkleinc095df52016-08-24 12:23:52 -0700996 test_lib("flags") {
997 public_include_dirs = [ "tools/flags" ]
998 sources = [
999 "tools/flags/SkCommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -07001000 ]
1001 }
1002 test_lib("common_flags") {
1003 public_include_dirs = [ "tools/flags" ]
1004 sources = [
mtkleinc095df52016-08-24 12:23:52 -07001005 "tools/flags/SkCommonFlags.cpp",
1006 "tools/flags/SkCommonFlagsConfig.cpp",
1007 ]
1008 deps = [
mtklein046cb562016-09-16 10:23:12 -07001009 ":flags",
mtkleinc095df52016-08-24 12:23:52 -07001010 ":gpu_tool_utils",
1011 ]
1012 }
mtklein25c81d42016-07-27 13:55:26 -07001013
mtkleinc095df52016-08-24 12:23:52 -07001014 test_lib("tool_utils") {
1015 public_include_dirs = [
1016 "tools",
1017 "tools/debugger",
1018 "tools/timer",
1019 ]
1020 sources = [
mtkleinb37c0342016-09-09 11:07:45 -07001021 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001022 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -07001023 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001024 "tools/ProcStats.cpp",
1025 "tools/Resources.cpp",
1026 "tools/ThermalManager.cpp",
1027 "tools/UrlDataManager.cpp",
1028 "tools/debugger/SkDebugCanvas.cpp",
1029 "tools/debugger/SkDrawCommand.cpp",
1030 "tools/debugger/SkJsonWriteBuffer.cpp",
1031 "tools/debugger/SkObjectParser.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001032 "tools/picture_utils.cpp",
1033 "tools/random_parse_path.cpp",
1034 "tools/sk_tool_utils.cpp",
1035 "tools/sk_tool_utils_font.cpp",
1036 "tools/timer/Timer.cpp",
1037 ]
Mike Kleinadacaef2017-02-06 09:26:14 -05001038 libs = []
1039 if (is_ios) {
1040 sources += [ "tools/ios_utils.m" ]
1041 libs += [ "Foundation.framework" ]
1042 }
mtkleinc095df52016-08-24 12:23:52 -07001043 deps = [
mtklein046cb562016-09-16 10:23:12 -07001044 ":common_flags",
mtkleinc095df52016-08-24 12:23:52 -07001045 ":flags",
1046 "//third_party/libpng",
1047 ]
1048 public_deps = [
1049 "//third_party/jsoncpp",
1050 ]
1051 }
mtklein25c81d42016-07-27 13:55:26 -07001052
Mike Klein6e744122016-10-27 12:21:40 -04001053 import("gn/gm.gni")
mtkleinc095df52016-08-24 12:23:52 -07001054 test_lib("gm") {
1055 public_include_dirs = [ "gm" ]
1056 sources = gm_sources
1057 deps = [
scroggo19b91532016-10-24 09:03:26 -07001058 ":flags",
mtkleinc095df52016-08-24 12:23:52 -07001059 ":gpu_tool_utils",
1060 ":skia",
1061 ":tool_utils",
1062 ]
1063 }
mtklein25c81d42016-07-27 13:55:26 -07001064
Mike Klein6e744122016-10-27 12:21:40 -04001065 import("gn/tests.gni")
mtkleinc095df52016-08-24 12:23:52 -07001066 test_lib("tests") {
1067 public_include_dirs = [ "tests" ]
Mike Klein6e744122016-10-27 12:21:40 -04001068 sources = tests_sources + pathops_tests_sources
mtkleina45be612016-08-29 15:22:10 -07001069 if (!fontmgr_android_enabled) {
Mike Klein6e744122016-10-27 12:21:40 -04001070 sources -= [ "//tests/FontMgrAndroidParserTest.cpp" ]
mtkleina45be612016-08-29 15:22:10 -07001071 }
mtkleinc095df52016-08-24 12:23:52 -07001072 deps = [
fmalita6cf896d2016-08-25 08:44:35 -07001073 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -07001074 ":flags",
mtkleinc095df52016-08-24 12:23:52 -07001075 ":skia",
1076 ":tool_utils",
1077 "//third_party/libpng",
1078 "//third_party/zlib",
1079 ]
Mike Kleind63442d2017-03-27 14:16:04 -04001080 public_deps = [
1081 ":gpu_tool_utils", # Test.h #includes headers from this target.
1082 ]
mtkleinc095df52016-08-24 12:23:52 -07001083 }
mtklein2f3416d2016-08-02 16:02:05 -07001084
Mike Klein6e744122016-10-27 12:21:40 -04001085 import("gn/bench.gni")
mtkleinc095df52016-08-24 12:23:52 -07001086 test_lib("bench") {
1087 public_include_dirs = [ "bench" ]
1088 sources = bench_sources
mtkleinc095df52016-08-24 12:23:52 -07001089 deps = [
1090 ":flags",
1091 ":gm",
1092 ":gpu_tool_utils",
1093 ":skia",
1094 ":tool_utils",
1095 ]
1096 }
mtklein2b6870c2016-07-28 14:17:33 -07001097
mtkleinc095df52016-08-24 12:23:52 -07001098 test_lib("experimental_svg_model") {
1099 public_include_dirs = [ "experimental/svg/model" ]
1100 sources = [
1101 "experimental/svg/model/SkSVGAttribute.cpp",
1102 "experimental/svg/model/SkSVGAttributeParser.cpp",
1103 "experimental/svg/model/SkSVGCircle.cpp",
Florin Malitace8840e2016-12-08 09:26:47 -05001104 "experimental/svg/model/SkSVGClipPath.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001105 "experimental/svg/model/SkSVGContainer.cpp",
1106 "experimental/svg/model/SkSVGDOM.cpp",
1107 "experimental/svg/model/SkSVGEllipse.cpp",
1108 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -07001109 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001110 "experimental/svg/model/SkSVGNode.cpp",
1111 "experimental/svg/model/SkSVGPath.cpp",
1112 "experimental/svg/model/SkSVGPoly.cpp",
1113 "experimental/svg/model/SkSVGRect.cpp",
1114 "experimental/svg/model/SkSVGRenderContext.cpp",
1115 "experimental/svg/model/SkSVGSVG.cpp",
1116 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -07001117 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001118 "experimental/svg/model/SkSVGTransformableNode.cpp",
1119 "experimental/svg/model/SkSVGValue.cpp",
1120 ]
1121 deps = [
1122 ":skia",
1123 ]
1124 }
fmalitaa2b9fdf2016-08-03 19:53:36 -07001125
Brian Osman16adfa32016-10-18 14:42:44 -04001126 test_lib("views") {
1127 public_include_dirs = [ "include/views" ]
1128 sources = [
1129 "src/views/SkEvent.cpp",
1130 "src/views/SkEventSink.cpp",
1131 "src/views/SkOSMenu.cpp",
1132 "src/views/SkTagList.cpp",
1133 "src/views/SkTouchGesture.cpp",
1134 "src/views/SkView.cpp",
1135 "src/views/SkViewPriv.cpp",
1136 ]
1137 libs = []
Brian Osman34755e22016-12-05 09:46:02 -05001138 deps = []
Brian Osman16adfa32016-10-18 14:42:44 -04001139 if (!is_android) {
1140 sources += [ "src/views/SkWindow.cpp" ]
1141 }
Jim Van Verth4e56a912016-10-21 10:58:52 -04001142 if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -04001143 public_include_dirs += [ "src/views/unix" ]
1144 sources += [
1145 "src/views/unix/SkOSWindow_Unix.cpp",
1146 "src/views/unix/keysym2ucs.c",
1147 ]
Mike Kleina979a1d2017-02-23 10:31:13 -05001148 libs += [
1149 "GL",
1150 "X11",
1151 ]
Brian Osman16adfa32016-10-18 14:42:44 -04001152 } else if (is_mac) {
1153 sources += [
1154 "src/views/mac/SkEventNotifier.mm",
1155 "src/views/mac/SkNSView.mm",
1156 "src/views/mac/SkOSWindow_Mac.mm",
1157 "src/views/mac/SkTextFieldCell.m",
1158 ]
1159 libs += [
1160 "QuartzCore.framework",
1161 "Cocoa.framework",
1162 "Foundation.framework",
1163 ]
1164 } else if (is_win) {
1165 sources += [ "src/views/win/SkOSWindow_win.cpp" ]
1166 }
Brian Osman34755e22016-12-05 09:46:02 -05001167 if (skia_use_angle) {
1168 deps += [ "//third_party/angle2" ]
1169 }
Brian Osman16adfa32016-10-18 14:42:44 -04001170 }
1171
Mike Klein38af9432016-11-11 11:39:44 -05001172 if (skia_use_lua) {
1173 test_lib("lua") {
1174 public_include_dirs = []
1175 sources = [
1176 "src/utils/SkLua.cpp",
1177 "src/utils/SkLuaCanvas.cpp",
1178 ]
1179 deps = [
1180 "//third_party/lua",
1181 ]
1182 }
1183
Mike Kleine6682eb2017-01-05 10:54:57 -05001184 test_app("lua_app") {
Mike Klein38af9432016-11-11 11:39:44 -05001185 sources = [
1186 "tools/lua/lua_app.cpp",
1187 ]
1188 deps = [
1189 ":lua",
1190 ":skia",
1191 "//third_party/lua",
1192 ]
Mike Klein38af9432016-11-11 11:39:44 -05001193 }
1194
Mike Kleine6682eb2017-01-05 10:54:57 -05001195 test_app("lua_pictures") {
Mike Klein38af9432016-11-11 11:39:44 -05001196 sources = [
1197 "tools/lua/lua_pictures.cpp",
1198 ]
1199 deps = [
1200 ":flags",
1201 ":lua",
1202 ":skia",
1203 ":tool_utils",
1204 "//third_party/lua",
1205 ]
Mike Klein38af9432016-11-11 11:39:44 -05001206 }
1207 }
1208
Mike Klein6e744122016-10-27 12:21:40 -04001209 import("gn/samples.gni")
Brian Osman16adfa32016-10-18 14:42:44 -04001210 test_lib("samples") {
Brian Osman16adfa32016-10-18 14:42:44 -04001211 public_include_dirs = [ "samplecode" ]
Mike Klein6e744122016-10-27 12:21:40 -04001212 include_dirs = [ "experimental" ]
1213 sources = samples_sources + [
Mike Klein6e744122016-10-27 12:21:40 -04001214 "experimental/SkSetPoly3To3.cpp",
1215 "experimental/SkSetPoly3To3_A.cpp",
1216 "experimental/SkSetPoly3To3_D.cpp",
Brian Osmancff94e42017-06-26 13:12:37 -04001217
1218 # Relocating these files here, so that clients don't try to build them while they're
1219 # still in active development. Clang's thread safety analysis gets tripped up by
1220 # conditional locks.
1221 "src/core/SkThreadedBMPDevice.cpp",
1222 "src/core/SkThreadedBMPDevice.h",
Mike Klein6e744122016-10-27 12:21:40 -04001223 ]
Brian Osman16adfa32016-10-18 14:42:44 -04001224 deps = [
1225 ":experimental_svg_model",
csmartdalton8c679092017-03-27 12:32:29 -06001226 ":flags",
Mike Klein6e744122016-10-27 12:21:40 -04001227 ":gm",
Brian Osman16adfa32016-10-18 14:42:44 -04001228 ":tool_utils",
1229 ":views",
1230 ":xml",
1231 ]
Mike Klein38af9432016-11-11 11:39:44 -05001232
1233 if (skia_use_lua) {
1234 sources += [ "samplecode/SampleLua.cpp" ]
1235 deps += [
1236 ":lua",
1237 "//third_party/lua",
1238 ]
1239 }
Brian Osman16adfa32016-10-18 14:42:44 -04001240 }
1241
Mike Kleine6682eb2017-01-05 10:54:57 -05001242 test_app("dm") {
mtklein2b6870c2016-07-28 14:17:33 -07001243 sources = [
1244 "dm/DM.cpp",
1245 "dm/DMJsonWriter.cpp",
1246 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -07001247 ]
1248 include_dirs = [ "tests" ]
1249 deps = [
mtklein046cb562016-09-16 10:23:12 -07001250 ":common_flags",
fmalitaa2b9fdf2016-08-03 19:53:36 -07001251 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -07001252 ":flags",
1253 ":gm",
1254 ":gpu_tool_utils",
1255 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -07001256 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -07001257 ":tool_utils",
1258 "//third_party/jsoncpp",
1259 "//third_party/libpng",
1260 ]
mtklein2b6870c2016-07-28 14:17:33 -07001261 }
1262
Mike Klein06432b22017-03-21 13:14:33 -04001263 test_app("ok") {
1264 sources = [
1265 "tools/ok.cpp",
Mike Klein7ac04832017-03-25 11:29:41 -04001266 "tools/ok_dsts.cpp",
1267 "tools/ok_srcs.cpp",
Mike Kleind63442d2017-03-27 14:16:04 -04001268 "tools/ok_test.cpp",
Mike Kleinf5d1a552017-03-25 12:32:22 -04001269 "tools/ok_vias.cpp",
Mike Klein06432b22017-03-21 13:14:33 -04001270 ]
1271 deps = [
1272 ":gm",
1273 ":skia",
Mike Kleind63442d2017-03-27 14:16:04 -04001274 ":tests",
Mike Klein62669ad2017-05-09 16:03:07 -04001275 ":tool_utils",
Mike Klein06432b22017-03-21 13:14:33 -04001276 ]
1277 }
1278
Mike Kleina3430172016-09-27 16:46:29 -04001279 if (!is_debug) { # I've benchmarked debug code once too many times...
Mike Kleine6682eb2017-01-05 10:54:57 -05001280 test_app("monobench") {
Mike Kleina3430172016-09-27 16:46:29 -04001281 sources = [
1282 "tools/monobench.cpp",
1283 ]
1284 deps = [
1285 ":bench",
1286 ":skia",
1287 ]
Mike Kleina3430172016-09-27 16:46:29 -04001288 }
mtklein2b6870c2016-07-28 14:17:33 -07001289 }
1290
Mike Kleine6682eb2017-01-05 10:54:57 -05001291 test_app("nanobench") {
mtklein2b6870c2016-07-28 14:17:33 -07001292 sources = [
1293 "bench/nanobench.cpp",
1294 ]
1295 deps = [
1296 ":bench",
mtklein046cb562016-09-16 10:23:12 -07001297 ":common_flags",
fmalita6519c212016-09-14 08:05:17 -07001298 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -07001299 ":flags",
1300 ":gm",
1301 ":gpu_tool_utils",
1302 ":skia",
1303 ":tool_utils",
1304 "//third_party/jsoncpp",
1305 ]
mtklein2b6870c2016-07-28 14:17:33 -07001306 }
halcanary19a97202016-08-03 15:08:04 -07001307
Ravi Mistry10d36c52017-01-31 09:49:18 -05001308 test_app("skpinfo") {
1309 sources = [
1310 "tools/skpinfo.cpp",
1311 ]
1312 deps = [
1313 ":flags",
1314 ":skia",
1315 ]
1316 }
1317
Jim Van Verth57a98fc2016-10-28 13:35:50 -04001318 if (is_linux || is_win || is_mac) {
Mike Kleine6682eb2017-01-05 10:54:57 -05001319 test_app("SampleApp") {
mtklein38925aa2016-09-21 10:11:25 -07001320 sources = [
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001321 "samplecode/SampleApp.cpp",
1322 "samplecode/SamplePictFile.cpp",
mtklein38925aa2016-09-21 10:11:25 -07001323 ]
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001324 if (is_mac) {
1325 sources += [ "src/views/mac/skia_mac.mm" ]
1326 } else if (is_win) {
1327 sources += [ "src/views/win/skia_win.cpp" ]
1328 } else if (is_linux) {
1329 sources += [ "src/views/unix/skia_unix.cpp" ]
1330 }
mtklein38925aa2016-09-21 10:11:25 -07001331 deps = [
1332 ":flags",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001333 ":gm",
mtklein38925aa2016-09-21 10:11:25 -07001334 ":gpu_tool_utils",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001335 ":samples",
mtklein38925aa2016-09-21 10:11:25 -07001336 ":skia",
1337 ":tool_utils",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001338 ":views",
mtklein38925aa2016-09-21 10:11:25 -07001339 ]
Mike Kleinc168a3a2016-11-14 14:53:13 +00001340 if (skia_use_angle) {
1341 deps += [ "//third_party/angle2" ]
1342 }
mtklein38925aa2016-09-21 10:11:25 -07001343 }
Jim Van Verth8f5468f2016-10-31 09:52:33 -04001344 }
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001345
Jim Van Verth8f5468f2016-10-31 09:52:33 -04001346 if (skia_enable_gpu) {
Mike Kleine6682eb2017-01-05 10:54:57 -05001347 test_app("skpbench") {
Jim Van Verth8f5468f2016-10-31 09:52:33 -04001348 sources = [
1349 "tools/skpbench/skpbench.cpp",
1350 ]
1351 deps = [
1352 ":flags",
1353 ":gpu_tool_utils",
1354 ":skia",
1355 ":tool_utils",
1356 ]
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001357 }
csmartdalton4b5179b2016-09-19 11:03:58 -07001358 }
1359
Mike Klein7d302882016-11-03 14:06:31 -04001360 # We can't yet build ICU on iOS or Windows.
1361 if (!is_ios && !is_win) {
Mike Kleine6682eb2017-01-05 10:54:57 -05001362 test_app("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -07001363 sources = [
1364 "tools/SkShaper_harfbuzz.cpp",
1365 "tools/using_skia_and_harfbuzz.cpp",
1366 ]
1367 deps = [
1368 ":skia",
1369 "//third_party/harfbuzz",
1370 ]
mtklein6f5df6a2016-08-29 16:01:10 -07001371 }
halcanary19a97202016-08-03 15:08:04 -07001372 }
Mike Kleine6682eb2017-01-05 10:54:57 -05001373 test_app("sktexttopdf") {
halcanary3eee9d92016-09-10 07:01:53 -07001374 sources = [
1375 "tools/SkShaper_primitive.cpp",
1376 "tools/using_skia_and_harfbuzz.cpp",
1377 ]
1378 deps = [
1379 ":skia",
1380 ]
halcanary3eee9d92016-09-10 07:01:53 -07001381 }
mtklein046cb562016-09-16 10:23:12 -07001382
Matt Sarett9f1c4032017-05-17 10:06:32 -04001383 test_app("create_flutter_test_images") {
1384 sources = [
1385 "tools/create_flutter_test_images.cpp",
1386 ]
1387 deps = [
1388 ":skia",
1389 ":tool_utils",
1390 ]
1391 }
1392
Mike Kleine6682eb2017-01-05 10:54:57 -05001393 test_app("get_images_from_skps") {
mtklein046cb562016-09-16 10:23:12 -07001394 sources = [
1395 "tools/get_images_from_skps.cpp",
1396 ]
1397 deps = [
1398 ":flags",
1399 ":skia",
1400 "//third_party/jsoncpp",
1401 ]
mtklein046cb562016-09-16 10:23:12 -07001402 }
mtkleinecbc5262016-09-22 11:51:24 -07001403
Mike Kleine6682eb2017-01-05 10:54:57 -05001404 test_app("colorspaceinfo") {
Matt Sarett8740d582016-11-11 13:59:14 -05001405 sources = [
1406 "tools/colorspaceinfo.cpp",
1407 ]
1408 deps = [
1409 ":flags",
1410 ":skia",
1411 ":tool_utils",
1412 ]
Matt Sarett8740d582016-11-11 13:59:14 -05001413 }
1414
Mike Klein7d302882016-11-03 14:06:31 -04001415 if (!is_ios) {
Mike Kleine6682eb2017-01-05 10:54:57 -05001416 test_app("skiaserve") {
Mike Klein7d302882016-11-03 14:06:31 -04001417 sources = [
1418 "tools/skiaserve/Request.cpp",
1419 "tools/skiaserve/Response.cpp",
1420 "tools/skiaserve/skiaserve.cpp",
Mike Klein7d302882016-11-03 14:06:31 -04001421 "tools/skiaserve/urlhandlers/BreakHandler.cpp",
1422 "tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp",
1423 "tools/skiaserve/urlhandlers/CmdHandler.cpp",
1424 "tools/skiaserve/urlhandlers/ColorModeHandler.cpp",
1425 "tools/skiaserve/urlhandlers/DataHandler.cpp",
1426 "tools/skiaserve/urlhandlers/DownloadHandler.cpp",
1427 "tools/skiaserve/urlhandlers/EnableGPUHandler.cpp",
1428 "tools/skiaserve/urlhandlers/ImgHandler.cpp",
1429 "tools/skiaserve/urlhandlers/InfoHandler.cpp",
Brian Salomon144a5c52016-12-20 16:48:59 -05001430 "tools/skiaserve/urlhandlers/OpBoundsHandler.cpp",
1431 "tools/skiaserve/urlhandlers/OpsHandler.cpp",
Mike Klein7d302882016-11-03 14:06:31 -04001432 "tools/skiaserve/urlhandlers/OverdrawHandler.cpp",
1433 "tools/skiaserve/urlhandlers/PostHandler.cpp",
1434 "tools/skiaserve/urlhandlers/QuitHandler.cpp",
1435 "tools/skiaserve/urlhandlers/RootHandler.cpp",
1436 ]
1437 deps = [
1438 ":flags",
1439 ":gpu_tool_utils",
1440 ":skia",
1441 ":tool_utils",
1442 "//third_party/jsoncpp",
1443 "//third_party/libmicrohttpd",
1444 "//third_party/libpng",
1445 ]
Mike Klein7d302882016-11-03 14:06:31 -04001446 }
mtkleinecbc5262016-09-22 11:51:24 -07001447 }
kjlubick14f984b2016-10-03 11:49:45 -07001448
Mike Kleine6682eb2017-01-05 10:54:57 -05001449 test_app("fuzz") {
kjlubick14f984b2016-10-03 11:49:45 -07001450 sources = [
1451 "fuzz/FilterFuzz.cpp",
Hal Canary24ac42b2017-02-14 13:35:14 -05001452 "fuzz/FuzzCanvas.cpp",
Kevin Lubickfec1dea2016-11-22 13:57:18 -05001453 "fuzz/FuzzDrawFunctions.cpp",
kjlubick14f984b2016-10-03 11:49:45 -07001454 "fuzz/FuzzGradients.cpp",
1455 "fuzz/FuzzParsePath.cpp",
1456 "fuzz/FuzzPathop.cpp",
1457 "fuzz/FuzzScaleToSides.cpp",
1458 "fuzz/fuzz.cpp",
1459 ]
1460 deps = [
1461 ":flags",
Hal Canary44801ca2017-03-15 11:39:06 -04001462 ":gpu_tool_utils",
kjlubick14f984b2016-10-03 11:49:45 -07001463 ":skia",
Hal Canarydb683012016-11-23 08:55:18 -07001464 ":tool_utils",
kjlubick14f984b2016-10-03 11:49:45 -07001465 ]
kjlubick14f984b2016-10-03 11:49:45 -07001466 }
Mike Klein38312422016-10-05 15:41:01 -04001467
Mike Kleine6682eb2017-01-05 10:54:57 -05001468 test_app("pathops_unittest") {
Mike Klein6e744122016-10-27 12:21:40 -04001469 sources = pathops_tests_sources + [
Mike Klein6e55fef2016-10-26 11:41:47 -04001470 rebase_path("tests/skia_test.cpp"),
1471 rebase_path("tests/Test.cpp"),
1472 ]
caryclark9feb6322016-10-25 08:58:26 -07001473 deps = [
1474 ":flags",
1475 ":gpu_tool_utils",
1476 ":skia",
1477 ":tool_utils",
1478 ]
caryclark9feb6322016-10-25 08:58:26 -07001479 }
1480
Mike Kleine6682eb2017-01-05 10:54:57 -05001481 test_app("dump_record") {
Mike Klein38312422016-10-05 15:41:01 -04001482 sources = [
1483 "tools/DumpRecord.cpp",
1484 "tools/dump_record.cpp",
1485 ]
1486 deps = [
1487 ":flags",
1488 ":skia",
1489 ]
Mike Klein38312422016-10-05 15:41:01 -04001490 }
bungemanfe917272016-10-13 17:36:40 -04001491
Mike Kleine6682eb2017-01-05 10:54:57 -05001492 test_app("skdiff") {
bungemanfe917272016-10-13 17:36:40 -04001493 sources = [
1494 "tools/skdiff/skdiff.cpp",
1495 "tools/skdiff/skdiff_html.cpp",
1496 "tools/skdiff/skdiff_main.cpp",
1497 "tools/skdiff/skdiff_utils.cpp",
1498 ]
1499 deps = [
1500 ":skia",
1501 ":tool_utils",
1502 ]
bungemanfe917272016-10-13 17:36:40 -04001503 }
halcanarya73d76a2016-10-17 13:19:02 -07001504
Mike Kleine6682eb2017-01-05 10:54:57 -05001505 test_app("skp_parser") {
halcanarya73d76a2016-10-17 13:19:02 -07001506 sources = [
1507 "tools/skp_parser.cpp",
1508 ]
1509 deps = [
1510 ":skia",
1511 ":tool_utils",
1512 "//third_party/jsoncpp",
1513 ]
halcanarya73d76a2016-10-17 13:19:02 -07001514 }
Brian Osman16adfa32016-10-18 14:42:44 -04001515
Mike Kleina92c3832016-12-08 09:49:39 -05001516 if (skia_enable_gpu && (is_android || is_linux || is_win || is_mac)) {
Mike Kleine6682eb2017-01-05 10:54:57 -05001517 test_app("viewer") {
1518 is_shared_library = is_android
Brian Osman16adfa32016-10-18 14:42:44 -04001519 sources = [
1520 "tools/viewer/GMSlide.cpp",
1521 "tools/viewer/ImageSlide.cpp",
1522 "tools/viewer/SKPSlide.cpp",
1523 "tools/viewer/SampleSlide.cpp",
1524 "tools/viewer/Viewer.cpp",
1525 "tools/viewer/sk_app/CommandSet.cpp",
1526 "tools/viewer/sk_app/GLWindowContext.cpp",
1527 "tools/viewer/sk_app/Window.cpp",
Brian Osman16adfa32016-10-18 14:42:44 -04001528 ]
Brian Osman2dd96932016-10-18 15:33:53 -04001529 libs = []
Brian Osman16adfa32016-10-18 14:42:44 -04001530
Jim Van Verth4e56a912016-10-21 10:58:52 -04001531 if (is_android) {
1532 sources += [
1533 "tools/viewer/sk_app/android/GLWindowContext_android.cpp",
1534 "tools/viewer/sk_app/android/RasterWindowContext_android.cpp",
1535 "tools/viewer/sk_app/android/Window_android.cpp",
1536 "tools/viewer/sk_app/android/main_android.cpp",
1537 "tools/viewer/sk_app/android/surface_glue_android.cpp",
1538 ]
Brian Osman462334e2017-02-09 11:22:57 -05001539 libs += [ "android" ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001540 } else if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -04001541 sources += [
1542 "tools/viewer/sk_app/unix/GLWindowContext_unix.cpp",
1543 "tools/viewer/sk_app/unix/RasterWindowContext_unix.cpp",
1544 "tools/viewer/sk_app/unix/Window_unix.cpp",
1545 "tools/viewer/sk_app/unix/main_unix.cpp",
1546 ]
1547 } else if (is_win) {
Brian Osman16adfa32016-10-18 14:42:44 -04001548 sources += [
1549 "tools/viewer/sk_app/win/GLWindowContext_win.cpp",
1550 "tools/viewer/sk_app/win/RasterWindowContext_win.cpp",
1551 "tools/viewer/sk_app/win/Window_win.cpp",
1552 "tools/viewer/sk_app/win/main_win.cpp",
1553 ]
Mike Klein43c25262016-10-20 10:17:47 -04001554 } else if (is_mac) {
1555 sources += [
1556 "tools/viewer/sk_app/mac/GLWindowContext_mac.cpp",
1557 "tools/viewer/sk_app/mac/RasterWindowContext_mac.cpp",
1558 "tools/viewer/sk_app/mac/Window_mac.cpp",
1559 "tools/viewer/sk_app/mac/main_mac.cpp",
1560 ]
Brian Osman16adfa32016-10-18 14:42:44 -04001561 }
1562
1563 if (skia_use_vulkan) {
1564 sources += [ "tools/viewer/sk_app/VulkanWindowContext.cpp" ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001565 if (is_android) {
1566 sources +=
1567 [ "tools/viewer/sk_app/android/VulkanWindowContext_android.cpp" ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001568 } else if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -04001569 sources += [ "tools/viewer/sk_app/unix/VulkanWindowContext_unix.cpp" ]
1570 libs += [ "X11-xcb" ]
1571 } else if (is_win) {
Brian Osman16adfa32016-10-18 14:42:44 -04001572 sources += [ "tools/viewer/sk_app/win/VulkanWindowContext_win.cpp" ]
1573 }
1574 }
1575
1576 include_dirs = []
1577 deps = [
1578 ":flags",
1579 ":gm",
1580 ":gpu_tool_utils",
1581 ":samples",
1582 ":skia",
1583 ":tool_utils",
1584 ":views",
Brian Osman79086b92017-02-10 13:36:16 -05001585 "//third_party/imgui",
Brian Osman16adfa32016-10-18 14:42:44 -04001586 "//third_party/jsoncpp",
1587 ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001588 if (is_android) {
1589 deps += [ "//third_party/native_app_glue" ]
1590 } else if (is_mac) {
Mike Klein43c25262016-10-20 10:17:47 -04001591 deps += [ "//third_party/libsdl" ]
1592 }
Mike Kleina92c3832016-12-08 09:49:39 -05001593 }
Brian Osman16adfa32016-10-18 14:42:44 -04001594 }
Ethan Nicholas4f3985c2016-11-14 11:16:37 -05001595
Jim Van Verth4c70c752017-07-11 12:03:01 -04001596 if (skia_enable_gpu && (is_linux || is_mac)) {
1597 test_app("SkiaSDLExample") {
1598 sources = [
1599 "example/SkiaSDLExample.cpp",
1600 ]
1601 libs = []
1602 include_dirs = []
1603 deps = [
1604 ":gpu_tool_utils",
1605 ":skia",
1606 "//third_party/libsdl",
1607 ]
1608 }
1609 }
1610
Mike Kleine459afd2017-03-03 09:21:30 -05001611 if (is_android && defined(ndk) && ndk != "") {
Derek Sollenberger70120c72017-01-05 11:39:04 -05001612 copy("gdbserver") {
1613 sources = [
1614 "$ndk/$ndk_gdbserver",
1615 ]
1616 outputs = [
1617 "$root_out_dir/gdbserver",
1618 ]
1619 }
Derek Sollenberger70120c72017-01-05 11:39:04 -05001620 }
mtklein25c81d42016-07-27 13:55:26 -07001621}
Mike Kleinc55a6cb2017-06-28 13:21:47 -04001622
1623if (skia_jumper_clang != "") {
1624 action("regen_jumper") {
1625 script = "src/jumper/build_stages.py"
1626
1627 inputs = [
1628 "src/jumper/SkJumper_stages.cpp",
1629 "src/jumper/SkJumper_stages_lowp.cpp",
1630 ]
1631
1632 # GN insists its outputs should go somewhere underneath target_out_dir, so we trick it.
1633 outputs = [
1634 "$target_out_dir/" +
1635 rebase_path("src/jumper/SkJumper_generated.S", target_out_dir),
1636 "$target_out_dir/" +
1637 rebase_path("src/jumper/SkJumper_generated_win.S", target_out_dir),
1638 ]
1639
1640 args = [
1641 skia_jumper_clang,
1642 skia_jumper_objdump,
1643 skia_jumper_ccache,
1644 ] + rebase_path(inputs) + rebase_path(outputs)
1645 }
1646}