blob: 463e0b5246a92826893f371252c400980f5c75d5 [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
Mike Kleincfc4f442016-10-26 17:19:03 -04006import("gn/android_framework_defines.gni")
mikejurka8c24f4f2016-09-12 16:51:58 -07007import("gn/shared_sources.gni")
brettwb9447282016-09-01 14:24:39 -07008
Forrest Reiling30229ac2017-04-17 13:36:39 -07009if (is_fuchsia) {
10 import("//build/vulkan/config.gni")
11}
12
Mike Klein3669a822017-03-03 10:55:02 -050013if (!defined(is_skia_standalone)) {
14 is_skia_standalone = false
15}
16is_skia_dev_build = is_skia_standalone && !is_official_build
17
mtkleinc04ff472016-06-23 10:29:30 -070018declare_args() {
Mike Kleinc168a3a2016-11-14 14:53:13 +000019 skia_use_angle = false
Kevin Lubick4a24e102017-03-29 11:19:01 -040020 skia_use_egl = false
mtklein63213812016-08-24 09:55:56 -070021 skia_use_expat = true
mtklein3cc22182016-08-29 13:26:14 -070022 skia_use_fontconfig = is_linux
mtkleincdedd0e2016-09-12 15:15:44 -070023 skia_use_freetype = is_android || is_fuchsia || is_linux
Mike Klein69f6ed42016-10-13 15:45:07 -040024 skia_use_gdi = false
Mike Klein7d302882016-11-03 14:06:31 -040025 skia_use_icu = !is_fuchsia && !is_ios && !is_win # TODO: Windows
mtklein63213812016-08-24 09:55:56 -070026 skia_use_libjpeg_turbo = true
27 skia_use_libpng = true
mtkleineb3c4252016-08-23 07:38:09 -070028 skia_use_libwebp = !is_fuchsia
Mike Klein38af9432016-11-11 11:39:44 -050029 skia_use_lua = false
mtkleina627b5c2016-09-20 13:36:47 -070030 skia_use_mesa = false
Mike Klein10d665d2016-11-01 11:46:10 -040031 skia_use_piex = !is_win
mtklein63213812016-08-24 09:55:56 -070032 skia_use_zlib = true
mtklein1bd72ba2016-09-16 07:45:52 -070033
Mike Klein7d921032017-01-05 12:20:41 -050034 skia_android_serial = ""
mtklein1bd72ba2016-09-16 07:45:52 -070035 skia_enable_android_framework_defines = false
Brian Osman3f375d02016-12-28 11:19:22 -050036 skia_enable_discrete_gpu = true
Mike Kleina04bb452017-02-09 12:24:07 -050037 skia_enable_effects = true
mtklein06c35c02016-09-20 12:28:12 -070038 skia_enable_gpu = true
Hal Canary43fb7a02016-12-30 13:09:03 -050039 skia_enable_pdf = true
Ethan Nicholasa6ae1f72017-03-16 09:56:54 -040040 skia_enable_spirv_validation = is_skia_dev_build && is_debug
Mike Klein3669a822017-03-03 10:55:02 -050041 skia_enable_tools = is_skia_dev_build
42 skia_enable_vulkan_debug_layers = is_skia_dev_build && is_debug
Greg Daniel686bb212016-10-27 10:48:48 -040043 skia_vulkan_sdk = getenv("VULKAN_SDK")
Ethan Nicholas762466e2017-06-29 10:03:38 -040044 skia_compile_processors = false
Mike Kleinc55a6cb2017-06-28 13:21:47 -040045
46 skia_jumper_clang = ""
47 skia_jumper_objdump = ""
48 skia_jumper_ccache = ""
mtkleinc04ff472016-06-23 10:29:30 -070049}
Brian Salomon23d73ea2016-10-27 13:31:37 -040050declare_args() {
Matt Sarett189491c2017-03-20 18:09:30 -040051 skia_use_dng_sdk = !is_fuchsia && skia_use_libjpeg_turbo && skia_use_zlib
Mike Klein10d665d2016-11-01 11:46:10 -040052 skia_use_sfntly = skia_use_icu
53
Mike Klein4d598a32016-10-31 13:44:49 -040054 if (is_android) {
55 skia_use_vulkan = defined(ndk_api) && ndk_api >= 24
Forrest Reiling30229ac2017-04-17 13:36:39 -070056 } else if (is_fuchsia) {
57 skia_use_vulkan = fuchsia_use_vulkan
Mike Klein4d598a32016-10-31 13:44:49 -040058 } else {
59 skia_use_vulkan = skia_vulkan_sdk != ""
60 }
Brian Salomon23d73ea2016-10-27 13:31:37 -040061}
Greg Danielec6ae522017-04-25 13:38:26 -040062declare_args() {
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000063 skia_vulkan_headers = ""
Greg Danielec6ae522017-04-25 13:38:26 -040064 if (skia_use_vulkan) {
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000065 # 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 -040066 if (is_fuchsia) {
67 skia_vulkan_headers = "$fuchsia_vulkan_sdk/include"
68 } else if (is_linux || is_win) {
69 skia_vulkan_headers = "$skia_vulkan_sdk/include"
Greg Danielec6ae522017-04-25 13:38:26 -040070 }
Greg Danielec6ae522017-04-25 13:38:26 -040071 }
72}
Brian Salomon789e25e2016-09-30 13:41:03 -040073
mtklein38925aa2016-09-21 10:11:25 -070074# Our tools require static linking (they use non-exported symbols).
75skia_enable_tools = skia_enable_tools && !is_component_build
mtklein06c35c02016-09-20 12:28:12 -070076
mtkleina45be612016-08-29 15:22:10 -070077fontmgr_android_enabled = skia_use_expat && skia_use_freetype
78
mtklein1211e0c2016-07-26 13:55:45 -070079skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070080 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070081 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070082 "include/codec",
83 "include/config",
84 "include/core",
85 "include/effects",
Matt Sarett94fd06f2017-05-08 17:31:00 -040086 "include/encode",
mtklein1211e0c2016-07-26 13:55:45 -070087 "include/gpu",
88 "include/gpu/gl",
mtklein1211e0c2016-07-26 13:55:45 -070089 "include/pathops",
90 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070091 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070092 "include/utils",
93 "include/utils/mac",
mtklein1211e0c2016-07-26 13:55:45 -070094]
95
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000096if (skia_use_vulkan) {
97 skia_public_includes += [ "include/gpu/vk" ]
98}
99
mtkleinc04ff472016-06-23 10:29:30 -0700100# Skia public API, generally provided by :skia.
101config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -0700102 include_dirs = skia_public_includes
Greg Danielec6ae522017-04-25 13:38:26 -0400103 if (skia_vulkan_headers != "") {
104 include_dirs += [ skia_vulkan_headers ]
105 }
Mike Kleinae7e6712016-10-11 17:49:33 -0400106 defines = []
107 if (is_component_build) {
108 defines += [ "SKIA_DLL" ]
109 }
Mike Kleinc4cbd742016-09-26 21:37:09 -0400110 if (is_fuchsia || is_linux) {
jcgregorio5561e3d2016-08-25 09:25:11 -0700111 defines += [ "SK_SAMPLES_FOR_X" ]
112 }
mtkleincae1be52016-09-20 08:24:34 -0700113 if (skia_enable_android_framework_defines) {
Mike Kleincfc4f442016-10-26 17:19:03 -0400114 defines += android_framework_defines
mtkleincae1be52016-09-20 08:24:34 -0700115 }
mtklein06c35c02016-09-20 12:28:12 -0700116 if (!skia_enable_gpu) {
117 defines += [ "SK_SUPPORT_GPU=0" ]
118 }
mtkleinc04ff472016-06-23 10:29:30 -0700119}
120
121# Skia internal APIs, used by Skia itself and a few test tools.
122config("skia_private") {
123 visibility = [ ":*" ]
124
125 include_dirs = [
126 "include/private",
127 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -0700128 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -0700129 "src/core",
130 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -0700131 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -0700132 "src/image",
133 "src/images",
134 "src/lazy",
135 "src/opts",
136 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -0700137 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -0700138 "src/ports",
139 "src/sfnt",
Florin Malita5edba452017-05-30 16:39:47 -0400140 "src/shaders",
141 "src/shaders/gradients",
mtklein9e0d9dd2016-08-30 10:37:19 -0700142 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -0700143 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -0700144 "src/utils/win",
Herb Derby5a8fe972017-02-14 14:42:30 -0500145 "src/xml",
scroggo19b91532016-10-24 09:03:26 -0700146 "third_party/gif",
mtkleinc04ff472016-06-23 10:29:30 -0700147 ]
mtklein150d1132016-08-01 06:56:40 -0700148
Mike Reeda9e241d2017-05-03 10:52:00 -0400149 defines = [ "SK_GAMMA_APPLY_TO_A8" ]
mtkleinb37c0342016-09-09 11:07:45 -0700150 if (is_android) {
151 defines += [
152 "SK_GAMMA_EXPONENT=1.4",
153 "SK_GAMMA_CONTRAST=0.0",
154 ]
155 }
mtklein88a7ac02016-09-14 11:16:49 -0700156 if (is_official_build || is_android) {
157 # TODO(bsalomon): it'd be nice to make Android normal.
158 defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
159 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400160 libs = []
161 lib_dirs = []
162 if (skia_use_vulkan) {
Michael Jurkada3e5962017-04-14 17:44:09 -0700163 if (skia_vulkan_sdk != "" && !is_android && !is_fuchsia) {
Mike Klein487bfc22016-10-14 14:04:56 -0400164 if (is_win) {
Brian Salomon3b5bf352017-03-20 15:54:41 -0400165 lib_dirs += [
166 "$skia_vulkan_sdk/Bin",
167 "$skia_vulkan_sdk/Lib",
168 ]
Mike Klein487bfc22016-10-14 14:04:56 -0400169 } else {
Greg Daniel686bb212016-10-27 10:48:48 -0400170 lib_dirs += [ "$skia_vulkan_sdk/lib/" ]
Mike Klein487bfc22016-10-14 14:04:56 -0400171 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400172 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400173 }
Brian Salomon03e05842017-02-23 12:23:47 -0500174 if (skia_enable_gpu) {
175 include_dirs += [ "src/gpu" ]
176 }
Brian Osman34755e22016-12-05 09:46:02 -0500177 if (skia_use_angle) {
178 defines += [ "SK_ANGLE" ]
179 }
Brian Osman3f375d02016-12-28 11:19:22 -0500180 if (skia_enable_discrete_gpu) {
181 defines += [ "SK_ENABLE_DISCRETE_GPU" ]
182 }
mtkleinc04ff472016-06-23 10:29:30 -0700183}
184
185# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
186config("skia_library") {
187 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -0700188 defines = [ "SKIA_IMPLEMENTATION=1" ]
189}
190
191skia_library_configs = [
192 ":skia_public",
193 ":skia_private",
194 ":skia_library",
195]
196
mtklein9b8583d2016-08-24 17:32:30 -0700197# Use for CPU-specific Skia code that needs particular compiler flags.
198template("opts") {
199 if (invoker.enabled) {
200 source_set(target_name) {
201 forward_variables_from(invoker, "*")
202 configs += skia_library_configs
203 }
204 } else {
205 # If not enabled, a phony empty target that swallows all otherwise unused variables.
206 source_set(target_name) {
207 forward_variables_from(invoker,
208 "*",
209 [
210 "sources",
211 "cflags",
212 ])
213 }
214 }
anmittala7eaf2e2016-08-17 13:57:26 -0700215}
216
mtklein422310d2016-08-16 18:28:43 -0700217is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700218
mtklein7d6fb2c2016-08-25 14:50:44 -0700219opts("none") {
220 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700221 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700222 cflags = []
223}
224
mtklein7d6fb2c2016-08-25 14:50:44 -0700225opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700226 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700227 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700228 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700229}
230
231opts("arm64") {
232 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700233 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700234 cflags = []
235}
236
237opts("crc32") {
238 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700239 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700240 cflags = [ "-march=armv8-a+crc" ]
241}
242
mtklein9b8583d2016-08-24 17:32:30 -0700243opts("sse2") {
244 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700245 sources = skia_opts.sse2_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400246 if (is_win) {
247 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE2" ]
248 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400249 cflags = [ "-msse2" ]
250 }
mtklein9b8583d2016-08-24 17:32:30 -0700251}
mtkleinc04ff472016-06-23 10:29:30 -0700252
mtklein9b8583d2016-08-24 17:32:30 -0700253opts("ssse3") {
254 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700255 sources = skia_opts.ssse3_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400256 if (is_win) {
257 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSSE3" ]
258 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400259 cflags = [ "-mssse3" ]
260 }
mtklein9b8583d2016-08-24 17:32:30 -0700261}
mtkleinc04ff472016-06-23 10:29:30 -0700262
mtklein9b8583d2016-08-24 17:32:30 -0700263opts("sse41") {
264 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700265 sources = skia_opts.sse41_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400266 if (is_win) {
267 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE41" ]
268 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400269 cflags = [ "-msse4.1" ]
270 }
mtklein9b8583d2016-08-24 17:32:30 -0700271}
mtklein4e976072016-08-08 09:06:27 -0700272
mtklein9b8583d2016-08-24 17:32:30 -0700273opts("sse42") {
274 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700275 sources = skia_opts.sse42_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400276 if (is_win) {
277 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE42" ]
278 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400279 cflags = [ "-msse4.2" ]
280 }
mtklein9b8583d2016-08-24 17:32:30 -0700281}
282
283opts("avx") {
284 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700285 sources = skia_opts.avx_sources
Mike Klein3eb71212016-10-11 17:08:53 -0400286 if (is_win) {
Mike Klein17b6e482016-11-18 22:11:41 +0000287 cflags = [ "/arch:AVX" ]
Mike Klein3eb71212016-10-11 17:08:53 -0400288 } else {
289 cflags = [ "-mavx" ]
290 }
mtkleinc04ff472016-06-23 10:29:30 -0700291}
292
Mike Klein78d5a3b2016-09-30 10:48:01 -0400293opts("hsw") {
294 enabled = is_x86
295 sources = skia_opts.hsw_sources
Mike Klein3eb71212016-10-11 17:08:53 -0400296 if (is_win) {
Mike Klein17b6e482016-11-18 22:11:41 +0000297 cflags = [ "/arch:AVX2" ]
Mike Klein3eb71212016-10-11 17:08:53 -0400298 } else {
299 cflags = [
300 "-mavx2",
301 "-mbmi",
302 "-mbmi2",
303 "-mf16c",
304 "-mfma",
305 ]
306 }
Mike Klein78d5a3b2016-09-30 10:48:01 -0400307}
308
mtkleinc095df52016-08-24 12:23:52 -0700309# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700310template("optional") {
311 if (invoker.enabled) {
312 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700313 if (defined(invoker.public_defines)) {
314 defines = invoker.public_defines
315 }
mtklein457b42a2016-08-23 13:56:37 -0700316 }
317 source_set(target_name) {
mtkleincd01b032016-08-31 04:58:19 -0700318 forward_variables_from(invoker,
319 "*",
320 [
321 "public_defines",
322 "sources_when_disabled",
scroggof84ad642016-10-31 09:02:57 -0700323 "configs_to_remove",
mtkleincd01b032016-08-31 04:58:19 -0700324 ])
mtklein457b42a2016-08-23 13:56:37 -0700325 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700326 configs += skia_library_configs
scroggof84ad642016-10-31 09:02:57 -0700327 if (defined(invoker.configs_to_remove)) {
328 configs -= invoker.configs_to_remove
329 }
mtklein457b42a2016-08-23 13:56:37 -0700330 }
331 } else {
mtklein457b42a2016-08-23 13:56:37 -0700332 source_set(target_name) {
333 forward_variables_from(invoker,
334 "*",
335 [
336 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700337 "deps",
mtklein6ef69992016-09-14 06:12:09 -0700338 "libs",
mtklein457b42a2016-08-23 13:56:37 -0700339 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700340 "sources_when_disabled",
scroggof84ad642016-10-31 09:02:57 -0700341 "configs_to_remove",
mtklein457b42a2016-08-23 13:56:37 -0700342 ])
mtkleincd01b032016-08-31 04:58:19 -0700343 if (defined(invoker.sources_when_disabled)) {
344 sources = invoker.sources_when_disabled
345 }
346 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700347 }
mtkleineb3c4252016-08-23 07:38:09 -0700348 }
mtklein457b42a2016-08-23 13:56:37 -0700349}
mtklein457b42a2016-08-23 13:56:37 -0700350
Mike Kleina04bb452017-02-09 12:24:07 -0500351optional("effects") {
352 enabled = skia_enable_effects
Ethan Nicholas762466e2017-06-29 10:03:38 -0400353 deps = [
354 ":compile_processors",
355 ]
Mike Kleina04bb452017-02-09 12:24:07 -0500356 sources =
357 skia_effects_sources + [ "src/ports/SkGlobalInitialization_default.cpp" ]
358 sources_when_disabled = [ "src/ports/SkGlobalInitialization_none.cpp" ]
359}
360
mtkleina45be612016-08-29 15:22:10 -0700361optional("fontmgr_android") {
362 enabled = fontmgr_android_enabled
mtkleina45be612016-08-29 15:22:10 -0700363
364 deps = [
Ben Wagnerfc497342017-02-24 11:15:26 -0500365 ":typeface_freetype",
mtkleina45be612016-08-29 15:22:10 -0700366 "//third_party/expat",
mtkleina45be612016-08-29 15:22:10 -0700367 ]
368 sources = [
369 "src/ports/SkFontMgr_android.cpp",
370 "src/ports/SkFontMgr_android_factory.cpp",
371 "src/ports/SkFontMgr_android_parser.cpp",
372 ]
373}
374
mtkleind2e39db2016-09-07 07:52:55 -0700375optional("fontmgr_custom") {
376 enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
377
378 deps = [
Ben Wagnerfc497342017-02-24 11:15:26 -0500379 ":typeface_freetype",
mtkleind2e39db2016-09-07 07:52:55 -0700380 ]
381 sources = [
382 "src/ports/SkFontMgr_custom.cpp",
Ben Wagner8ab590f2017-02-08 17:29:33 -0500383 "src/ports/SkFontMgr_custom.h",
384 "src/ports/SkFontMgr_custom_directory.cpp",
mtkleind2e39db2016-09-07 07:52:55 -0700385 "src/ports/SkFontMgr_custom_directory_factory.cpp",
Ben Wagner8ab590f2017-02-08 17:29:33 -0500386 "src/ports/SkFontMgr_custom_embedded.cpp",
387 "src/ports/SkFontMgr_custom_empty.cpp",
mtkleind2e39db2016-09-07 07:52:55 -0700388 ]
389}
390
mtklein3cc22182016-08-29 13:26:14 -0700391optional("fontmgr_fontconfig") {
392 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700393
394 deps = [
Ben Wagnerfc497342017-02-24 11:15:26 -0500395 ":typeface_freetype",
mtklein3cc22182016-08-29 13:26:14 -0700396 "//third_party:fontconfig",
mtklein3cc22182016-08-29 13:26:14 -0700397 ]
398 sources = [
bungeman1ae0e012016-09-19 12:13:16 -0700399 "src/ports/SkFontConfigInterface.cpp",
mtklein3cc22182016-08-29 13:26:14 -0700400 "src/ports/SkFontConfigInterface_direct.cpp",
401 "src/ports/SkFontConfigInterface_direct_factory.cpp",
402 "src/ports/SkFontMgr_FontConfigInterface.cpp",
403 "src/ports/SkFontMgr_fontconfig.cpp",
404 "src/ports/SkFontMgr_fontconfig_factory.cpp",
405 ]
406}
407
mtkleincdedd0e2016-09-12 15:15:44 -0700408optional("fontmgr_fuchsia") {
409 enabled = is_fuchsia && skia_use_freetype
410
411 deps = [
Ben Wagnerfc497342017-02-24 11:15:26 -0500412 ":typeface_freetype",
mtkleincdedd0e2016-09-12 15:15:44 -0700413 ]
414 sources = [
415 "src/ports/SkFontMgr_custom.cpp",
Ben Wagner8ab590f2017-02-08 17:29:33 -0500416 "src/ports/SkFontMgr_custom_empty.cpp",
mtkleincdedd0e2016-09-12 15:15:44 -0700417 "src/ports/SkFontMgr_custom_empty_factory.cpp",
418 ]
419}
420
Ethan Nicholas762466e2017-06-29 10:03:38 -0400421if (skia_compile_processors) {
422 executable("skslc") {
423 defines = [ "SKSL_STANDALONE" ]
424 sources = [
425 "src/sksl/SkSLMain.cpp",
426 ]
427 sources += skia_sksl_sources
428 include_dirs = [
429 "src/gpu",
430 "src/sksl",
431 ]
432 deps = [
433 "//third_party/spirv-tools",
434 ]
435 }
436
437 skia_gpu_processor_outputs = []
438 foreach(src, skia_gpu_processor_sources) {
439 dir = get_path_info(src, "dir")
440 name = get_path_info(src, "name")
441
442 # GN insists its outputs should go somewhere underneath target_out_dir, so we trick it with a
443 # path that starts with target_out_dir and then uses ".." to back up into the src dir.
444 skia_gpu_processor_outputs += [
445 "$target_out_dir/" + rebase_path("$dir/$name.h", target_out_dir),
446 # the script also modifies the corresponding .cpp file, but if we tell GN that it gets
447 # confused due to the same file being named by two different paths
448 ]
449 }
450
451 action("compile_processors") {
452 script = "gn/compile_processors.py"
453 deps = [
454 ":skslc(//gn/toolchain:$host_toolchain)",
455 ]
456 sources = skia_gpu_processor_sources
457 outputs = skia_gpu_processor_outputs
458 skslc_path = "$root_out_dir/"
459 if (host_toolchain != default_toolchain_name) {
460 skslc_path += "$host_toolchain/"
461 }
462 skslc_path += "skslc"
463 if (host_os == "win") {
464 skslc_path += ".exe"
465 }
466 args = [ rebase_path(skslc_path) ]
467 args += rebase_path(skia_gpu_processor_sources)
468 }
469} else {
470 skia_gpu_processor_outputs = []
471 group("compile_processors") {
472 }
473}
474
mtklein06c35c02016-09-20 12:28:12 -0700475optional("gpu") {
476 enabled = skia_enable_gpu
Ethan Nicholas762466e2017-06-29 10:03:38 -0400477 deps = [
478 ":compile_processors",
479 ]
mtkleine9fb3d52016-09-20 15:11:46 -0700480 public_defines = []
481
Mike Klein29b3e582017-02-09 11:57:32 -0500482 sources = skia_gpu_sources + skia_sksl_sources +
Ethan Nicholas762466e2017-06-29 10:03:38 -0400483 [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ] +
484 skia_gpu_processor_outputs
mtklein06c35c02016-09-20 12:28:12 -0700485
486 # These paths need to be absolute to match the ones produced by shared_sources.gni.
487 sources -= get_path_info([
488 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
489 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
490 ],
491 "abspath")
Mike Klein703cf5a2016-10-13 17:18:04 -0400492 libs = []
mtklein06c35c02016-09-20 12:28:12 -0700493 if (is_android) {
494 sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
Derek Sollenberger7a869872017-06-27 15:37:25 -0400495
496 # this lib is required to link against AHardwareBuffer
497 if (defined(ndk_api) && ndk_api >= 26) {
498 libs += [ "android" ]
499 }
Kevin Lubick4a24e102017-03-29 11:19:01 -0400500 } else if (skia_use_egl) {
501 sources += [ "src/gpu/gl/egl/GrGLCreateNativeInterface_egl.cpp" ]
502 libs += [ "EGL" ]
mtklein06c35c02016-09-20 12:28:12 -0700503 } else if (is_linux) {
504 sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
Mike Kleina979a1d2017-02-23 10:31:13 -0500505 libs += [
506 "GL",
507 "GLU",
508 ]
mtklein06c35c02016-09-20 12:28:12 -0700509 } else if (is_mac) {
510 sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
Chinmay Garde130a1182016-11-23 11:43:56 -0800511 } else if (is_ios) {
512 sources += [ "src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp" ]
Mike Klein703cf5a2016-10-13 17:18:04 -0400513 } else if (is_win) {
514 sources += [ "src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp" ]
515 libs += [ "OpenGL32.lib" ]
mtklein06c35c02016-09-20 12:28:12 -0700516 } else {
517 sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
518 }
mtkleine9fb3d52016-09-20 15:11:46 -0700519
520 if (skia_use_vulkan) {
521 public_defines += [ "SK_VULKAN" ]
522 sources += skia_vk_sources
egdaniele4a9bd72016-09-21 07:36:14 -0700523 if (skia_enable_vulkan_debug_layers) {
524 public_defines += [ "SK_ENABLE_VK_LAYERS" ]
525 }
mtkleine9fb3d52016-09-20 15:11:46 -0700526 }
Ethan Nicholasa6ae1f72017-03-16 09:56:54 -0400527 if (skia_enable_spirv_validation) {
Ethan Nicholas762466e2017-06-29 10:03:38 -0400528 deps += [ "//third_party/spirv-tools" ]
Ethan Nicholasa6ae1f72017-03-16 09:56:54 -0400529 public_defines += [ "SK_ENABLE_SPIRV_VALIDATION" ]
530 }
mtklein06c35c02016-09-20 12:28:12 -0700531}
532
mtklein63213812016-08-24 09:55:56 -0700533optional("jpeg") {
534 enabled = skia_use_libjpeg_turbo
535 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
536
mtklein63213812016-08-24 09:55:56 -0700537 deps = [
538 "//third_party/libjpeg-turbo:libjpeg",
539 ]
540 sources = [
541 "src/codec/SkJpegCodec.cpp",
542 "src/codec/SkJpegDecoderMgr.cpp",
543 "src/codec/SkJpegUtility.cpp",
mtklein63213812016-08-24 09:55:56 -0700544 "src/images/SkJPEGWriteUtility.cpp",
Matt Sarett04c37312017-05-05 14:02:13 -0400545 "src/images/SkJpegEncoder.cpp",
mtklein63213812016-08-24 09:55:56 -0700546 ]
547}
548
549optional("pdf") {
Hal Canary43fb7a02016-12-30 13:09:03 -0500550 enabled = skia_use_zlib && skia_enable_pdf
551 public_defines = [ "SK_SUPPORT_PDF" ]
mtklein63213812016-08-24 09:55:56 -0700552
mtklein63213812016-08-24 09:55:56 -0700553 deps = [
554 "//third_party/zlib",
555 ]
brettwb9447282016-09-01 14:24:39 -0700556 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700557 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700558
559 if (skia_use_sfntly) {
560 deps += [ "//third_party/sfntly" ]
Hal Canary43fb7a02016-12-30 13:09:03 -0500561 public_defines += [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700562 }
563}
564
565optional("png") {
566 enabled = skia_use_libpng
567 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
568
mtklein63213812016-08-24 09:55:56 -0700569 deps = [
570 "//third_party/libpng",
571 ]
572 sources = [
573 "src/codec/SkIcoCodec.cpp",
574 "src/codec/SkPngCodec.cpp",
Matt Sarett04c37312017-05-05 14:02:13 -0400575 "src/images/SkPngEncoder.cpp",
mtklein63213812016-08-24 09:55:56 -0700576 ]
577}
578
scroggof84ad642016-10-31 09:02:57 -0700579optional("raw") {
Mike Klein10d665d2016-11-01 11:46:10 -0400580 enabled = skia_use_dng_sdk && skia_use_libjpeg_turbo && skia_use_piex
scroggof84ad642016-10-31 09:02:57 -0700581 public_defines = [ "SK_CODEC_DECODES_RAW" ]
582
583 deps = [
584 "//third_party/dng_sdk",
585 "//third_party/libjpeg-turbo:libjpeg",
586 "//third_party/piex",
587 ]
588
589 # SkRawCodec catches any exceptions thrown by dng_sdk, insulating the rest of
590 # Skia.
591 configs_to_remove = [ "//gn:no_exceptions" ]
592
593 sources = [
594 "src/codec/SkRawAdapterCodec.cpp",
595 "src/codec/SkRawCodec.cpp",
596 ]
597}
598
mtklein3cc22182016-08-29 13:26:14 -0700599optional("typeface_freetype") {
600 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700601
602 deps = [
603 "//third_party/freetype2",
604 ]
605 sources = [
606 "src/ports/SkFontHost_FreeType.cpp",
607 "src/ports/SkFontHost_FreeType_common.cpp",
608 ]
609}
610
mtklein457b42a2016-08-23 13:56:37 -0700611optional("webp") {
612 enabled = skia_use_libwebp
613 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
614
mtklein457b42a2016-08-23 13:56:37 -0700615 deps = [
616 "//third_party/libwebp",
617 ]
618 sources = [
619 "src/codec/SkWebpAdapterCodec.cpp",
620 "src/codec/SkWebpCodec.cpp",
Matt Sarett04c37312017-05-05 14:02:13 -0400621 "src/images/SkWebpEncoder.cpp",
mtklein457b42a2016-08-23 13:56:37 -0700622 ]
mtkleineb3c4252016-08-23 07:38:09 -0700623}
624
mtklein63213812016-08-24 09:55:56 -0700625optional("xml") {
626 enabled = skia_use_expat
Florin Malita442fff92016-11-08 16:07:52 +0000627 public_defines = [ "SK_XML" ]
mtklein63213812016-08-24 09:55:56 -0700628
mtklein63213812016-08-24 09:55:56 -0700629 deps = [
630 "//third_party/expat",
631 ]
632 sources = [
Mike Kleinbd41bcc2017-02-09 16:38:15 -0500633 "src/svg/SkSVGCanvas.cpp",
634 "src/svg/SkSVGDevice.cpp",
mtklein63213812016-08-24 09:55:56 -0700635 "src/xml/SkDOM.cpp",
636 "src/xml/SkXMLParser.cpp",
637 "src/xml/SkXMLWriter.cpp",
638 ]
639}
640
mtkleinc04ff472016-06-23 10:29:30 -0700641component("skia") {
642 public_configs = [ ":skia_public" ]
643 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700644
645 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700646 ":arm64",
647 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700648 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700649 ":crc32",
Mike Kleina04bb452017-02-09 12:24:07 -0500650 ":effects",
mtkleina45be612016-08-29 15:22:10 -0700651 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700652 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700653 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700654 ":fontmgr_fuchsia",
mtklein06c35c02016-09-20 12:28:12 -0700655 ":gpu",
Mike Klein78d5a3b2016-09-30 10:48:01 -0400656 ":hsw",
mtklein63213812016-08-24 09:55:56 -0700657 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700658 ":none",
mtklein63213812016-08-24 09:55:56 -0700659 ":pdf",
660 ":png",
scroggof84ad642016-10-31 09:02:57 -0700661 ":raw",
mtklein9b8583d2016-08-24 17:32:30 -0700662 ":sse2",
663 ":sse41",
664 ":sse42",
665 ":ssse3",
mtkleineb3c4252016-08-23 07:38:09 -0700666 ":webp",
mtklein63213812016-08-24 09:55:56 -0700667 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700668 ]
669
Chinmay Garde43f115c2016-11-16 15:04:12 -0800670 # This file (and all GN files in Skia) are designed to work with an
671 # empty sources assignment filter; we handle all that explicitly.
672 # We clear the filter here for clients who may have set up a global filter.
673 set_sources_assignment_filter([])
674
mtkleinc04ff472016-06-23 10:29:30 -0700675 sources = []
brettwb9447282016-09-01 14:24:39 -0700676 sources += skia_core_sources
brettwb9447282016-09-01 14:24:39 -0700677 sources += skia_utils_sources
Hal Canary6ad3d2f2016-12-20 16:15:56 -0500678 sources += skia_xps_sources
mtkleinc04ff472016-06-23 10:29:30 -0700679 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700680 "src/android/SkBitmapRegionCodec.cpp",
681 "src/android/SkBitmapRegionDecoder.cpp",
682 "src/codec/SkAndroidCodec.cpp",
Leon Scroggins IIId81fed92017-06-01 13:42:28 -0400683 "src/codec/SkBmpBaseCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700684 "src/codec/SkBmpCodec.cpp",
685 "src/codec/SkBmpMaskCodec.cpp",
686 "src/codec/SkBmpRLECodec.cpp",
687 "src/codec/SkBmpStandardCodec.cpp",
688 "src/codec/SkCodec.cpp",
689 "src/codec/SkCodecImageGenerator.cpp",
scroggo19b91532016-10-24 09:03:26 -0700690 "src/codec/SkGifCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700691 "src/codec/SkMaskSwizzler.cpp",
692 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700693 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700694 "src/codec/SkSampler.cpp",
scroggo19b91532016-10-24 09:03:26 -0700695 "src/codec/SkStreamBuffer.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700696 "src/codec/SkSwizzler.cpp",
697 "src/codec/SkWbmpCodec.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700698 "src/images/SkImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700699 "src/ports/SkDiscardableMemory_none.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700700 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700701 "src/ports/SkMemory_malloc.cpp",
702 "src/ports/SkOSFile_stdio.cpp",
703 "src/sfnt/SkOTTable_name.cpp",
704 "src/sfnt/SkOTUtils.cpp",
705 "src/utils/mac/SkStream_mac.cpp",
scroggo3d3a65c2016-10-24 12:28:30 -0700706 "third_party/gif/SkGifImageReader.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700707 ]
brettwb9447282016-09-01 14:24:39 -0700708
mtklein7d6fb2c2016-08-25 14:50:44 -0700709 libs = []
710
mtkleinc04ff472016-06-23 10:29:30 -0700711 if (is_win) {
712 sources += [
Mike Kleinae7e6712016-10-11 17:49:33 -0400713 "src/fonts/SkFontMgr_indirect.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700714 "src/ports/SkDebug_win.cpp",
715 "src/ports/SkFontHost_win.cpp",
716 "src/ports/SkFontMgr_win_dw.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700717 "src/ports/SkImageEncoder_WIC.cpp",
718 "src/ports/SkImageGeneratorWIC.cpp",
719 "src/ports/SkOSFile_win.cpp",
mtklein605d9522016-09-21 14:01:32 -0700720 "src/ports/SkOSLibrary_win.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700721 "src/ports/SkScalerContext_win_dw.cpp",
722 "src/ports/SkTLS_win.cpp",
723 "src/ports/SkTypeface_win_dw.cpp",
724 ]
Mike Klein69f6ed42016-10-13 15:45:07 -0400725 if (skia_use_gdi) {
726 sources += [ "src/ports/SkFontMgr_win_gdi_factory.cpp" ]
727 libs += [
728 "Gdi32.lib",
729 "Usp10.lib",
730 ]
731 } else {
732 sources += [ "src/ports/SkFontMgr_win_dw_factory.cpp" ]
733 }
mtkleinb9be9792016-09-16 14:44:18 -0700734 sources -=
735 [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
Mike Klein4b167fc2016-10-11 18:13:53 -0400736 libs += [
737 "FontSub.lib",
738 "Ole32.lib",
739 "OleAut32.lib",
740 "User32.lib",
741 ]
mtkleinc04ff472016-06-23 10:29:30 -0700742 } else {
743 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700744 "src/ports/SkOSFile_posix.cpp",
mtklein605d9522016-09-21 14:01:32 -0700745 "src/ports/SkOSLibrary_posix.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700746 "src/ports/SkTLS_pthread.cpp",
747 ]
748 }
749
mtklein7d6fb2c2016-08-25 14:50:44 -0700750 if (is_android) {
Mike Klein1c471872017-01-13 15:27:45 -0500751 deps += [ "//third_party/expat" ]
Mike Kleine459afd2017-03-03 09:21:30 -0500752 if (defined(ndk) && ndk != "") {
Mike Klein1c471872017-01-13 15:27:45 -0500753 deps += [ "//third_party/cpu-features" ]
754 }
mtklein06c35c02016-09-20 12:28:12 -0700755 sources += [ "src/ports/SkDebug_android.cpp" ]
mtklein7d6fb2c2016-08-25 14:50:44 -0700756 libs += [
757 "EGL",
758 "GLESv2",
759 "log",
760 ]
761 }
762
mtkleinc04ff472016-06-23 10:29:30 -0700763 if (is_linux) {
mtklein06c35c02016-09-20 12:28:12 -0700764 sources += [ "src/ports/SkDebug_stdio.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700765 }
766
767 if (is_mac) {
768 sources += [
mtklein7d6fb2c2016-08-25 14:50:44 -0700769 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700770 "src/ports/SkFontHost_mac.cpp",
771 "src/ports/SkImageEncoder_CG.cpp",
772 "src/ports/SkImageGeneratorCG.cpp",
773 ]
mtklein09e61f72016-08-23 13:35:28 -0700774 libs += [
bungeman3e306f62017-03-29 11:32:02 -0400775 # AppKit symbols NSFontWeightXXX may be dlsym'ed.
776 "AppKit.framework",
mtklein09e61f72016-08-23 13:35:28 -0700777 "ApplicationServices.framework",
778 "OpenGL.framework",
779 ]
mtkleinc04ff472016-06-23 10:29:30 -0700780 }
abarth6fc8ff02016-07-15 15:15:15 -0700781
Mike Klein7d302882016-11-03 14:06:31 -0400782 if (is_ios) {
783 sources += [
784 "src/ports/SkDebug_stdio.cpp",
785 "src/ports/SkFontHost_mac.cpp",
786 "src/ports/SkImageEncoder_CG.cpp",
787 "src/ports/SkImageGeneratorCG.cpp",
788 ]
789 libs += [
790 "CoreFoundation.framework",
791 "CoreGraphics.framework",
792 "CoreText.framework",
793 "ImageIO.framework",
794 "MobileCoreServices.framework",
bungeman3e306f62017-03-29 11:32:02 -0400795
796 # UIKit symbols UIFontWeightXXX may be dlsym'ed.
797 "UIKit.framework",
Mike Klein7d302882016-11-03 14:06:31 -0400798 ]
799 }
800
abarth6fc8ff02016-07-15 15:15:15 -0700801 if (is_fuchsia) {
mtklein06c35c02016-09-20 12:28:12 -0700802 sources += [ "src/ports/SkDebug_stdio.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700803 }
mtkleinc04ff472016-06-23 10:29:30 -0700804}
805
mtkleinc095df52016-08-24 12:23:52 -0700806# Targets guarded by skia_enable_tools may use //third_party freely.
807if (skia_enable_tools) {
Mike Klein308b5ac2016-12-06 16:03:52 -0500808 # Used by gn_to_bp.py to list our public include dirs.
809 source_set("public") {
810 configs += [ ":skia_public" ]
811 }
812
Mike Kleinc36dedf2016-11-18 09:35:28 -0500813 config("skia.h_config") {
814 include_dirs = [ "$target_gen_dir" ]
815 }
816 action("skia.h") {
817 public_configs = [ ":skia.h_config" ]
818 skia_h = "$target_gen_dir/skia.h"
819 script = "gn/find_headers.py"
Greg Danielc819e662017-04-19 16:39:45 -0400820 args = [ rebase_path(skia_h, root_build_dir) ] +
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000821 rebase_path(skia_public_includes)
Mike Kleinc36dedf2016-11-18 09:35:28 -0500822 depfile = "$skia_h.deps"
823 outputs = [
824 skia_h,
825 ]
826 }
827
828 if (skia_enable_gpu && target_cpu == "x64") {
829 # Our bots only have 64-bit libOSMesa installed.
830 # TODO: worth fixing?
831 executable("fiddle") {
832 libs = []
Mike Kleinc36dedf2016-11-18 09:35:28 -0500833 sources = [
Mike Kleinc36dedf2016-11-18 09:35:28 -0500834 "tools/fiddle/draw.cpp",
835 "tools/fiddle/fiddle_main.cpp",
836 ]
Joe Gregorioa8fabd32017-05-31 09:45:19 -0400837
838 if (skia_use_egl) {
839 sources += [ "tools/fiddle/egl_context.cpp" ]
840 } else if (skia_use_mesa) {
841 sources += [ "tools/fiddle/mesa_context.cpp" ]
842 if (is_linux) {
843 libs += [ "OSMesa" ]
844 }
845 } else {
846 sources += [ "tools/fiddle/null_context.cpp" ]
847 }
Joe Gregorio1e735c02017-04-19 14:05:14 -0400848 testonly = true
Mike Kleinc36dedf2016-11-18 09:35:28 -0500849 deps = [
Joe Gregorio1e735c02017-04-19 14:05:14 -0400850 ":flags",
Mike Kleinc36dedf2016-11-18 09:35:28 -0500851 ":skia",
852 ":skia.h",
853 ]
854 }
855 }
856
857 if (skia_enable_gpu) {
858 source_set("public_headers_warnings_check") {
859 sources = [
860 "tools/public_headers_warnings_check.cpp",
861 ]
862 configs -= [ "//gn:warnings_except_public_headers" ]
863 deps = [
864 ":skia",
865 ":skia.h",
866 ]
867 }
868 }
869
mtkleinc095df52016-08-24 12:23:52 -0700870 template("test_lib") {
871 config(target_name + "_config") {
872 include_dirs = invoker.public_include_dirs
mtkleina627b5c2016-09-20 13:36:47 -0700873 if (defined(invoker.public_defines)) {
874 defines = invoker.public_defines
875 }
mtklein25c81d42016-07-27 13:55:26 -0700876 }
mtkleinc095df52016-08-24 12:23:52 -0700877 source_set(target_name) {
878 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
879 public_configs = [
880 ":" + target_name + "_config",
881 ":skia_private",
882 ]
883
884 if (!defined(deps)) {
885 deps = []
886 }
887 deps += [ ":skia" ]
888 testonly = true
889 }
mtklein25c81d42016-07-27 13:55:26 -0700890 }
mtklein25c81d42016-07-27 13:55:26 -0700891
Mike Kleine6682eb2017-01-05 10:54:57 -0500892 template("test_app") {
893 if (defined(invoker.is_shared_library) && invoker.is_shared_library) {
894 shared_library("lib" + target_name) {
895 forward_variables_from(invoker, "*", [ "is_shared_library" ])
896 testonly = true
897 }
898 } else {
Mike Klein7d921032017-01-05 12:20:41 -0500899 _executable = target_name
900 executable(_executable) {
Mike Kleine6682eb2017-01-05 10:54:57 -0500901 forward_variables_from(invoker, "*", [ "is_shared_library" ])
902 testonly = true
903 }
904 }
Mike Klein7d921032017-01-05 12:20:41 -0500905 if (is_android && skia_android_serial != "" && defined(_executable)) {
906 action("push_" + target_name) {
907 script = "gn/push_to_android.py"
908 deps = [
909 ":" + _executable,
910 ]
911 _stamp = "$target_gen_dir/$_executable.pushed_$skia_android_serial"
912 outputs = [
913 _stamp,
914 ]
915 args = [
916 rebase_path("$root_build_dir/$_executable"),
917 skia_android_serial,
918 rebase_path(_stamp),
919 ]
920 testonly = true
921 }
922 }
Mike Kleine6682eb2017-01-05 10:54:57 -0500923 }
924
mtkleinc095df52016-08-24 12:23:52 -0700925 test_lib("gpu_tool_utils") {
mtklein38925aa2016-09-21 10:11:25 -0700926 public_include_dirs = []
927 if (skia_enable_gpu) {
928 public_defines = []
929 public_include_dirs += [ "tools/gpu" ]
mtkleind68f9b02016-09-23 13:18:41 -0700930
931 deps = []
mtklein38925aa2016-09-21 10:11:25 -0700932 sources = [
933 "tools/gpu/GrContextFactory.cpp",
934 "tools/gpu/GrTest.cpp",
935 "tools/gpu/TestContext.cpp",
936 "tools/gpu/gl/GLTestContext.cpp",
mtklein605d9522016-09-21 14:01:32 -0700937 "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
mtklein38925aa2016-09-21 10:11:25 -0700938 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
939 "tools/gpu/gl/debug/GrBufferObj.cpp",
940 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
941 "tools/gpu/gl/debug/GrProgramObj.cpp",
942 "tools/gpu/gl/debug/GrShaderObj.cpp",
943 "tools/gpu/gl/debug/GrTextureObj.cpp",
944 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
945 "tools/gpu/gl/null/NullGLTestContext.cpp",
946 ]
947 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700948
Kevin Lubick4a24e102017-03-29 11:19:01 -0400949 if (is_android || skia_use_egl) {
mtklein38925aa2016-09-21 10:11:25 -0700950 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
Mike Klein7d302882016-11-03 14:06:31 -0400951 } else if (is_ios) {
952 sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
953 libs += [ "OpenGLES.framework" ]
mtklein38925aa2016-09-21 10:11:25 -0700954 } else if (is_linux) {
955 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
Mike Kleina979a1d2017-02-23 10:31:13 -0500956 libs += [ "X11" ]
mtklein38925aa2016-09-21 10:11:25 -0700957 } else if (is_mac) {
958 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
Mike Klein4b167fc2016-10-11 18:13:53 -0400959 } else if (is_win) {
960 sources += [ "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp" ]
961 libs += [
962 "Gdi32.lib",
963 "OpenGL32.lib",
964 ]
mtklein38925aa2016-09-21 10:11:25 -0700965 }
mtklein6ef69992016-09-14 06:12:09 -0700966
Mike Kleinc168a3a2016-11-14 14:53:13 +0000967 if (skia_use_angle) {
Mike Kleinc168a3a2016-11-14 14:53:13 +0000968 deps += [ "//third_party/angle2" ]
969 sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
970 }
mtklein38925aa2016-09-21 10:11:25 -0700971 if (skia_use_mesa) {
972 public_defines += [ "SK_MESA" ]
973 sources += [ "tools/gpu/gl/mesa/GLTestContext_mesa.cpp" ]
974 libs += [ "OSMesa" ]
975 }
mtkleind68f9b02016-09-23 13:18:41 -0700976 if (skia_use_vulkan) {
977 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
Brian Salomon5db010b2017-04-25 16:05:29 -0400978 if (is_win) {
979 libs += [ "vulkan-1.lib" ]
980 } else {
981 libs += [ "vulkan" ]
982 }
mtkleind68f9b02016-09-23 13:18:41 -0700983 }
mtkleina627b5c2016-09-20 13:36:47 -0700984 }
mtklein25c81d42016-07-27 13:55:26 -0700985 }
mtklein25c81d42016-07-27 13:55:26 -0700986
mtkleinc095df52016-08-24 12:23:52 -0700987 test_lib("flags") {
988 public_include_dirs = [ "tools/flags" ]
989 sources = [
990 "tools/flags/SkCommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -0700991 ]
992 }
993 test_lib("common_flags") {
994 public_include_dirs = [ "tools/flags" ]
995 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700996 "tools/flags/SkCommonFlags.cpp",
997 "tools/flags/SkCommonFlagsConfig.cpp",
998 ]
999 deps = [
mtklein046cb562016-09-16 10:23:12 -07001000 ":flags",
mtkleinc095df52016-08-24 12:23:52 -07001001 ":gpu_tool_utils",
1002 ]
1003 }
mtklein25c81d42016-07-27 13:55:26 -07001004
mtkleinc095df52016-08-24 12:23:52 -07001005 test_lib("tool_utils") {
1006 public_include_dirs = [
1007 "tools",
1008 "tools/debugger",
1009 "tools/timer",
1010 ]
1011 sources = [
mtkleinb37c0342016-09-09 11:07:45 -07001012 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001013 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -07001014 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001015 "tools/ProcStats.cpp",
1016 "tools/Resources.cpp",
1017 "tools/ThermalManager.cpp",
1018 "tools/UrlDataManager.cpp",
1019 "tools/debugger/SkDebugCanvas.cpp",
1020 "tools/debugger/SkDrawCommand.cpp",
1021 "tools/debugger/SkJsonWriteBuffer.cpp",
1022 "tools/debugger/SkObjectParser.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001023 "tools/picture_utils.cpp",
1024 "tools/random_parse_path.cpp",
1025 "tools/sk_tool_utils.cpp",
1026 "tools/sk_tool_utils_font.cpp",
1027 "tools/timer/Timer.cpp",
1028 ]
Mike Kleinadacaef2017-02-06 09:26:14 -05001029 libs = []
1030 if (is_ios) {
1031 sources += [ "tools/ios_utils.m" ]
1032 libs += [ "Foundation.framework" ]
1033 }
mtkleinc095df52016-08-24 12:23:52 -07001034 deps = [
mtklein046cb562016-09-16 10:23:12 -07001035 ":common_flags",
mtkleinc095df52016-08-24 12:23:52 -07001036 ":flags",
1037 "//third_party/libpng",
1038 ]
1039 public_deps = [
1040 "//third_party/jsoncpp",
1041 ]
1042 }
mtklein25c81d42016-07-27 13:55:26 -07001043
Mike Klein6e744122016-10-27 12:21:40 -04001044 import("gn/gm.gni")
mtkleinc095df52016-08-24 12:23:52 -07001045 test_lib("gm") {
1046 public_include_dirs = [ "gm" ]
1047 sources = gm_sources
1048 deps = [
scroggo19b91532016-10-24 09:03:26 -07001049 ":flags",
mtkleinc095df52016-08-24 12:23:52 -07001050 ":gpu_tool_utils",
1051 ":skia",
1052 ":tool_utils",
1053 ]
1054 }
mtklein25c81d42016-07-27 13:55:26 -07001055
Mike Klein6e744122016-10-27 12:21:40 -04001056 import("gn/tests.gni")
mtkleinc095df52016-08-24 12:23:52 -07001057 test_lib("tests") {
1058 public_include_dirs = [ "tests" ]
Mike Klein6e744122016-10-27 12:21:40 -04001059 sources = tests_sources + pathops_tests_sources
mtkleina45be612016-08-29 15:22:10 -07001060 if (!fontmgr_android_enabled) {
Mike Klein6e744122016-10-27 12:21:40 -04001061 sources -= [ "//tests/FontMgrAndroidParserTest.cpp" ]
mtkleina45be612016-08-29 15:22:10 -07001062 }
mtkleinc095df52016-08-24 12:23:52 -07001063 deps = [
fmalita6cf896d2016-08-25 08:44:35 -07001064 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -07001065 ":flags",
mtkleinc095df52016-08-24 12:23:52 -07001066 ":skia",
1067 ":tool_utils",
1068 "//third_party/libpng",
1069 "//third_party/zlib",
1070 ]
Mike Kleind63442d2017-03-27 14:16:04 -04001071 public_deps = [
1072 ":gpu_tool_utils", # Test.h #includes headers from this target.
1073 ]
mtkleinc095df52016-08-24 12:23:52 -07001074 }
mtklein2f3416d2016-08-02 16:02:05 -07001075
Mike Klein6e744122016-10-27 12:21:40 -04001076 import("gn/bench.gni")
mtkleinc095df52016-08-24 12:23:52 -07001077 test_lib("bench") {
1078 public_include_dirs = [ "bench" ]
1079 sources = bench_sources
mtkleinc095df52016-08-24 12:23:52 -07001080 deps = [
1081 ":flags",
1082 ":gm",
1083 ":gpu_tool_utils",
1084 ":skia",
1085 ":tool_utils",
1086 ]
1087 }
mtklein2b6870c2016-07-28 14:17:33 -07001088
mtkleinc095df52016-08-24 12:23:52 -07001089 test_lib("experimental_svg_model") {
1090 public_include_dirs = [ "experimental/svg/model" ]
1091 sources = [
1092 "experimental/svg/model/SkSVGAttribute.cpp",
1093 "experimental/svg/model/SkSVGAttributeParser.cpp",
1094 "experimental/svg/model/SkSVGCircle.cpp",
Florin Malitace8840e2016-12-08 09:26:47 -05001095 "experimental/svg/model/SkSVGClipPath.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001096 "experimental/svg/model/SkSVGContainer.cpp",
1097 "experimental/svg/model/SkSVGDOM.cpp",
1098 "experimental/svg/model/SkSVGEllipse.cpp",
1099 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -07001100 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001101 "experimental/svg/model/SkSVGNode.cpp",
1102 "experimental/svg/model/SkSVGPath.cpp",
1103 "experimental/svg/model/SkSVGPoly.cpp",
1104 "experimental/svg/model/SkSVGRect.cpp",
1105 "experimental/svg/model/SkSVGRenderContext.cpp",
1106 "experimental/svg/model/SkSVGSVG.cpp",
1107 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -07001108 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001109 "experimental/svg/model/SkSVGTransformableNode.cpp",
1110 "experimental/svg/model/SkSVGValue.cpp",
1111 ]
1112 deps = [
1113 ":skia",
1114 ]
1115 }
fmalitaa2b9fdf2016-08-03 19:53:36 -07001116
Brian Osman16adfa32016-10-18 14:42:44 -04001117 test_lib("views") {
1118 public_include_dirs = [ "include/views" ]
1119 sources = [
1120 "src/views/SkEvent.cpp",
1121 "src/views/SkEventSink.cpp",
1122 "src/views/SkOSMenu.cpp",
1123 "src/views/SkTagList.cpp",
1124 "src/views/SkTouchGesture.cpp",
1125 "src/views/SkView.cpp",
1126 "src/views/SkViewPriv.cpp",
1127 ]
1128 libs = []
Brian Osman34755e22016-12-05 09:46:02 -05001129 deps = []
Brian Osman16adfa32016-10-18 14:42:44 -04001130 if (!is_android) {
1131 sources += [ "src/views/SkWindow.cpp" ]
1132 }
Jim Van Verth4e56a912016-10-21 10:58:52 -04001133 if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -04001134 public_include_dirs += [ "src/views/unix" ]
1135 sources += [
1136 "src/views/unix/SkOSWindow_Unix.cpp",
1137 "src/views/unix/keysym2ucs.c",
1138 ]
Mike Kleina979a1d2017-02-23 10:31:13 -05001139 libs += [
1140 "GL",
1141 "X11",
1142 ]
Brian Osman16adfa32016-10-18 14:42:44 -04001143 } else if (is_mac) {
1144 sources += [
1145 "src/views/mac/SkEventNotifier.mm",
1146 "src/views/mac/SkNSView.mm",
1147 "src/views/mac/SkOSWindow_Mac.mm",
1148 "src/views/mac/SkTextFieldCell.m",
1149 ]
1150 libs += [
1151 "QuartzCore.framework",
1152 "Cocoa.framework",
1153 "Foundation.framework",
1154 ]
1155 } else if (is_win) {
1156 sources += [ "src/views/win/SkOSWindow_win.cpp" ]
1157 }
Brian Osman34755e22016-12-05 09:46:02 -05001158 if (skia_use_angle) {
1159 deps += [ "//third_party/angle2" ]
1160 }
Brian Osman16adfa32016-10-18 14:42:44 -04001161 }
1162
Mike Klein38af9432016-11-11 11:39:44 -05001163 if (skia_use_lua) {
1164 test_lib("lua") {
1165 public_include_dirs = []
1166 sources = [
1167 "src/utils/SkLua.cpp",
1168 "src/utils/SkLuaCanvas.cpp",
1169 ]
1170 deps = [
1171 "//third_party/lua",
1172 ]
1173 }
1174
Mike Kleine6682eb2017-01-05 10:54:57 -05001175 test_app("lua_app") {
Mike Klein38af9432016-11-11 11:39:44 -05001176 sources = [
1177 "tools/lua/lua_app.cpp",
1178 ]
1179 deps = [
1180 ":lua",
1181 ":skia",
1182 "//third_party/lua",
1183 ]
Mike Klein38af9432016-11-11 11:39:44 -05001184 }
1185
Mike Kleine6682eb2017-01-05 10:54:57 -05001186 test_app("lua_pictures") {
Mike Klein38af9432016-11-11 11:39:44 -05001187 sources = [
1188 "tools/lua/lua_pictures.cpp",
1189 ]
1190 deps = [
1191 ":flags",
1192 ":lua",
1193 ":skia",
1194 ":tool_utils",
1195 "//third_party/lua",
1196 ]
Mike Klein38af9432016-11-11 11:39:44 -05001197 }
1198 }
1199
Mike Klein6e744122016-10-27 12:21:40 -04001200 import("gn/samples.gni")
Brian Osman16adfa32016-10-18 14:42:44 -04001201 test_lib("samples") {
Brian Osman16adfa32016-10-18 14:42:44 -04001202 public_include_dirs = [ "samplecode" ]
Mike Klein6e744122016-10-27 12:21:40 -04001203 include_dirs = [ "experimental" ]
1204 sources = samples_sources + [
Mike Klein6e744122016-10-27 12:21:40 -04001205 "experimental/SkSetPoly3To3.cpp",
1206 "experimental/SkSetPoly3To3_A.cpp",
1207 "experimental/SkSetPoly3To3_D.cpp",
Brian Osmancff94e42017-06-26 13:12:37 -04001208
1209 # Relocating these files here, so that clients don't try to build them while they're
1210 # still in active development. Clang's thread safety analysis gets tripped up by
1211 # conditional locks.
1212 "src/core/SkThreadedBMPDevice.cpp",
1213 "src/core/SkThreadedBMPDevice.h",
Mike Klein6e744122016-10-27 12:21:40 -04001214 ]
Brian Osman16adfa32016-10-18 14:42:44 -04001215 deps = [
1216 ":experimental_svg_model",
csmartdalton8c679092017-03-27 12:32:29 -06001217 ":flags",
Mike Klein6e744122016-10-27 12:21:40 -04001218 ":gm",
Brian Osman16adfa32016-10-18 14:42:44 -04001219 ":tool_utils",
1220 ":views",
1221 ":xml",
1222 ]
Mike Klein38af9432016-11-11 11:39:44 -05001223
1224 if (skia_use_lua) {
1225 sources += [ "samplecode/SampleLua.cpp" ]
1226 deps += [
1227 ":lua",
1228 "//third_party/lua",
1229 ]
1230 }
Brian Osman16adfa32016-10-18 14:42:44 -04001231 }
1232
Mike Kleine6682eb2017-01-05 10:54:57 -05001233 test_app("dm") {
mtklein2b6870c2016-07-28 14:17:33 -07001234 sources = [
1235 "dm/DM.cpp",
1236 "dm/DMJsonWriter.cpp",
1237 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -07001238 ]
1239 include_dirs = [ "tests" ]
1240 deps = [
mtklein046cb562016-09-16 10:23:12 -07001241 ":common_flags",
fmalitaa2b9fdf2016-08-03 19:53:36 -07001242 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -07001243 ":flags",
1244 ":gm",
1245 ":gpu_tool_utils",
1246 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -07001247 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -07001248 ":tool_utils",
1249 "//third_party/jsoncpp",
1250 "//third_party/libpng",
1251 ]
mtklein2b6870c2016-07-28 14:17:33 -07001252 }
1253
Mike Klein06432b22017-03-21 13:14:33 -04001254 test_app("ok") {
1255 sources = [
1256 "tools/ok.cpp",
Mike Klein7ac04832017-03-25 11:29:41 -04001257 "tools/ok_dsts.cpp",
1258 "tools/ok_srcs.cpp",
Mike Kleind63442d2017-03-27 14:16:04 -04001259 "tools/ok_test.cpp",
Mike Kleinf5d1a552017-03-25 12:32:22 -04001260 "tools/ok_vias.cpp",
Mike Klein06432b22017-03-21 13:14:33 -04001261 ]
1262 deps = [
1263 ":gm",
1264 ":skia",
Mike Kleind63442d2017-03-27 14:16:04 -04001265 ":tests",
Mike Klein62669ad2017-05-09 16:03:07 -04001266 ":tool_utils",
Mike Klein06432b22017-03-21 13:14:33 -04001267 ]
1268 }
1269
Mike Kleina3430172016-09-27 16:46:29 -04001270 if (!is_debug) { # I've benchmarked debug code once too many times...
Mike Kleine6682eb2017-01-05 10:54:57 -05001271 test_app("monobench") {
Mike Kleina3430172016-09-27 16:46:29 -04001272 sources = [
1273 "tools/monobench.cpp",
1274 ]
1275 deps = [
1276 ":bench",
1277 ":skia",
1278 ]
Mike Kleina3430172016-09-27 16:46:29 -04001279 }
mtklein2b6870c2016-07-28 14:17:33 -07001280 }
1281
Mike Kleine6682eb2017-01-05 10:54:57 -05001282 test_app("nanobench") {
mtklein2b6870c2016-07-28 14:17:33 -07001283 sources = [
1284 "bench/nanobench.cpp",
1285 ]
1286 deps = [
1287 ":bench",
mtklein046cb562016-09-16 10:23:12 -07001288 ":common_flags",
fmalita6519c212016-09-14 08:05:17 -07001289 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -07001290 ":flags",
1291 ":gm",
1292 ":gpu_tool_utils",
1293 ":skia",
1294 ":tool_utils",
1295 "//third_party/jsoncpp",
1296 ]
mtklein2b6870c2016-07-28 14:17:33 -07001297 }
halcanary19a97202016-08-03 15:08:04 -07001298
Ravi Mistry10d36c52017-01-31 09:49:18 -05001299 test_app("skpinfo") {
1300 sources = [
1301 "tools/skpinfo.cpp",
1302 ]
1303 deps = [
1304 ":flags",
1305 ":skia",
1306 ]
1307 }
1308
Jim Van Verth57a98fc2016-10-28 13:35:50 -04001309 if (is_linux || is_win || is_mac) {
Mike Kleine6682eb2017-01-05 10:54:57 -05001310 test_app("SampleApp") {
mtklein38925aa2016-09-21 10:11:25 -07001311 sources = [
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001312 "samplecode/SampleApp.cpp",
1313 "samplecode/SamplePictFile.cpp",
mtklein38925aa2016-09-21 10:11:25 -07001314 ]
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001315 if (is_mac) {
1316 sources += [ "src/views/mac/skia_mac.mm" ]
1317 } else if (is_win) {
1318 sources += [ "src/views/win/skia_win.cpp" ]
1319 } else if (is_linux) {
1320 sources += [ "src/views/unix/skia_unix.cpp" ]
1321 }
mtklein38925aa2016-09-21 10:11:25 -07001322 deps = [
1323 ":flags",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001324 ":gm",
mtklein38925aa2016-09-21 10:11:25 -07001325 ":gpu_tool_utils",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001326 ":samples",
mtklein38925aa2016-09-21 10:11:25 -07001327 ":skia",
1328 ":tool_utils",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001329 ":views",
mtklein38925aa2016-09-21 10:11:25 -07001330 ]
Mike Kleinc168a3a2016-11-14 14:53:13 +00001331 if (skia_use_angle) {
1332 deps += [ "//third_party/angle2" ]
1333 }
mtklein38925aa2016-09-21 10:11:25 -07001334 }
Jim Van Verth8f5468f2016-10-31 09:52:33 -04001335 }
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001336
Jim Van Verth8f5468f2016-10-31 09:52:33 -04001337 if (skia_enable_gpu) {
Mike Kleine6682eb2017-01-05 10:54:57 -05001338 test_app("skpbench") {
Jim Van Verth8f5468f2016-10-31 09:52:33 -04001339 sources = [
1340 "tools/skpbench/skpbench.cpp",
1341 ]
1342 deps = [
1343 ":flags",
1344 ":gpu_tool_utils",
1345 ":skia",
1346 ":tool_utils",
1347 ]
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001348 }
csmartdalton4b5179b2016-09-19 11:03:58 -07001349 }
1350
Mike Klein7d302882016-11-03 14:06:31 -04001351 # We can't yet build ICU on iOS or Windows.
1352 if (!is_ios && !is_win) {
Mike Kleine6682eb2017-01-05 10:54:57 -05001353 test_app("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -07001354 sources = [
1355 "tools/SkShaper_harfbuzz.cpp",
1356 "tools/using_skia_and_harfbuzz.cpp",
1357 ]
1358 deps = [
1359 ":skia",
1360 "//third_party/harfbuzz",
1361 ]
mtklein6f5df6a2016-08-29 16:01:10 -07001362 }
halcanary19a97202016-08-03 15:08:04 -07001363 }
Mike Kleine6682eb2017-01-05 10:54:57 -05001364 test_app("sktexttopdf") {
halcanary3eee9d92016-09-10 07:01:53 -07001365 sources = [
1366 "tools/SkShaper_primitive.cpp",
1367 "tools/using_skia_and_harfbuzz.cpp",
1368 ]
1369 deps = [
1370 ":skia",
1371 ]
halcanary3eee9d92016-09-10 07:01:53 -07001372 }
mtklein046cb562016-09-16 10:23:12 -07001373
Matt Sarett9f1c4032017-05-17 10:06:32 -04001374 test_app("create_flutter_test_images") {
1375 sources = [
1376 "tools/create_flutter_test_images.cpp",
1377 ]
1378 deps = [
1379 ":skia",
1380 ":tool_utils",
1381 ]
1382 }
1383
Mike Kleine6682eb2017-01-05 10:54:57 -05001384 test_app("get_images_from_skps") {
mtklein046cb562016-09-16 10:23:12 -07001385 sources = [
1386 "tools/get_images_from_skps.cpp",
1387 ]
1388 deps = [
1389 ":flags",
1390 ":skia",
1391 "//third_party/jsoncpp",
1392 ]
mtklein046cb562016-09-16 10:23:12 -07001393 }
mtkleinecbc5262016-09-22 11:51:24 -07001394
Mike Kleine6682eb2017-01-05 10:54:57 -05001395 test_app("colorspaceinfo") {
Matt Sarett8740d582016-11-11 13:59:14 -05001396 sources = [
1397 "tools/colorspaceinfo.cpp",
1398 ]
1399 deps = [
1400 ":flags",
1401 ":skia",
1402 ":tool_utils",
1403 ]
Matt Sarett8740d582016-11-11 13:59:14 -05001404 }
1405
Mike Klein7d302882016-11-03 14:06:31 -04001406 if (!is_ios) {
Mike Kleine6682eb2017-01-05 10:54:57 -05001407 test_app("skiaserve") {
Mike Klein7d302882016-11-03 14:06:31 -04001408 sources = [
1409 "tools/skiaserve/Request.cpp",
1410 "tools/skiaserve/Response.cpp",
1411 "tools/skiaserve/skiaserve.cpp",
Mike Klein7d302882016-11-03 14:06:31 -04001412 "tools/skiaserve/urlhandlers/BreakHandler.cpp",
1413 "tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp",
1414 "tools/skiaserve/urlhandlers/CmdHandler.cpp",
1415 "tools/skiaserve/urlhandlers/ColorModeHandler.cpp",
1416 "tools/skiaserve/urlhandlers/DataHandler.cpp",
1417 "tools/skiaserve/urlhandlers/DownloadHandler.cpp",
1418 "tools/skiaserve/urlhandlers/EnableGPUHandler.cpp",
1419 "tools/skiaserve/urlhandlers/ImgHandler.cpp",
1420 "tools/skiaserve/urlhandlers/InfoHandler.cpp",
Brian Salomon144a5c52016-12-20 16:48:59 -05001421 "tools/skiaserve/urlhandlers/OpBoundsHandler.cpp",
1422 "tools/skiaserve/urlhandlers/OpsHandler.cpp",
Mike Klein7d302882016-11-03 14:06:31 -04001423 "tools/skiaserve/urlhandlers/OverdrawHandler.cpp",
1424 "tools/skiaserve/urlhandlers/PostHandler.cpp",
1425 "tools/skiaserve/urlhandlers/QuitHandler.cpp",
1426 "tools/skiaserve/urlhandlers/RootHandler.cpp",
1427 ]
1428 deps = [
1429 ":flags",
1430 ":gpu_tool_utils",
1431 ":skia",
1432 ":tool_utils",
1433 "//third_party/jsoncpp",
1434 "//third_party/libmicrohttpd",
1435 "//third_party/libpng",
1436 ]
Mike Klein7d302882016-11-03 14:06:31 -04001437 }
mtkleinecbc5262016-09-22 11:51:24 -07001438 }
kjlubick14f984b2016-10-03 11:49:45 -07001439
Mike Kleine6682eb2017-01-05 10:54:57 -05001440 test_app("fuzz") {
kjlubick14f984b2016-10-03 11:49:45 -07001441 sources = [
1442 "fuzz/FilterFuzz.cpp",
Hal Canary24ac42b2017-02-14 13:35:14 -05001443 "fuzz/FuzzCanvas.cpp",
Kevin Lubickfec1dea2016-11-22 13:57:18 -05001444 "fuzz/FuzzDrawFunctions.cpp",
kjlubick14f984b2016-10-03 11:49:45 -07001445 "fuzz/FuzzGradients.cpp",
1446 "fuzz/FuzzParsePath.cpp",
1447 "fuzz/FuzzPathop.cpp",
1448 "fuzz/FuzzScaleToSides.cpp",
1449 "fuzz/fuzz.cpp",
1450 ]
1451 deps = [
1452 ":flags",
Hal Canary44801ca2017-03-15 11:39:06 -04001453 ":gpu_tool_utils",
kjlubick14f984b2016-10-03 11:49:45 -07001454 ":skia",
Hal Canarydb683012016-11-23 08:55:18 -07001455 ":tool_utils",
kjlubick14f984b2016-10-03 11:49:45 -07001456 ]
kjlubick14f984b2016-10-03 11:49:45 -07001457 }
Mike Klein38312422016-10-05 15:41:01 -04001458
Mike Kleine6682eb2017-01-05 10:54:57 -05001459 test_app("pathops_unittest") {
Mike Klein6e744122016-10-27 12:21:40 -04001460 sources = pathops_tests_sources + [
Mike Klein6e55fef2016-10-26 11:41:47 -04001461 rebase_path("tests/skia_test.cpp"),
1462 rebase_path("tests/Test.cpp"),
1463 ]
caryclark9feb6322016-10-25 08:58:26 -07001464 deps = [
1465 ":flags",
1466 ":gpu_tool_utils",
1467 ":skia",
1468 ":tool_utils",
1469 ]
caryclark9feb6322016-10-25 08:58:26 -07001470 }
1471
Mike Kleine6682eb2017-01-05 10:54:57 -05001472 test_app("dump_record") {
Mike Klein38312422016-10-05 15:41:01 -04001473 sources = [
1474 "tools/DumpRecord.cpp",
1475 "tools/dump_record.cpp",
1476 ]
1477 deps = [
1478 ":flags",
1479 ":skia",
1480 ]
Mike Klein38312422016-10-05 15:41:01 -04001481 }
bungemanfe917272016-10-13 17:36:40 -04001482
Mike Kleine6682eb2017-01-05 10:54:57 -05001483 test_app("skdiff") {
bungemanfe917272016-10-13 17:36:40 -04001484 sources = [
1485 "tools/skdiff/skdiff.cpp",
1486 "tools/skdiff/skdiff_html.cpp",
1487 "tools/skdiff/skdiff_main.cpp",
1488 "tools/skdiff/skdiff_utils.cpp",
1489 ]
1490 deps = [
1491 ":skia",
1492 ":tool_utils",
1493 ]
bungemanfe917272016-10-13 17:36:40 -04001494 }
halcanarya73d76a2016-10-17 13:19:02 -07001495
Mike Kleine6682eb2017-01-05 10:54:57 -05001496 test_app("skp_parser") {
halcanarya73d76a2016-10-17 13:19:02 -07001497 sources = [
1498 "tools/skp_parser.cpp",
1499 ]
1500 deps = [
1501 ":skia",
1502 ":tool_utils",
1503 "//third_party/jsoncpp",
1504 ]
halcanarya73d76a2016-10-17 13:19:02 -07001505 }
Brian Osman16adfa32016-10-18 14:42:44 -04001506
Mike Kleina92c3832016-12-08 09:49:39 -05001507 if (skia_enable_gpu && (is_android || is_linux || is_win || is_mac)) {
Mike Kleine6682eb2017-01-05 10:54:57 -05001508 test_app("viewer") {
1509 is_shared_library = is_android
Brian Osman16adfa32016-10-18 14:42:44 -04001510 sources = [
1511 "tools/viewer/GMSlide.cpp",
1512 "tools/viewer/ImageSlide.cpp",
1513 "tools/viewer/SKPSlide.cpp",
1514 "tools/viewer/SampleSlide.cpp",
1515 "tools/viewer/Viewer.cpp",
1516 "tools/viewer/sk_app/CommandSet.cpp",
1517 "tools/viewer/sk_app/GLWindowContext.cpp",
1518 "tools/viewer/sk_app/Window.cpp",
Brian Osman16adfa32016-10-18 14:42:44 -04001519 ]
Brian Osman2dd96932016-10-18 15:33:53 -04001520 libs = []
Brian Osman16adfa32016-10-18 14:42:44 -04001521
Jim Van Verth4e56a912016-10-21 10:58:52 -04001522 if (is_android) {
1523 sources += [
1524 "tools/viewer/sk_app/android/GLWindowContext_android.cpp",
1525 "tools/viewer/sk_app/android/RasterWindowContext_android.cpp",
1526 "tools/viewer/sk_app/android/Window_android.cpp",
1527 "tools/viewer/sk_app/android/main_android.cpp",
1528 "tools/viewer/sk_app/android/surface_glue_android.cpp",
1529 ]
Brian Osman462334e2017-02-09 11:22:57 -05001530 libs += [ "android" ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001531 } else if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -04001532 sources += [
1533 "tools/viewer/sk_app/unix/GLWindowContext_unix.cpp",
1534 "tools/viewer/sk_app/unix/RasterWindowContext_unix.cpp",
1535 "tools/viewer/sk_app/unix/Window_unix.cpp",
1536 "tools/viewer/sk_app/unix/main_unix.cpp",
1537 ]
1538 } else if (is_win) {
Brian Osman16adfa32016-10-18 14:42:44 -04001539 sources += [
1540 "tools/viewer/sk_app/win/GLWindowContext_win.cpp",
1541 "tools/viewer/sk_app/win/RasterWindowContext_win.cpp",
1542 "tools/viewer/sk_app/win/Window_win.cpp",
1543 "tools/viewer/sk_app/win/main_win.cpp",
1544 ]
Mike Klein43c25262016-10-20 10:17:47 -04001545 } else if (is_mac) {
1546 sources += [
1547 "tools/viewer/sk_app/mac/GLWindowContext_mac.cpp",
1548 "tools/viewer/sk_app/mac/RasterWindowContext_mac.cpp",
1549 "tools/viewer/sk_app/mac/Window_mac.cpp",
1550 "tools/viewer/sk_app/mac/main_mac.cpp",
1551 ]
Brian Osman16adfa32016-10-18 14:42:44 -04001552 }
1553
1554 if (skia_use_vulkan) {
1555 sources += [ "tools/viewer/sk_app/VulkanWindowContext.cpp" ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001556 if (is_android) {
1557 sources +=
1558 [ "tools/viewer/sk_app/android/VulkanWindowContext_android.cpp" ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001559 } else if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -04001560 sources += [ "tools/viewer/sk_app/unix/VulkanWindowContext_unix.cpp" ]
1561 libs += [ "X11-xcb" ]
1562 } else if (is_win) {
Brian Osman16adfa32016-10-18 14:42:44 -04001563 sources += [ "tools/viewer/sk_app/win/VulkanWindowContext_win.cpp" ]
1564 }
1565 }
1566
1567 include_dirs = []
1568 deps = [
1569 ":flags",
1570 ":gm",
1571 ":gpu_tool_utils",
1572 ":samples",
1573 ":skia",
1574 ":tool_utils",
1575 ":views",
Brian Osman79086b92017-02-10 13:36:16 -05001576 "//third_party/imgui",
Brian Osman16adfa32016-10-18 14:42:44 -04001577 "//third_party/jsoncpp",
1578 ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001579 if (is_android) {
1580 deps += [ "//third_party/native_app_glue" ]
1581 } else if (is_mac) {
Mike Klein43c25262016-10-20 10:17:47 -04001582 deps += [ "//third_party/libsdl" ]
1583 }
Mike Kleina92c3832016-12-08 09:49:39 -05001584 }
Brian Osman16adfa32016-10-18 14:42:44 -04001585 }
Ethan Nicholas4f3985c2016-11-14 11:16:37 -05001586
Mike Kleine459afd2017-03-03 09:21:30 -05001587 if (is_android && defined(ndk) && ndk != "") {
Derek Sollenberger70120c72017-01-05 11:39:04 -05001588 copy("gdbserver") {
1589 sources = [
1590 "$ndk/$ndk_gdbserver",
1591 ]
1592 outputs = [
1593 "$root_out_dir/gdbserver",
1594 ]
1595 }
Derek Sollenberger70120c72017-01-05 11:39:04 -05001596 }
mtklein25c81d42016-07-27 13:55:26 -07001597}
Mike Kleinc55a6cb2017-06-28 13:21:47 -04001598
1599if (skia_jumper_clang != "") {
1600 action("regen_jumper") {
1601 script = "src/jumper/build_stages.py"
1602
1603 inputs = [
1604 "src/jumper/SkJumper_stages.cpp",
1605 "src/jumper/SkJumper_stages_lowp.cpp",
1606 ]
1607
1608 # GN insists its outputs should go somewhere underneath target_out_dir, so we trick it.
1609 outputs = [
1610 "$target_out_dir/" +
1611 rebase_path("src/jumper/SkJumper_generated.S", target_out_dir),
1612 "$target_out_dir/" +
1613 rebase_path("src/jumper/SkJumper_generated_win.S", target_out_dir),
1614 ]
1615
1616 args = [
1617 skia_jumper_clang,
1618 skia_jumper_objdump,
1619 skia_jumper_ccache,
1620 ] + rebase_path(inputs) + rebase_path(outputs)
1621 }
1622}