blob: 1274a641a91c99790c2aed81cb6d406377104078 [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
Brian Osmanf2c90142017-07-13 15:50:03 -04006import("gn/flutter_defines.gni")
Mike Reed025f7832018-11-12 09:27:05 -05007import("gn/fuchsia_defines.gni")
mikejurka8c24f4f2016-09-12 16:51:58 -07008import("gn/shared_sources.gni")
Hal Canary32498f02019-02-04 15:36:31 -05009import("gn/skia.gni")
brettwb9447282016-09-01 14:24:39 -070010
Forrest Reiling30229ac2017-04-17 13:36:39 -070011if (is_fuchsia) {
12 import("//build/vulkan/config.gni")
13}
14
mtkleinc04ff472016-06-23 10:29:30 -070015declare_args() {
Mike Klein26a60492018-10-15 10:38:25 -040016 skia_enable_flutter_defines = false
17}
18
19declare_args() {
Mike Kleinc168a3a2016-11-14 14:53:13 +000020 skia_use_angle = false
Kevin Lubick4a24e102017-03-29 11:19:01 -040021 skia_use_egl = false
mtklein63213812016-08-24 09:55:56 -070022 skia_use_expat = true
mtklein3cc22182016-08-29 13:26:14 -070023 skia_use_fontconfig = is_linux
Leon Scroggins III85e22fc2018-11-28 08:58:47 -050024 skia_use_fonthost_mac = is_mac
mtkleincdedd0e2016-09-12 15:15:44 -070025 skia_use_freetype = is_android || is_fuchsia || is_linux
Leon Scroggins IIIc41a5f52018-11-15 15:54:59 -050026 skia_use_fixed_gamma_text = is_android
mtklein63213812016-08-24 09:55:56 -070027 skia_use_libjpeg_turbo = true
28 skia_use_libpng = true
mtkleineb3c4252016-08-23 07:38:09 -070029 skia_use_libwebp = !is_fuchsia
Mike Kleinfae86b72018-01-08 15:49:09 -050030 skia_use_lua = is_skia_dev_build && !is_ios
Mike Kleinf9ae6702018-06-20 14:05:05 -040031 skia_use_opencl = false
Mike Klein10d665d2016-11-01 11:46:10 -040032 skia_use_piex = !is_win
Leon Scroggins IIIe93ec682018-10-26 09:25:51 -040033 skia_use_wuffs = false
mtklein63213812016-08-24 09:55:56 -070034 skia_use_zlib = true
Greg Daniele5ddff52017-07-05 16:49:36 -040035 skia_use_metal = false
Mike Klein36f182f2017-10-20 12:33:53 -040036 skia_use_libheif = is_skia_dev_build
Chinmay Garded92d0352018-09-17 10:23:28 -070037 skia_use_x11 = is_linux
Leon Scroggins IIIee0e5d02019-02-27 10:59:11 -050038 skia_use_xps = true
mtklein1bd72ba2016-09-16 07:45:52 -070039
Mike Klein7d921032017-01-05 12:20:41 -050040 skia_android_serial = ""
Kevin Lubick93faa672018-10-10 15:54:53 -040041 skia_enable_ccpr = true
Kevin Lubickca7c2972018-10-17 13:52:24 +000042 skia_enable_nvpr = !skia_enable_flutter_defines
Brian Osman3f375d02016-12-28 11:19:22 -050043 skia_enable_discrete_gpu = true
Kevin Lubick134be1d2018-10-30 15:05:04 -040044 skia_enable_nima = false
Hal Canary43fb7a02016-12-30 13:09:03 -050045 skia_enable_pdf = true
Ethan Nicholasa6ae1f72017-03-16 09:56:54 -040046 skia_enable_spirv_validation = is_skia_dev_build && is_debug
Kevin Lubick32dfdbe2018-10-18 09:47:01 -040047 skia_enable_skpicture = true
Mike Klein3669a822017-03-03 10:55:02 -050048 skia_enable_vulkan_debug_layers = is_skia_dev_build && is_debug
Robert Phillipsa6d2d702017-09-01 12:17:03 -040049 skia_qt_path = getenv("QT_PATH")
Ethan Nicholas762466e2017-06-29 10:03:38 -040050 skia_compile_processors = false
Adrienne Walker1df7cd82018-04-18 13:46:25 -070051 skia_generate_workarounds = false
Ethan Nicholas5b5f0962017-09-11 13:50:14 -070052 skia_lex = false
Mike Kleinc55a6cb2017-06-28 13:21:47 -040053
Hal Canary2331c822018-02-01 14:06:13 -050054 skia_skqp_global_error_tolerance = 0
Ethan Nicholas26a9aad2018-03-27 14:10:52 -040055
56 skia_llvm_path = ""
57 skia_llvm_lib = "LLVM"
Hal Canaryfd9bcab2018-04-24 11:47:23 -040058
59 skia_tools_require_resources = false
mtkleinc04ff472016-06-23 10:29:30 -070060}
Brian Salomon23d73ea2016-10-27 13:31:37 -040061declare_args() {
Matt Sarett189491c2017-03-20 18:09:30 -040062 skia_use_dng_sdk = !is_fuchsia && skia_use_libjpeg_turbo && skia_use_zlib
Mike Klein10d665d2016-11-01 11:46:10 -040063 skia_use_sfntly = skia_use_icu
Brian Salomoncbcb0a12017-11-19 13:20:13 -050064 skia_enable_atlas_text = is_skia_dev_build && skia_enable_gpu
Leon Scroggins IIIbe85c192018-11-13 13:50:12 -050065 skia_enable_fontmgr_empty = false
Kevin Lubickddd0a332018-12-12 10:35:13 -050066 skia_enable_fontmgr_custom =
67 is_linux && skia_use_freetype && !skia_use_fontconfig
Leon Scroggins IIIbe85c192018-11-13 13:50:12 -050068 skia_enable_fontmgr_custom_empty = is_fuchsia && skia_use_freetype
69 skia_enable_fontmgr_android = skia_use_expat && skia_use_freetype
Sergey Ulanovf3babcd2018-11-30 17:42:00 -080070 skia_enable_fontmgr_fuchsia = is_fuchsia
Leon Scroggins III631dbc82019-03-04 13:54:02 -050071 skia_enable_fontmgr_win = is_win
72 skia_enable_fontmgr_win_gdi = is_win
Mike Klein10d665d2016-11-01 11:46:10 -040073
Kevin Lubick27ba7032019-03-21 08:13:54 -040074 if (is_mac) {
75 skia_gl_standard = "gl"
76 } else if (is_ios) {
77 skia_gl_standard = "gles"
78 } else {
79 skia_gl_standard = ""
80 }
81
Mike Klein4d598a32016-10-31 13:44:49 -040082 if (is_android) {
83 skia_use_vulkan = defined(ndk_api) && ndk_api >= 24
Forrest Reiling30229ac2017-04-17 13:36:39 -070084 } else if (is_fuchsia) {
85 skia_use_vulkan = fuchsia_use_vulkan
Mike Klein4d598a32016-10-31 13:44:49 -040086 } else {
Mike Klein98dea7b2019-01-15 11:26:43 -050087 skia_use_vulkan = defined(skia_moltenvk_path) && skia_moltenvk_path != ""
Mike Klein4d598a32016-10-31 13:44:49 -040088 }
Jim Van Verth4e502972017-12-07 15:16:10 -050089
90 if (is_ios) {
91 skia_ios_identity = ".*Google.*"
92 skia_ios_profile = "Google Development"
93 }
Brian Salomon23d73ea2016-10-27 13:31:37 -040094}
Brian Salomon789e25e2016-09-30 13:41:03 -040095
Adam Barth54ef74a2017-10-13 10:59:38 -070096if (defined(skia_settings)) {
97 import(skia_settings)
98}
99
mtklein1211e0c2016-07-26 13:55:45 -0700100skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -0700101 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -0700102 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -0700103 "include/codec",
104 "include/config",
105 "include/core",
Hal Canary23564b92018-09-07 14:33:14 -0400106 "include/docs",
mtklein1211e0c2016-07-26 13:55:45 -0700107 "include/effects",
Matt Sarett94fd06f2017-05-08 17:31:00 -0400108 "include/encode",
mtklein1211e0c2016-07-26 13:55:45 -0700109 "include/gpu",
Brian Salomoncbcb0a12017-11-19 13:20:13 -0500110 "include/atlastext",
mtklein1211e0c2016-07-26 13:55:45 -0700111 "include/pathops",
112 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -0700113 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -0700114 "include/utils",
115 "include/utils/mac",
mtklein1211e0c2016-07-26 13:55:45 -0700116]
117
Brian Salomoncbcb0a12017-11-19 13:20:13 -0500118if (skia_enable_atlas_text) {
119 skia_public_includes += [ "include/atlastext" ]
120}
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000121
mtkleinc04ff472016-06-23 10:29:30 -0700122# Skia public API, generally provided by :skia.
123config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -0700124 include_dirs = skia_public_includes
Mike Kleinae7e6712016-10-11 17:49:33 -0400125 defines = []
126 if (is_component_build) {
127 defines += [ "SKIA_DLL" ]
128 }
Mike Kleinc4cbd742016-09-26 21:37:09 -0400129 if (is_fuchsia || is_linux) {
jcgregorio5561e3d2016-08-25 09:25:11 -0700130 defines += [ "SK_SAMPLES_FOR_X" ]
131 }
Brian Osmanf2c90142017-07-13 15:50:03 -0400132 if (skia_enable_flutter_defines) {
133 defines += flutter_defines
134 }
mtklein06c35c02016-09-20 12:28:12 -0700135 if (!skia_enable_gpu) {
136 defines += [ "SK_SUPPORT_GPU=0" ]
137 }
Brian Salomoncbcb0a12017-11-19 13:20:13 -0500138 if (skia_enable_atlas_text) {
139 defines += [ "SK_SUPPORT_ATLAS_TEXT=1" ]
140 }
Mike Reed025f7832018-11-12 09:27:05 -0500141 if (is_fuchsia) {
142 defines += fuchsia_defines
143 }
Kevin Lubick27ba7032019-03-21 08:13:54 -0400144 if (skia_gl_standard == "gles") {
145 defines += [ "SK_ASSUME_GL_ES=1" ]
146 } else if (skia_gl_standard == "gl") {
147 defines += [ "SK_ASSUME_GL=1" ]
148 }
mtkleinc04ff472016-06-23 10:29:30 -0700149}
150
151# Skia internal APIs, used by Skia itself and a few test tools.
152config("skia_private") {
153 visibility = [ ":*" ]
154
155 include_dirs = [
156 "include/private",
157 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -0700158 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -0700159 "src/core",
160 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -0700161 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -0700162 "src/image",
163 "src/images",
164 "src/lazy",
165 "src/opts",
166 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -0700167 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -0700168 "src/ports",
169 "src/sfnt",
Florin Malita5edba452017-05-30 16:39:47 -0400170 "src/shaders",
171 "src/shaders/gradients",
mtklein9e0d9dd2016-08-30 10:37:19 -0700172 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -0700173 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -0700174 "src/utils/win",
Herb Derby5a8fe972017-02-14 14:42:30 -0500175 "src/xml",
Jim Van Verth1676cb92019-01-15 13:24:45 -0500176 "third_party/etc1",
scroggo19b91532016-10-24 09:03:26 -0700177 "third_party/gif",
mtkleinc04ff472016-06-23 10:29:30 -0700178 ]
mtklein150d1132016-08-01 06:56:40 -0700179
Mike Reeda9e241d2017-05-03 10:52:00 -0400180 defines = [ "SK_GAMMA_APPLY_TO_A8" ]
Leon Scroggins IIIc41a5f52018-11-15 15:54:59 -0500181 if (skia_use_fixed_gamma_text) {
mtkleinb37c0342016-09-09 11:07:45 -0700182 defines += [
183 "SK_GAMMA_EXPONENT=1.4",
184 "SK_GAMMA_CONTRAST=0.0",
185 ]
186 }
mtklein88a7ac02016-09-14 11:16:49 -0700187 if (is_official_build || is_android) {
188 # TODO(bsalomon): it'd be nice to make Android normal.
189 defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
190 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400191 libs = []
192 lib_dirs = []
Brian Salomon03e05842017-02-23 12:23:47 -0500193 if (skia_enable_gpu) {
194 include_dirs += [ "src/gpu" ]
Greg Danielafb7ec72017-12-07 12:48:30 -0500195 if (is_skia_dev_build && skia_use_vulkan) {
196 include_dirs += [ "tools/gpu/vk" ]
197 }
Brian Salomon03e05842017-02-23 12:23:47 -0500198 }
Brian Osman34755e22016-12-05 09:46:02 -0500199 if (skia_use_angle) {
200 defines += [ "SK_ANGLE" ]
201 }
Brian Osman3f375d02016-12-28 11:19:22 -0500202 if (skia_enable_discrete_gpu) {
203 defines += [ "SK_ENABLE_DISCRETE_GPU" ]
204 }
Brian Salomon0c26a9d2017-07-06 10:09:38 -0400205 if (!is_official_build) {
206 defines += [ "GR_TEST_UTILS=1" ]
207 }
Ethan Nicholas26a9aad2018-03-27 14:10:52 -0400208 if (skia_llvm_path != "") {
209 defines += [ "SK_LLVM_AVAILABLE" ]
210 include_dirs += [ "$skia_llvm_path/include" ]
211 libs += [ skia_llvm_lib ]
212 lib_dirs += [ "$skia_llvm_path/lib/" ]
213 }
mtkleinc04ff472016-06-23 10:29:30 -0700214}
215
216# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
217config("skia_library") {
218 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -0700219 defines = [ "SKIA_IMPLEMENTATION=1" ]
220}
221
222skia_library_configs = [
223 ":skia_public",
224 ":skia_private",
225 ":skia_library",
226]
227
mtklein9b8583d2016-08-24 17:32:30 -0700228# Use for CPU-specific Skia code that needs particular compiler flags.
229template("opts") {
Mike Klein6d1df6d2018-11-07 15:03:58 -0500230 visibility = [ ":*" ]
mtklein9b8583d2016-08-24 17:32:30 -0700231 if (invoker.enabled) {
232 source_set(target_name) {
Hal Canaryc25f4e92019-02-26 11:54:25 -0500233 check_includes = false
mtklein9b8583d2016-08-24 17:32:30 -0700234 forward_variables_from(invoker, "*")
235 configs += skia_library_configs
236 }
237 } else {
238 # If not enabled, a phony empty target that swallows all otherwise unused variables.
239 source_set(target_name) {
Hal Canaryc25f4e92019-02-26 11:54:25 -0500240 check_includes = false
mtklein9b8583d2016-08-24 17:32:30 -0700241 forward_variables_from(invoker,
242 "*",
243 [
244 "sources",
245 "cflags",
246 ])
247 }
248 }
anmittala7eaf2e2016-08-17 13:57:26 -0700249}
250
mtklein422310d2016-08-16 18:28:43 -0700251is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700252
mtklein7d6fb2c2016-08-25 14:50:44 -0700253opts("none") {
254 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700255 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700256 cflags = []
257}
258
mtklein7d6fb2c2016-08-25 14:50:44 -0700259opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700260 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700261 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700262 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700263}
264
265opts("arm64") {
266 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700267 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700268 cflags = []
269}
270
271opts("crc32") {
272 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700273 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700274 cflags = [ "-march=armv8-a+crc" ]
275}
276
mtklein9b8583d2016-08-24 17:32:30 -0700277opts("sse2") {
278 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700279 sources = skia_opts.sse2_sources
Mike Kleinc722f792017-07-31 11:57:21 -0400280 if (!is_clang && is_win) {
Mike Kleind8765e32016-10-19 13:39:13 -0400281 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE2" ]
282 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400283 cflags = [ "-msse2" ]
284 }
mtklein9b8583d2016-08-24 17:32:30 -0700285}
mtkleinc04ff472016-06-23 10:29:30 -0700286
mtklein9b8583d2016-08-24 17:32:30 -0700287opts("ssse3") {
288 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700289 sources = skia_opts.ssse3_sources
Mike Kleinc722f792017-07-31 11:57:21 -0400290 if (!is_clang && is_win) {
Mike Kleind8765e32016-10-19 13:39:13 -0400291 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSSE3" ]
292 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400293 cflags = [ "-mssse3" ]
294 }
mtklein9b8583d2016-08-24 17:32:30 -0700295}
mtkleinc04ff472016-06-23 10:29:30 -0700296
mtklein9b8583d2016-08-24 17:32:30 -0700297opts("sse41") {
298 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700299 sources = skia_opts.sse41_sources
Mike Kleinc722f792017-07-31 11:57:21 -0400300 if (!is_clang && is_win) {
Mike Kleind8765e32016-10-19 13:39:13 -0400301 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE41" ]
302 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400303 cflags = [ "-msse4.1" ]
304 }
mtklein9b8583d2016-08-24 17:32:30 -0700305}
mtklein4e976072016-08-08 09:06:27 -0700306
mtklein9b8583d2016-08-24 17:32:30 -0700307opts("sse42") {
308 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700309 sources = skia_opts.sse42_sources
Mike Kleinc722f792017-07-31 11:57:21 -0400310 if (!is_clang && is_win) {
Mike Kleind8765e32016-10-19 13:39:13 -0400311 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE42" ]
312 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400313 cflags = [ "-msse4.2" ]
314 }
mtklein9b8583d2016-08-24 17:32:30 -0700315}
316
317opts("avx") {
318 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700319 sources = skia_opts.avx_sources
Mike Klein4d4b3aa2018-03-21 13:07:35 -0400320 if (is_win) {
Mike Klein17b6e482016-11-18 22:11:41 +0000321 cflags = [ "/arch:AVX" ]
Mike Klein3eb71212016-10-11 17:08:53 -0400322 } else {
323 cflags = [ "-mavx" ]
324 }
mtkleinc04ff472016-06-23 10:29:30 -0700325}
326
Mike Klein1b9b7d52018-02-27 10:37:40 -0500327opts("hsw") {
328 enabled = is_x86
329 sources = skia_opts.hsw_sources
Mike Klein4d4b3aa2018-03-21 13:07:35 -0400330 if (is_win) {
Mike Klein1b9b7d52018-02-27 10:37:40 -0500331 cflags = [ "/arch:AVX2" ]
332 } else {
Mike Kleine87c4862018-03-23 00:13:58 +0000333 cflags = [ "-march=haswell" ]
Mike Klein1b9b7d52018-02-27 10:37:40 -0500334 }
335
336 # Oddly, clang-cl doesn't recognize this as a valid flag.
337 # If it ever does, it'd nice to move this up with -mavx2 and co.
338 if (is_clang && !is_win) {
339 # This flag lets Clang generate FMAs when it sees a mul-then-add. It's optional,
340 # but nice to have, generating slightly better code for paths without explicit FMAs.
341 cflags += [ "-ffp-contract=fast" ]
342 }
343}
344
mtkleinc095df52016-08-24 12:23:52 -0700345# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700346template("optional") {
Mike Klein6d1df6d2018-11-07 15:03:58 -0500347 visibility = [ ":*" ]
mtklein457b42a2016-08-23 13:56:37 -0700348 if (invoker.enabled) {
349 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700350 if (defined(invoker.public_defines)) {
351 defines = invoker.public_defines
352 }
Chris Dalton3a67b8e2018-05-03 09:30:29 -0600353 if (defined(invoker.public_configs)) {
354 configs = invoker.public_configs
355 }
mtklein457b42a2016-08-23 13:56:37 -0700356 }
357 source_set(target_name) {
Hal Canaryc25f4e92019-02-26 11:54:25 -0500358 check_includes = false
mtkleincd01b032016-08-31 04:58:19 -0700359 forward_variables_from(invoker,
360 "*",
361 [
362 "public_defines",
363 "sources_when_disabled",
scroggof84ad642016-10-31 09:02:57 -0700364 "configs_to_remove",
mtkleincd01b032016-08-31 04:58:19 -0700365 ])
mtklein457b42a2016-08-23 13:56:37 -0700366 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700367 configs += skia_library_configs
scroggof84ad642016-10-31 09:02:57 -0700368 if (defined(invoker.configs_to_remove)) {
369 configs -= invoker.configs_to_remove
370 }
mtklein457b42a2016-08-23 13:56:37 -0700371 }
372 } else {
mtklein457b42a2016-08-23 13:56:37 -0700373 source_set(target_name) {
374 forward_variables_from(invoker,
375 "*",
376 [
377 "public_defines",
Greg Daniel91dfa3b2018-05-22 13:25:15 -0400378 "public_deps",
mtklein457b42a2016-08-23 13:56:37 -0700379 "deps",
mtklein6ef69992016-09-14 06:12:09 -0700380 "libs",
mtklein457b42a2016-08-23 13:56:37 -0700381 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700382 "sources_when_disabled",
scroggof84ad642016-10-31 09:02:57 -0700383 "configs_to_remove",
mtklein457b42a2016-08-23 13:56:37 -0700384 ])
mtkleincd01b032016-08-31 04:58:19 -0700385 if (defined(invoker.sources_when_disabled)) {
386 sources = invoker.sources_when_disabled
387 }
388 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700389 }
mtkleineb3c4252016-08-23 07:38:09 -0700390 }
mtklein457b42a2016-08-23 13:56:37 -0700391}
mtklein457b42a2016-08-23 13:56:37 -0700392
mtkleina45be612016-08-29 15:22:10 -0700393optional("fontmgr_android") {
Leon Scroggins IIIbe85c192018-11-13 13:50:12 -0500394 enabled = skia_enable_fontmgr_android
mtkleina45be612016-08-29 15:22:10 -0700395
396 deps = [
Ben Wagnerfc497342017-02-24 11:15:26 -0500397 ":typeface_freetype",
mtkleina45be612016-08-29 15:22:10 -0700398 "//third_party/expat",
mtkleina45be612016-08-29 15:22:10 -0700399 ]
400 sources = [
401 "src/ports/SkFontMgr_android.cpp",
402 "src/ports/SkFontMgr_android_factory.cpp",
403 "src/ports/SkFontMgr_android_parser.cpp",
404 ]
405}
406
mtkleind2e39db2016-09-07 07:52:55 -0700407optional("fontmgr_custom") {
Leon Scroggins IIIbe85c192018-11-13 13:50:12 -0500408 enabled = skia_enable_fontmgr_custom
mtkleind2e39db2016-09-07 07:52:55 -0700409
410 deps = [
Ben Wagnerfc497342017-02-24 11:15:26 -0500411 ":typeface_freetype",
mtkleind2e39db2016-09-07 07:52:55 -0700412 ]
413 sources = [
414 "src/ports/SkFontMgr_custom.cpp",
Ben Wagner8ab590f2017-02-08 17:29:33 -0500415 "src/ports/SkFontMgr_custom.h",
416 "src/ports/SkFontMgr_custom_directory.cpp",
mtkleind2e39db2016-09-07 07:52:55 -0700417 "src/ports/SkFontMgr_custom_directory_factory.cpp",
Ben Wagner8ab590f2017-02-08 17:29:33 -0500418 "src/ports/SkFontMgr_custom_embedded.cpp",
419 "src/ports/SkFontMgr_custom_empty.cpp",
mtkleind2e39db2016-09-07 07:52:55 -0700420 ]
421}
422
Leon Scroggins III631dbc82019-03-04 13:54:02 -0500423optional("fontmgr_custom_empty") {
424 enabled = skia_enable_fontmgr_custom_empty
Kevin Lubickddd0a332018-12-12 10:35:13 -0500425
426 deps = [
427 ":typeface_freetype",
428 ]
429 sources = [
430 "src/ports/SkFontMgr_custom.cpp",
Leon Scroggins III631dbc82019-03-04 13:54:02 -0500431 "src/ports/SkFontMgr_custom_empty.cpp",
432 "src/ports/SkFontMgr_custom_empty_factory.cpp",
Sergey Ulanovf3babcd2018-11-30 17:42:00 -0800433 ]
434}
435
Hal Canaryff2742e2018-01-30 11:35:47 -0500436optional("fontmgr_empty") {
437 enabled = skia_enable_fontmgr_empty
438 sources = [
439 "src/ports/SkFontMgr_empty_factory.cpp",
440 ]
441}
442
mtklein3cc22182016-08-29 13:26:14 -0700443optional("fontmgr_fontconfig") {
444 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700445
446 deps = [
Ben Wagnerfc497342017-02-24 11:15:26 -0500447 ":typeface_freetype",
mtklein3cc22182016-08-29 13:26:14 -0700448 "//third_party:fontconfig",
mtklein3cc22182016-08-29 13:26:14 -0700449 ]
450 sources = [
bungeman1ae0e012016-09-19 12:13:16 -0700451 "src/ports/SkFontConfigInterface.cpp",
mtklein3cc22182016-08-29 13:26:14 -0700452 "src/ports/SkFontConfigInterface_direct.cpp",
453 "src/ports/SkFontConfigInterface_direct_factory.cpp",
454 "src/ports/SkFontMgr_FontConfigInterface.cpp",
455 "src/ports/SkFontMgr_fontconfig.cpp",
456 "src/ports/SkFontMgr_fontconfig_factory.cpp",
457 ]
458}
459
Leon Scroggins III631dbc82019-03-04 13:54:02 -0500460optional("fontmgr_fuchsia") {
461 enabled = skia_enable_fontmgr_fuchsia
462
463 deps = [
464 "//sdk/fidl/fuchsia.fonts",
465 ]
466 sources = [
467 "src/ports/SkFontMgr_fuchsia.cpp",
468 "src/ports/SkFontMgr_fuchsia.h",
469 ]
470}
471
472optional("fontmgr_wasm") {
473 enabled = target_cpu == "wasm"
mtkleincdedd0e2016-09-12 15:15:44 -0700474
475 deps = [
Ben Wagnerfc497342017-02-24 11:15:26 -0500476 ":typeface_freetype",
mtkleincdedd0e2016-09-12 15:15:44 -0700477 ]
478 sources = [
479 "src/ports/SkFontMgr_custom.cpp",
Leon Scroggins III631dbc82019-03-04 13:54:02 -0500480 "src/ports/SkFontMgr_custom.h",
481 "src/ports/SkFontMgr_custom_embedded.cpp",
482 "src/ports/SkFontMgr_custom_embedded_factory.cpp",
mtkleincdedd0e2016-09-12 15:15:44 -0700483 ]
484}
485
Leon Scroggins III631dbc82019-03-04 13:54:02 -0500486optional("fontmgr_win") {
487 enabled = skia_enable_fontmgr_win
488
489 sources = [
490 "src/fonts/SkFontMgr_indirect.cpp",
491 "src/ports/SkFontMgr_win_dw.cpp",
492 "src/ports/SkFontMgr_win_dw_factory.cpp",
493 "src/ports/SkScalerContext_win_dw.cpp",
494 "src/ports/SkTypeface_win_dw.cpp",
495 ]
496}
497
498optional("fontmgr_win_gdi") {
499 enabled = skia_enable_fontmgr_win_gdi
500
501 sources = [
502 "src/ports/SkFontHost_win.cpp",
503 ]
504 libs = [ "Gdi32.lib" ]
505}
506
Ethan Nicholas5b5f0962017-09-11 13:50:14 -0700507if (skia_lex) {
Ethan Nicholasca82a922017-09-07 09:39:50 -0400508 executable("sksllex") {
509 sources = [
510 "src/sksl/lex/Main.cpp",
511 "src/sksl/lex/NFA.cpp",
512 "src/sksl/lex/RegexNode.cpp",
513 "src/sksl/lex/RegexParser.cpp",
514 ]
515 include_dirs = [ "src/sksl/lex" ]
516 }
517
Ethan Nicholas5b5f0962017-09-11 13:50:14 -0700518 action("run_sksllex") {
519 script = "gn/run_sksllex.py"
Ethan Nicholase148bf72017-10-06 14:22:22 -0400520 deps = [
521 ":sksllex(//gn/toolchain:$host_toolchain)",
522 ]
Ethan Nicholas5b5f0962017-09-11 13:50:14 -0700523 sources = [
Ethan Nicholas5b5f0962017-09-11 13:50:14 -0700524 "src/sksl/lex/sksl.lex",
525 ]
526
527 # GN insists its outputs should go somewhere underneath target_out_dir, so we trick it with a
528 # path that starts with target_out_dir and then uses ".." to back up into the src dir.
529 outputs = [
530 "$target_out_dir/" +
531 rebase_path("src/sksl/lex/SkSLLexer.h", target_out_dir),
532 # the script also modifies the corresponding .cpp file, but if we tell GN that it gets
533 # confused due to the same file being named by two different paths
534 ]
535 sksllex_path = "$root_out_dir/"
536 sksllex_path += "sksllex"
537 if (host_os == "win") {
538 sksllex_path += ".exe"
539 }
540 args = [
541 rebase_path(sksllex_path),
542 rebase_path("bin/clang-format"),
543 rebase_path("src"),
544 ]
545 }
546} else {
547 group("run_sksllex") {
548 }
549}
550
551if (skia_compile_processors) {
Ethan Nicholas762466e2017-06-29 10:03:38 -0400552 executable("skslc") {
553 defines = [ "SKSL_STANDALONE" ]
554 sources = [
555 "src/sksl/SkSLMain.cpp",
556 ]
557 sources += skia_sksl_sources
558 include_dirs = [
559 "src/gpu",
560 "src/sksl",
561 ]
562 deps = [
Ethan Nicholasaae47c82017-11-10 15:34:03 -0500563 ":run_sksllex",
Ethan Nicholas762466e2017-06-29 10:03:38 -0400564 "//third_party/spirv-tools",
565 ]
566 }
567
568 skia_gpu_processor_outputs = []
569 foreach(src, skia_gpu_processor_sources) {
570 dir = get_path_info(src, "dir")
571 name = get_path_info(src, "name")
572
573 # GN insists its outputs should go somewhere underneath target_out_dir, so we trick it with a
574 # path that starts with target_out_dir and then uses ".." to back up into the src dir.
575 skia_gpu_processor_outputs += [
576 "$target_out_dir/" + rebase_path("$dir/$name.h", target_out_dir),
577 # the script also modifies the corresponding .cpp file, but if we tell GN that it gets
578 # confused due to the same file being named by two different paths
579 ]
580 }
581
Ethan Nicholasaae47c82017-11-10 15:34:03 -0500582 action("create_sksl_enums") {
583 script = "gn/create_sksl_enums.py"
584 sources = [
585 "include/private/GrSharedEnums.h",
586 ]
587 outputs = [
588 "$target_out_dir/" +
Ben Wagnera56c4d22018-01-24 17:32:17 -0500589 rebase_path("src/sksl/sksl_enums.inc", target_out_dir),
Ethan Nicholasaae47c82017-11-10 15:34:03 -0500590 ]
591 args = [
592 rebase_path(sources[0]),
593 rebase_path(outputs[0]),
594 ]
595 }
596
Ethan Nicholas762466e2017-06-29 10:03:38 -0400597 action("compile_processors") {
598 script = "gn/compile_processors.py"
599 deps = [
Ethan Nicholasaae47c82017-11-10 15:34:03 -0500600 ":create_sksl_enums",
Ethan Nicholas762466e2017-06-29 10:03:38 -0400601 ":skslc(//gn/toolchain:$host_toolchain)",
602 ]
603 sources = skia_gpu_processor_sources
604 outputs = skia_gpu_processor_outputs
605 skslc_path = "$root_out_dir/"
606 if (host_toolchain != default_toolchain_name) {
607 skslc_path += "$host_toolchain/"
608 }
609 skslc_path += "skslc"
610 if (host_os == "win") {
611 skslc_path += ".exe"
612 }
Ethan Nicholasb9f6afb2017-07-27 16:02:37 -0400613 args = [
614 rebase_path(skslc_path),
Eric Borenb121be72017-07-28 10:00:51 -0400615 rebase_path("bin/clang-format"),
Ethan Nicholasb9f6afb2017-07-27 16:02:37 -0400616 ]
Ethan Nicholas762466e2017-06-29 10:03:38 -0400617 args += rebase_path(skia_gpu_processor_sources)
618 }
619} else {
620 skia_gpu_processor_outputs = []
621 group("compile_processors") {
622 }
623}
624
Ben Wagnere27ee6c2019-02-15 14:59:30 -0500625optional("gpu") {
mtklein06c35c02016-09-20 12:28:12 -0700626 enabled = skia_enable_gpu
Ethan Nicholas762466e2017-06-29 10:03:38 -0400627 deps = [
628 ":compile_processors",
Ethan Nicholas5b5f0962017-09-11 13:50:14 -0700629 ":run_sksllex",
Ethan Nicholas762466e2017-06-29 10:03:38 -0400630 ]
Adrienne Walker1df7cd82018-04-18 13:46:25 -0700631 if (skia_generate_workarounds) {
632 deps += [ ":workaround_list" ]
633 }
mtkleine9fb3d52016-09-20 15:11:46 -0700634 public_defines = []
Chris Dalton3a67b8e2018-05-03 09:30:29 -0600635 public_configs = []
Greg Daniel91dfa3b2018-05-22 13:25:15 -0400636 public_deps = []
mtkleine9fb3d52016-09-20 15:11:46 -0700637
Brian Salomon3d6801e2017-12-11 10:06:31 -0500638 sources = skia_gpu_sources + skia_sksl_sources + skia_gpu_processor_outputs
Kevin Lubick93faa672018-10-10 15:54:53 -0400639 if (!skia_enable_ccpr) {
640 sources -= skia_ccpr_sources
641 sources += [ "src/gpu/ccpr/GrCoverageCountingPathRenderer_none.cpp" ]
642 }
Kevin Lubick4bf2c262018-10-15 09:35:54 -0400643 if (!skia_enable_nvpr) {
644 sources -= skia_nvpr_sources
645 sources += [ "src/gpu/GrPathRendering_none.cpp" ]
646 }
mtklein06c35c02016-09-20 12:28:12 -0700647
648 # These paths need to be absolute to match the ones produced by shared_sources.gni.
Brian Salomon3d6801e2017-12-11 10:06:31 -0500649 sources -= get_path_info([ "src/gpu/gl/GrGLMakeNativeInterface_none.cpp" ],
mtklein06c35c02016-09-20 12:28:12 -0700650 "abspath")
Mike Klein703cf5a2016-10-13 17:18:04 -0400651 libs = []
mtklein06c35c02016-09-20 12:28:12 -0700652 if (is_android) {
Hal Canary25375e82018-03-14 15:16:56 -0400653 sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ]
Derek Sollenberger7a869872017-06-27 15:37:25 -0400654
655 # this lib is required to link against AHardwareBuffer
656 if (defined(ndk_api) && ndk_api >= 26) {
657 libs += [ "android" ]
658 }
Kevin Lubick4a24e102017-03-29 11:19:01 -0400659 } else if (skia_use_egl) {
Brian Salomon3d6801e2017-12-11 10:06:31 -0500660 sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ]
Kevin Lubick4a24e102017-03-29 11:19:01 -0400661 libs += [ "EGL" ]
Chinmay Garded92d0352018-09-17 10:23:28 -0700662 } else if (is_linux && skia_use_x11) {
Brian Salomon3d6801e2017-12-11 10:06:31 -0500663 sources += [ "src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp" ]
Mike Kleina27f2692018-06-20 11:06:39 -0400664 libs += [ "GL" ]
mtklein06c35c02016-09-20 12:28:12 -0700665 } else if (is_mac) {
Brian Salomon3d6801e2017-12-11 10:06:31 -0500666 sources += [ "src/gpu/gl/mac/GrGLMakeNativeInterface_mac.cpp" ]
Chinmay Garde130a1182016-11-23 11:43:56 -0800667 } else if (is_ios) {
Brian Salomon3d6801e2017-12-11 10:06:31 -0500668 sources += [ "src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp" ]
Mike Klein703cf5a2016-10-13 17:18:04 -0400669 } else if (is_win) {
Brian Salomon3d6801e2017-12-11 10:06:31 -0500670 sources += [ "src/gpu/gl/win/GrGLMakeNativeInterface_win.cpp" ]
Brian Osman0c757272018-12-10 10:27:26 -0500671 if (target_cpu != "arm64") {
672 libs += [ "OpenGL32.lib" ]
673 }
mtklein06c35c02016-09-20 12:28:12 -0700674 } else {
Brian Salomon3d6801e2017-12-11 10:06:31 -0500675 sources += [ "src/gpu/gl/GrGLMakeNativeInterface_none.cpp" ]
mtklein06c35c02016-09-20 12:28:12 -0700676 }
mtkleine9fb3d52016-09-20 15:11:46 -0700677
678 if (skia_use_vulkan) {
Greg Danielda16cce2018-08-01 09:23:57 -0400679 public_defines += [ "SK_VULKAN" ]
Greg Daniel18dbfd02018-05-29 10:46:51 -0400680 deps += [ "third_party/vulkanmemoryallocator" ]
mtkleine9fb3d52016-09-20 15:11:46 -0700681 sources += skia_vk_sources
egdaniele4a9bd72016-09-21 07:36:14 -0700682 if (skia_enable_vulkan_debug_layers) {
683 public_defines += [ "SK_ENABLE_VK_LAYERS" ]
684 }
Craig Stoutcb6b4bd2018-12-13 10:20:07 -0800685 if (is_fuchsia) {
Kevin Lubickec1c6202018-12-14 11:42:53 -0500686 public_deps +=
687 [ "//third_party/vulkan_loader_and_validation_layers:vulkan" ]
Craig Stoutcb6b4bd2018-12-13 10:20:07 -0800688 }
mtkleine9fb3d52016-09-20 15:11:46 -0700689 }
Greg Daniel91dfa3b2018-05-22 13:25:15 -0400690
Ethan Nicholasa6ae1f72017-03-16 09:56:54 -0400691 if (skia_enable_spirv_validation) {
Ethan Nicholas762466e2017-06-29 10:03:38 -0400692 deps += [ "//third_party/spirv-tools" ]
Ethan Nicholasa6ae1f72017-03-16 09:56:54 -0400693 public_defines += [ "SK_ENABLE_SPIRV_VALIDATION" ]
694 }
Greg Daniele5ddff52017-07-05 16:49:36 -0400695
Greg Daniel6b7e0e22017-07-12 16:21:09 -0400696 cflags_objcc = []
Greg Daniele5ddff52017-07-05 16:49:36 -0400697 if (skia_use_metal) {
698 public_defines += [ "SK_METAL" ]
699 sources += skia_metal_sources
700 libs += [ "Metal.framework" ]
Greg Daniel53956d92018-08-08 14:41:19 -0400701 libs += [ "Foundation.framework" ]
Greg Daniel6b7e0e22017-07-12 16:21:09 -0400702 cflags_objcc += [ "-fobjc-arc" ]
Greg Daniele5ddff52017-07-05 16:49:36 -0400703 }
Brian Salomoncbcb0a12017-11-19 13:20:13 -0500704
705 if (skia_enable_atlas_text) {
706 sources += skia_atlas_text_sources
707 }
Kevin Lubickf4def342018-10-04 12:52:50 -0400708
709 if (is_debug) {
710 public_defines += [ "SK_ENABLE_DUMP_GPU" ]
711 }
mtklein06c35c02016-09-20 12:28:12 -0700712}
713
Leon Scroggins III41169202019-01-29 09:29:57 -0500714optional("gif") {
715 enabled = !skia_use_wuffs
716 sources = [
717 "src/codec/SkGifCodec.cpp",
718 "third_party/gif/SkGifImageReader.cpp",
719 ]
720}
721
Leon Scroggins III04be2b52017-08-17 15:13:20 -0400722optional("heif") {
723 enabled = skia_use_libheif
724 public_defines = [ "SK_HAS_HEIF_LIBRARY" ]
725
726 deps = []
727
728 sources = [
729 "src/codec/SkHeifCodec.cpp",
730 ]
731}
732
mtklein63213812016-08-24 09:55:56 -0700733optional("jpeg") {
734 enabled = skia_use_libjpeg_turbo
735 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
736
mtklein63213812016-08-24 09:55:56 -0700737 deps = [
738 "//third_party/libjpeg-turbo:libjpeg",
739 ]
Mike Kleinf105dc72018-06-05 15:22:54 -0400740 public = [
741 "include/encode/SkJpegEncoder.h",
742 ]
mtklein63213812016-08-24 09:55:56 -0700743 sources = [
744 "src/codec/SkJpegCodec.cpp",
745 "src/codec/SkJpegDecoderMgr.cpp",
746 "src/codec/SkJpegUtility.cpp",
mtklein63213812016-08-24 09:55:56 -0700747 "src/images/SkJPEGWriteUtility.cpp",
Matt Sarett04c37312017-05-05 14:02:13 -0400748 "src/images/SkJpegEncoder.cpp",
mtklein63213812016-08-24 09:55:56 -0700749 ]
750}
751
752optional("pdf") {
Hal Canary43fb7a02016-12-30 13:09:03 -0500753 enabled = skia_use_zlib && skia_enable_pdf
754 public_defines = [ "SK_SUPPORT_PDF" ]
mtklein63213812016-08-24 09:55:56 -0700755
mtklein63213812016-08-24 09:55:56 -0700756 deps = [
757 "//third_party/zlib",
758 ]
Hal Canary83e0f1b2018-04-05 16:58:41 -0400759 if (skia_use_libjpeg_turbo) {
Adrienne Walker1df7cd82018-04-18 13:46:25 -0700760 deps += [ ":jpeg" ]
Hal Canary83e0f1b2018-04-05 16:58:41 -0400761 }
brettwb9447282016-09-01 14:24:39 -0700762 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700763 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
Hal Canary2a3093c2019-02-20 11:25:45 -0500764 if (skia_use_icu && skia_use_harfbuzz && skia_pdf_subset_harfbuzz) {
765 deps += [ "//third_party/harfbuzz" ]
766 defines = [ "SK_PDF_USE_HARFBUZZ_SUBSET" ]
767 } else if (skia_use_icu && skia_use_sfntly) {
mtklein63213812016-08-24 09:55:56 -0700768 deps += [ "//third_party/sfntly" ]
Hal Canary32498f02019-02-04 15:36:31 -0500769 defines = [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700770 }
771}
772
773optional("png") {
774 enabled = skia_use_libpng
775 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
776
mtklein63213812016-08-24 09:55:56 -0700777 deps = [
778 "//third_party/libpng",
779 ]
780 sources = [
781 "src/codec/SkIcoCodec.cpp",
782 "src/codec/SkPngCodec.cpp",
Matt Sarett04c37312017-05-05 14:02:13 -0400783 "src/images/SkPngEncoder.cpp",
mtklein63213812016-08-24 09:55:56 -0700784 ]
785}
786
scroggof84ad642016-10-31 09:02:57 -0700787optional("raw") {
Mike Klein10d665d2016-11-01 11:46:10 -0400788 enabled = skia_use_dng_sdk && skia_use_libjpeg_turbo && skia_use_piex
scroggof84ad642016-10-31 09:02:57 -0700789 public_defines = [ "SK_CODEC_DECODES_RAW" ]
790
791 deps = [
792 "//third_party/dng_sdk",
793 "//third_party/libjpeg-turbo:libjpeg",
794 "//third_party/piex",
795 ]
796
797 # SkRawCodec catches any exceptions thrown by dng_sdk, insulating the rest of
798 # Skia.
799 configs_to_remove = [ "//gn:no_exceptions" ]
800
801 sources = [
scroggof84ad642016-10-31 09:02:57 -0700802 "src/codec/SkRawCodec.cpp",
803 ]
804}
805
Mike Klein852a8cb2018-05-15 10:46:58 -0400806import("third_party/skcms/skcms.gni")
Brian Osman8dc68c62018-05-30 12:57:45 -0400807source_set("skcms") {
Mike Klein852a8cb2018-05-15 10:46:58 -0400808 cflags = []
809 if (!is_win || is_clang) {
810 cflags += [
811 "-w",
812 "-std=c11",
813 ]
814 }
815
816 public = [
817 "third_party/skcms/skcms.h",
818 ]
819 sources = rebase_path(skcms_sources, ".", "third_party/skcms")
820}
821
mtklein3cc22182016-08-29 13:26:14 -0700822optional("typeface_freetype") {
823 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700824
825 deps = [
826 "//third_party/freetype2",
827 ]
828 sources = [
829 "src/ports/SkFontHost_FreeType.cpp",
830 "src/ports/SkFontHost_FreeType_common.cpp",
831 ]
832}
833
mtklein457b42a2016-08-23 13:56:37 -0700834optional("webp") {
835 enabled = skia_use_libwebp
836 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
837
mtklein457b42a2016-08-23 13:56:37 -0700838 deps = [
839 "//third_party/libwebp",
840 ]
841 sources = [
mtklein457b42a2016-08-23 13:56:37 -0700842 "src/codec/SkWebpCodec.cpp",
Matt Sarett04c37312017-05-05 14:02:13 -0400843 "src/images/SkWebpEncoder.cpp",
mtklein457b42a2016-08-23 13:56:37 -0700844 ]
mtkleineb3c4252016-08-23 07:38:09 -0700845}
846
Leon Scroggins IIIe93ec682018-10-26 09:25:51 -0400847optional("wuffs") {
848 enabled = skia_use_wuffs
849 public_defines = [ "SK_HAS_WUFFS_LIBRARY" ]
850
851 deps = [
852 "//third_party/wuffs",
853 ]
854 sources = [
855 "src/codec/SkWuffsCodec.cpp",
856 ]
857}
858
mtklein63213812016-08-24 09:55:56 -0700859optional("xml") {
860 enabled = skia_use_expat
Florin Malita442fff92016-11-08 16:07:52 +0000861 public_defines = [ "SK_XML" ]
mtklein63213812016-08-24 09:55:56 -0700862
mtklein63213812016-08-24 09:55:56 -0700863 deps = [
864 "//third_party/expat",
865 ]
866 sources = [
Mike Kleinbd41bcc2017-02-09 16:38:15 -0500867 "src/svg/SkSVGCanvas.cpp",
868 "src/svg/SkSVGDevice.cpp",
mtklein63213812016-08-24 09:55:56 -0700869 "src/xml/SkDOM.cpp",
870 "src/xml/SkXMLParser.cpp",
871 "src/xml/SkXMLWriter.cpp",
872 ]
873}
874
Adrienne Walker1df7cd82018-04-18 13:46:25 -0700875if (skia_enable_gpu && skia_generate_workarounds) {
876 action("workaround_list") {
877 script = "tools/build_workaround_header.py"
878
879 inputs = [
880 "src/gpu/gpu_workaround_list.txt",
881 ]
882
883 # see comments in skia_compile_processors about out dir path shenanigans.
884 output_file =
Adrienne Walkerab7181d2018-05-14 14:02:03 -0700885 rebase_path("include/gpu/GrDriverBugWorkaroundsAutogen.h", root_out_dir)
Adrienne Walker1df7cd82018-04-18 13:46:25 -0700886
887 outputs = [
888 "$root_out_dir/$output_file",
889 ]
890 args = [
891 "--output-file",
892 "$output_file",
893 ]
894
895 foreach(file, inputs) {
896 args += [ rebase_path(file, root_build_dir) ]
897 }
898 }
899}
900
mtkleinc04ff472016-06-23 10:29:30 -0700901component("skia") {
902 public_configs = [ ":skia_public" ]
903 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700904
Mike Klein607b0a72018-11-07 16:17:34 -0500905 public_deps = [
Ben Wagnere27ee6c2019-02-15 14:59:30 -0500906 ":gpu",
Mike Klein607b0a72018-11-07 16:17:34 -0500907 ":pdf",
908 ":skcms",
909 ]
910
mtkleinc04ff472016-06-23 10:29:30 -0700911 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700912 ":arm64",
913 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700914 ":avx",
Mike Klein54378232018-11-08 12:08:05 +0000915 ":compile_processors",
anmittalb8b3f712016-08-25 04:55:19 -0700916 ":crc32",
mtkleina45be612016-08-29 15:22:10 -0700917 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700918 ":fontmgr_custom",
Leon Scroggins IIIbe85c192018-11-13 13:50:12 -0500919 ":fontmgr_custom_empty",
Hal Canaryff2742e2018-01-30 11:35:47 -0500920 ":fontmgr_empty",
mtklein3cc22182016-08-29 13:26:14 -0700921 ":fontmgr_fontconfig",
Sergey Ulanovf3babcd2018-11-30 17:42:00 -0800922 ":fontmgr_fuchsia",
Kevin Lubickddd0a332018-12-12 10:35:13 -0500923 ":fontmgr_wasm",
Leon Scroggins III631dbc82019-03-04 13:54:02 -0500924 ":fontmgr_win",
925 ":fontmgr_win_gdi",
Leon Scroggins III41169202019-01-29 09:29:57 -0500926 ":gif",
Leon Scroggins III04be2b52017-08-17 15:13:20 -0400927 ":heif",
Mike Klein1b9b7d52018-02-27 10:37:40 -0500928 ":hsw",
mtklein63213812016-08-24 09:55:56 -0700929 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700930 ":none",
mtklein63213812016-08-24 09:55:56 -0700931 ":png",
scroggof84ad642016-10-31 09:02:57 -0700932 ":raw",
mtklein9b8583d2016-08-24 17:32:30 -0700933 ":sse2",
934 ":sse41",
935 ":sse42",
936 ":ssse3",
mtkleineb3c4252016-08-23 07:38:09 -0700937 ":webp",
Leon Scroggins IIIe93ec682018-10-26 09:25:51 -0400938 ":wuffs",
mtklein63213812016-08-24 09:55:56 -0700939 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700940 ]
941
Kevin Lubick134be1d2018-10-30 15:05:04 -0400942 if (skia_enable_nima) {
943 deps += [ "//third_party/Nima-Cpp" ]
944 }
945
Chinmay Garde43f115c2016-11-16 15:04:12 -0800946 # This file (and all GN files in Skia) are designed to work with an
947 # empty sources assignment filter; we handle all that explicitly.
948 # We clear the filter here for clients who may have set up a global filter.
949 set_sources_assignment_filter([])
950
Hal Canaryc25f4e92019-02-26 11:54:25 -0500951 public = skia_core_public
952 public += skia_utils_public
953 public += skia_effects_public
954 public += skia_effects_imagefilter_public
955 public += skia_xps_public
956
mtkleinc04ff472016-06-23 10:29:30 -0700957 sources = []
brettwb9447282016-09-01 14:24:39 -0700958 sources += skia_core_sources
brettwb9447282016-09-01 14:24:39 -0700959 sources += skia_utils_sources
Leon Scroggins IIIee0e5d02019-02-27 10:59:11 -0500960 if (skia_use_xps) {
961 sources += skia_xps_sources
962 }
Mike Klein54378232018-11-08 12:08:05 +0000963 sources += skia_effects_sources
964 sources += skia_effects_imagefilter_sources
mtkleinc04ff472016-06-23 10:29:30 -0700965 sources += [
Stan Iliev73d8fd92017-08-02 15:36:24 -0400966 "src/android/SkAndroidFrameworkUtils.cpp",
Leon Scroggins III42ee2842018-01-14 14:46:51 -0500967 "src/android/SkAnimatedImage.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700968 "src/android/SkBitmapRegionCodec.cpp",
969 "src/android/SkBitmapRegionDecoder.cpp",
970 "src/codec/SkAndroidCodec.cpp",
Nigel Tao612a65d2018-11-09 10:10:31 +1100971 "src/codec/SkAndroidCodecAdapter.cpp",
Leon Scroggins IIId81fed92017-06-01 13:42:28 -0400972 "src/codec/SkBmpBaseCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700973 "src/codec/SkBmpCodec.cpp",
974 "src/codec/SkBmpMaskCodec.cpp",
975 "src/codec/SkBmpRLECodec.cpp",
976 "src/codec/SkBmpStandardCodec.cpp",
977 "src/codec/SkCodec.cpp",
978 "src/codec/SkCodecImageGenerator.cpp",
Leon Scroggins III22f673d2018-05-30 15:33:46 -0400979 "src/codec/SkColorTable.cpp",
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400980 "src/codec/SkEncodedInfo.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700981 "src/codec/SkMaskSwizzler.cpp",
982 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700983 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700984 "src/codec/SkSampler.cpp",
scroggo19b91532016-10-24 09:03:26 -0700985 "src/codec/SkStreamBuffer.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700986 "src/codec/SkSwizzler.cpp",
987 "src/codec/SkWbmpCodec.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700988 "src/images/SkImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700989 "src/ports/SkDiscardableMemory_none.cpp",
Mike Klein54378232018-11-08 12:08:05 +0000990 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700991 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700992 "src/ports/SkMemory_malloc.cpp",
993 "src/ports/SkOSFile_stdio.cpp",
994 "src/sfnt/SkOTTable_name.cpp",
995 "src/sfnt/SkOTUtils.cpp",
996 "src/utils/mac/SkStream_mac.cpp",
Jim Van Verth1676cb92019-01-15 13:24:45 -0500997 "third_party/etc1/etc1.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700998 ]
brettwb9447282016-09-01 14:24:39 -0700999
Kevin Lubick32dfdbe2018-10-18 09:47:01 -04001000 defines = []
1001 if (!skia_enable_skpicture) {
1002 defines = [ "SK_DISABLE_SKPICTURE" ]
Hal Canaryc25f4e92019-02-26 11:54:25 -05001003 public -= skia_skpicture_public
Kevin Lubick32dfdbe2018-10-18 09:47:01 -04001004 sources -= skia_skpicture_sources
Mike Klein54378232018-11-08 12:08:05 +00001005 sources -= [ "//src/effects/imagefilters/SkPictureImageFilter.cpp" ]
Kevin Lubick32dfdbe2018-10-18 09:47:01 -04001006 sources += [ "src/core/SkPicture_none.cpp" ]
1007 }
1008
mtklein7d6fb2c2016-08-25 14:50:44 -07001009 libs = []
1010
mtkleinc04ff472016-06-23 10:29:30 -07001011 if (is_win) {
1012 sources += [
1013 "src/ports/SkDebug_win.cpp",
mtkleinc04ff472016-06-23 10:29:30 -07001014 "src/ports/SkImageEncoder_WIC.cpp",
1015 "src/ports/SkImageGeneratorWIC.cpp",
1016 "src/ports/SkOSFile_win.cpp",
mtklein605d9522016-09-21 14:01:32 -07001017 "src/ports/SkOSLibrary_win.cpp",
mtkleinc04ff472016-06-23 10:29:30 -07001018 "src/ports/SkTLS_win.cpp",
mtkleinc04ff472016-06-23 10:29:30 -07001019 ]
Mike Klein4b167fc2016-10-11 18:13:53 -04001020 libs += [
1021 "FontSub.lib",
1022 "Ole32.lib",
1023 "OleAut32.lib",
1024 "User32.lib",
Mike Klein0c5fdcb2017-11-13 12:40:46 -05001025 "Usp10.lib",
Mike Klein4b167fc2016-10-11 18:13:53 -04001026 ]
mtkleinc04ff472016-06-23 10:29:30 -07001027 } else {
1028 sources += [
mtkleinc04ff472016-06-23 10:29:30 -07001029 "src/ports/SkOSFile_posix.cpp",
mtklein605d9522016-09-21 14:01:32 -07001030 "src/ports/SkOSLibrary_posix.cpp",
mtkleinc04ff472016-06-23 10:29:30 -07001031 "src/ports/SkTLS_pthread.cpp",
1032 ]
Ben Wagnerbe6ae5b2017-08-31 16:45:23 -04001033 libs += [ "dl" ]
mtkleinc04ff472016-06-23 10:29:30 -07001034 }
1035
mtklein7d6fb2c2016-08-25 14:50:44 -07001036 if (is_android) {
Mike Klein1c471872017-01-13 15:27:45 -05001037 deps += [ "//third_party/expat" ]
Mike Kleine459afd2017-03-03 09:21:30 -05001038 if (defined(ndk) && ndk != "") {
Mike Klein1c471872017-01-13 15:27:45 -05001039 deps += [ "//third_party/cpu-features" ]
1040 }
mtklein06c35c02016-09-20 12:28:12 -07001041 sources += [ "src/ports/SkDebug_android.cpp" ]
mtklein7d6fb2c2016-08-25 14:50:44 -07001042 libs += [
1043 "EGL",
1044 "GLESv2",
1045 "log",
1046 ]
1047 }
1048
Kevin Lubick217056c2018-09-20 17:39:31 -04001049 if (is_linux || target_cpu == "wasm") {
mtklein06c35c02016-09-20 12:28:12 -07001050 sources += [ "src/ports/SkDebug_stdio.cpp" ]
Hal Canary25375e82018-03-14 15:16:56 -04001051 if (skia_use_egl) {
1052 libs += [ "GLESv2" ]
1053 }
mtkleinc04ff472016-06-23 10:29:30 -07001054 }
1055
Leon Scroggins III85e22fc2018-11-28 08:58:47 -05001056 if (skia_use_fonthost_mac) {
Sergey Ulanovf3babcd2018-11-30 17:42:00 -08001057 sources += [ "src/ports/SkFontHost_mac.cpp" ]
Leon Scroggins III85e22fc2018-11-28 08:58:47 -05001058 }
1059
mtkleinc04ff472016-06-23 10:29:30 -07001060 if (is_mac) {
1061 sources += [
mtklein7d6fb2c2016-08-25 14:50:44 -07001062 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -07001063 "src/ports/SkImageEncoder_CG.cpp",
1064 "src/ports/SkImageGeneratorCG.cpp",
1065 ]
mtklein09e61f72016-08-23 13:35:28 -07001066 libs += [
bungeman3e306f62017-03-29 11:32:02 -04001067 # AppKit symbols NSFontWeightXXX may be dlsym'ed.
1068 "AppKit.framework",
mtklein09e61f72016-08-23 13:35:28 -07001069 "ApplicationServices.framework",
1070 "OpenGL.framework",
1071 ]
mtkleinc04ff472016-06-23 10:29:30 -07001072 }
abarth6fc8ff02016-07-15 15:15:15 -07001073
Mike Klein7d302882016-11-03 14:06:31 -04001074 if (is_ios) {
1075 sources += [
1076 "src/ports/SkDebug_stdio.cpp",
1077 "src/ports/SkFontHost_mac.cpp",
1078 "src/ports/SkImageEncoder_CG.cpp",
1079 "src/ports/SkImageGeneratorCG.cpp",
1080 ]
1081 libs += [
1082 "CoreFoundation.framework",
1083 "CoreGraphics.framework",
1084 "CoreText.framework",
1085 "ImageIO.framework",
1086 "MobileCoreServices.framework",
bungeman3e306f62017-03-29 11:32:02 -04001087
1088 # UIKit symbols UIFontWeightXXX may be dlsym'ed.
1089 "UIKit.framework",
Mike Klein7d302882016-11-03 14:06:31 -04001090 ]
1091 }
1092
abarth6fc8ff02016-07-15 15:15:15 -07001093 if (is_fuchsia) {
mtklein06c35c02016-09-20 12:28:12 -07001094 sources += [ "src/ports/SkDebug_stdio.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -07001095 }
mtkleinc04ff472016-06-23 10:29:30 -07001096}
1097
Nathaniel Nifongad5f6cd2019-03-05 10:45:40 -05001098# DebugCanvas used in experimental/wasm-skp-debugger
1099if (target_cpu == "wasm") {
1100 static_library("debugcanvas") {
1101 public_configs = [ ":skia_public" ]
1102
1103 include_dirs = [
1104 "include/gpu",
1105 "include/private",
1106 "src/gpu",
1107 "src/core",
1108 "src/shaders",
1109 "src/utils",
1110 "tools",
1111 "tools/debugger",
1112 ]
1113
1114 sources = [
1115 "tools/UrlDataManager.cpp",
Mike Klein8f4e2242019-03-20 11:59:00 -05001116 "tools/debugger/DebugCanvas.cpp",
1117 "tools/debugger/DrawCommand.cpp",
1118 "tools/debugger/JsonWriteBuffer.cpp",
Nathaniel Nifongad5f6cd2019-03-05 10:45:40 -05001119 ]
1120
1121 deps = [
1122 ":fontmgr_wasm",
1123 ]
1124 }
1125}
1126
Kevin Lubickcbcff382018-10-02 09:02:18 -04001127static_library("pathkit") {
Hal Canaryc25f4e92019-02-26 11:54:25 -05001128 check_includes = false
Kevin Lubickcbcff382018-10-02 09:02:18 -04001129 public_configs = [ ":skia_public" ]
1130 configs += skia_library_configs
1131
1132 deps = [
1133 ":arm64",
1134 ":armv7",
1135 ":avx",
1136 ":crc32",
1137 ":hsw",
1138 ":none",
1139 ":sse2",
1140 ":sse41",
1141 ":sse42",
1142 ":ssse3",
1143 ]
1144
1145 # This file (and all GN files in Skia) are designed to work with an
1146 # empty sources assignment filter; we handle all that explicitly.
1147 # We clear the filter here for clients who may have set up a global filter.
1148 set_sources_assignment_filter([])
1149
1150 sources = []
1151 sources += skia_pathops_sources
Hal Canaryc25f4e92019-02-26 11:54:25 -05001152 sources += skia_pathops_public
Kevin Lubickcbcff382018-10-02 09:02:18 -04001153 sources += [
1154 "src/core/SkAnalyticEdge.cpp",
1155 "src/core/SkArenaAlloc.cpp",
Mike Reedcc88f3a2019-02-06 11:40:27 -05001156 "src/core/SkContourMeasure.cpp",
Kevin Lubickcbcff382018-10-02 09:02:18 -04001157 "src/core/SkCubicMap.cpp",
1158 "src/core/SkEdge.cpp",
1159 "src/core/SkEdgeBuilder.cpp",
1160 "src/core/SkEdgeClipper.cpp",
1161 "src/core/SkGeometry.cpp",
1162 "src/core/SkLineClipper.cpp",
1163 "src/core/SkMallocPixelRef.cpp",
1164 "src/core/SkMath.cpp",
1165 "src/core/SkMatrix.cpp",
1166 "src/core/SkOpts.cpp",
1167 "src/core/SkPaint.cpp",
1168 "src/core/SkPath.cpp",
1169 "src/core/SkPathEffect.cpp",
1170 "src/core/SkPathMeasure.cpp",
1171 "src/core/SkPathRef.cpp",
1172 "src/core/SkPoint.cpp",
1173 "src/core/SkRRect.cpp",
1174 "src/core/SkRect.cpp",
1175 "src/core/SkSemaphore.cpp",
1176 "src/core/SkStream.cpp",
1177 "src/core/SkString.cpp",
1178 "src/core/SkStringUtils.cpp",
1179 "src/core/SkStroke.cpp",
1180 "src/core/SkStrokeRec.cpp",
1181 "src/core/SkStrokerPriv.cpp",
1182 "src/core/SkThreadID.cpp",
1183 "src/core/SkUtils.cpp",
1184 "src/effects/SkDashPathEffect.cpp",
1185 "src/effects/SkTrimPathEffect.cpp",
1186 "src/ports/SkDebug_stdio.cpp",
1187 "src/ports/SkMemory_malloc.cpp",
1188 "src/utils/SkDashPath.cpp",
1189 "src/utils/SkParse.cpp",
1190 "src/utils/SkParsePath.cpp",
1191 "src/utils/SkUTF.cpp",
1192 ]
1193}
1194
Kevin Lubick1ba9c4d2019-02-22 10:04:06 -05001195group("modules") {
1196 deps = [
Kevin Lubick96634842019-03-05 14:09:24 -05001197 "modules/particles",
Kevin Lubick1ba9c4d2019-02-22 10:04:06 -05001198 "modules/skottie",
1199 "modules/skshaper",
1200 ]
1201}
1202
mtkleinc095df52016-08-24 12:23:52 -07001203# Targets guarded by skia_enable_tools may use //third_party freely.
1204if (skia_enable_tools) {
Mike Klein308b5ac2016-12-06 16:03:52 -05001205 # Used by gn_to_bp.py to list our public include dirs.
1206 source_set("public") {
1207 configs += [ ":skia_public" ]
1208 }
1209
Mike Kleinc36dedf2016-11-18 09:35:28 -05001210 config("skia.h_config") {
1211 include_dirs = [ "$target_gen_dir" ]
1212 }
1213 action("skia.h") {
1214 public_configs = [ ":skia.h_config" ]
1215 skia_h = "$target_gen_dir/skia.h"
1216 script = "gn/find_headers.py"
Florin Malita6e4d95f2018-05-30 09:27:32 -04001217
1218 # TODO: would be cool to not hard-code these here, but how?
1219 module_public_includes = [
1220 "modules/sksg/include",
1221 "modules/skottie/include",
1222 ]
1223 args =
1224 [ rebase_path("//bin/gn") ] + [ rebase_path("//") ] +
1225 [ rebase_path(skia_h, root_build_dir) ] +
1226 rebase_path(skia_public_includes) + rebase_path(module_public_includes)
Mike Kleinc36dedf2016-11-18 09:35:28 -05001227 depfile = "$skia_h.deps"
1228 outputs = [
1229 skia_h,
1230 ]
1231 }
1232
Brian Osmanc9a42472018-05-31 13:17:12 -04001233 if (target_cpu == "x64") {
Mike Kleinc36dedf2016-11-18 09:35:28 -05001234 executable("fiddle") {
Hal Canaryc25f4e92019-02-26 11:54:25 -05001235 check_includes = false
Mike Kleinc36dedf2016-11-18 09:35:28 -05001236 libs = []
Mike Kleinc36dedf2016-11-18 09:35:28 -05001237 sources = [
Mike Kleinc36dedf2016-11-18 09:35:28 -05001238 "tools/fiddle/draw.cpp",
1239 "tools/fiddle/fiddle_main.cpp",
1240 ]
Joe Gregorioa8fabd32017-05-31 09:45:19 -04001241
1242 if (skia_use_egl) {
1243 sources += [ "tools/fiddle/egl_context.cpp" ]
Joe Gregorioa8fabd32017-05-31 09:45:19 -04001244 } else {
1245 sources += [ "tools/fiddle/null_context.cpp" ]
1246 }
Joe Gregorio1e735c02017-04-19 14:05:14 -04001247 testonly = true
Mike Kleinc36dedf2016-11-18 09:35:28 -05001248 deps = [
Joe Gregorio1e735c02017-04-19 14:05:14 -04001249 ":flags",
Robert Phillips57e08282017-11-16 14:59:48 -05001250 ":gpu_tool_utils",
Mike Kleinc36dedf2016-11-18 09:35:28 -05001251 ":skia",
1252 ":skia.h",
Florin Malita6e4d95f2018-05-30 09:27:32 -04001253 "modules/skottie",
Mike Kleinc36dedf2016-11-18 09:35:28 -05001254 ]
1255 }
1256 }
1257
Brian Osmanc9a42472018-05-31 13:17:12 -04001258 source_set("public_headers_warnings_check") {
1259 sources = [
1260 "tools/public_headers_warnings_check.cpp",
1261 ]
1262 configs -= [ "//gn:warnings_except_public_headers" ]
1263 deps = [
1264 ":skia",
1265 ":skia.h",
1266 "modules/skottie",
1267 ]
Greg Daniel54bfb182018-11-20 17:12:36 -05001268
1269 # We add this directory to simulate the client already have
1270 # vulkan/vulkan_core.h on their path.
Greg Daniel54200e42018-12-11 17:03:39 -05001271 include_dirs = [ "include/third_party/vulkan" ]
Mike Kleinc36dedf2016-11-18 09:35:28 -05001272 }
1273
mtkleinc095df52016-08-24 12:23:52 -07001274 template("test_lib") {
1275 config(target_name + "_config") {
1276 include_dirs = invoker.public_include_dirs
mtkleina627b5c2016-09-20 13:36:47 -07001277 if (defined(invoker.public_defines)) {
1278 defines = invoker.public_defines
1279 }
mtklein25c81d42016-07-27 13:55:26 -07001280 }
mtkleinc095df52016-08-24 12:23:52 -07001281 source_set(target_name) {
1282 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
Hal Canaryc25f4e92019-02-26 11:54:25 -05001283 check_includes = false
mtkleinc095df52016-08-24 12:23:52 -07001284 public_configs = [
1285 ":" + target_name + "_config",
1286 ":skia_private",
1287 ]
1288
1289 if (!defined(deps)) {
1290 deps = []
1291 }
1292 deps += [ ":skia" ]
1293 testonly = true
1294 }
mtklein25c81d42016-07-27 13:55:26 -07001295 }
mtklein25c81d42016-07-27 13:55:26 -07001296
Mike Kleine6682eb2017-01-05 10:54:57 -05001297 template("test_app") {
Jim Van Verth443a9132017-11-28 09:45:26 -05001298 if (is_ios) {
1299 app_name = target_name
1300 gen_path = target_gen_dir
1301
1302 action("${app_name}_generate_info_plist") {
1303 script = "//gn/gen_plist_ios.py"
1304 outputs = [
1305 "$gen_path/${app_name}_Info.plist",
1306 ]
1307 args = [ rebase_path("$gen_path/$app_name", root_build_dir) ]
1308 }
1309
1310 bundle_data("${app_name}_bundle_info_plist") {
1311 public_deps = [
1312 ":${app_name}_generate_info_plist",
1313 ]
1314 sources = [
1315 "$gen_path/${app_name}_Info.plist",
1316 ]
1317 outputs = [
1318 "{{bundle_root_dir}}/Info.plist",
1319 ]
1320 }
1321
Jim Van Verth329c5a62017-11-29 11:42:33 -05001322 bundle_ios_data =
1323 defined(invoker.bundle_ios_data) && invoker.bundle_ios_data
1324
1325 if (bundle_ios_data) {
1326 has_skps =
1327 "True" == exec_script("//gn/checkdir.py",
1328 [ rebase_path("skps", root_build_dir) ],
1329 "trim string")
1330 bundle_data("${app_name}_bundle_resources") {
1331 sources = [
1332 "resources",
1333 ]
1334 outputs = [
1335 # iOS reserves the folders 'Resources' and 'resources' so store one level deeper
1336 "{{bundle_resources_dir}}/data/resources",
1337 ]
1338 }
1339
1340 if (has_skps) {
1341 bundle_data("${app_name}_bundle_skps") {
1342 sources = [
1343 "skps",
1344 ]
1345 outputs = [
1346 # Store in same folder as resources
1347 "{{bundle_resources_dir}}/data/skps",
1348 ]
1349 }
1350 }
1351 }
1352
Jim Van Verth443a9132017-11-28 09:45:26 -05001353 executable("${app_name}_generate_executable") {
1354 forward_variables_from(invoker,
1355 "*",
1356 [
1357 "output_name",
1358 "visibility",
1359 "is_shared_library",
1360 ])
Mike Klein154e6da2017-07-26 15:13:47 -04001361 configs += [ ":skia_private" ]
Mike Kleine6682eb2017-01-05 10:54:57 -05001362 testonly = true
Jim Van Verth443a9132017-11-28 09:45:26 -05001363 output_name = rebase_path("$gen_path/$app_name", root_build_dir)
1364 }
1365
1366 bundle_data("${app_name}_bundle_executable") {
1367 public_deps = [
1368 ":${app_name}_generate_executable",
1369 ]
1370 sources = [
1371 "$gen_path/$app_name",
1372 ]
1373 outputs = [
1374 "{{bundle_executable_dir}}/$app_name",
1375 ]
1376 testonly = true
1377 }
1378
1379 create_bundle("$app_name") {
1380 product_type = "com.apple.product-type.application"
1381 testonly = true
1382
1383 bundle_root_dir = "${root_build_dir}/${target_name}.app"
1384 bundle_resources_dir = bundle_root_dir
1385 bundle_executable_dir = bundle_root_dir
1386 bundle_plugins_dir = bundle_root_dir + "/Plugins"
1387
1388 deps = [
1389 ":${app_name}_bundle_executable",
1390 ":${app_name}_bundle_info_plist",
1391 ]
Jim Van Verth329c5a62017-11-29 11:42:33 -05001392 if (bundle_ios_data) {
1393 deps += [ ":${app_name}_bundle_resources" ]
1394 if (has_skps) {
1395 deps += [ ":${app_name}_bundle_skps" ]
1396 }
1397 }
Jim Van Verth443a9132017-11-28 09:45:26 -05001398
1399 # should only code sign when running on a device, not the simulator
1400 if (target_cpu != "x64") {
1401 code_signing_script = "//gn/codesign_ios.py"
1402 code_signing_sources = [ "$target_gen_dir/$app_name" ]
1403 code_signing_outputs = [
1404 "$bundle_root_dir/_CodeSignature/CodeResources",
1405 "$bundle_root_dir/embedded.mobileprovision",
1406 ]
Jim Van Verth4e502972017-12-07 15:16:10 -05001407 code_signing_args = [
1408 rebase_path("$bundle_root_dir", root_build_dir),
1409 skia_ios_identity,
1410 skia_ios_profile,
1411 ]
Jim Van Verth443a9132017-11-28 09:45:26 -05001412 }
Mike Kleine6682eb2017-01-05 10:54:57 -05001413 }
1414 } else {
Jim Van Verth443a9132017-11-28 09:45:26 -05001415 # !is_ios
1416
1417 if (defined(invoker.is_shared_library) && invoker.is_shared_library) {
1418 shared_library("lib" + target_name) {
1419 forward_variables_from(invoker, "*", [ "is_shared_library" ])
1420 configs += [ ":skia_private" ]
1421 testonly = true
1422 }
1423 } else {
1424 _executable = target_name
1425 executable(_executable) {
Hal Canaryc25f4e92019-02-26 11:54:25 -05001426 check_includes = false
Jim Van Verth443a9132017-11-28 09:45:26 -05001427 forward_variables_from(invoker, "*", [ "is_shared_library" ])
1428 configs += [ ":skia_private" ]
1429 testonly = true
1430 }
Mike Kleine6682eb2017-01-05 10:54:57 -05001431 }
Jim Van Verth443a9132017-11-28 09:45:26 -05001432 if (is_android && skia_android_serial != "" && defined(_executable)) {
1433 action("push_" + target_name) {
1434 script = "gn/push_to_android.py"
1435 deps = [
1436 ":" + _executable,
1437 ]
1438 _stamp = "$target_gen_dir/$_executable.pushed_$skia_android_serial"
1439 outputs = [
1440 _stamp,
1441 ]
1442 args = [
1443 rebase_path("$root_build_dir/$_executable"),
1444 skia_android_serial,
1445 rebase_path(_stamp),
1446 ]
1447 testonly = true
1448 }
Mike Klein7d921032017-01-05 12:20:41 -05001449 }
1450 }
Mike Kleine6682eb2017-01-05 10:54:57 -05001451 }
1452
Greg Danielda16cce2018-08-01 09:23:57 -04001453 config("moltenvk_config") {
1454 if (defined(skia_moltenvk_path) && skia_moltenvk_path != "") {
1455 if (is_ios) {
1456 moltenvk_framework_path = "$skia_moltenvk_path/MoltenVK/iOS"
1457 } else {
1458 moltenvk_framework_path = "$skia_moltenvk_path/MoltenVK/macOS"
1459 }
1460 cflags = [ "-F$moltenvk_framework_path" ]
1461 ldflags = [ "-F$moltenvk_framework_path" ]
1462 libs = [
1463 "MoltenVK.framework",
1464 "Metal.framework",
1465 "IOSurface.framework",
1466 "QuartzCore.framework",
1467 "Foundation.framework",
1468 ]
1469 if (is_ios) {
1470 libs += [ "UIKit.framework" ]
1471 } else {
1472 libs += [ "IOKit.framework" ]
1473 }
1474 defines = [ "SK_MOLTENVK" ]
1475 }
1476 }
1477
1478 source_set("moltenvk") {
1479 public_configs = [ ":moltenvk_config" ]
1480 }
1481
mtkleinc095df52016-08-24 12:23:52 -07001482 test_lib("gpu_tool_utils") {
mtklein38925aa2016-09-21 10:11:25 -07001483 public_include_dirs = []
Brian Osmanc9a42472018-05-31 13:17:12 -04001484 public_defines = []
1485 public_include_dirs += [ "tools/gpu" ]
mtkleind68f9b02016-09-23 13:18:41 -07001486
Brian Osmanc9a42472018-05-31 13:17:12 -04001487 deps = []
Greg Danielda16cce2018-08-01 09:23:57 -04001488 public_deps = []
Brian Osmanc9a42472018-05-31 13:17:12 -04001489 sources = [
1490 "tools/gpu/GrContextFactory.cpp",
1491 "tools/gpu/GrTest.cpp",
Brian Salomon00a5eb82018-07-11 15:32:05 -04001492 "tools/gpu/MemoryCache.cpp",
1493 "tools/gpu/MemoryCache.h",
Brian Osmanc9a42472018-05-31 13:17:12 -04001494 "tools/gpu/ProxyUtils.cpp",
1495 "tools/gpu/TestContext.cpp",
Michael Ludwigd9958f82019-03-21 13:08:36 -04001496 "tools/gpu/YUVUtils.cpp",
1497 "tools/gpu/YUVUtils.h",
Brian Osmanc9a42472018-05-31 13:17:12 -04001498 "tools/gpu/atlastext/GLTestAtlasTextRenderer.cpp",
1499 "tools/gpu/gl/GLTestContext.cpp",
1500 "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
Brian Osmanc9a42472018-05-31 13:17:12 -04001501 "tools/gpu/gl/null/NullGLTestContext.cpp",
1502 "tools/gpu/mock/MockTestContext.cpp",
1503 ]
1504 libs = []
1505
1506 if (is_android || skia_use_egl) {
1507 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
1508 } else if (is_ios) {
1509 sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
1510 libs += [ "OpenGLES.framework" ]
1511 } else if (is_linux) {
1512 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
Mike Kleina27f2692018-06-20 11:06:39 -04001513 libs += [
1514 "GLU",
1515 "X11",
1516 ]
Brian Osmanc9a42472018-05-31 13:17:12 -04001517 } else if (is_mac) {
1518 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
1519 } else if (is_win) {
1520 sources += [ "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp" ]
Brian Osman0c757272018-12-10 10:27:26 -05001521 libs += [ "Gdi32.lib" ]
1522 if (target_cpu != "arm64") {
1523 libs += [ "OpenGL32.lib" ]
1524 }
Brian Osmanc9a42472018-05-31 13:17:12 -04001525 }
mtklein25c81d42016-07-27 13:55:26 -07001526
Brian Osmanc9a42472018-05-31 13:17:12 -04001527 cflags_objcc = [ "-fobjc-arc" ]
mtklein6ef69992016-09-14 06:12:09 -07001528
Brian Osmanc9a42472018-05-31 13:17:12 -04001529 if (skia_use_angle) {
1530 deps += [ "//third_party/angle2" ]
1531 sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
1532 }
Greg Daniel54200e42018-12-11 17:03:39 -05001533
Greg Daniel487132b2018-12-20 14:09:36 -05001534 public_include_dirs += [ "include/third_party/vulkan" ]
Brian Osmanc9a42472018-05-31 13:17:12 -04001535 if (skia_use_vulkan) {
1536 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
1537 sources += [ "tools/gpu/vk/VkTestUtils.cpp" ]
Greg Danielda16cce2018-08-01 09:23:57 -04001538 if (defined(skia_moltenvk_path) && skia_moltenvk_path != "") {
1539 public_deps += [ ":moltenvk" ]
1540 }
Brian Osmanc9a42472018-05-31 13:17:12 -04001541 }
1542 if (skia_use_metal) {
1543 sources += [ "tools/gpu/mtl/MtlTestContext.mm" ]
mtkleina627b5c2016-09-20 13:36:47 -07001544 }
mtklein25c81d42016-07-27 13:55:26 -07001545 }
mtklein25c81d42016-07-27 13:55:26 -07001546
mtkleinc095df52016-08-24 12:23:52 -07001547 test_lib("flags") {
1548 public_include_dirs = [ "tools/flags" ]
1549 sources = [
Mike Klein88544fb2019-03-20 10:50:33 -05001550 "tools/flags/CommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -07001551 ]
1552 }
Mike Kleinc6142d82019-03-25 10:54:59 -05001553
1554 test_lib("common_flags_config") {
mtklein046cb562016-09-16 10:23:12 -07001555 public_include_dirs = [ "tools/flags" ]
1556 sources = [
Mike Klein88544fb2019-03-20 10:50:33 -05001557 "tools/flags/CommonFlagsConfig.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001558 ]
1559 deps = [
mtklein046cb562016-09-16 10:23:12 -07001560 ":flags",
Greg Danielda16cce2018-08-01 09:23:57 -04001561 ]
1562 public_deps = [
mtkleinc095df52016-08-24 12:23:52 -07001563 ":gpu_tool_utils",
1564 ]
1565 }
Mike Kleinc6142d82019-03-25 10:54:59 -05001566 test_lib("common_flags_gpu") {
1567 public_include_dirs = [ "tools/flags" ]
1568 sources = [
1569 "tools/flags/CommonFlagsGpu.cpp",
1570 ]
1571 deps = [
1572 ":flags",
1573 ]
1574 public_deps = [
1575 ":gpu_tool_utils",
1576 ]
1577 }
1578 test_lib("common_flags_images") {
1579 public_include_dirs = [ "tools/flags" ]
1580 sources = [
1581 "tools/flags/CommonFlagsImages.cpp",
1582 ]
1583 deps = [
1584 ":flags",
1585 ]
1586 }
1587 test_lib("common_flags_aa") {
1588 public_include_dirs = [ "tools/flags" ]
1589 sources = [
1590 "tools/flags/CommonFlagsAA.cpp",
1591 ]
1592 deps = [
1593 ":flags",
1594 ]
1595 }
mtklein25c81d42016-07-27 13:55:26 -07001596
Mike Klein499f0ac2019-03-25 13:00:12 -05001597 test_lib("trace") {
1598 public_include_dirs = [ "tools/trace" ]
1599 deps = [
1600 ":flags",
1601 ]
1602 sources = [
1603 "tools/trace/ChromeTracingTracer.cpp",
1604 "tools/trace/ChromeTracingTracer.h",
1605 "tools/trace/EventTracingPriv.cpp",
1606 "tools/trace/EventTracingPriv.h",
1607 "tools/trace/SkDebugfTracer.cpp",
1608 "tools/trace/SkDebugfTracer.h",
1609 ]
1610 }
1611
mtkleinc095df52016-08-24 12:23:52 -07001612 test_lib("tool_utils") {
1613 public_include_dirs = [
1614 "tools",
1615 "tools/debugger",
Ben Wagner483c7722018-02-20 17:06:07 -05001616 "tools/fonts",
mtkleinc095df52016-08-24 12:23:52 -07001617 "tools/timer",
1618 ]
1619 sources = [
mtkleinb37c0342016-09-09 11:07:45 -07001620 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001621 "tools/CrashHandler.cpp",
Robert Phillips96601082018-05-29 16:13:26 -04001622 "tools/DDLPromiseImageHelper.cpp",
1623 "tools/DDLTileHelper.cpp",
mtklein0590fa52016-09-01 07:06:54 -07001624 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001625 "tools/ProcStats.cpp",
1626 "tools/Resources.cpp",
Mike Kleinea3f0142019-03-20 11:12:10 -05001627 "tools/ToolUtils.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001628 "tools/UrlDataManager.cpp",
Mike Klein8f4e2242019-03-20 11:59:00 -05001629 "tools/debugger/DebugCanvas.cpp",
1630 "tools/debugger/DrawCommand.cpp",
1631 "tools/debugger/JsonWriteBuffer.cpp",
Mike Klein0cffcbf92019-03-20 11:08:46 -05001632 "tools/fonts/RandomScalerContext.cpp",
1633 "tools/fonts/TestEmptyTypeface.h",
1634 "tools/fonts/TestFontMgr.cpp",
1635 "tools/fonts/TestFontMgr.h",
1636 "tools/fonts/TestSVGTypeface.cpp",
1637 "tools/fonts/TestSVGTypeface.h",
1638 "tools/fonts/TestTypeface.cpp",
1639 "tools/fonts/TestTypeface.h",
Mike Kleinea3f0142019-03-20 11:12:10 -05001640 "tools/fonts/ToolUtilsFont.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001641 "tools/random_parse_path.cpp",
Mike Kleincd5104e2019-03-20 11:55:08 -05001642 "tools/timer/AnimTimer.h",
mtkleinc095df52016-08-24 12:23:52 -07001643 "tools/timer/Timer.cpp",
1644 ]
Mike Kleinadacaef2017-02-06 09:26:14 -05001645 libs = []
1646 if (is_ios) {
1647 sources += [ "tools/ios_utils.m" ]
1648 libs += [ "Foundation.framework" ]
1649 }
Hal Canaryfd9bcab2018-04-24 11:47:23 -04001650 defines = []
1651 if (skia_tools_require_resources) {
1652 defines += [ "SK_TOOLS_REQUIRE_RESOURCES" ]
1653 }
mtkleinc095df52016-08-24 12:23:52 -07001654 deps = [
Ben Wagner97182cc2018-02-15 10:20:04 -05001655 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -07001656 ":flags",
Mike Kleinc6142d82019-03-25 10:54:59 -05001657 ":gpu_tool_utils",
mtkleinc095df52016-08-24 12:23:52 -07001658 ]
mtkleinc095df52016-08-24 12:23:52 -07001659 }
mtklein25c81d42016-07-27 13:55:26 -07001660
Mike Klein6e744122016-10-27 12:21:40 -04001661 import("gn/gm.gni")
mtkleinc095df52016-08-24 12:23:52 -07001662 test_lib("gm") {
1663 public_include_dirs = [ "gm" ]
1664 sources = gm_sources
1665 deps = [
scroggo19b91532016-10-24 09:03:26 -07001666 ":flags",
mtkleinc095df52016-08-24 12:23:52 -07001667 ":skia",
1668 ":tool_utils",
Mike Reed2f0edd52018-05-31 14:22:30 -04001669 "modules/skottie",
Florin Malita26870722018-09-20 14:35:30 -04001670 "modules/skottie:gm",
Florin Malita3b526b02018-05-25 12:43:51 -04001671 "modules/sksg",
mtkleinc095df52016-08-24 12:23:52 -07001672 ]
Greg Danielda16cce2018-08-01 09:23:57 -04001673 public_deps = [
1674 ":gpu_tool_utils",
1675 ]
Hal Canaryb6f53782019-02-13 10:29:50 -05001676 if (skia_enable_skshaper) {
1677 deps += [ "modules/skshaper" ]
1678 defines = [ "SK_USING_SKSHAPER" ]
1679 }
mtkleinc095df52016-08-24 12:23:52 -07001680 }
mtklein25c81d42016-07-27 13:55:26 -07001681
Mike Klein6e744122016-10-27 12:21:40 -04001682 import("gn/tests.gni")
mtkleinc095df52016-08-24 12:23:52 -07001683 test_lib("tests") {
1684 public_include_dirs = [ "tests" ]
Mike Klein6e744122016-10-27 12:21:40 -04001685 sources = tests_sources + pathops_tests_sources
Leon Scroggins IIIbe85c192018-11-13 13:50:12 -05001686 if (!skia_enable_fontmgr_android) {
Mike Klein6e744122016-10-27 12:21:40 -04001687 sources -= [ "//tests/FontMgrAndroidParserTest.cpp" ]
mtkleina45be612016-08-29 15:22:10 -07001688 }
Ben Wagner37a06c02018-06-22 21:11:00 +00001689 if (!(skia_use_freetype && skia_use_fontconfig)) {
1690 sources -= [ "//tests/FontMgrFontConfigTest.cpp" ]
1691 }
mtkleinc095df52016-08-24 12:23:52 -07001692 deps = [
Hal Canary0f666812018-03-22 15:21:12 -04001693 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -07001694 ":flags",
mtkleinc095df52016-08-24 12:23:52 -07001695 ":skia",
1696 ":tool_utils",
Florin Malita94d4d3e2018-06-18 13:10:51 -04001697 "modules/skottie:tests",
Brian Osmanccb87522018-06-01 19:20:00 +00001698 "modules/sksg:tests",
mtkleinc095df52016-08-24 12:23:52 -07001699 "//third_party/libpng",
Leon Scroggins III194580d2019-02-22 12:32:16 -05001700 "//third_party/libwebp",
mtkleinc095df52016-08-24 12:23:52 -07001701 "//third_party/zlib",
1702 ]
Mike Kleind63442d2017-03-27 14:16:04 -04001703 public_deps = [
1704 ":gpu_tool_utils", # Test.h #includes headers from this target.
1705 ]
Hal Canaryb6f53782019-02-13 10:29:50 -05001706 if (skia_enable_skshaper) {
1707 deps += [ "modules/skshaper" ]
1708 defines = [ "SK_USING_SKSHAPER" ]
1709 }
mtkleinc095df52016-08-24 12:23:52 -07001710 }
mtklein2f3416d2016-08-02 16:02:05 -07001711
Mike Klein6e744122016-10-27 12:21:40 -04001712 import("gn/bench.gni")
mtkleinc095df52016-08-24 12:23:52 -07001713 test_lib("bench") {
1714 public_include_dirs = [ "bench" ]
1715 sources = bench_sources
mtkleinc095df52016-08-24 12:23:52 -07001716 deps = [
1717 ":flags",
1718 ":gm",
1719 ":gpu_tool_utils",
1720 ":skia",
1721 ":tool_utils",
1722 ]
1723 }
mtklein2b6870c2016-07-28 14:17:33 -07001724
mtkleinc095df52016-08-24 12:23:52 -07001725 test_lib("experimental_svg_model") {
Hal Canary0f666812018-03-22 15:21:12 -04001726 public_include_dirs = []
1727 if (skia_use_expat) {
1728 public_include_dirs += [ "experimental/svg/model" ]
1729 sources = [
1730 "experimental/svg/model/SkSVGAttribute.cpp",
1731 "experimental/svg/model/SkSVGAttributeParser.cpp",
1732 "experimental/svg/model/SkSVGCircle.cpp",
1733 "experimental/svg/model/SkSVGClipPath.cpp",
1734 "experimental/svg/model/SkSVGContainer.cpp",
1735 "experimental/svg/model/SkSVGDOM.cpp",
1736 "experimental/svg/model/SkSVGEllipse.cpp",
1737 "experimental/svg/model/SkSVGGradient.cpp",
1738 "experimental/svg/model/SkSVGLine.cpp",
1739 "experimental/svg/model/SkSVGLinearGradient.cpp",
1740 "experimental/svg/model/SkSVGNode.cpp",
1741 "experimental/svg/model/SkSVGPath.cpp",
1742 "experimental/svg/model/SkSVGPattern.cpp",
1743 "experimental/svg/model/SkSVGPoly.cpp",
1744 "experimental/svg/model/SkSVGRadialGradient.cpp",
1745 "experimental/svg/model/SkSVGRect.cpp",
1746 "experimental/svg/model/SkSVGRenderContext.cpp",
1747 "experimental/svg/model/SkSVGSVG.cpp",
1748 "experimental/svg/model/SkSVGShape.cpp",
1749 "experimental/svg/model/SkSVGStop.cpp",
1750 "experimental/svg/model/SkSVGTransformableNode.cpp",
1751 "experimental/svg/model/SkSVGUse.cpp",
1752 "experimental/svg/model/SkSVGValue.cpp",
1753 ]
1754 deps = [
1755 ":skia",
1756 ":xml",
1757 ]
1758 }
mtkleinc095df52016-08-24 12:23:52 -07001759 }
fmalitaa2b9fdf2016-08-03 19:53:36 -07001760
Mike Klein38af9432016-11-11 11:39:44 -05001761 if (skia_use_lua) {
1762 test_lib("lua") {
1763 public_include_dirs = []
1764 sources = [
1765 "src/utils/SkLua.cpp",
1766 "src/utils/SkLuaCanvas.cpp",
1767 ]
1768 deps = [
Herb Derby264182c2018-05-29 15:53:40 -04001769 "modules/skshaper",
Mike Klein38af9432016-11-11 11:39:44 -05001770 "//third_party/lua",
1771 ]
1772 }
1773
Mike Kleine6682eb2017-01-05 10:54:57 -05001774 test_app("lua_app") {
Mike Klein38af9432016-11-11 11:39:44 -05001775 sources = [
1776 "tools/lua/lua_app.cpp",
1777 ]
1778 deps = [
1779 ":lua",
1780 ":skia",
1781 "//third_party/lua",
1782 ]
Mike Klein38af9432016-11-11 11:39:44 -05001783 }
1784
Mike Kleine6682eb2017-01-05 10:54:57 -05001785 test_app("lua_pictures") {
Mike Klein38af9432016-11-11 11:39:44 -05001786 sources = [
1787 "tools/lua/lua_pictures.cpp",
1788 ]
1789 deps = [
1790 ":flags",
1791 ":lua",
1792 ":skia",
1793 ":tool_utils",
1794 "//third_party/lua",
1795 ]
Mike Klein38af9432016-11-11 11:39:44 -05001796 }
1797 }
1798
Florin Malitabfe876a2018-09-02 12:33:59 -04001799 if (is_linux || is_mac) {
Florin Malita79725d32018-06-05 16:16:57 -04001800 test_app("skottie_tool") {
1801 deps = [
1802 "modules/skottie:tool",
1803 ]
1804 }
1805 }
1806
Kevin Lubickebf648e2017-09-21 13:45:16 -04001807 if (target_cpu != "wasm") {
1808 import("gn/samples.gni")
1809 test_lib("samples") {
1810 public_include_dirs = [ "samplecode" ]
1811 include_dirs = [ "experimental" ]
Yuqian Li56a4a092018-02-12 14:47:34 +08001812 sources = samples_sources
Ben Wagnerb2c4ea62018-08-08 11:36:17 -04001813 public_deps = [
1814 ":tool_utils",
1815 ]
Kevin Lubickebf648e2017-09-21 13:45:16 -04001816 deps = [
1817 ":experimental_svg_model",
1818 ":flags",
Mike Kleinc6142d82019-03-25 10:54:59 -05001819 ":gpu_tool_utils",
Kevin Lubickebf648e2017-09-21 13:45:16 -04001820 ":xml",
Mike Reedec80d902019-02-12 11:31:27 -05001821 "modules/sksg",
Herb Derby264182c2018-05-29 15:53:40 -04001822 "modules/skshaper",
Kevin Lubickebf648e2017-09-21 13:45:16 -04001823 ]
Mike Klein38af9432016-11-11 11:39:44 -05001824
Ruiqi Maof5101492018-06-29 14:32:21 -04001825 # NIMA does not build on Windows clang
1826 if (!is_win || !is_clang) {
Kevin Lubickd9699322018-10-30 15:08:53 -04001827 sources += [ "experimental/nima/NimaActor.cpp" ]
Ruiqi Maof5101492018-06-29 14:32:21 -04001828 deps += [ "//third_party/Nima-Cpp" ]
1829 }
1830
Kevin Lubickebf648e2017-09-21 13:45:16 -04001831 if (skia_use_lua) {
1832 sources += [ "samplecode/SampleLua.cpp" ]
1833 deps += [
1834 ":lua",
1835 "//third_party/lua",
1836 ]
1837 }
1838 }
Mike Klein7af351a2018-07-27 09:54:43 -04001839 test_app("imgcvt") {
1840 sources = [
1841 "tools/imgcvt.cpp",
1842 ]
1843 deps = [
1844 ":skcms",
1845 ":skia",
1846 ]
1847 }
Kevin Lubickebf648e2017-09-21 13:45:16 -04001848 test_app("dm") {
1849 sources = [
1850 "dm/DM.cpp",
Hal Canaryb6c5e5b2017-10-09 16:13:02 -04001851 "dm/DMGpuTestProcs.cpp",
Kevin Lubickebf648e2017-09-21 13:45:16 -04001852 "dm/DMJsonWriter.cpp",
1853 "dm/DMSrcSink.cpp",
1854 ]
Kevin Lubickebf648e2017-09-21 13:45:16 -04001855 deps = [
Mike Kleinc6142d82019-03-25 10:54:59 -05001856 ":common_flags_aa",
1857 ":common_flags_config",
1858 ":common_flags_gpu",
1859 ":common_flags_images",
Kevin Lubickebf648e2017-09-21 13:45:16 -04001860 ":experimental_svg_model",
1861 ":flags",
1862 ":gm",
1863 ":gpu_tool_utils",
1864 ":skia",
1865 ":tests",
1866 ":tool_utils",
Mike Klein499f0ac2019-03-25 13:00:12 -05001867 ":trace",
Florin Malita3d856bd2018-05-26 09:49:28 -04001868 "modules/skottie",
Florin Malitaa8316552018-11-09 16:19:44 -05001869 "modules/skottie:utils",
Florin Malita3b526b02018-05-25 12:43:51 -04001870 "modules/sksg",
Kevin Lubickebf648e2017-09-21 13:45:16 -04001871 "//third_party/libpng",
Mike Klein38af9432016-11-11 11:39:44 -05001872 ]
Ruiqi Maof5101492018-06-29 14:32:21 -04001873
1874 # NIMA does not build on Windows clang
1875 if (!is_win || !is_clang) {
1876 deps += [ "//third_party/Nima-Cpp" ]
1877 }
Mike Klein38af9432016-11-11 11:39:44 -05001878 }
Brian Osman16adfa32016-10-18 14:42:44 -04001879 }
1880
Mike Kleina8a51ce2018-01-09 12:34:11 -05001881 if (!is_win) {
1882 test_app("remote_demo") {
1883 sources = [
1884 "tools/remote_demo.cpp",
1885 ]
1886 deps = [
1887 ":skia",
1888 ]
1889 }
1890 }
1891
Mike Kleine6682eb2017-01-05 10:54:57 -05001892 test_app("nanobench") {
mtklein2b6870c2016-07-28 14:17:33 -07001893 sources = [
1894 "bench/nanobench.cpp",
1895 ]
1896 deps = [
1897 ":bench",
Mike Kleinc6142d82019-03-25 10:54:59 -05001898 ":common_flags_aa",
1899 ":common_flags_config",
1900 ":common_flags_gpu",
1901 ":common_flags_images",
fmalita6519c212016-09-14 08:05:17 -07001902 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -07001903 ":flags",
1904 ":gm",
1905 ":gpu_tool_utils",
1906 ":skia",
1907 ":tool_utils",
Mike Klein499f0ac2019-03-25 13:00:12 -05001908 ":trace",
Florin Malita3b526b02018-05-25 12:43:51 -04001909 "modules/sksg",
mtklein2b6870c2016-07-28 14:17:33 -07001910 ]
mtklein2b6870c2016-07-28 14:17:33 -07001911 }
halcanary19a97202016-08-03 15:08:04 -07001912
Ravi Mistry10d36c52017-01-31 09:49:18 -05001913 test_app("skpinfo") {
1914 sources = [
1915 "tools/skpinfo.cpp",
1916 ]
1917 deps = [
1918 ":flags",
1919 ":skia",
1920 ]
1921 }
1922
Brian Osmanc9a42472018-05-31 13:17:12 -04001923 test_app("skpbench") {
1924 sources = [
1925 "tools/skpbench/skpbench.cpp",
1926 ]
1927 deps = [
Mike Kleinc6142d82019-03-25 10:54:59 -05001928 ":common_flags_config",
1929 ":common_flags_gpu",
Brian Osmanc9a42472018-05-31 13:17:12 -04001930 ":flags",
1931 ":gpu_tool_utils",
1932 ":skia",
1933 ":tool_utils",
1934 ]
csmartdalton4b5179b2016-09-19 11:03:58 -07001935 }
1936
Mike Kleine6682eb2017-01-05 10:54:57 -05001937 test_app("sktexttopdf") {
halcanary3eee9d92016-09-10 07:01:53 -07001938 sources = [
Herb Derby264182c2018-05-29 15:53:40 -04001939 "tools/using_skia_and_harfbuzz.cpp",
halcanary3eee9d92016-09-10 07:01:53 -07001940 ]
1941 deps = [
1942 ":skia",
Herb Derby264182c2018-05-29 15:53:40 -04001943 "modules/skshaper",
halcanary3eee9d92016-09-10 07:01:53 -07001944 ]
halcanary3eee9d92016-09-10 07:01:53 -07001945 }
mtklein046cb562016-09-16 10:23:12 -07001946
Ben Wagner219f3622017-07-17 15:32:25 -04001947 test_app("create_test_font") {
1948 sources = [
Ben Wagner483c7722018-02-20 17:06:07 -05001949 "tools/fonts/create_test_font.cpp",
Ben Wagner219f3622017-07-17 15:32:25 -04001950 ]
1951 deps = [
1952 ":skia",
1953 ]
1954 assert_no_deps = [
1955 # tool_utils requires the output of this app.
1956 ":tool_utils",
1957 ]
1958 }
1959
Florin Malita5d3ff432018-07-31 16:38:43 -04001960 if (skia_use_expat) {
1961 test_app("create_test_font_color") {
1962 sources = [
1963 "tools/fonts/create_test_font_color.cpp",
1964 ]
1965 deps = [
1966 ":flags",
1967 ":skia",
1968 ":tool_utils",
1969 ]
1970 }
Ben Wagner97182cc2018-02-15 10:20:04 -05001971 }
1972
Mike Kleine6682eb2017-01-05 10:54:57 -05001973 test_app("get_images_from_skps") {
mtklein046cb562016-09-16 10:23:12 -07001974 sources = [
1975 "tools/get_images_from_skps.cpp",
1976 ]
1977 deps = [
1978 ":flags",
1979 ":skia",
mtklein046cb562016-09-16 10:23:12 -07001980 ]
mtklein046cb562016-09-16 10:23:12 -07001981 }
mtkleinecbc5262016-09-22 11:51:24 -07001982
Brian Osman6788a542018-12-10 11:56:01 -05001983 if (!is_ios && target_cpu != "wasm" && !(is_win && target_cpu == "arm64")) {
Mike Kleine6682eb2017-01-05 10:54:57 -05001984 test_app("skiaserve") {
Mike Klein7d302882016-11-03 14:06:31 -04001985 sources = [
1986 "tools/skiaserve/Request.cpp",
1987 "tools/skiaserve/Response.cpp",
1988 "tools/skiaserve/skiaserve.cpp",
Mike Klein7d302882016-11-03 14:06:31 -04001989 "tools/skiaserve/urlhandlers/BreakHandler.cpp",
1990 "tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp",
1991 "tools/skiaserve/urlhandlers/CmdHandler.cpp",
1992 "tools/skiaserve/urlhandlers/ColorModeHandler.cpp",
1993 "tools/skiaserve/urlhandlers/DataHandler.cpp",
1994 "tools/skiaserve/urlhandlers/DownloadHandler.cpp",
1995 "tools/skiaserve/urlhandlers/EnableGPUHandler.cpp",
1996 "tools/skiaserve/urlhandlers/ImgHandler.cpp",
1997 "tools/skiaserve/urlhandlers/InfoHandler.cpp",
Brian Salomon144a5c52016-12-20 16:48:59 -05001998 "tools/skiaserve/urlhandlers/OpBoundsHandler.cpp",
1999 "tools/skiaserve/urlhandlers/OpsHandler.cpp",
Mike Klein7d302882016-11-03 14:06:31 -04002000 "tools/skiaserve/urlhandlers/OverdrawHandler.cpp",
2001 "tools/skiaserve/urlhandlers/PostHandler.cpp",
2002 "tools/skiaserve/urlhandlers/QuitHandler.cpp",
2003 "tools/skiaserve/urlhandlers/RootHandler.cpp",
2004 ]
2005 deps = [
2006 ":flags",
2007 ":gpu_tool_utils",
2008 ":skia",
2009 ":tool_utils",
Mike Klein7d302882016-11-03 14:06:31 -04002010 "//third_party/libmicrohttpd",
Mike Klein7d302882016-11-03 14:06:31 -04002011 ]
Mike Klein7d302882016-11-03 14:06:31 -04002012 }
mtkleinecbc5262016-09-22 11:51:24 -07002013 }
kjlubick14f984b2016-10-03 11:49:45 -07002014
Mike Kleine6682eb2017-01-05 10:54:57 -05002015 test_app("fuzz") {
Kevin Lubick9ff5dc92018-01-09 12:47:33 -05002016 include_dirs = [
2017 "tools",
2018 "tools/debugger",
Kevin Lubickec1c6202018-12-14 11:42:53 -05002019 "tools/fonts",
Kevin Lubicke9c1ce82019-03-11 11:09:40 -04002020 "src/sksl",
Kevin Lubick9ff5dc92018-01-09 12:47:33 -05002021 ]
kjlubick14f984b2016-10-03 11:49:45 -07002022 sources = [
Kevin Lubickbc9a1a82018-09-17 14:46:57 -04002023 "fuzz/Fuzz.cpp",
Hal Canary24ac42b2017-02-14 13:35:14 -05002024 "fuzz/FuzzCanvas.cpp",
Cary Clark91390c82018-03-09 14:02:46 -05002025 "fuzz/FuzzCommon.cpp",
Kevin Lubickfec1dea2016-11-22 13:57:18 -05002026 "fuzz/FuzzDrawFunctions.cpp",
Kevin Lubicke4be55d2018-03-30 15:05:13 -04002027 "fuzz/FuzzEncoders.cpp",
kjlubick14f984b2016-10-03 11:49:45 -07002028 "fuzz/FuzzGradients.cpp",
Kevin Lubickbc9a1a82018-09-17 14:46:57 -04002029 "fuzz/FuzzMain.cpp",
kjlubick14f984b2016-10-03 11:49:45 -07002030 "fuzz/FuzzParsePath.cpp",
Cary Clark91390c82018-03-09 14:02:46 -05002031 "fuzz/FuzzPathMeasure.cpp",
kjlubick14f984b2016-10-03 11:49:45 -07002032 "fuzz/FuzzPathop.cpp",
Jim Van Verth061cc212018-07-11 14:09:09 -04002033 "fuzz/FuzzPolyUtils.cpp",
Hal Canary13872dd2018-04-06 10:25:12 -04002034 "fuzz/FuzzRegionOp.cpp",
Leon Scroggins III0b8fcbc2018-10-16 15:52:17 -04002035 "fuzz/oss_fuzz/FuzzAndroidCodec.cpp",
Kevin Lubick2416f962018-02-12 08:26:39 -05002036 "fuzz/oss_fuzz/FuzzAnimatedImage.cpp",
2037 "fuzz/oss_fuzz/FuzzImage.cpp",
Kevin Lubickf034d112018-02-08 14:31:24 -05002038 "fuzz/oss_fuzz/FuzzImageFilterDeserialize.cpp",
Leon Scroggins III0b8fcbc2018-10-16 15:52:17 -04002039 "fuzz/oss_fuzz/FuzzIncrementalImage.cpp",
Florin Malita80452be2018-06-19 11:27:20 -04002040 "fuzz/oss_fuzz/FuzzJSON.cpp",
Kevin Lubickf034d112018-02-08 14:31:24 -05002041 "fuzz/oss_fuzz/FuzzPathDeserialize.cpp",
Kevin Lubick2541edf2018-01-11 10:27:14 -05002042 "fuzz/oss_fuzz/FuzzRegionDeserialize.cpp",
2043 "fuzz/oss_fuzz/FuzzRegionSetPath.cpp",
Kevin Lubicke9c1ce82019-03-11 11:09:40 -04002044 "fuzz/oss_fuzz/FuzzSKSL2GLSL.cpp",
2045 "fuzz/oss_fuzz/FuzzSKSL2Metal.cpp",
Kevin Lubick0f0a7102019-03-18 16:20:55 -04002046 "fuzz/oss_fuzz/FuzzSKSL2Pipeline.cpp",
Kevin Lubicke9c1ce82019-03-11 11:09:40 -04002047 "fuzz/oss_fuzz/FuzzSKSL2SPIRV.cpp",
Kevin Lubickf034d112018-02-08 14:31:24 -05002048 "fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp",
Kevin Lubick9ff5dc92018-01-09 12:47:33 -05002049 "tools/UrlDataManager.cpp",
Mike Klein8f4e2242019-03-20 11:59:00 -05002050 "tools/debugger/DebugCanvas.cpp",
2051 "tools/debugger/DrawCommand.cpp",
2052 "tools/debugger/JsonWriteBuffer.cpp",
kjlubick14f984b2016-10-03 11:49:45 -07002053 ]
2054 deps = [
2055 ":flags",
Hal Canary44801ca2017-03-15 11:39:06 -04002056 ":gpu_tool_utils",
kjlubick14f984b2016-10-03 11:49:45 -07002057 ":skia",
Florin Malita3d856bd2018-05-26 09:49:28 -04002058 "modules/skottie:fuzz",
kjlubick14f984b2016-10-03 11:49:45 -07002059 ]
kjlubick14f984b2016-10-03 11:49:45 -07002060 }
Mike Klein38312422016-10-05 15:41:01 -04002061
Mike Kleine6682eb2017-01-05 10:54:57 -05002062 test_app("pathops_unittest") {
Mike Klein6e744122016-10-27 12:21:40 -04002063 sources = pathops_tests_sources + [
Mike Klein6e55fef2016-10-26 11:41:47 -04002064 rebase_path("tests/skia_test.cpp"),
2065 rebase_path("tests/Test.cpp"),
2066 ]
caryclark9feb6322016-10-25 08:58:26 -07002067 deps = [
2068 ":flags",
2069 ":gpu_tool_utils",
2070 ":skia",
2071 ":tool_utils",
2072 ]
caryclark9feb6322016-10-25 08:58:26 -07002073 }
2074
Mike Kleine6682eb2017-01-05 10:54:57 -05002075 test_app("dump_record") {
Mike Klein38312422016-10-05 15:41:01 -04002076 sources = [
2077 "tools/DumpRecord.cpp",
2078 "tools/dump_record.cpp",
2079 ]
2080 deps = [
2081 ":flags",
2082 ":skia",
2083 ]
Mike Klein38312422016-10-05 15:41:01 -04002084 }
bungemanfe917272016-10-13 17:36:40 -04002085
Mike Kleine6682eb2017-01-05 10:54:57 -05002086 test_app("skdiff") {
bungemanfe917272016-10-13 17:36:40 -04002087 sources = [
2088 "tools/skdiff/skdiff.cpp",
2089 "tools/skdiff/skdiff_html.cpp",
2090 "tools/skdiff/skdiff_main.cpp",
2091 "tools/skdiff/skdiff_utils.cpp",
2092 ]
2093 deps = [
2094 ":skia",
2095 ":tool_utils",
2096 ]
bungemanfe917272016-10-13 17:36:40 -04002097 }
halcanarya73d76a2016-10-17 13:19:02 -07002098
Mike Kleine6682eb2017-01-05 10:54:57 -05002099 test_app("skp_parser") {
halcanarya73d76a2016-10-17 13:19:02 -07002100 sources = [
2101 "tools/skp_parser.cpp",
2102 ]
2103 deps = [
2104 ":skia",
2105 ":tool_utils",
halcanarya73d76a2016-10-17 13:19:02 -07002106 ]
halcanarya73d76a2016-10-17 13:19:02 -07002107 }
Brian Osman16adfa32016-10-18 14:42:44 -04002108
Brian Osmanc9a42472018-05-31 13:17:12 -04002109 if (!is_win) {
Hal Canaryd7b38452017-12-11 17:46:26 -05002110 test_lib("skqp_lib") {
Hal Canaryac7f23c2018-11-26 14:07:41 -05002111 public_include_dirs = [ "tools/skqp/src" ]
Hal Canary0e07ad72018-02-08 13:06:56 -05002112 defines =
2113 [ "SK_SKQP_GLOBAL_ERROR_TOLERANCE=$skia_skqp_global_error_tolerance" ]
Hal Canary75427132017-10-11 16:00:31 -04002114 sources = [
2115 "dm/DMGpuTestProcs.cpp",
Hal Canaryac7f23c2018-11-26 14:07:41 -05002116 "tools/skqp/src/skqp.cpp",
2117 "tools/skqp/src/skqp_model.cpp",
Hal Canary75427132017-10-11 16:00:31 -04002118 ]
2119 deps = [
2120 ":gm",
2121 ":gpu_tool_utils",
2122 ":skia",
2123 ":tests",
Hal Canaryd7b38452017-12-11 17:46:26 -05002124 ":tool_utils",
2125 ]
2126 }
2127 test_app("skqp") {
2128 sources = [
Hal Canaryac7f23c2018-11-26 14:07:41 -05002129 "tools/skqp/src/skqp_main.cpp",
Hal Canaryd7b38452017-12-11 17:46:26 -05002130 ]
2131 deps = [
2132 ":skia",
2133 ":skqp_lib",
Hal Canary537d9c02018-01-30 11:30:48 -05002134 ":tool_utils",
Hal Canaryac7f23c2018-11-26 14:07:41 -05002135 ]
2136 }
2137 test_app("jitter_gms") {
2138 sources = [
2139 "tools/skqp/jitter_gms.cpp",
2140 ]
2141 deps = [
2142 ":gm",
2143 ":skia",
2144 ":skqp_lib",
Hal Canary75427132017-10-11 16:00:31 -04002145 ]
2146 }
2147 }
Brian Osmanc9a42472018-05-31 13:17:12 -04002148 if (is_android) {
Hal Canary28f89382017-12-12 09:42:14 -05002149 test_app("skqp_app") {
2150 is_shared_library = true
2151 sources = [
Hal Canaryac7f23c2018-11-26 14:07:41 -05002152 "tools/skqp/src/jni_skqp.cpp",
Hal Canary28f89382017-12-12 09:42:14 -05002153 ]
2154 deps = [
2155 ":skia",
2156 ":skqp_lib",
Hal Canaryb4d01a92018-01-29 13:10:08 -05002157 ":tool_utils",
Hal Canary28f89382017-12-12 09:42:14 -05002158 ]
2159 libs = [ "android" ]
2160 }
2161 }
Stan Iliev93151722018-08-02 11:10:52 -04002162 if (is_android && skia_enable_gpu) {
2163 test_app("skottie_android") {
2164 is_shared_library = true
2165
2166 sources = [
2167 "platform_tools/android/apps/skottie/src/main/cpp/JavaInputStreamAdaptor.cpp",
2168 "platform_tools/android/apps/skottie/src/main/cpp/native-lib.cpp",
2169 ]
2170 libs = []
2171
2172 include_dirs = []
2173 deps = [
2174 ":skia",
2175 "modules/skottie",
Stan Ilieva7a52b92018-10-01 15:36:32 -04002176 "modules/sksg:samples",
Stan Iliev93151722018-08-02 11:10:52 -04002177 ]
2178 }
2179 }
Hal Canary75427132017-10-11 16:00:31 -04002180
Hal Canarya9de7602018-01-19 13:08:23 -05002181 test_app("list_gms") {
2182 sources = [
2183 "tools/list_gms.cpp",
2184 ]
2185 deps = [
2186 ":gm",
2187 ":skia",
2188 ]
2189 }
2190 test_app("list_gpu_unit_tests") {
2191 sources = [
2192 "dm/DMGpuTestProcs.cpp",
2193 "tools/list_gpu_unit_tests.cpp",
2194 ]
2195 deps = [
2196 ":skia",
2197 ":tests",
2198 ]
2199 }
2200
Brian Osmanc9a42472018-05-31 13:17:12 -04002201 test_lib("sk_app") {
2202 public_include_dirs = [ "tools/sk_app" ]
2203 sources = [
2204 "tools/sk_app/CommandSet.cpp",
2205 "tools/sk_app/GLWindowContext.cpp",
2206 "tools/sk_app/Window.cpp",
2207 ]
2208 libs = []
2209
2210 if (is_android) {
2211 sources += [
2212 "tools/sk_app/android/GLWindowContext_android.cpp",
2213 "tools/sk_app/android/RasterWindowContext_android.cpp",
2214 "tools/sk_app/android/Window_android.cpp",
2215 "tools/sk_app/android/main_android.cpp",
2216 "tools/sk_app/android/surface_glue_android.cpp",
Brian Osman16adfa32016-10-18 14:42:44 -04002217 ]
Brian Osmanc9a42472018-05-31 13:17:12 -04002218 libs += [ "android" ]
2219 } else if (is_linux) {
2220 sources += [
2221 "tools/sk_app/unix/GLWindowContext_unix.cpp",
2222 "tools/sk_app/unix/RasterWindowContext_unix.cpp",
2223 "tools/sk_app/unix/Window_unix.cpp",
2224 "tools/sk_app/unix/keysym2ucs.c",
2225 "tools/sk_app/unix/main_unix.cpp",
Brian Osman16adfa32016-10-18 14:42:44 -04002226 ]
Brian Osmanc9a42472018-05-31 13:17:12 -04002227 libs += [
2228 "GL",
2229 "X11",
2230 ]
2231 } else if (is_win) {
2232 sources += [
2233 "tools/sk_app/win/GLWindowContext_win.cpp",
2234 "tools/sk_app/win/RasterWindowContext_win.cpp",
2235 "tools/sk_app/win/Window_win.cpp",
2236 "tools/sk_app/win/main_win.cpp",
2237 ]
Brian Salomon194db172017-08-17 14:37:06 -04002238 if (skia_use_angle) {
Brian Osmanc9a42472018-05-31 13:17:12 -04002239 sources += [ "tools/sk_app/win/ANGLEWindowContext_win.cpp" ]
Brian Salomon194db172017-08-17 14:37:06 -04002240 }
Brian Osmanc9a42472018-05-31 13:17:12 -04002241 } else if (is_mac) {
2242 sources += [
Jim Van Verth1f086ca2019-01-28 14:46:04 -05002243 "tools/sk_app/mac/GLWindowContext_mac.mm",
2244 "tools/sk_app/mac/RasterWindowContext_mac.mm",
2245 "tools/sk_app/mac/Window_mac.mm",
2246 "tools/sk_app/mac/main_mac.mm",
Brian Osmanc9a42472018-05-31 13:17:12 -04002247 ]
2248 libs += [
2249 "QuartzCore.framework",
2250 "Cocoa.framework",
2251 "Foundation.framework",
2252 ]
2253 } else if (is_ios) {
2254 sources += [
2255 "tools/sk_app/ios/GLWindowContext_ios.cpp",
2256 "tools/sk_app/ios/RasterWindowContext_ios.cpp",
2257 "tools/sk_app/ios/Window_ios.cpp",
2258 "tools/sk_app/ios/main_ios.cpp",
2259 ]
2260 }
2261
2262 if (skia_use_vulkan) {
2263 sources += [ "tools/sk_app/VulkanWindowContext.cpp" ]
2264 if (is_android) {
2265 sources += [ "tools/sk_app/android/VulkanWindowContext_android.cpp" ]
2266 } else if (is_linux) {
2267 sources += [ "tools/sk_app/unix/VulkanWindowContext_unix.cpp" ]
2268 libs += [ "X11-xcb" ]
2269 } else if (is_win) {
2270 sources += [ "tools/sk_app/win/VulkanWindowContext_win.cpp" ]
Jim Van Verthce51c142019-02-14 14:07:46 -05002271 } else if (is_mac) {
2272 sources += [ "tools/sk_app/mac/VulkanWindowContext_mac.mm" ]
2273 libs += [ "MetalKit.framework" ]
Brian Osmanc9a42472018-05-31 13:17:12 -04002274 }
2275 }
2276
Jim Van Verthbe39f712019-02-08 15:36:14 -05002277 if (skia_use_metal) {
2278 sources += [ "tools/sk_app/MetalWindowContext.mm" ]
2279 if (is_mac) {
2280 sources += [ "tools/sk_app/mac/MetalWindowContext_mac.mm" ]
2281 }
2282 libs += [ "MetalKit.framework" ]
2283 }
2284
Brian Osmanc9a42472018-05-31 13:17:12 -04002285 deps = [
2286 ":gpu_tool_utils",
2287 ":skia",
2288 ":tool_utils",
Brian Osmanc9a42472018-05-31 13:17:12 -04002289 ]
2290 if (is_android) {
2291 deps += [ "//third_party/native_app_glue" ]
Jim Van Verth1f086ca2019-01-28 14:46:04 -05002292 } else if (is_ios) {
Brian Osmanc9a42472018-05-31 13:17:12 -04002293 deps += [ "//third_party/libsdl" ]
2294 }
2295 if (skia_use_angle) {
2296 deps += [ "//third_party/angle2" ]
Mike Kleina92c3832016-12-08 09:49:39 -05002297 }
Brian Osman16adfa32016-10-18 14:42:44 -04002298 }
Ethan Nicholas4f3985c2016-11-14 11:16:37 -05002299
Hal Canary87515122019-03-15 14:22:51 -04002300 import("gn/examples.gni")
2301 if (!skia_use_vulkan && (is_mac || is_linux || is_win)) {
2302 test_app("fiddle_examples") {
2303 sources = [
2304 "tools/fiddle/examples.cpp",
Brian Osman72ef2d52019-03-17 11:09:17 -04002305 "tools/fiddle/examples.h",
Hal Canary87515122019-03-15 14:22:51 -04002306 ]
2307 sources += examples_sources
2308 include_dirs = [ "tools" ]
Brian Osman72ef2d52019-03-17 11:09:17 -04002309 if (is_win) {
2310 cflags = [ "/wd4756" ] # Overflow in constant arithmetic
2311 }
Hal Canary87515122019-03-15 14:22:51 -04002312 deps = [
2313 ":skia",
2314 ":skia.h",
2315 "modules/skottie",
2316 ]
2317 }
2318 }
Brian Osmanc9a42472018-05-31 13:17:12 -04002319 test_app("viewer") {
2320 is_shared_library = is_android
2321 if (is_ios) {
2322 bundle_ios_data = true
Brian Osmaneff04b52017-11-21 13:18:02 -05002323 }
Brian Osmanc9a42472018-05-31 13:17:12 -04002324 sources = [
2325 "tools/viewer/BisectSlide.cpp",
2326 "tools/viewer/GMSlide.cpp",
2327 "tools/viewer/ImGuiLayer.cpp",
2328 "tools/viewer/ImageSlide.cpp",
Brian Osman7c979f52019-02-12 13:27:51 -05002329 "tools/viewer/ParticlesSlide.cpp",
Brian Osmanc9a42472018-05-31 13:17:12 -04002330 "tools/viewer/SKPSlide.cpp",
2331 "tools/viewer/SampleSlide.cpp",
2332 "tools/viewer/SkottieSlide.cpp",
2333 "tools/viewer/SlideDir.cpp",
2334 "tools/viewer/StatsLayer.cpp",
2335 "tools/viewer/SvgSlide.cpp",
Ben Wagnerb2c4ea62018-08-08 11:36:17 -04002336 "tools/viewer/TouchGesture.cpp",
Leon Scroggins III81886e82018-08-22 11:18:08 -04002337 "tools/viewer/TouchGesture.h",
Brian Osmanc9a42472018-05-31 13:17:12 -04002338 "tools/viewer/Viewer.cpp",
2339 ]
2340 libs = []
2341
Kevin Lubickd9699322018-10-30 15:08:53 -04002342 include_dirs = [ "experimental" ]
Brian Osmanc9a42472018-05-31 13:17:12 -04002343 deps = [
Mike Kleinc6142d82019-03-25 10:54:59 -05002344 ":common_flags_gpu",
Brian Osmanc9a42472018-05-31 13:17:12 -04002345 ":experimental_svg_model",
2346 ":flags",
2347 ":gm",
2348 ":gpu_tool_utils",
2349 ":samples",
2350 ":sk_app",
2351 ":skia",
2352 ":tool_utils",
Mike Klein499f0ac2019-03-25 13:00:12 -05002353 ":trace",
Brian Osman7c979f52019-02-12 13:27:51 -05002354 "modules/particles",
Brian Osmanc9a42472018-05-31 13:17:12 -04002355 "modules/skottie",
Florin Malitaa8316552018-11-09 16:19:44 -05002356 "modules/skottie:utils",
Brian Osmanc9a42472018-05-31 13:17:12 -04002357 "modules/sksg",
Ben Wagnerb2c4ea62018-08-08 11:36:17 -04002358 "modules/sksg:samples",
Brian Osmanc9a42472018-05-31 13:17:12 -04002359 "//third_party/imgui",
Brian Osmanc9a42472018-05-31 13:17:12 -04002360 ]
Ruiqi Maof5101492018-06-29 14:32:21 -04002361
2362 # NIMA does not build on Windows clang
2363 if (!is_win || !is_clang) {
2364 sources += [ "tools/viewer/NIMASlide.cpp" ]
2365 deps += [ "//third_party/Nima-Cpp" ]
2366 }
Brian Osmaneff04b52017-11-21 13:18:02 -05002367 }
2368
ziadbbceddbc2018-06-19 13:57:15 -04002369 if (is_android) {
2370 test_app("arcore") {
2371 is_shared_library = true
2372 configs = [
2373 ":skia_public",
2374 "gn:default",
2375 ]
2376
2377 # For internship expedience, yes, we're rebuilding Skia rather than depending on :skia.
2378 # At the moment there's no way to use Skia and Skottie/SkShaper unless they're in the same .so.
Hal Canaryc25f4e92019-02-26 11:54:25 -05002379 public = skia_core_public
2380 public += skia_utils_public
ziadbbceddbc2018-06-19 13:57:15 -04002381 sources = []
2382 sources += skia_core_sources
2383 sources += skia_utils_sources
2384 sources += skia_xps_sources
2385 sources += [
2386 "src/android/SkAndroidFrameworkUtils.cpp",
2387 "src/android/SkAnimatedImage.cpp",
2388 "src/android/SkBitmapRegionCodec.cpp",
2389 "src/android/SkBitmapRegionDecoder.cpp",
2390 "src/codec/SkAndroidCodec.cpp",
2391 "src/codec/SkBmpBaseCodec.cpp",
2392 "src/codec/SkBmpCodec.cpp",
2393 "src/codec/SkBmpMaskCodec.cpp",
2394 "src/codec/SkBmpRLECodec.cpp",
2395 "src/codec/SkBmpStandardCodec.cpp",
2396 "src/codec/SkCodec.cpp",
2397 "src/codec/SkCodecImageGenerator.cpp",
2398 "src/codec/SkColorTable.cpp",
2399 "src/codec/SkGifCodec.cpp",
2400 "src/codec/SkMaskSwizzler.cpp",
2401 "src/codec/SkMasks.cpp",
2402 "src/codec/SkSampledCodec.cpp",
2403 "src/codec/SkSampler.cpp",
2404 "src/codec/SkStreamBuffer.cpp",
2405 "src/codec/SkSwizzler.cpp",
2406 "src/codec/SkWbmpCodec.cpp",
2407 "src/images/SkImageEncoder.cpp",
2408 "src/ports/SkDiscardableMemory_none.cpp",
2409 "src/ports/SkImageGenerator_skia.cpp",
2410 "src/ports/SkMemory_malloc.cpp",
2411 "src/ports/SkOSFile_stdio.cpp",
2412 "src/sfnt/SkOTTable_name.cpp",
2413 "src/sfnt/SkOTUtils.cpp",
2414 "src/utils/mac/SkStream_mac.cpp",
Jim Van Verth1676cb92019-01-15 13:24:45 -05002415 "third_party/etc1/etc1.cpp",
ziadbbceddbc2018-06-19 13:57:15 -04002416 "third_party/gif/SkGifImageReader.cpp",
2417 ]
2418 deps = [
2419 ":tool_utils",
2420 "modules/skottie",
2421 "modules/skshaper",
2422 ]
2423 }
2424 }
2425
Brian Osmanc9a42472018-05-31 13:17:12 -04002426 if (!skia_use_angle && (is_linux || is_win || is_mac)) {
Brian Osmaneff04b52017-11-21 13:18:02 -05002427 test_app("HelloWorld") {
2428 sources = [
2429 "example/HelloWorld.cpp",
2430 ]
2431 libs = []
2432
2433 include_dirs = []
2434 deps = [
2435 ":flags",
2436 ":gpu_tool_utils",
2437 ":sk_app",
2438 ":skia",
2439 ":tool_utils",
Brian Osmaneff04b52017-11-21 13:18:02 -05002440 ]
2441 }
2442 }
2443
Brian Osmanc9a42472018-05-31 13:17:12 -04002444 if (is_linux || is_mac || is_ios) {
Jim Van Verth4c70c752017-07-11 12:03:01 -04002445 test_app("SkiaSDLExample") {
2446 sources = [
2447 "example/SkiaSDLExample.cpp",
2448 ]
2449 libs = []
2450 include_dirs = []
2451 deps = [
2452 ":gpu_tool_utils",
2453 ":skia",
2454 "//third_party/libsdl",
2455 ]
2456 }
2457 }
2458
Robert Phillipsa6d2d702017-09-01 12:17:03 -04002459 if (skia_qt_path != "" && (is_win || is_linux || is_mac)) {
2460 action_foreach("generate_mocs") {
2461 script = "gn/call.py"
2462 sources = [
2463 "tools/mdbviz/MainWindow.h",
2464 ]
2465 outputs = [
2466 "$target_gen_dir/mdbviz/{{source_name_part}}_moc.cpp",
2467 ]
2468 args = [
2469 "$skia_qt_path" + "/bin/moc",
2470 "{{source}}",
2471 "-o",
2472 "gen/mdbviz/{{source_name_part}}_moc.cpp",
2473 ]
2474 }
2475 action_foreach("generate_resources") {
2476 script = "gn/call.py"
2477 sources = [
2478 "tools/mdbviz/resources.qrc",
2479 ]
2480 outputs = [
2481 "$target_gen_dir/mdbviz/{{source_name_part}}_res.cpp",
2482 ]
2483 args = [
2484 "$skia_qt_path" + "/bin/rcc",
2485 "{{source}}",
2486 "-o",
2487 "gen/mdbviz/{{source_name_part}}_res.cpp",
2488 ]
2489 }
2490 test_app("mdbviz") {
2491 if (is_win) {
2492 # on Windows we need to disable some exception handling warnings due to the Qt headers
2493 cflags = [ "/Wv:18" ] # 18 -> VS2013, 19 -> VS2015, 1910 -> VS2017
2494 }
2495 sources = [
Robert Phillips5fccf9d2017-09-05 15:10:12 -04002496 "tools/UrlDataManager.cpp",
Mike Klein8f4e2242019-03-20 11:59:00 -05002497 "tools/debugger/DebugCanvas.cpp",
2498 "tools/debugger/DrawCommand.cpp",
2499 "tools/debugger/JsonWriteBuffer.cpp",
Robert Phillipsa6d2d702017-09-01 12:17:03 -04002500 "tools/mdbviz/MainWindow.cpp",
Robert Phillipsdeaf5682017-09-06 13:07:21 -04002501 "tools/mdbviz/Model.cpp",
Robert Phillipsa6d2d702017-09-01 12:17:03 -04002502 "tools/mdbviz/main.cpp",
2503
2504 # generated files
2505 "$target_gen_dir/mdbviz/MainWindow_moc.cpp",
2506 "$target_gen_dir/mdbviz/resources_res.cpp",
2507 ]
2508 lib_dirs = [ "$skia_qt_path/lib" ]
2509 libs = [
2510 "Qt5Core.lib",
2511 "Qt5Gui.lib",
2512 "Qt5Widgets.lib",
2513 ]
2514 include_dirs = [
2515 "$skia_qt_path/include",
Robert Phillips276066b2017-09-06 17:17:44 -04002516 "$skia_qt_path/include/QtCore",
Robert Phillipsa6d2d702017-09-01 12:17:03 -04002517 "$skia_qt_path/include/QtWidgets",
Robert Phillips5fccf9d2017-09-05 15:10:12 -04002518 "tools",
2519 "tools/debugger",
Robert Phillipsa6d2d702017-09-01 12:17:03 -04002520 ]
2521 deps = [
2522 ":generate_mocs",
2523 ":generate_resources",
2524 ":skia",
2525 ]
2526 }
2527 }
2528
Mike Kleine459afd2017-03-03 09:21:30 -05002529 if (is_android && defined(ndk) && ndk != "") {
Derek Sollenberger70120c72017-01-05 11:39:04 -05002530 copy("gdbserver") {
2531 sources = [
2532 "$ndk/$ndk_gdbserver",
2533 ]
2534 outputs = [
2535 "$root_out_dir/gdbserver",
2536 ]
2537 }
Derek Sollenberger70120c72017-01-05 11:39:04 -05002538 }
Mike Kleinf9ae6702018-06-20 14:05:05 -04002539
2540 if (skia_use_opencl) {
2541 test_app("hello-opencl") {
2542 sources = [
Mike Kleinf9ae6702018-06-20 14:05:05 -04002543 "tools/hello-opencl.cpp",
2544 ]
Mike Klein8a1f15d2019-02-11 11:59:41 -05002545 deps = [
2546 "//third_party/opencl",
2547 ]
Mike Kleinf9ae6702018-06-20 14:05:05 -04002548 }
2549 }
mtklein25c81d42016-07-27 13:55:26 -07002550}