blob: 2fac60ea90115760094975a8a12c74f55f46dc25 [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")
mikejurka8c24f4f2016-09-12 16:51:58 -07007import("gn/shared_sources.gni")
brettwb9447282016-09-01 14:24:39 -07008
Forrest Reiling30229ac2017-04-17 13:36:39 -07009if (is_fuchsia) {
10 import("//build/vulkan/config.gni")
11}
12
Mike Klein3669a822017-03-03 10:55:02 -050013if (!defined(is_skia_standalone)) {
14 is_skia_standalone = false
15}
16is_skia_dev_build = is_skia_standalone && !is_official_build
17
mtkleinc04ff472016-06-23 10:29:30 -070018declare_args() {
Mike Kleinc168a3a2016-11-14 14:53:13 +000019 skia_use_angle = false
Kevin Lubick4a24e102017-03-29 11:19:01 -040020 skia_use_egl = false
mtklein63213812016-08-24 09:55:56 -070021 skia_use_expat = true
mtklein3cc22182016-08-29 13:26:14 -070022 skia_use_fontconfig = is_linux
mtkleincdedd0e2016-09-12 15:15:44 -070023 skia_use_freetype = is_android || is_fuchsia || is_linux
Mike Klein69f6ed42016-10-13 15:45:07 -040024 skia_use_gdi = false
Mike Klein7d302882016-11-03 14:06:31 -040025 skia_use_icu = !is_fuchsia && !is_ios && !is_win # TODO: Windows
mtklein63213812016-08-24 09:55:56 -070026 skia_use_libjpeg_turbo = true
27 skia_use_libpng = true
mtkleineb3c4252016-08-23 07:38:09 -070028 skia_use_libwebp = !is_fuchsia
Mike Klein38af9432016-11-11 11:39:44 -050029 skia_use_lua = false
mtkleina627b5c2016-09-20 13:36:47 -070030 skia_use_mesa = false
Mike Klein10d665d2016-11-01 11:46:10 -040031 skia_use_piex = !is_win
mtklein63213812016-08-24 09:55:56 -070032 skia_use_zlib = true
Greg Daniele5ddff52017-07-05 16:49:36 -040033 skia_use_metal = false
mtklein1bd72ba2016-09-16 07:45:52 -070034
Mike Klein7d921032017-01-05 12:20:41 -050035 skia_android_serial = ""
Brian Osman3f375d02016-12-28 11:19:22 -050036 skia_enable_discrete_gpu = true
Mike Kleina04bb452017-02-09 12:24:07 -050037 skia_enable_effects = true
Brian Osmanf2c90142017-07-13 15:50:03 -040038 skia_enable_flutter_defines = false
mtklein06c35c02016-09-20 12:28:12 -070039 skia_enable_gpu = true
Hal Canary43fb7a02016-12-30 13:09:03 -050040 skia_enable_pdf = true
Ethan Nicholasa6ae1f72017-03-16 09:56:54 -040041 skia_enable_spirv_validation = is_skia_dev_build && is_debug
Mike Klein3669a822017-03-03 10:55:02 -050042 skia_enable_tools = is_skia_dev_build
43 skia_enable_vulkan_debug_layers = is_skia_dev_build && is_debug
Greg Daniel686bb212016-10-27 10:48:48 -040044 skia_vulkan_sdk = getenv("VULKAN_SDK")
Ethan Nicholas762466e2017-06-29 10:03:38 -040045 skia_compile_processors = false
Mike Kleinc55a6cb2017-06-28 13:21:47 -040046
47 skia_jumper_clang = ""
48 skia_jumper_objdump = ""
49 skia_jumper_ccache = ""
mtkleinc04ff472016-06-23 10:29:30 -070050}
Brian Salomon23d73ea2016-10-27 13:31:37 -040051declare_args() {
Matt Sarett189491c2017-03-20 18:09:30 -040052 skia_use_dng_sdk = !is_fuchsia && skia_use_libjpeg_turbo && skia_use_zlib
Mike Klein10d665d2016-11-01 11:46:10 -040053 skia_use_sfntly = skia_use_icu
54
Mike Klein4d598a32016-10-31 13:44:49 -040055 if (is_android) {
56 skia_use_vulkan = defined(ndk_api) && ndk_api >= 24
Forrest Reiling30229ac2017-04-17 13:36:39 -070057 } else if (is_fuchsia) {
58 skia_use_vulkan = fuchsia_use_vulkan
Mike Klein4d598a32016-10-31 13:44:49 -040059 } else {
60 skia_use_vulkan = skia_vulkan_sdk != ""
61 }
Brian Salomon23d73ea2016-10-27 13:31:37 -040062}
Greg Danielec6ae522017-04-25 13:38:26 -040063declare_args() {
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000064 skia_vulkan_headers = ""
Greg Danielec6ae522017-04-25 13:38:26 -040065 if (skia_use_vulkan) {
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000066 # When buliding on Android we get the header via the NDK so no need for any extra path.
Greg Danielec6ae522017-04-25 13:38:26 -040067 if (is_fuchsia) {
68 skia_vulkan_headers = "$fuchsia_vulkan_sdk/include"
69 } else if (is_linux || is_win) {
70 skia_vulkan_headers = "$skia_vulkan_sdk/include"
Greg Danielec6ae522017-04-25 13:38:26 -040071 }
Greg Danielec6ae522017-04-25 13:38:26 -040072 }
73}
Brian Salomon789e25e2016-09-30 13:41:03 -040074
mtklein38925aa2016-09-21 10:11:25 -070075# Our tools require static linking (they use non-exported symbols).
76skia_enable_tools = skia_enable_tools && !is_component_build
mtklein06c35c02016-09-20 12:28:12 -070077
mtkleina45be612016-08-29 15:22:10 -070078fontmgr_android_enabled = skia_use_expat && skia_use_freetype
79
mtklein1211e0c2016-07-26 13:55:45 -070080skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070081 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070082 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070083 "include/codec",
84 "include/config",
85 "include/core",
86 "include/effects",
Matt Sarett94fd06f2017-05-08 17:31:00 -040087 "include/encode",
mtklein1211e0c2016-07-26 13:55:45 -070088 "include/gpu",
89 "include/gpu/gl",
mtklein1211e0c2016-07-26 13:55:45 -070090 "include/pathops",
91 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070092 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070093 "include/utils",
94 "include/utils/mac",
mtklein1211e0c2016-07-26 13:55:45 -070095]
96
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +000097if (skia_use_vulkan) {
98 skia_public_includes += [ "include/gpu/vk" ]
99}
Greg Daniele5ddff52017-07-05 16:49:36 -0400100if (skia_use_metal) {
101 skia_public_includes += [ "include/gpu/mtl" ]
102}
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000103
mtkleinc04ff472016-06-23 10:29:30 -0700104# Skia public API, generally provided by :skia.
105config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -0700106 include_dirs = skia_public_includes
Greg Danielec6ae522017-04-25 13:38:26 -0400107 if (skia_vulkan_headers != "") {
108 include_dirs += [ skia_vulkan_headers ]
109 }
Mike Kleinae7e6712016-10-11 17:49:33 -0400110 defines = []
111 if (is_component_build) {
112 defines += [ "SKIA_DLL" ]
113 }
Mike Kleinc4cbd742016-09-26 21:37:09 -0400114 if (is_fuchsia || is_linux) {
jcgregorio5561e3d2016-08-25 09:25:11 -0700115 defines += [ "SK_SAMPLES_FOR_X" ]
116 }
Brian Osmanf2c90142017-07-13 15:50:03 -0400117 if (skia_enable_flutter_defines) {
118 defines += flutter_defines
119 }
mtklein06c35c02016-09-20 12:28:12 -0700120 if (!skia_enable_gpu) {
121 defines += [ "SK_SUPPORT_GPU=0" ]
122 }
mtkleinc04ff472016-06-23 10:29:30 -0700123}
124
125# Skia internal APIs, used by Skia itself and a few test tools.
126config("skia_private") {
127 visibility = [ ":*" ]
128
129 include_dirs = [
130 "include/private",
131 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -0700132 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -0700133 "src/core",
134 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -0700135 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -0700136 "src/image",
137 "src/images",
138 "src/lazy",
139 "src/opts",
140 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -0700141 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -0700142 "src/ports",
143 "src/sfnt",
Florin Malita5edba452017-05-30 16:39:47 -0400144 "src/shaders",
145 "src/shaders/gradients",
mtklein9e0d9dd2016-08-30 10:37:19 -0700146 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -0700147 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -0700148 "src/utils/win",
Herb Derby5a8fe972017-02-14 14:42:30 -0500149 "src/xml",
scroggo19b91532016-10-24 09:03:26 -0700150 "third_party/gif",
mtkleinc04ff472016-06-23 10:29:30 -0700151 ]
mtklein150d1132016-08-01 06:56:40 -0700152
Mike Reeda9e241d2017-05-03 10:52:00 -0400153 defines = [ "SK_GAMMA_APPLY_TO_A8" ]
mtkleinb37c0342016-09-09 11:07:45 -0700154 if (is_android) {
155 defines += [
156 "SK_GAMMA_EXPONENT=1.4",
157 "SK_GAMMA_CONTRAST=0.0",
158 ]
159 }
mtklein88a7ac02016-09-14 11:16:49 -0700160 if (is_official_build || is_android) {
161 # TODO(bsalomon): it'd be nice to make Android normal.
162 defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
163 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400164 libs = []
165 lib_dirs = []
166 if (skia_use_vulkan) {
Michael Jurkada3e5962017-04-14 17:44:09 -0700167 if (skia_vulkan_sdk != "" && !is_android && !is_fuchsia) {
Mike Klein487bfc22016-10-14 14:04:56 -0400168 if (is_win) {
Brian Salomon3b5bf352017-03-20 15:54:41 -0400169 lib_dirs += [
170 "$skia_vulkan_sdk/Bin",
171 "$skia_vulkan_sdk/Lib",
172 ]
Mike Klein487bfc22016-10-14 14:04:56 -0400173 } else {
Greg Daniel686bb212016-10-27 10:48:48 -0400174 lib_dirs += [ "$skia_vulkan_sdk/lib/" ]
Mike Klein487bfc22016-10-14 14:04:56 -0400175 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400176 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400177 }
Brian Salomon03e05842017-02-23 12:23:47 -0500178 if (skia_enable_gpu) {
179 include_dirs += [ "src/gpu" ]
180 }
Brian Osman34755e22016-12-05 09:46:02 -0500181 if (skia_use_angle) {
182 defines += [ "SK_ANGLE" ]
183 }
Brian Osman3f375d02016-12-28 11:19:22 -0500184 if (skia_enable_discrete_gpu) {
185 defines += [ "SK_ENABLE_DISCRETE_GPU" ]
186 }
Brian Salomon0c26a9d2017-07-06 10:09:38 -0400187 if (!is_official_build) {
188 defines += [ "GR_TEST_UTILS=1" ]
189 }
mtkleinc04ff472016-06-23 10:29:30 -0700190}
191
192# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
193config("skia_library") {
194 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -0700195 defines = [ "SKIA_IMPLEMENTATION=1" ]
196}
197
198skia_library_configs = [
199 ":skia_public",
200 ":skia_private",
201 ":skia_library",
202]
203
mtklein9b8583d2016-08-24 17:32:30 -0700204# Use for CPU-specific Skia code that needs particular compiler flags.
205template("opts") {
206 if (invoker.enabled) {
207 source_set(target_name) {
208 forward_variables_from(invoker, "*")
209 configs += skia_library_configs
210 }
211 } else {
212 # If not enabled, a phony empty target that swallows all otherwise unused variables.
213 source_set(target_name) {
214 forward_variables_from(invoker,
215 "*",
216 [
217 "sources",
218 "cflags",
219 ])
220 }
221 }
anmittala7eaf2e2016-08-17 13:57:26 -0700222}
223
mtklein422310d2016-08-16 18:28:43 -0700224is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700225
mtklein7d6fb2c2016-08-25 14:50:44 -0700226opts("none") {
227 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700228 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700229 cflags = []
230}
231
mtklein7d6fb2c2016-08-25 14:50:44 -0700232opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700233 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700234 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700235 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700236}
237
238opts("arm64") {
239 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700240 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700241 cflags = []
242}
243
244opts("crc32") {
245 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700246 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700247 cflags = [ "-march=armv8-a+crc" ]
248}
249
mtklein9b8583d2016-08-24 17:32:30 -0700250opts("sse2") {
251 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700252 sources = skia_opts.sse2_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400253 if (is_win) {
254 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE2" ]
255 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400256 cflags = [ "-msse2" ]
257 }
mtklein9b8583d2016-08-24 17:32:30 -0700258}
mtkleinc04ff472016-06-23 10:29:30 -0700259
mtklein9b8583d2016-08-24 17:32:30 -0700260opts("ssse3") {
261 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700262 sources = skia_opts.ssse3_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400263 if (is_win) {
264 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSSE3" ]
265 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400266 cflags = [ "-mssse3" ]
267 }
mtklein9b8583d2016-08-24 17:32:30 -0700268}
mtkleinc04ff472016-06-23 10:29:30 -0700269
mtklein9b8583d2016-08-24 17:32:30 -0700270opts("sse41") {
271 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700272 sources = skia_opts.sse41_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400273 if (is_win) {
274 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE41" ]
275 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400276 cflags = [ "-msse4.1" ]
277 }
mtklein9b8583d2016-08-24 17:32:30 -0700278}
mtklein4e976072016-08-08 09:06:27 -0700279
mtklein9b8583d2016-08-24 17:32:30 -0700280opts("sse42") {
281 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700282 sources = skia_opts.sse42_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400283 if (is_win) {
284 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE42" ]
285 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400286 cflags = [ "-msse4.2" ]
287 }
mtklein9b8583d2016-08-24 17:32:30 -0700288}
289
290opts("avx") {
291 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700292 sources = skia_opts.avx_sources
Mike Klein3eb71212016-10-11 17:08:53 -0400293 if (is_win) {
Mike Klein17b6e482016-11-18 22:11:41 +0000294 cflags = [ "/arch:AVX" ]
Mike Klein3eb71212016-10-11 17:08:53 -0400295 } else {
296 cflags = [ "-mavx" ]
297 }
mtkleinc04ff472016-06-23 10:29:30 -0700298}
299
Mike Klein78d5a3b2016-09-30 10:48:01 -0400300opts("hsw") {
301 enabled = is_x86
302 sources = skia_opts.hsw_sources
Mike Klein3eb71212016-10-11 17:08:53 -0400303 if (is_win) {
Mike Klein17b6e482016-11-18 22:11:41 +0000304 cflags = [ "/arch:AVX2" ]
Mike Klein3eb71212016-10-11 17:08:53 -0400305 } else {
306 cflags = [
307 "-mavx2",
308 "-mbmi",
309 "-mbmi2",
310 "-mf16c",
311 "-mfma",
312 ]
313 }
Mike Klein78d5a3b2016-09-30 10:48:01 -0400314}
315
mtkleinc095df52016-08-24 12:23:52 -0700316# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700317template("optional") {
318 if (invoker.enabled) {
319 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700320 if (defined(invoker.public_defines)) {
321 defines = invoker.public_defines
322 }
mtklein457b42a2016-08-23 13:56:37 -0700323 }
324 source_set(target_name) {
mtkleincd01b032016-08-31 04:58:19 -0700325 forward_variables_from(invoker,
326 "*",
327 [
328 "public_defines",
329 "sources_when_disabled",
scroggof84ad642016-10-31 09:02:57 -0700330 "configs_to_remove",
mtkleincd01b032016-08-31 04:58:19 -0700331 ])
mtklein457b42a2016-08-23 13:56:37 -0700332 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700333 configs += skia_library_configs
scroggof84ad642016-10-31 09:02:57 -0700334 if (defined(invoker.configs_to_remove)) {
335 configs -= invoker.configs_to_remove
336 }
mtklein457b42a2016-08-23 13:56:37 -0700337 }
338 } else {
mtklein457b42a2016-08-23 13:56:37 -0700339 source_set(target_name) {
340 forward_variables_from(invoker,
341 "*",
342 [
343 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700344 "deps",
mtklein6ef69992016-09-14 06:12:09 -0700345 "libs",
mtklein457b42a2016-08-23 13:56:37 -0700346 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700347 "sources_when_disabled",
scroggof84ad642016-10-31 09:02:57 -0700348 "configs_to_remove",
mtklein457b42a2016-08-23 13:56:37 -0700349 ])
mtkleincd01b032016-08-31 04:58:19 -0700350 if (defined(invoker.sources_when_disabled)) {
351 sources = invoker.sources_when_disabled
352 }
353 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700354 }
mtkleineb3c4252016-08-23 07:38:09 -0700355 }
mtklein457b42a2016-08-23 13:56:37 -0700356}
mtklein457b42a2016-08-23 13:56:37 -0700357
Mike Kleina04bb452017-02-09 12:24:07 -0500358optional("effects") {
359 enabled = skia_enable_effects
Ethan Nicholas762466e2017-06-29 10:03:38 -0400360 deps = [
361 ":compile_processors",
362 ]
Mike Kleina04bb452017-02-09 12:24:07 -0500363 sources =
364 skia_effects_sources + [ "src/ports/SkGlobalInitialization_default.cpp" ]
365 sources_when_disabled = [ "src/ports/SkGlobalInitialization_none.cpp" ]
366}
367
mtkleina45be612016-08-29 15:22:10 -0700368optional("fontmgr_android") {
369 enabled = fontmgr_android_enabled
mtkleina45be612016-08-29 15:22:10 -0700370
371 deps = [
Ben Wagnerfc497342017-02-24 11:15:26 -0500372 ":typeface_freetype",
mtkleina45be612016-08-29 15:22:10 -0700373 "//third_party/expat",
mtkleina45be612016-08-29 15:22:10 -0700374 ]
375 sources = [
376 "src/ports/SkFontMgr_android.cpp",
377 "src/ports/SkFontMgr_android_factory.cpp",
378 "src/ports/SkFontMgr_android_parser.cpp",
379 ]
380}
381
mtkleind2e39db2016-09-07 07:52:55 -0700382optional("fontmgr_custom") {
383 enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
384
385 deps = [
Ben Wagnerfc497342017-02-24 11:15:26 -0500386 ":typeface_freetype",
mtkleind2e39db2016-09-07 07:52:55 -0700387 ]
388 sources = [
389 "src/ports/SkFontMgr_custom.cpp",
Ben Wagner8ab590f2017-02-08 17:29:33 -0500390 "src/ports/SkFontMgr_custom.h",
391 "src/ports/SkFontMgr_custom_directory.cpp",
mtkleind2e39db2016-09-07 07:52:55 -0700392 "src/ports/SkFontMgr_custom_directory_factory.cpp",
Ben Wagner8ab590f2017-02-08 17:29:33 -0500393 "src/ports/SkFontMgr_custom_embedded.cpp",
394 "src/ports/SkFontMgr_custom_empty.cpp",
mtkleind2e39db2016-09-07 07:52:55 -0700395 ]
396}
397
mtklein3cc22182016-08-29 13:26:14 -0700398optional("fontmgr_fontconfig") {
399 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700400
401 deps = [
Ben Wagnerfc497342017-02-24 11:15:26 -0500402 ":typeface_freetype",
mtklein3cc22182016-08-29 13:26:14 -0700403 "//third_party:fontconfig",
mtklein3cc22182016-08-29 13:26:14 -0700404 ]
405 sources = [
bungeman1ae0e012016-09-19 12:13:16 -0700406 "src/ports/SkFontConfigInterface.cpp",
mtklein3cc22182016-08-29 13:26:14 -0700407 "src/ports/SkFontConfigInterface_direct.cpp",
408 "src/ports/SkFontConfigInterface_direct_factory.cpp",
409 "src/ports/SkFontMgr_FontConfigInterface.cpp",
410 "src/ports/SkFontMgr_fontconfig.cpp",
411 "src/ports/SkFontMgr_fontconfig_factory.cpp",
412 ]
413}
414
mtkleincdedd0e2016-09-12 15:15:44 -0700415optional("fontmgr_fuchsia") {
416 enabled = is_fuchsia && skia_use_freetype
417
418 deps = [
Ben Wagnerfc497342017-02-24 11:15:26 -0500419 ":typeface_freetype",
mtkleincdedd0e2016-09-12 15:15:44 -0700420 ]
421 sources = [
422 "src/ports/SkFontMgr_custom.cpp",
Ben Wagner8ab590f2017-02-08 17:29:33 -0500423 "src/ports/SkFontMgr_custom_empty.cpp",
mtkleincdedd0e2016-09-12 15:15:44 -0700424 "src/ports/SkFontMgr_custom_empty_factory.cpp",
425 ]
426}
427
Ethan Nicholas762466e2017-06-29 10:03:38 -0400428if (skia_compile_processors) {
429 executable("skslc") {
430 defines = [ "SKSL_STANDALONE" ]
431 sources = [
432 "src/sksl/SkSLMain.cpp",
433 ]
434 sources += skia_sksl_sources
435 include_dirs = [
436 "src/gpu",
437 "src/sksl",
438 ]
439 deps = [
440 "//third_party/spirv-tools",
441 ]
442 }
443
444 skia_gpu_processor_outputs = []
445 foreach(src, skia_gpu_processor_sources) {
446 dir = get_path_info(src, "dir")
447 name = get_path_info(src, "name")
448
449 # GN insists its outputs should go somewhere underneath target_out_dir, so we trick it with a
450 # path that starts with target_out_dir and then uses ".." to back up into the src dir.
451 skia_gpu_processor_outputs += [
452 "$target_out_dir/" + rebase_path("$dir/$name.h", target_out_dir),
453 # the script also modifies the corresponding .cpp file, but if we tell GN that it gets
454 # confused due to the same file being named by two different paths
455 ]
456 }
457
458 action("compile_processors") {
459 script = "gn/compile_processors.py"
460 deps = [
461 ":skslc(//gn/toolchain:$host_toolchain)",
462 ]
463 sources = skia_gpu_processor_sources
464 outputs = skia_gpu_processor_outputs
465 skslc_path = "$root_out_dir/"
466 if (host_toolchain != default_toolchain_name) {
467 skslc_path += "$host_toolchain/"
468 }
469 skslc_path += "skslc"
470 if (host_os == "win") {
471 skslc_path += ".exe"
472 }
473 args = [ rebase_path(skslc_path) ]
474 args += rebase_path(skia_gpu_processor_sources)
475 }
476} else {
477 skia_gpu_processor_outputs = []
478 group("compile_processors") {
479 }
480}
481
mtklein06c35c02016-09-20 12:28:12 -0700482optional("gpu") {
483 enabled = skia_enable_gpu
Ethan Nicholas762466e2017-06-29 10:03:38 -0400484 deps = [
485 ":compile_processors",
486 ]
mtkleine9fb3d52016-09-20 15:11:46 -0700487 public_defines = []
488
Mike Klein29b3e582017-02-09 11:57:32 -0500489 sources = skia_gpu_sources + skia_sksl_sources +
Ethan Nicholas762466e2017-06-29 10:03:38 -0400490 [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ] +
491 skia_gpu_processor_outputs
mtklein06c35c02016-09-20 12:28:12 -0700492
493 # These paths need to be absolute to match the ones produced by shared_sources.gni.
494 sources -= get_path_info([
495 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
496 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
497 ],
498 "abspath")
Mike Klein703cf5a2016-10-13 17:18:04 -0400499 libs = []
mtklein06c35c02016-09-20 12:28:12 -0700500 if (is_android) {
501 sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
Derek Sollenberger7a869872017-06-27 15:37:25 -0400502
503 # this lib is required to link against AHardwareBuffer
504 if (defined(ndk_api) && ndk_api >= 26) {
505 libs += [ "android" ]
506 }
Kevin Lubick4a24e102017-03-29 11:19:01 -0400507 } else if (skia_use_egl) {
508 sources += [ "src/gpu/gl/egl/GrGLCreateNativeInterface_egl.cpp" ]
509 libs += [ "EGL" ]
mtklein06c35c02016-09-20 12:28:12 -0700510 } else if (is_linux) {
511 sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
Mike Kleina979a1d2017-02-23 10:31:13 -0500512 libs += [
513 "GL",
514 "GLU",
515 ]
mtklein06c35c02016-09-20 12:28:12 -0700516 } else if (is_mac) {
517 sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
Chinmay Garde130a1182016-11-23 11:43:56 -0800518 } else if (is_ios) {
519 sources += [ "src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp" ]
Mike Klein703cf5a2016-10-13 17:18:04 -0400520 } else if (is_win) {
521 sources += [ "src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp" ]
522 libs += [ "OpenGL32.lib" ]
mtklein06c35c02016-09-20 12:28:12 -0700523 } else {
524 sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
525 }
mtkleine9fb3d52016-09-20 15:11:46 -0700526
527 if (skia_use_vulkan) {
528 public_defines += [ "SK_VULKAN" ]
529 sources += skia_vk_sources
egdaniele4a9bd72016-09-21 07:36:14 -0700530 if (skia_enable_vulkan_debug_layers) {
531 public_defines += [ "SK_ENABLE_VK_LAYERS" ]
532 }
mtkleine9fb3d52016-09-20 15:11:46 -0700533 }
Ethan Nicholasa6ae1f72017-03-16 09:56:54 -0400534 if (skia_enable_spirv_validation) {
Ethan Nicholas762466e2017-06-29 10:03:38 -0400535 deps += [ "//third_party/spirv-tools" ]
Ethan Nicholasa6ae1f72017-03-16 09:56:54 -0400536 public_defines += [ "SK_ENABLE_SPIRV_VALIDATION" ]
537 }
Greg Daniele5ddff52017-07-05 16:49:36 -0400538
Greg Daniel6b7e0e22017-07-12 16:21:09 -0400539 cflags_objcc = []
Greg Daniele5ddff52017-07-05 16:49:36 -0400540 if (skia_use_metal) {
541 public_defines += [ "SK_METAL" ]
542 sources += skia_metal_sources
543 libs += [ "Metal.framework" ]
Greg Daniel6b7e0e22017-07-12 16:21:09 -0400544 cflags_objcc += [ "-fobjc-arc" ]
Greg Daniele5ddff52017-07-05 16:49:36 -0400545 }
mtklein06c35c02016-09-20 12:28:12 -0700546}
547
mtklein63213812016-08-24 09:55:56 -0700548optional("jpeg") {
549 enabled = skia_use_libjpeg_turbo
550 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
551
mtklein63213812016-08-24 09:55:56 -0700552 deps = [
553 "//third_party/libjpeg-turbo:libjpeg",
554 ]
555 sources = [
556 "src/codec/SkJpegCodec.cpp",
557 "src/codec/SkJpegDecoderMgr.cpp",
558 "src/codec/SkJpegUtility.cpp",
mtklein63213812016-08-24 09:55:56 -0700559 "src/images/SkJPEGWriteUtility.cpp",
Matt Sarett04c37312017-05-05 14:02:13 -0400560 "src/images/SkJpegEncoder.cpp",
mtklein63213812016-08-24 09:55:56 -0700561 ]
562}
563
564optional("pdf") {
Hal Canary43fb7a02016-12-30 13:09:03 -0500565 enabled = skia_use_zlib && skia_enable_pdf
566 public_defines = [ "SK_SUPPORT_PDF" ]
mtklein63213812016-08-24 09:55:56 -0700567
mtklein63213812016-08-24 09:55:56 -0700568 deps = [
569 "//third_party/zlib",
570 ]
brettwb9447282016-09-01 14:24:39 -0700571 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700572 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700573
574 if (skia_use_sfntly) {
575 deps += [ "//third_party/sfntly" ]
Hal Canary43fb7a02016-12-30 13:09:03 -0500576 public_defines += [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700577 }
578}
579
580optional("png") {
581 enabled = skia_use_libpng
582 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
583
mtklein63213812016-08-24 09:55:56 -0700584 deps = [
585 "//third_party/libpng",
586 ]
587 sources = [
588 "src/codec/SkIcoCodec.cpp",
589 "src/codec/SkPngCodec.cpp",
Matt Sarett04c37312017-05-05 14:02:13 -0400590 "src/images/SkPngEncoder.cpp",
mtklein63213812016-08-24 09:55:56 -0700591 ]
592}
593
scroggof84ad642016-10-31 09:02:57 -0700594optional("raw") {
Mike Klein10d665d2016-11-01 11:46:10 -0400595 enabled = skia_use_dng_sdk && skia_use_libjpeg_turbo && skia_use_piex
scroggof84ad642016-10-31 09:02:57 -0700596 public_defines = [ "SK_CODEC_DECODES_RAW" ]
597
598 deps = [
599 "//third_party/dng_sdk",
600 "//third_party/libjpeg-turbo:libjpeg",
601 "//third_party/piex",
602 ]
603
604 # SkRawCodec catches any exceptions thrown by dng_sdk, insulating the rest of
605 # Skia.
606 configs_to_remove = [ "//gn:no_exceptions" ]
607
608 sources = [
609 "src/codec/SkRawAdapterCodec.cpp",
610 "src/codec/SkRawCodec.cpp",
611 ]
612}
613
mtklein3cc22182016-08-29 13:26:14 -0700614optional("typeface_freetype") {
615 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700616
617 deps = [
618 "//third_party/freetype2",
619 ]
620 sources = [
621 "src/ports/SkFontHost_FreeType.cpp",
622 "src/ports/SkFontHost_FreeType_common.cpp",
623 ]
624}
625
mtklein457b42a2016-08-23 13:56:37 -0700626optional("webp") {
627 enabled = skia_use_libwebp
628 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
629
mtklein457b42a2016-08-23 13:56:37 -0700630 deps = [
631 "//third_party/libwebp",
632 ]
633 sources = [
634 "src/codec/SkWebpAdapterCodec.cpp",
635 "src/codec/SkWebpCodec.cpp",
Matt Sarett04c37312017-05-05 14:02:13 -0400636 "src/images/SkWebpEncoder.cpp",
mtklein457b42a2016-08-23 13:56:37 -0700637 ]
mtkleineb3c4252016-08-23 07:38:09 -0700638}
639
mtklein63213812016-08-24 09:55:56 -0700640optional("xml") {
641 enabled = skia_use_expat
Florin Malita442fff92016-11-08 16:07:52 +0000642 public_defines = [ "SK_XML" ]
mtklein63213812016-08-24 09:55:56 -0700643
mtklein63213812016-08-24 09:55:56 -0700644 deps = [
645 "//third_party/expat",
646 ]
647 sources = [
Mike Kleinbd41bcc2017-02-09 16:38:15 -0500648 "src/svg/SkSVGCanvas.cpp",
649 "src/svg/SkSVGDevice.cpp",
mtklein63213812016-08-24 09:55:56 -0700650 "src/xml/SkDOM.cpp",
651 "src/xml/SkXMLParser.cpp",
652 "src/xml/SkXMLWriter.cpp",
653 ]
654}
655
mtkleinc04ff472016-06-23 10:29:30 -0700656component("skia") {
657 public_configs = [ ":skia_public" ]
658 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700659
660 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700661 ":arm64",
662 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700663 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700664 ":crc32",
Mike Kleina04bb452017-02-09 12:24:07 -0500665 ":effects",
mtkleina45be612016-08-29 15:22:10 -0700666 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700667 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700668 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700669 ":fontmgr_fuchsia",
mtklein06c35c02016-09-20 12:28:12 -0700670 ":gpu",
Mike Klein78d5a3b2016-09-30 10:48:01 -0400671 ":hsw",
mtklein63213812016-08-24 09:55:56 -0700672 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700673 ":none",
mtklein63213812016-08-24 09:55:56 -0700674 ":pdf",
675 ":png",
scroggof84ad642016-10-31 09:02:57 -0700676 ":raw",
mtklein9b8583d2016-08-24 17:32:30 -0700677 ":sse2",
678 ":sse41",
679 ":sse42",
680 ":ssse3",
mtkleineb3c4252016-08-23 07:38:09 -0700681 ":webp",
mtklein63213812016-08-24 09:55:56 -0700682 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700683 ]
684
Chinmay Garde43f115c2016-11-16 15:04:12 -0800685 # This file (and all GN files in Skia) are designed to work with an
686 # empty sources assignment filter; we handle all that explicitly.
687 # We clear the filter here for clients who may have set up a global filter.
688 set_sources_assignment_filter([])
689
mtkleinc04ff472016-06-23 10:29:30 -0700690 sources = []
brettwb9447282016-09-01 14:24:39 -0700691 sources += skia_core_sources
brettwb9447282016-09-01 14:24:39 -0700692 sources += skia_utils_sources
Hal Canary6ad3d2f2016-12-20 16:15:56 -0500693 sources += skia_xps_sources
mtkleinc04ff472016-06-23 10:29:30 -0700694 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700695 "src/android/SkBitmapRegionCodec.cpp",
696 "src/android/SkBitmapRegionDecoder.cpp",
697 "src/codec/SkAndroidCodec.cpp",
Leon Scroggins IIId81fed92017-06-01 13:42:28 -0400698 "src/codec/SkBmpBaseCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700699 "src/codec/SkBmpCodec.cpp",
700 "src/codec/SkBmpMaskCodec.cpp",
701 "src/codec/SkBmpRLECodec.cpp",
702 "src/codec/SkBmpStandardCodec.cpp",
703 "src/codec/SkCodec.cpp",
704 "src/codec/SkCodecImageGenerator.cpp",
scroggo19b91532016-10-24 09:03:26 -0700705 "src/codec/SkGifCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700706 "src/codec/SkMaskSwizzler.cpp",
707 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700708 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700709 "src/codec/SkSampler.cpp",
scroggo19b91532016-10-24 09:03:26 -0700710 "src/codec/SkStreamBuffer.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700711 "src/codec/SkSwizzler.cpp",
712 "src/codec/SkWbmpCodec.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700713 "src/images/SkImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700714 "src/ports/SkDiscardableMemory_none.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700715 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700716 "src/ports/SkMemory_malloc.cpp",
717 "src/ports/SkOSFile_stdio.cpp",
718 "src/sfnt/SkOTTable_name.cpp",
719 "src/sfnt/SkOTUtils.cpp",
720 "src/utils/mac/SkStream_mac.cpp",
scroggo3d3a65c2016-10-24 12:28:30 -0700721 "third_party/gif/SkGifImageReader.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700722 ]
brettwb9447282016-09-01 14:24:39 -0700723
mtklein7d6fb2c2016-08-25 14:50:44 -0700724 libs = []
725
mtkleinc04ff472016-06-23 10:29:30 -0700726 if (is_win) {
727 sources += [
Mike Kleinae7e6712016-10-11 17:49:33 -0400728 "src/fonts/SkFontMgr_indirect.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700729 "src/ports/SkDebug_win.cpp",
730 "src/ports/SkFontHost_win.cpp",
731 "src/ports/SkFontMgr_win_dw.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700732 "src/ports/SkImageEncoder_WIC.cpp",
733 "src/ports/SkImageGeneratorWIC.cpp",
734 "src/ports/SkOSFile_win.cpp",
mtklein605d9522016-09-21 14:01:32 -0700735 "src/ports/SkOSLibrary_win.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700736 "src/ports/SkScalerContext_win_dw.cpp",
737 "src/ports/SkTLS_win.cpp",
738 "src/ports/SkTypeface_win_dw.cpp",
739 ]
Mike Klein69f6ed42016-10-13 15:45:07 -0400740 if (skia_use_gdi) {
741 sources += [ "src/ports/SkFontMgr_win_gdi_factory.cpp" ]
742 libs += [
743 "Gdi32.lib",
744 "Usp10.lib",
745 ]
746 } else {
747 sources += [ "src/ports/SkFontMgr_win_dw_factory.cpp" ]
748 }
mtkleinb9be9792016-09-16 14:44:18 -0700749 sources -=
750 [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
Mike Klein4b167fc2016-10-11 18:13:53 -0400751 libs += [
752 "FontSub.lib",
753 "Ole32.lib",
754 "OleAut32.lib",
755 "User32.lib",
756 ]
mtkleinc04ff472016-06-23 10:29:30 -0700757 } else {
758 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700759 "src/ports/SkOSFile_posix.cpp",
mtklein605d9522016-09-21 14:01:32 -0700760 "src/ports/SkOSLibrary_posix.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700761 "src/ports/SkTLS_pthread.cpp",
762 ]
763 }
764
mtklein7d6fb2c2016-08-25 14:50:44 -0700765 if (is_android) {
Mike Klein1c471872017-01-13 15:27:45 -0500766 deps += [ "//third_party/expat" ]
Mike Kleine459afd2017-03-03 09:21:30 -0500767 if (defined(ndk) && ndk != "") {
Mike Klein1c471872017-01-13 15:27:45 -0500768 deps += [ "//third_party/cpu-features" ]
769 }
mtklein06c35c02016-09-20 12:28:12 -0700770 sources += [ "src/ports/SkDebug_android.cpp" ]
mtklein7d6fb2c2016-08-25 14:50:44 -0700771 libs += [
772 "EGL",
773 "GLESv2",
774 "log",
775 ]
776 }
777
mtkleinc04ff472016-06-23 10:29:30 -0700778 if (is_linux) {
mtklein06c35c02016-09-20 12:28:12 -0700779 sources += [ "src/ports/SkDebug_stdio.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700780 }
781
782 if (is_mac) {
783 sources += [
mtklein7d6fb2c2016-08-25 14:50:44 -0700784 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700785 "src/ports/SkFontHost_mac.cpp",
786 "src/ports/SkImageEncoder_CG.cpp",
787 "src/ports/SkImageGeneratorCG.cpp",
788 ]
mtklein09e61f72016-08-23 13:35:28 -0700789 libs += [
bungeman3e306f62017-03-29 11:32:02 -0400790 # AppKit symbols NSFontWeightXXX may be dlsym'ed.
791 "AppKit.framework",
mtklein09e61f72016-08-23 13:35:28 -0700792 "ApplicationServices.framework",
793 "OpenGL.framework",
794 ]
mtkleinc04ff472016-06-23 10:29:30 -0700795 }
abarth6fc8ff02016-07-15 15:15:15 -0700796
Mike Klein7d302882016-11-03 14:06:31 -0400797 if (is_ios) {
798 sources += [
799 "src/ports/SkDebug_stdio.cpp",
800 "src/ports/SkFontHost_mac.cpp",
801 "src/ports/SkImageEncoder_CG.cpp",
802 "src/ports/SkImageGeneratorCG.cpp",
803 ]
804 libs += [
805 "CoreFoundation.framework",
806 "CoreGraphics.framework",
807 "CoreText.framework",
808 "ImageIO.framework",
809 "MobileCoreServices.framework",
bungeman3e306f62017-03-29 11:32:02 -0400810
811 # UIKit symbols UIFontWeightXXX may be dlsym'ed.
812 "UIKit.framework",
Mike Klein7d302882016-11-03 14:06:31 -0400813 ]
814 }
815
abarth6fc8ff02016-07-15 15:15:15 -0700816 if (is_fuchsia) {
mtklein06c35c02016-09-20 12:28:12 -0700817 sources += [ "src/ports/SkDebug_stdio.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700818 }
mtkleinc04ff472016-06-23 10:29:30 -0700819}
820
mtkleinc095df52016-08-24 12:23:52 -0700821# Targets guarded by skia_enable_tools may use //third_party freely.
822if (skia_enable_tools) {
Mike Klein308b5ac2016-12-06 16:03:52 -0500823 # Used by gn_to_bp.py to list our public include dirs.
824 source_set("public") {
825 configs += [ ":skia_public" ]
826 }
827
Mike Kleinc36dedf2016-11-18 09:35:28 -0500828 config("skia.h_config") {
829 include_dirs = [ "$target_gen_dir" ]
830 }
831 action("skia.h") {
832 public_configs = [ ":skia.h_config" ]
833 skia_h = "$target_gen_dir/skia.h"
834 script = "gn/find_headers.py"
Greg Danielc819e662017-04-19 16:39:45 -0400835 args = [ rebase_path(skia_h, root_build_dir) ] +
Robert Phillipsfcd5fdd2017-06-14 01:43:29 +0000836 rebase_path(skia_public_includes)
Mike Kleinc36dedf2016-11-18 09:35:28 -0500837 depfile = "$skia_h.deps"
838 outputs = [
839 skia_h,
840 ]
841 }
842
843 if (skia_enable_gpu && target_cpu == "x64") {
844 # Our bots only have 64-bit libOSMesa installed.
845 # TODO: worth fixing?
846 executable("fiddle") {
847 libs = []
Mike Kleinc36dedf2016-11-18 09:35:28 -0500848 sources = [
Mike Kleinc36dedf2016-11-18 09:35:28 -0500849 "tools/fiddle/draw.cpp",
850 "tools/fiddle/fiddle_main.cpp",
851 ]
Joe Gregorioa8fabd32017-05-31 09:45:19 -0400852
853 if (skia_use_egl) {
854 sources += [ "tools/fiddle/egl_context.cpp" ]
855 } else if (skia_use_mesa) {
856 sources += [ "tools/fiddle/mesa_context.cpp" ]
857 if (is_linux) {
858 libs += [ "OSMesa" ]
859 }
860 } else {
861 sources += [ "tools/fiddle/null_context.cpp" ]
862 }
Joe Gregorio1e735c02017-04-19 14:05:14 -0400863 testonly = true
Mike Kleinc36dedf2016-11-18 09:35:28 -0500864 deps = [
Joe Gregorio1e735c02017-04-19 14:05:14 -0400865 ":flags",
Mike Kleinc36dedf2016-11-18 09:35:28 -0500866 ":skia",
867 ":skia.h",
868 ]
869 }
870 }
871
872 if (skia_enable_gpu) {
873 source_set("public_headers_warnings_check") {
874 sources = [
875 "tools/public_headers_warnings_check.cpp",
876 ]
877 configs -= [ "//gn:warnings_except_public_headers" ]
878 deps = [
879 ":skia",
880 ":skia.h",
881 ]
882 }
883 }
884
mtkleinc095df52016-08-24 12:23:52 -0700885 template("test_lib") {
886 config(target_name + "_config") {
887 include_dirs = invoker.public_include_dirs
mtkleina627b5c2016-09-20 13:36:47 -0700888 if (defined(invoker.public_defines)) {
889 defines = invoker.public_defines
890 }
mtklein25c81d42016-07-27 13:55:26 -0700891 }
mtkleinc095df52016-08-24 12:23:52 -0700892 source_set(target_name) {
893 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
894 public_configs = [
895 ":" + target_name + "_config",
896 ":skia_private",
897 ]
898
899 if (!defined(deps)) {
900 deps = []
901 }
902 deps += [ ":skia" ]
903 testonly = true
904 }
mtklein25c81d42016-07-27 13:55:26 -0700905 }
mtklein25c81d42016-07-27 13:55:26 -0700906
Mike Kleine6682eb2017-01-05 10:54:57 -0500907 template("test_app") {
908 if (defined(invoker.is_shared_library) && invoker.is_shared_library) {
909 shared_library("lib" + target_name) {
910 forward_variables_from(invoker, "*", [ "is_shared_library" ])
911 testonly = true
912 }
913 } else {
Mike Klein7d921032017-01-05 12:20:41 -0500914 _executable = target_name
915 executable(_executable) {
Mike Kleine6682eb2017-01-05 10:54:57 -0500916 forward_variables_from(invoker, "*", [ "is_shared_library" ])
917 testonly = true
918 }
919 }
Mike Klein7d921032017-01-05 12:20:41 -0500920 if (is_android && skia_android_serial != "" && defined(_executable)) {
921 action("push_" + target_name) {
922 script = "gn/push_to_android.py"
923 deps = [
924 ":" + _executable,
925 ]
926 _stamp = "$target_gen_dir/$_executable.pushed_$skia_android_serial"
927 outputs = [
928 _stamp,
929 ]
930 args = [
931 rebase_path("$root_build_dir/$_executable"),
932 skia_android_serial,
933 rebase_path(_stamp),
934 ]
935 testonly = true
936 }
937 }
Mike Kleine6682eb2017-01-05 10:54:57 -0500938 }
939
mtkleinc095df52016-08-24 12:23:52 -0700940 test_lib("gpu_tool_utils") {
mtklein38925aa2016-09-21 10:11:25 -0700941 public_include_dirs = []
942 if (skia_enable_gpu) {
943 public_defines = []
944 public_include_dirs += [ "tools/gpu" ]
mtkleind68f9b02016-09-23 13:18:41 -0700945
946 deps = []
mtklein38925aa2016-09-21 10:11:25 -0700947 sources = [
948 "tools/gpu/GrContextFactory.cpp",
949 "tools/gpu/GrTest.cpp",
950 "tools/gpu/TestContext.cpp",
951 "tools/gpu/gl/GLTestContext.cpp",
mtklein605d9522016-09-21 14:01:32 -0700952 "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
mtklein38925aa2016-09-21 10:11:25 -0700953 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
954 "tools/gpu/gl/debug/GrBufferObj.cpp",
955 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
956 "tools/gpu/gl/debug/GrProgramObj.cpp",
957 "tools/gpu/gl/debug/GrShaderObj.cpp",
958 "tools/gpu/gl/debug/GrTextureObj.cpp",
959 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
960 "tools/gpu/gl/null/NullGLTestContext.cpp",
Brian Salomoncfe910d2017-07-06 16:40:18 -0400961 "tools/gpu/mock/MockTestContext.cpp",
mtklein38925aa2016-09-21 10:11:25 -0700962 ]
963 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700964
Kevin Lubick4a24e102017-03-29 11:19:01 -0400965 if (is_android || skia_use_egl) {
mtklein38925aa2016-09-21 10:11:25 -0700966 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
Mike Klein7d302882016-11-03 14:06:31 -0400967 } else if (is_ios) {
968 sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
969 libs += [ "OpenGLES.framework" ]
mtklein38925aa2016-09-21 10:11:25 -0700970 } else if (is_linux) {
971 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
Mike Kleina979a1d2017-02-23 10:31:13 -0500972 libs += [ "X11" ]
mtklein38925aa2016-09-21 10:11:25 -0700973 } else if (is_mac) {
974 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
Mike Klein4b167fc2016-10-11 18:13:53 -0400975 } else if (is_win) {
976 sources += [ "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp" ]
977 libs += [
978 "Gdi32.lib",
979 "OpenGL32.lib",
980 ]
mtklein38925aa2016-09-21 10:11:25 -0700981 }
mtklein6ef69992016-09-14 06:12:09 -0700982
Greg Daniel6b7e0e22017-07-12 16:21:09 -0400983 cflags_objcc = [ "-fobjc-arc" ]
984
Mike Kleinc168a3a2016-11-14 14:53:13 +0000985 if (skia_use_angle) {
Mike Kleinc168a3a2016-11-14 14:53:13 +0000986 deps += [ "//third_party/angle2" ]
987 sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
988 }
mtklein38925aa2016-09-21 10:11:25 -0700989 if (skia_use_mesa) {
990 public_defines += [ "SK_MESA" ]
991 sources += [ "tools/gpu/gl/mesa/GLTestContext_mesa.cpp" ]
992 libs += [ "OSMesa" ]
993 }
mtkleind68f9b02016-09-23 13:18:41 -0700994 if (skia_use_vulkan) {
995 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
Brian Salomon5db010b2017-04-25 16:05:29 -0400996 if (is_win) {
997 libs += [ "vulkan-1.lib" ]
998 } else {
999 libs += [ "vulkan" ]
1000 }
mtkleind68f9b02016-09-23 13:18:41 -07001001 }
Greg Danielb76a72a2017-07-13 15:07:54 -04001002 if (skia_use_metal) {
1003 sources += [ "tools/gpu/mtl/MtlTestContext.mm" ]
1004 }
mtkleina627b5c2016-09-20 13:36:47 -07001005 }
mtklein25c81d42016-07-27 13:55:26 -07001006 }
mtklein25c81d42016-07-27 13:55:26 -07001007
mtkleinc095df52016-08-24 12:23:52 -07001008 test_lib("flags") {
1009 public_include_dirs = [ "tools/flags" ]
1010 sources = [
1011 "tools/flags/SkCommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -07001012 ]
1013 }
1014 test_lib("common_flags") {
1015 public_include_dirs = [ "tools/flags" ]
1016 sources = [
mtkleinc095df52016-08-24 12:23:52 -07001017 "tools/flags/SkCommonFlags.cpp",
1018 "tools/flags/SkCommonFlagsConfig.cpp",
1019 ]
1020 deps = [
mtklein046cb562016-09-16 10:23:12 -07001021 ":flags",
mtkleinc095df52016-08-24 12:23:52 -07001022 ":gpu_tool_utils",
1023 ]
1024 }
mtklein25c81d42016-07-27 13:55:26 -07001025
mtkleinc095df52016-08-24 12:23:52 -07001026 test_lib("tool_utils") {
1027 public_include_dirs = [
1028 "tools",
1029 "tools/debugger",
1030 "tools/timer",
Brian Salomondcbb9d92017-07-19 10:53:20 -04001031 "tools/trace",
mtkleinc095df52016-08-24 12:23:52 -07001032 ]
1033 sources = [
mtkleinb37c0342016-09-09 11:07:45 -07001034 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001035 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -07001036 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001037 "tools/ProcStats.cpp",
1038 "tools/Resources.cpp",
1039 "tools/ThermalManager.cpp",
1040 "tools/UrlDataManager.cpp",
1041 "tools/debugger/SkDebugCanvas.cpp",
1042 "tools/debugger/SkDrawCommand.cpp",
1043 "tools/debugger/SkJsonWriteBuffer.cpp",
1044 "tools/debugger/SkObjectParser.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001045 "tools/picture_utils.cpp",
1046 "tools/random_parse_path.cpp",
1047 "tools/sk_tool_utils.cpp",
1048 "tools/sk_tool_utils_font.cpp",
1049 "tools/timer/Timer.cpp",
Brian Salomondcbb9d92017-07-19 10:53:20 -04001050 "tools/trace/SkDebugfTracer.cpp",
1051 "tools/trace/SkDebugfTracer.h",
mtkleinc095df52016-08-24 12:23:52 -07001052 ]
Mike Kleinadacaef2017-02-06 09:26:14 -05001053 libs = []
1054 if (is_ios) {
1055 sources += [ "tools/ios_utils.m" ]
1056 libs += [ "Foundation.framework" ]
1057 }
mtkleinc095df52016-08-24 12:23:52 -07001058 deps = [
mtklein046cb562016-09-16 10:23:12 -07001059 ":common_flags",
mtkleinc095df52016-08-24 12:23:52 -07001060 ":flags",
1061 "//third_party/libpng",
1062 ]
1063 public_deps = [
1064 "//third_party/jsoncpp",
1065 ]
1066 }
mtklein25c81d42016-07-27 13:55:26 -07001067
Mike Klein6e744122016-10-27 12:21:40 -04001068 import("gn/gm.gni")
mtkleinc095df52016-08-24 12:23:52 -07001069 test_lib("gm") {
1070 public_include_dirs = [ "gm" ]
1071 sources = gm_sources
1072 deps = [
scroggo19b91532016-10-24 09:03:26 -07001073 ":flags",
mtkleinc095df52016-08-24 12:23:52 -07001074 ":gpu_tool_utils",
1075 ":skia",
1076 ":tool_utils",
1077 ]
1078 }
mtklein25c81d42016-07-27 13:55:26 -07001079
Mike Klein6e744122016-10-27 12:21:40 -04001080 import("gn/tests.gni")
mtkleinc095df52016-08-24 12:23:52 -07001081 test_lib("tests") {
1082 public_include_dirs = [ "tests" ]
Mike Klein6e744122016-10-27 12:21:40 -04001083 sources = tests_sources + pathops_tests_sources
mtkleina45be612016-08-29 15:22:10 -07001084 if (!fontmgr_android_enabled) {
Mike Klein6e744122016-10-27 12:21:40 -04001085 sources -= [ "//tests/FontMgrAndroidParserTest.cpp" ]
mtkleina45be612016-08-29 15:22:10 -07001086 }
mtkleinc095df52016-08-24 12:23:52 -07001087 deps = [
fmalita6cf896d2016-08-25 08:44:35 -07001088 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -07001089 ":flags",
mtkleinc095df52016-08-24 12:23:52 -07001090 ":skia",
1091 ":tool_utils",
1092 "//third_party/libpng",
1093 "//third_party/zlib",
1094 ]
Mike Kleind63442d2017-03-27 14:16:04 -04001095 public_deps = [
1096 ":gpu_tool_utils", # Test.h #includes headers from this target.
1097 ]
mtkleinc095df52016-08-24 12:23:52 -07001098 }
mtklein2f3416d2016-08-02 16:02:05 -07001099
Mike Klein6e744122016-10-27 12:21:40 -04001100 import("gn/bench.gni")
mtkleinc095df52016-08-24 12:23:52 -07001101 test_lib("bench") {
1102 public_include_dirs = [ "bench" ]
1103 sources = bench_sources
mtkleinc095df52016-08-24 12:23:52 -07001104 deps = [
1105 ":flags",
1106 ":gm",
1107 ":gpu_tool_utils",
1108 ":skia",
1109 ":tool_utils",
1110 ]
1111 }
mtklein2b6870c2016-07-28 14:17:33 -07001112
mtkleinc095df52016-08-24 12:23:52 -07001113 test_lib("experimental_svg_model") {
1114 public_include_dirs = [ "experimental/svg/model" ]
1115 sources = [
1116 "experimental/svg/model/SkSVGAttribute.cpp",
1117 "experimental/svg/model/SkSVGAttributeParser.cpp",
1118 "experimental/svg/model/SkSVGCircle.cpp",
Florin Malitace8840e2016-12-08 09:26:47 -05001119 "experimental/svg/model/SkSVGClipPath.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001120 "experimental/svg/model/SkSVGContainer.cpp",
1121 "experimental/svg/model/SkSVGDOM.cpp",
1122 "experimental/svg/model/SkSVGEllipse.cpp",
1123 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -07001124 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001125 "experimental/svg/model/SkSVGNode.cpp",
1126 "experimental/svg/model/SkSVGPath.cpp",
1127 "experimental/svg/model/SkSVGPoly.cpp",
1128 "experimental/svg/model/SkSVGRect.cpp",
1129 "experimental/svg/model/SkSVGRenderContext.cpp",
1130 "experimental/svg/model/SkSVGSVG.cpp",
1131 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -07001132 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -07001133 "experimental/svg/model/SkSVGTransformableNode.cpp",
1134 "experimental/svg/model/SkSVGValue.cpp",
1135 ]
1136 deps = [
1137 ":skia",
1138 ]
1139 }
fmalitaa2b9fdf2016-08-03 19:53:36 -07001140
Brian Osman16adfa32016-10-18 14:42:44 -04001141 test_lib("views") {
1142 public_include_dirs = [ "include/views" ]
1143 sources = [
1144 "src/views/SkEvent.cpp",
1145 "src/views/SkEventSink.cpp",
1146 "src/views/SkOSMenu.cpp",
1147 "src/views/SkTagList.cpp",
1148 "src/views/SkTouchGesture.cpp",
1149 "src/views/SkView.cpp",
1150 "src/views/SkViewPriv.cpp",
1151 ]
1152 libs = []
Brian Osman34755e22016-12-05 09:46:02 -05001153 deps = []
Brian Osman16adfa32016-10-18 14:42:44 -04001154 if (!is_android) {
1155 sources += [ "src/views/SkWindow.cpp" ]
1156 }
Jim Van Verth4e56a912016-10-21 10:58:52 -04001157 if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -04001158 public_include_dirs += [ "src/views/unix" ]
1159 sources += [
1160 "src/views/unix/SkOSWindow_Unix.cpp",
1161 "src/views/unix/keysym2ucs.c",
1162 ]
Mike Kleina979a1d2017-02-23 10:31:13 -05001163 libs += [
1164 "GL",
1165 "X11",
1166 ]
Brian Osman16adfa32016-10-18 14:42:44 -04001167 } else if (is_mac) {
1168 sources += [
1169 "src/views/mac/SkEventNotifier.mm",
1170 "src/views/mac/SkNSView.mm",
1171 "src/views/mac/SkOSWindow_Mac.mm",
1172 "src/views/mac/SkTextFieldCell.m",
1173 ]
1174 libs += [
1175 "QuartzCore.framework",
1176 "Cocoa.framework",
1177 "Foundation.framework",
1178 ]
1179 } else if (is_win) {
1180 sources += [ "src/views/win/SkOSWindow_win.cpp" ]
1181 }
Brian Osman34755e22016-12-05 09:46:02 -05001182 if (skia_use_angle) {
1183 deps += [ "//third_party/angle2" ]
1184 }
Brian Osman16adfa32016-10-18 14:42:44 -04001185 }
1186
Mike Klein38af9432016-11-11 11:39:44 -05001187 if (skia_use_lua) {
1188 test_lib("lua") {
1189 public_include_dirs = []
1190 sources = [
1191 "src/utils/SkLua.cpp",
1192 "src/utils/SkLuaCanvas.cpp",
1193 ]
1194 deps = [
1195 "//third_party/lua",
1196 ]
1197 }
1198
Mike Kleine6682eb2017-01-05 10:54:57 -05001199 test_app("lua_app") {
Mike Klein38af9432016-11-11 11:39:44 -05001200 sources = [
1201 "tools/lua/lua_app.cpp",
1202 ]
1203 deps = [
1204 ":lua",
1205 ":skia",
1206 "//third_party/lua",
1207 ]
Mike Klein38af9432016-11-11 11:39:44 -05001208 }
1209
Mike Kleine6682eb2017-01-05 10:54:57 -05001210 test_app("lua_pictures") {
Mike Klein38af9432016-11-11 11:39:44 -05001211 sources = [
1212 "tools/lua/lua_pictures.cpp",
1213 ]
1214 deps = [
1215 ":flags",
1216 ":lua",
1217 ":skia",
1218 ":tool_utils",
1219 "//third_party/lua",
1220 ]
Mike Klein38af9432016-11-11 11:39:44 -05001221 }
1222 }
1223
Mike Klein6e744122016-10-27 12:21:40 -04001224 import("gn/samples.gni")
Brian Osman16adfa32016-10-18 14:42:44 -04001225 test_lib("samples") {
Brian Osman16adfa32016-10-18 14:42:44 -04001226 public_include_dirs = [ "samplecode" ]
Mike Klein6e744122016-10-27 12:21:40 -04001227 include_dirs = [ "experimental" ]
1228 sources = samples_sources + [
Mike Klein6e744122016-10-27 12:21:40 -04001229 "experimental/SkSetPoly3To3.cpp",
1230 "experimental/SkSetPoly3To3_A.cpp",
1231 "experimental/SkSetPoly3To3_D.cpp",
Brian Osmancff94e42017-06-26 13:12:37 -04001232
1233 # Relocating these files here, so that clients don't try to build them while they're
1234 # still in active development. Clang's thread safety analysis gets tripped up by
1235 # conditional locks.
1236 "src/core/SkThreadedBMPDevice.cpp",
1237 "src/core/SkThreadedBMPDevice.h",
Mike Klein6e744122016-10-27 12:21:40 -04001238 ]
Brian Osman16adfa32016-10-18 14:42:44 -04001239 deps = [
1240 ":experimental_svg_model",
csmartdalton8c679092017-03-27 12:32:29 -06001241 ":flags",
Mike Klein6e744122016-10-27 12:21:40 -04001242 ":gm",
Brian Osman16adfa32016-10-18 14:42:44 -04001243 ":tool_utils",
1244 ":views",
1245 ":xml",
1246 ]
Mike Klein38af9432016-11-11 11:39:44 -05001247
1248 if (skia_use_lua) {
1249 sources += [ "samplecode/SampleLua.cpp" ]
1250 deps += [
1251 ":lua",
1252 "//third_party/lua",
1253 ]
1254 }
Brian Osman16adfa32016-10-18 14:42:44 -04001255 }
1256
Mike Kleine6682eb2017-01-05 10:54:57 -05001257 test_app("dm") {
mtklein2b6870c2016-07-28 14:17:33 -07001258 sources = [
1259 "dm/DM.cpp",
1260 "dm/DMJsonWriter.cpp",
1261 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -07001262 ]
1263 include_dirs = [ "tests" ]
1264 deps = [
mtklein046cb562016-09-16 10:23:12 -07001265 ":common_flags",
fmalitaa2b9fdf2016-08-03 19:53:36 -07001266 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -07001267 ":flags",
1268 ":gm",
1269 ":gpu_tool_utils",
1270 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -07001271 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -07001272 ":tool_utils",
1273 "//third_party/jsoncpp",
1274 "//third_party/libpng",
1275 ]
mtklein2b6870c2016-07-28 14:17:33 -07001276 }
1277
Mike Klein06432b22017-03-21 13:14:33 -04001278 test_app("ok") {
1279 sources = [
1280 "tools/ok.cpp",
Mike Klein7ac04832017-03-25 11:29:41 -04001281 "tools/ok_dsts.cpp",
1282 "tools/ok_srcs.cpp",
Mike Kleind63442d2017-03-27 14:16:04 -04001283 "tools/ok_test.cpp",
Mike Kleinf5d1a552017-03-25 12:32:22 -04001284 "tools/ok_vias.cpp",
Mike Klein06432b22017-03-21 13:14:33 -04001285 ]
1286 deps = [
1287 ":gm",
1288 ":skia",
Mike Kleind63442d2017-03-27 14:16:04 -04001289 ":tests",
Mike Klein62669ad2017-05-09 16:03:07 -04001290 ":tool_utils",
Mike Klein06432b22017-03-21 13:14:33 -04001291 ]
1292 }
1293
Mike Kleina3430172016-09-27 16:46:29 -04001294 if (!is_debug) { # I've benchmarked debug code once too many times...
Mike Kleine6682eb2017-01-05 10:54:57 -05001295 test_app("monobench") {
Mike Kleina3430172016-09-27 16:46:29 -04001296 sources = [
1297 "tools/monobench.cpp",
1298 ]
1299 deps = [
1300 ":bench",
1301 ":skia",
1302 ]
Mike Kleina3430172016-09-27 16:46:29 -04001303 }
mtklein2b6870c2016-07-28 14:17:33 -07001304 }
1305
Mike Kleine6682eb2017-01-05 10:54:57 -05001306 test_app("nanobench") {
mtklein2b6870c2016-07-28 14:17:33 -07001307 sources = [
1308 "bench/nanobench.cpp",
1309 ]
1310 deps = [
1311 ":bench",
mtklein046cb562016-09-16 10:23:12 -07001312 ":common_flags",
fmalita6519c212016-09-14 08:05:17 -07001313 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -07001314 ":flags",
1315 ":gm",
1316 ":gpu_tool_utils",
1317 ":skia",
1318 ":tool_utils",
1319 "//third_party/jsoncpp",
1320 ]
mtklein2b6870c2016-07-28 14:17:33 -07001321 }
halcanary19a97202016-08-03 15:08:04 -07001322
Ravi Mistry10d36c52017-01-31 09:49:18 -05001323 test_app("skpinfo") {
1324 sources = [
1325 "tools/skpinfo.cpp",
1326 ]
1327 deps = [
1328 ":flags",
1329 ":skia",
1330 ]
1331 }
1332
Jim Van Verth57a98fc2016-10-28 13:35:50 -04001333 if (is_linux || is_win || is_mac) {
Mike Kleine6682eb2017-01-05 10:54:57 -05001334 test_app("SampleApp") {
mtklein38925aa2016-09-21 10:11:25 -07001335 sources = [
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001336 "samplecode/SampleApp.cpp",
1337 "samplecode/SamplePictFile.cpp",
mtklein38925aa2016-09-21 10:11:25 -07001338 ]
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001339 if (is_mac) {
1340 sources += [ "src/views/mac/skia_mac.mm" ]
1341 } else if (is_win) {
1342 sources += [ "src/views/win/skia_win.cpp" ]
1343 } else if (is_linux) {
1344 sources += [ "src/views/unix/skia_unix.cpp" ]
1345 }
mtklein38925aa2016-09-21 10:11:25 -07001346 deps = [
1347 ":flags",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001348 ":gm",
mtklein38925aa2016-09-21 10:11:25 -07001349 ":gpu_tool_utils",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001350 ":samples",
mtklein38925aa2016-09-21 10:11:25 -07001351 ":skia",
1352 ":tool_utils",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001353 ":views",
mtklein38925aa2016-09-21 10:11:25 -07001354 ]
Mike Kleinc168a3a2016-11-14 14:53:13 +00001355 if (skia_use_angle) {
1356 deps += [ "//third_party/angle2" ]
1357 }
mtklein38925aa2016-09-21 10:11:25 -07001358 }
Jim Van Verth8f5468f2016-10-31 09:52:33 -04001359 }
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001360
Jim Van Verth8f5468f2016-10-31 09:52:33 -04001361 if (skia_enable_gpu) {
Mike Kleine6682eb2017-01-05 10:54:57 -05001362 test_app("skpbench") {
Jim Van Verth8f5468f2016-10-31 09:52:33 -04001363 sources = [
1364 "tools/skpbench/skpbench.cpp",
1365 ]
1366 deps = [
1367 ":flags",
1368 ":gpu_tool_utils",
1369 ":skia",
1370 ":tool_utils",
1371 ]
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001372 }
csmartdalton4b5179b2016-09-19 11:03:58 -07001373 }
1374
Mike Klein7d302882016-11-03 14:06:31 -04001375 # We can't yet build ICU on iOS or Windows.
1376 if (!is_ios && !is_win) {
Mike Kleine6682eb2017-01-05 10:54:57 -05001377 test_app("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -07001378 sources = [
1379 "tools/SkShaper_harfbuzz.cpp",
1380 "tools/using_skia_and_harfbuzz.cpp",
1381 ]
1382 deps = [
1383 ":skia",
1384 "//third_party/harfbuzz",
1385 ]
mtklein6f5df6a2016-08-29 16:01:10 -07001386 }
halcanary19a97202016-08-03 15:08:04 -07001387 }
Mike Kleine6682eb2017-01-05 10:54:57 -05001388 test_app("sktexttopdf") {
halcanary3eee9d92016-09-10 07:01:53 -07001389 sources = [
1390 "tools/SkShaper_primitive.cpp",
1391 "tools/using_skia_and_harfbuzz.cpp",
1392 ]
1393 deps = [
1394 ":skia",
1395 ]
halcanary3eee9d92016-09-10 07:01:53 -07001396 }
mtklein046cb562016-09-16 10:23:12 -07001397
Matt Sarett9f1c4032017-05-17 10:06:32 -04001398 test_app("create_flutter_test_images") {
1399 sources = [
1400 "tools/create_flutter_test_images.cpp",
1401 ]
1402 deps = [
1403 ":skia",
1404 ":tool_utils",
1405 ]
1406 }
1407
Mike Kleine6682eb2017-01-05 10:54:57 -05001408 test_app("get_images_from_skps") {
mtklein046cb562016-09-16 10:23:12 -07001409 sources = [
1410 "tools/get_images_from_skps.cpp",
1411 ]
1412 deps = [
1413 ":flags",
1414 ":skia",
1415 "//third_party/jsoncpp",
1416 ]
mtklein046cb562016-09-16 10:23:12 -07001417 }
mtkleinecbc5262016-09-22 11:51:24 -07001418
Mike Kleine6682eb2017-01-05 10:54:57 -05001419 test_app("colorspaceinfo") {
Matt Sarett8740d582016-11-11 13:59:14 -05001420 sources = [
1421 "tools/colorspaceinfo.cpp",
1422 ]
1423 deps = [
1424 ":flags",
1425 ":skia",
1426 ":tool_utils",
1427 ]
Matt Sarett8740d582016-11-11 13:59:14 -05001428 }
1429
Mike Klein7d302882016-11-03 14:06:31 -04001430 if (!is_ios) {
Mike Kleine6682eb2017-01-05 10:54:57 -05001431 test_app("skiaserve") {
Mike Klein7d302882016-11-03 14:06:31 -04001432 sources = [
1433 "tools/skiaserve/Request.cpp",
1434 "tools/skiaserve/Response.cpp",
1435 "tools/skiaserve/skiaserve.cpp",
Mike Klein7d302882016-11-03 14:06:31 -04001436 "tools/skiaserve/urlhandlers/BreakHandler.cpp",
1437 "tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp",
1438 "tools/skiaserve/urlhandlers/CmdHandler.cpp",
1439 "tools/skiaserve/urlhandlers/ColorModeHandler.cpp",
1440 "tools/skiaserve/urlhandlers/DataHandler.cpp",
1441 "tools/skiaserve/urlhandlers/DownloadHandler.cpp",
1442 "tools/skiaserve/urlhandlers/EnableGPUHandler.cpp",
1443 "tools/skiaserve/urlhandlers/ImgHandler.cpp",
1444 "tools/skiaserve/urlhandlers/InfoHandler.cpp",
Brian Salomon144a5c52016-12-20 16:48:59 -05001445 "tools/skiaserve/urlhandlers/OpBoundsHandler.cpp",
1446 "tools/skiaserve/urlhandlers/OpsHandler.cpp",
Mike Klein7d302882016-11-03 14:06:31 -04001447 "tools/skiaserve/urlhandlers/OverdrawHandler.cpp",
1448 "tools/skiaserve/urlhandlers/PostHandler.cpp",
1449 "tools/skiaserve/urlhandlers/QuitHandler.cpp",
1450 "tools/skiaserve/urlhandlers/RootHandler.cpp",
1451 ]
1452 deps = [
1453 ":flags",
1454 ":gpu_tool_utils",
1455 ":skia",
1456 ":tool_utils",
1457 "//third_party/jsoncpp",
1458 "//third_party/libmicrohttpd",
1459 "//third_party/libpng",
1460 ]
Mike Klein7d302882016-11-03 14:06:31 -04001461 }
mtkleinecbc5262016-09-22 11:51:24 -07001462 }
kjlubick14f984b2016-10-03 11:49:45 -07001463
Mike Kleine6682eb2017-01-05 10:54:57 -05001464 test_app("fuzz") {
kjlubick14f984b2016-10-03 11:49:45 -07001465 sources = [
1466 "fuzz/FilterFuzz.cpp",
Hal Canary24ac42b2017-02-14 13:35:14 -05001467 "fuzz/FuzzCanvas.cpp",
Kevin Lubickfec1dea2016-11-22 13:57:18 -05001468 "fuzz/FuzzDrawFunctions.cpp",
kjlubick14f984b2016-10-03 11:49:45 -07001469 "fuzz/FuzzGradients.cpp",
1470 "fuzz/FuzzParsePath.cpp",
1471 "fuzz/FuzzPathop.cpp",
1472 "fuzz/FuzzScaleToSides.cpp",
1473 "fuzz/fuzz.cpp",
1474 ]
1475 deps = [
1476 ":flags",
Hal Canary44801ca2017-03-15 11:39:06 -04001477 ":gpu_tool_utils",
kjlubick14f984b2016-10-03 11:49:45 -07001478 ":skia",
Hal Canarydb683012016-11-23 08:55:18 -07001479 ":tool_utils",
kjlubick14f984b2016-10-03 11:49:45 -07001480 ]
kjlubick14f984b2016-10-03 11:49:45 -07001481 }
Mike Klein38312422016-10-05 15:41:01 -04001482
Mike Kleine6682eb2017-01-05 10:54:57 -05001483 test_app("pathops_unittest") {
Mike Klein6e744122016-10-27 12:21:40 -04001484 sources = pathops_tests_sources + [
Mike Klein6e55fef2016-10-26 11:41:47 -04001485 rebase_path("tests/skia_test.cpp"),
1486 rebase_path("tests/Test.cpp"),
1487 ]
caryclark9feb6322016-10-25 08:58:26 -07001488 deps = [
1489 ":flags",
1490 ":gpu_tool_utils",
1491 ":skia",
1492 ":tool_utils",
1493 ]
caryclark9feb6322016-10-25 08:58:26 -07001494 }
1495
Mike Kleine6682eb2017-01-05 10:54:57 -05001496 test_app("dump_record") {
Mike Klein38312422016-10-05 15:41:01 -04001497 sources = [
1498 "tools/DumpRecord.cpp",
1499 "tools/dump_record.cpp",
1500 ]
1501 deps = [
1502 ":flags",
1503 ":skia",
1504 ]
Mike Klein38312422016-10-05 15:41:01 -04001505 }
bungemanfe917272016-10-13 17:36:40 -04001506
Mike Kleine6682eb2017-01-05 10:54:57 -05001507 test_app("skdiff") {
bungemanfe917272016-10-13 17:36:40 -04001508 sources = [
1509 "tools/skdiff/skdiff.cpp",
1510 "tools/skdiff/skdiff_html.cpp",
1511 "tools/skdiff/skdiff_main.cpp",
1512 "tools/skdiff/skdiff_utils.cpp",
1513 ]
1514 deps = [
1515 ":skia",
1516 ":tool_utils",
1517 ]
bungemanfe917272016-10-13 17:36:40 -04001518 }
halcanarya73d76a2016-10-17 13:19:02 -07001519
Mike Kleine6682eb2017-01-05 10:54:57 -05001520 test_app("skp_parser") {
halcanarya73d76a2016-10-17 13:19:02 -07001521 sources = [
1522 "tools/skp_parser.cpp",
1523 ]
1524 deps = [
1525 ":skia",
1526 ":tool_utils",
1527 "//third_party/jsoncpp",
1528 ]
halcanarya73d76a2016-10-17 13:19:02 -07001529 }
Brian Osman16adfa32016-10-18 14:42:44 -04001530
Mike Kleina92c3832016-12-08 09:49:39 -05001531 if (skia_enable_gpu && (is_android || is_linux || is_win || is_mac)) {
Mike Kleine6682eb2017-01-05 10:54:57 -05001532 test_app("viewer") {
1533 is_shared_library = is_android
Brian Osman16adfa32016-10-18 14:42:44 -04001534 sources = [
1535 "tools/viewer/GMSlide.cpp",
1536 "tools/viewer/ImageSlide.cpp",
1537 "tools/viewer/SKPSlide.cpp",
1538 "tools/viewer/SampleSlide.cpp",
1539 "tools/viewer/Viewer.cpp",
1540 "tools/viewer/sk_app/CommandSet.cpp",
1541 "tools/viewer/sk_app/GLWindowContext.cpp",
1542 "tools/viewer/sk_app/Window.cpp",
Brian Osman16adfa32016-10-18 14:42:44 -04001543 ]
Brian Osman2dd96932016-10-18 15:33:53 -04001544 libs = []
Brian Osman16adfa32016-10-18 14:42:44 -04001545
Jim Van Verth4e56a912016-10-21 10:58:52 -04001546 if (is_android) {
1547 sources += [
1548 "tools/viewer/sk_app/android/GLWindowContext_android.cpp",
1549 "tools/viewer/sk_app/android/RasterWindowContext_android.cpp",
1550 "tools/viewer/sk_app/android/Window_android.cpp",
1551 "tools/viewer/sk_app/android/main_android.cpp",
1552 "tools/viewer/sk_app/android/surface_glue_android.cpp",
1553 ]
Brian Osman462334e2017-02-09 11:22:57 -05001554 libs += [ "android" ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001555 } else if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -04001556 sources += [
1557 "tools/viewer/sk_app/unix/GLWindowContext_unix.cpp",
1558 "tools/viewer/sk_app/unix/RasterWindowContext_unix.cpp",
1559 "tools/viewer/sk_app/unix/Window_unix.cpp",
1560 "tools/viewer/sk_app/unix/main_unix.cpp",
1561 ]
1562 } else if (is_win) {
Brian Osman16adfa32016-10-18 14:42:44 -04001563 sources += [
1564 "tools/viewer/sk_app/win/GLWindowContext_win.cpp",
1565 "tools/viewer/sk_app/win/RasterWindowContext_win.cpp",
1566 "tools/viewer/sk_app/win/Window_win.cpp",
1567 "tools/viewer/sk_app/win/main_win.cpp",
1568 ]
Mike Klein43c25262016-10-20 10:17:47 -04001569 } else if (is_mac) {
1570 sources += [
1571 "tools/viewer/sk_app/mac/GLWindowContext_mac.cpp",
1572 "tools/viewer/sk_app/mac/RasterWindowContext_mac.cpp",
1573 "tools/viewer/sk_app/mac/Window_mac.cpp",
1574 "tools/viewer/sk_app/mac/main_mac.cpp",
1575 ]
Brian Osman16adfa32016-10-18 14:42:44 -04001576 }
1577
1578 if (skia_use_vulkan) {
1579 sources += [ "tools/viewer/sk_app/VulkanWindowContext.cpp" ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001580 if (is_android) {
1581 sources +=
1582 [ "tools/viewer/sk_app/android/VulkanWindowContext_android.cpp" ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001583 } else if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -04001584 sources += [ "tools/viewer/sk_app/unix/VulkanWindowContext_unix.cpp" ]
1585 libs += [ "X11-xcb" ]
1586 } else if (is_win) {
Brian Osman16adfa32016-10-18 14:42:44 -04001587 sources += [ "tools/viewer/sk_app/win/VulkanWindowContext_win.cpp" ]
1588 }
1589 }
1590
1591 include_dirs = []
1592 deps = [
1593 ":flags",
1594 ":gm",
1595 ":gpu_tool_utils",
1596 ":samples",
1597 ":skia",
1598 ":tool_utils",
1599 ":views",
Brian Osman79086b92017-02-10 13:36:16 -05001600 "//third_party/imgui",
Brian Osman16adfa32016-10-18 14:42:44 -04001601 "//third_party/jsoncpp",
1602 ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001603 if (is_android) {
1604 deps += [ "//third_party/native_app_glue" ]
1605 } else if (is_mac) {
Mike Klein43c25262016-10-20 10:17:47 -04001606 deps += [ "//third_party/libsdl" ]
1607 }
Mike Kleina92c3832016-12-08 09:49:39 -05001608 }
Brian Osman16adfa32016-10-18 14:42:44 -04001609 }
Ethan Nicholas4f3985c2016-11-14 11:16:37 -05001610
Jim Van Verth4c70c752017-07-11 12:03:01 -04001611 if (skia_enable_gpu && (is_linux || is_mac)) {
1612 test_app("SkiaSDLExample") {
1613 sources = [
1614 "example/SkiaSDLExample.cpp",
1615 ]
1616 libs = []
1617 include_dirs = []
1618 deps = [
1619 ":gpu_tool_utils",
1620 ":skia",
1621 "//third_party/libsdl",
1622 ]
1623 }
1624 }
1625
Mike Kleine459afd2017-03-03 09:21:30 -05001626 if (is_android && defined(ndk) && ndk != "") {
Derek Sollenberger70120c72017-01-05 11:39:04 -05001627 copy("gdbserver") {
1628 sources = [
1629 "$ndk/$ndk_gdbserver",
1630 ]
1631 outputs = [
1632 "$root_out_dir/gdbserver",
1633 ]
1634 }
Derek Sollenberger70120c72017-01-05 11:39:04 -05001635 }
mtklein25c81d42016-07-27 13:55:26 -07001636}
Mike Kleinc55a6cb2017-06-28 13:21:47 -04001637
1638if (skia_jumper_clang != "") {
1639 action("regen_jumper") {
1640 script = "src/jumper/build_stages.py"
1641
1642 inputs = [
1643 "src/jumper/SkJumper_stages.cpp",
1644 "src/jumper/SkJumper_stages_lowp.cpp",
1645 ]
1646
1647 # GN insists its outputs should go somewhere underneath target_out_dir, so we trick it.
1648 outputs = [
1649 "$target_out_dir/" +
1650 rebase_path("src/jumper/SkJumper_generated.S", target_out_dir),
1651 "$target_out_dir/" +
1652 rebase_path("src/jumper/SkJumper_generated_win.S", target_out_dir),
1653 ]
1654
1655 args = [
1656 skia_jumper_clang,
1657 skia_jumper_objdump,
1658 skia_jumper_ccache,
1659 ] + rebase_path(inputs) + rebase_path(outputs)
1660 }
1661}