blob: a04809240ee7200df1d16faaec91c84fa55d0b76 [file] [log] [blame]
mtkleinc04ff472016-06-23 10:29:30 -07001# Copyright 2016 Google Inc.
2#
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
Mike Kleincfc4f442016-10-26 17:19:03 -04006import("gn/android_framework_defines.gni")
mikejurka8c24f4f2016-09-12 16:51:58 -07007import("gn/shared_sources.gni")
brettwb9447282016-09-01 14:24:39 -07008
mtklein3e8012e2016-09-21 09:14:19 -07009if (!defined(is_skia_standalone)) {
10 is_skia_standalone = false
11}
12
mtkleinc04ff472016-06-23 10:29:30 -070013declare_args() {
Mike Kleinc168a3a2016-11-14 14:53:13 +000014 skia_use_angle = false
mtklein63213812016-08-24 09:55:56 -070015 skia_use_expat = true
mtklein3cc22182016-08-29 13:26:14 -070016 skia_use_fontconfig = is_linux
mtkleincdedd0e2016-09-12 15:15:44 -070017 skia_use_freetype = is_android || is_fuchsia || is_linux
Mike Klein69f6ed42016-10-13 15:45:07 -040018 skia_use_gdi = false
Mike Klein7d302882016-11-03 14:06:31 -040019 skia_use_icu = !is_fuchsia && !is_ios && !is_win # TODO: Windows
mtklein63213812016-08-24 09:55:56 -070020 skia_use_libjpeg_turbo = true
21 skia_use_libpng = true
mtkleineb3c4252016-08-23 07:38:09 -070022 skia_use_libwebp = !is_fuchsia
Mike Klein38af9432016-11-11 11:39:44 -050023 skia_use_lua = false
mtkleina627b5c2016-09-20 13:36:47 -070024 skia_use_mesa = false
Mike Klein10d665d2016-11-01 11:46:10 -040025 skia_use_piex = !is_win
mtklein63213812016-08-24 09:55:56 -070026 skia_use_zlib = true
mtklein1bd72ba2016-09-16 07:45:52 -070027
28 skia_enable_android_framework_defines = false
mtklein06c35c02016-09-20 12:28:12 -070029 skia_enable_gpu = true
mtklein3e8012e2016-09-21 09:14:19 -070030 skia_enable_tools = is_skia_standalone
31 skia_enable_vulkan_debug_layers = is_skia_standalone && is_debug
Greg Daniel686bb212016-10-27 10:48:48 -040032 skia_vulkan_sdk = getenv("VULKAN_SDK")
mtkleinc04ff472016-06-23 10:29:30 -070033}
Brian Salomon23d73ea2016-10-27 13:31:37 -040034declare_args() {
James Robinson14b748d2016-11-12 18:29:39 -080035 skia_use_dng_sdk =
36 !is_fuchsia && !is_win && skia_use_libjpeg_turbo && skia_use_zlib
Mike Klein10d665d2016-11-01 11:46:10 -040037 skia_use_sfntly = skia_use_icu
38
Mike Klein4d598a32016-10-31 13:44:49 -040039 if (is_android) {
40 skia_use_vulkan = defined(ndk_api) && ndk_api >= 24
41 } else {
42 skia_use_vulkan = skia_vulkan_sdk != ""
43 }
Brian Salomon23d73ea2016-10-27 13:31:37 -040044}
Brian Salomon789e25e2016-09-30 13:41:03 -040045
mtklein38925aa2016-09-21 10:11:25 -070046# Our tools require static linking (they use non-exported symbols).
47skia_enable_tools = skia_enable_tools && !is_component_build
mtklein06c35c02016-09-20 12:28:12 -070048
mtkleina45be612016-08-29 15:22:10 -070049fontmgr_android_enabled = skia_use_expat && skia_use_freetype
50
mtklein1211e0c2016-07-26 13:55:45 -070051skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070052 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070053 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070054 "include/codec",
55 "include/config",
56 "include/core",
57 "include/effects",
58 "include/gpu",
59 "include/gpu/gl",
60 "include/images",
61 "include/pathops",
62 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070063 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070064 "include/utils",
65 "include/utils/mac",
mtklein25c81d42016-07-27 13:55:26 -070066 "include/xml",
mtklein1211e0c2016-07-26 13:55:45 -070067]
68
mtkleinc04ff472016-06-23 10:29:30 -070069# Skia public API, generally provided by :skia.
70config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -070071 include_dirs = skia_public_includes
Mike Kleinae7e6712016-10-11 17:49:33 -040072 defines = []
73 if (is_component_build) {
74 defines += [ "SKIA_DLL" ]
75 }
Mike Kleinc4cbd742016-09-26 21:37:09 -040076 if (is_fuchsia || is_linux) {
jcgregorio5561e3d2016-08-25 09:25:11 -070077 defines += [ "SK_SAMPLES_FOR_X" ]
78 }
mtkleincae1be52016-09-20 08:24:34 -070079 if (skia_enable_android_framework_defines) {
Mike Kleincfc4f442016-10-26 17:19:03 -040080 defines += android_framework_defines
mtkleincae1be52016-09-20 08:24:34 -070081 }
mtklein06c35c02016-09-20 12:28:12 -070082 if (!skia_enable_gpu) {
83 defines += [ "SK_SUPPORT_GPU=0" ]
84 }
mtkleinc04ff472016-06-23 10:29:30 -070085}
86
87# Skia internal APIs, used by Skia itself and a few test tools.
88config("skia_private") {
89 visibility = [ ":*" ]
90
91 include_dirs = [
92 "include/private",
93 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -070094 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -070095 "src/core",
96 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -070097 "src/effects/gradients",
98 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -070099 "src/gpu",
100 "src/image",
101 "src/images",
102 "src/lazy",
103 "src/opts",
104 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -0700105 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -0700106 "src/ports",
107 "src/sfnt",
mtklein9e0d9dd2016-08-30 10:37:19 -0700108 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -0700109 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -0700110 "src/utils/win",
mtkleinc04ff472016-06-23 10:29:30 -0700111 "third_party/etc1",
scroggo19b91532016-10-24 09:03:26 -0700112 "third_party/gif",
Leon Scroggins427da6f2016-12-16 13:51:59 +0000113 "third_party/ktx",
mtkleinc04ff472016-06-23 10:29:30 -0700114 ]
mtklein150d1132016-08-01 06:56:40 -0700115
Jim Van Verthb6c5e532016-10-28 10:38:08 -0400116 defines = [
117 "SK_GAMMA_APPLY_TO_A8",
118 "SK_INTERNAL",
119 ]
mtkleinb37c0342016-09-09 11:07:45 -0700120 if (is_android) {
121 defines += [
122 "SK_GAMMA_EXPONENT=1.4",
123 "SK_GAMMA_CONTRAST=0.0",
124 ]
125 }
mtklein88a7ac02016-09-14 11:16:49 -0700126 if (is_official_build || is_android) {
127 # TODO(bsalomon): it'd be nice to make Android normal.
128 defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
129 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400130 libs = []
131 lib_dirs = []
132 if (skia_use_vulkan) {
Greg Danielab563d42016-10-31 11:19:59 -0400133 if (skia_vulkan_sdk != "" && !is_android) {
Mike Klein487bfc22016-10-14 14:04:56 -0400134 if (is_win) {
135 include_dirs += [ "$skia_vulkan_sdk/Include/" ]
136 lib_dirs += [ "$skia_vulkan_sdk/Bin" ]
137 } else {
Greg Daniel686bb212016-10-27 10:48:48 -0400138 include_dirs += [ "$skia_vulkan_sdk/include/" ]
139 lib_dirs += [ "$skia_vulkan_sdk/lib/" ]
Mike Klein487bfc22016-10-14 14:04:56 -0400140 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400141 }
Mike Klein487bfc22016-10-14 14:04:56 -0400142 if (is_win) {
143 libs += [ "vulkan-1.lib" ]
144 } else {
145 libs += [ "vulkan" ]
146 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400147 }
Brian Osman34755e22016-12-05 09:46:02 -0500148 if (skia_use_angle) {
149 defines += [ "SK_ANGLE" ]
150 }
mtkleinc04ff472016-06-23 10:29:30 -0700151}
152
153# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
154config("skia_library") {
155 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -0700156 defines = [ "SKIA_IMPLEMENTATION=1" ]
157}
158
159skia_library_configs = [
160 ":skia_public",
161 ":skia_private",
162 ":skia_library",
163]
164
mtklein9b8583d2016-08-24 17:32:30 -0700165# Use for CPU-specific Skia code that needs particular compiler flags.
166template("opts") {
167 if (invoker.enabled) {
168 source_set(target_name) {
169 forward_variables_from(invoker, "*")
170 configs += skia_library_configs
171 }
172 } else {
173 # If not enabled, a phony empty target that swallows all otherwise unused variables.
174 source_set(target_name) {
175 forward_variables_from(invoker,
176 "*",
177 [
178 "sources",
179 "cflags",
180 ])
181 }
182 }
anmittala7eaf2e2016-08-17 13:57:26 -0700183}
184
mtklein422310d2016-08-16 18:28:43 -0700185is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700186
mtklein7d6fb2c2016-08-25 14:50:44 -0700187opts("none") {
188 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700189 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700190 cflags = []
191}
192
mtklein7d6fb2c2016-08-25 14:50:44 -0700193opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700194 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700195 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700196 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700197}
198
199opts("arm64") {
200 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700201 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700202 cflags = []
203}
204
205opts("crc32") {
206 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700207 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700208 cflags = [ "-march=armv8-a+crc" ]
209}
210
mtklein9b8583d2016-08-24 17:32:30 -0700211opts("sse2") {
212 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700213 sources = skia_opts.sse2_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400214 if (is_win) {
215 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE2" ]
216 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400217 cflags = [ "-msse2" ]
218 }
mtklein9b8583d2016-08-24 17:32:30 -0700219}
mtkleinc04ff472016-06-23 10:29:30 -0700220
mtklein9b8583d2016-08-24 17:32:30 -0700221opts("ssse3") {
222 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700223 sources = skia_opts.ssse3_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400224 if (is_win) {
225 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSSE3" ]
226 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400227 cflags = [ "-mssse3" ]
228 }
mtklein9b8583d2016-08-24 17:32:30 -0700229}
mtkleinc04ff472016-06-23 10:29:30 -0700230
mtklein9b8583d2016-08-24 17:32:30 -0700231opts("sse41") {
232 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700233 sources = skia_opts.sse41_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400234 if (is_win) {
235 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE41" ]
236 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400237 cflags = [ "-msse4.1" ]
238 }
mtklein9b8583d2016-08-24 17:32:30 -0700239}
mtklein4e976072016-08-08 09:06:27 -0700240
mtklein9b8583d2016-08-24 17:32:30 -0700241opts("sse42") {
242 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700243 sources = skia_opts.sse42_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400244 if (is_win) {
245 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE42" ]
246 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400247 cflags = [ "-msse4.2" ]
248 }
mtklein9b8583d2016-08-24 17:32:30 -0700249}
250
251opts("avx") {
252 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700253 sources = skia_opts.avx_sources
Mike Klein3eb71212016-10-11 17:08:53 -0400254 if (is_win) {
Mike Klein17b6e482016-11-18 22:11:41 +0000255 cflags = [ "/arch:AVX" ]
Mike Klein3eb71212016-10-11 17:08:53 -0400256 } else {
257 cflags = [ "-mavx" ]
258 }
mtkleinc04ff472016-06-23 10:29:30 -0700259}
260
Mike Klein78d5a3b2016-09-30 10:48:01 -0400261opts("hsw") {
262 enabled = is_x86
263 sources = skia_opts.hsw_sources
Mike Klein3eb71212016-10-11 17:08:53 -0400264 if (is_win) {
Mike Klein17b6e482016-11-18 22:11:41 +0000265 cflags = [ "/arch:AVX2" ]
Mike Klein3eb71212016-10-11 17:08:53 -0400266 } else {
267 cflags = [
268 "-mavx2",
269 "-mbmi",
270 "-mbmi2",
271 "-mf16c",
272 "-mfma",
273 ]
274 }
Mike Klein78d5a3b2016-09-30 10:48:01 -0400275}
276
mtklein349cece2016-08-26 08:13:04 -0700277opts("dsp") {
278 enabled = current_cpu == "mipsel"
brettwb9447282016-09-01 14:24:39 -0700279 sources = skia_opts.mips_dsp_sources
mtkleinb6064ef2016-08-30 11:49:24 -0700280 cflags = []
mtklein349cece2016-08-26 08:13:04 -0700281}
282
mtkleinc095df52016-08-24 12:23:52 -0700283# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700284template("optional") {
285 if (invoker.enabled) {
286 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700287 if (defined(invoker.public_defines)) {
288 defines = invoker.public_defines
289 }
mtklein457b42a2016-08-23 13:56:37 -0700290 }
291 source_set(target_name) {
mtkleincd01b032016-08-31 04:58:19 -0700292 forward_variables_from(invoker,
293 "*",
294 [
295 "public_defines",
296 "sources_when_disabled",
scroggof84ad642016-10-31 09:02:57 -0700297 "configs_to_remove",
mtkleincd01b032016-08-31 04:58:19 -0700298 ])
mtklein457b42a2016-08-23 13:56:37 -0700299 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700300 configs += skia_library_configs
scroggof84ad642016-10-31 09:02:57 -0700301 if (defined(invoker.configs_to_remove)) {
302 configs -= invoker.configs_to_remove
303 }
mtklein457b42a2016-08-23 13:56:37 -0700304 }
305 } else {
mtklein457b42a2016-08-23 13:56:37 -0700306 source_set(target_name) {
307 forward_variables_from(invoker,
308 "*",
309 [
310 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700311 "deps",
mtklein6ef69992016-09-14 06:12:09 -0700312 "libs",
mtklein457b42a2016-08-23 13:56:37 -0700313 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700314 "sources_when_disabled",
scroggof84ad642016-10-31 09:02:57 -0700315 "configs_to_remove",
mtklein457b42a2016-08-23 13:56:37 -0700316 ])
mtkleincd01b032016-08-31 04:58:19 -0700317 if (defined(invoker.sources_when_disabled)) {
318 sources = invoker.sources_when_disabled
319 }
320 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700321 }
mtkleineb3c4252016-08-23 07:38:09 -0700322 }
mtklein457b42a2016-08-23 13:56:37 -0700323}
mtklein457b42a2016-08-23 13:56:37 -0700324
mtkleina45be612016-08-29 15:22:10 -0700325optional("fontmgr_android") {
326 enabled = fontmgr_android_enabled
mtkleina45be612016-08-29 15:22:10 -0700327
328 deps = [
329 "//third_party/expat",
330 "//third_party/freetype2",
331 ]
332 sources = [
333 "src/ports/SkFontMgr_android.cpp",
334 "src/ports/SkFontMgr_android_factory.cpp",
335 "src/ports/SkFontMgr_android_parser.cpp",
336 ]
337}
338
mtkleind2e39db2016-09-07 07:52:55 -0700339optional("fontmgr_custom") {
340 enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
341
342 deps = [
343 "//third_party/freetype2",
344 ]
345 sources = [
346 "src/ports/SkFontMgr_custom.cpp",
347 "src/ports/SkFontMgr_custom_directory_factory.cpp",
348 ]
349}
350
mtklein3cc22182016-08-29 13:26:14 -0700351optional("fontmgr_fontconfig") {
352 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700353
354 deps = [
355 "//third_party:fontconfig",
356 "//third_party/freetype2",
357 ]
358 sources = [
bungeman1ae0e012016-09-19 12:13:16 -0700359 "src/ports/SkFontConfigInterface.cpp",
mtklein3cc22182016-08-29 13:26:14 -0700360 "src/ports/SkFontConfigInterface_direct.cpp",
361 "src/ports/SkFontConfigInterface_direct_factory.cpp",
362 "src/ports/SkFontMgr_FontConfigInterface.cpp",
363 "src/ports/SkFontMgr_fontconfig.cpp",
364 "src/ports/SkFontMgr_fontconfig_factory.cpp",
365 ]
366}
367
mtkleincdedd0e2016-09-12 15:15:44 -0700368optional("fontmgr_fuchsia") {
369 enabled = is_fuchsia && skia_use_freetype
370
371 deps = [
372 "//third_party/freetype2",
373 ]
374 sources = [
375 "src/ports/SkFontMgr_custom.cpp",
376 "src/ports/SkFontMgr_custom_empty_factory.cpp",
377 ]
378}
379
mtklein06c35c02016-09-20 12:28:12 -0700380optional("gpu") {
381 enabled = skia_enable_gpu
mtkleine9fb3d52016-09-20 15:11:46 -0700382 public_defines = []
383
mtklein06c35c02016-09-20 12:28:12 -0700384 sources = skia_gpu_sources + [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ]
385
386 # These paths need to be absolute to match the ones produced by shared_sources.gni.
387 sources -= get_path_info([
388 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
389 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
390 ],
391 "abspath")
Mike Klein703cf5a2016-10-13 17:18:04 -0400392 libs = []
mtklein06c35c02016-09-20 12:28:12 -0700393 if (is_android) {
394 sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
395 } else if (is_linux) {
396 sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
397 } else if (is_mac) {
398 sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
Chinmay Garde130a1182016-11-23 11:43:56 -0800399 } else if (is_ios) {
400 sources += [ "src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp" ]
Mike Klein703cf5a2016-10-13 17:18:04 -0400401 } else if (is_win) {
402 sources += [ "src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp" ]
403 libs += [ "OpenGL32.lib" ]
mtklein06c35c02016-09-20 12:28:12 -0700404 } else {
405 sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
406 }
mtkleine9fb3d52016-09-20 15:11:46 -0700407
408 if (skia_use_vulkan) {
409 public_defines += [ "SK_VULKAN" ]
410 sources += skia_vk_sources
egdaniele4a9bd72016-09-21 07:36:14 -0700411 if (skia_enable_vulkan_debug_layers) {
412 public_defines += [ "SK_ENABLE_VK_LAYERS" ]
413 }
mtkleine9fb3d52016-09-20 15:11:46 -0700414 }
mtklein06c35c02016-09-20 12:28:12 -0700415}
416
mtklein63213812016-08-24 09:55:56 -0700417optional("jpeg") {
418 enabled = skia_use_libjpeg_turbo
419 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
420
mtklein63213812016-08-24 09:55:56 -0700421 deps = [
422 "//third_party/libjpeg-turbo:libjpeg",
423 ]
424 sources = [
425 "src/codec/SkJpegCodec.cpp",
426 "src/codec/SkJpegDecoderMgr.cpp",
427 "src/codec/SkJpegUtility.cpp",
428 "src/images/SkJPEGImageEncoder.cpp",
429 "src/images/SkJPEGWriteUtility.cpp",
430 ]
431}
432
433optional("pdf") {
434 enabled = skia_use_zlib
mtklein63213812016-08-24 09:55:56 -0700435
mtklein63213812016-08-24 09:55:56 -0700436 deps = [
437 "//third_party/zlib",
438 ]
brettwb9447282016-09-01 14:24:39 -0700439 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700440 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700441
442 if (skia_use_sfntly) {
443 deps += [ "//third_party/sfntly" ]
mtkleincd01b032016-08-31 04:58:19 -0700444 public_defines = [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700445 }
446}
447
448optional("png") {
449 enabled = skia_use_libpng
450 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
451
mtklein63213812016-08-24 09:55:56 -0700452 deps = [
453 "//third_party/libpng",
454 ]
455 sources = [
456 "src/codec/SkIcoCodec.cpp",
457 "src/codec/SkPngCodec.cpp",
458 "src/images/SkPNGImageEncoder.cpp",
459 ]
460}
461
scroggof84ad642016-10-31 09:02:57 -0700462optional("raw") {
Mike Klein10d665d2016-11-01 11:46:10 -0400463 enabled = skia_use_dng_sdk && skia_use_libjpeg_turbo && skia_use_piex
scroggof84ad642016-10-31 09:02:57 -0700464 public_defines = [ "SK_CODEC_DECODES_RAW" ]
465
466 deps = [
467 "//third_party/dng_sdk",
468 "//third_party/libjpeg-turbo:libjpeg",
469 "//third_party/piex",
470 ]
471
472 # SkRawCodec catches any exceptions thrown by dng_sdk, insulating the rest of
473 # Skia.
474 configs_to_remove = [ "//gn:no_exceptions" ]
475
476 sources = [
477 "src/codec/SkRawAdapterCodec.cpp",
478 "src/codec/SkRawCodec.cpp",
479 ]
480}
481
mtklein3cc22182016-08-29 13:26:14 -0700482optional("typeface_freetype") {
483 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700484
485 deps = [
486 "//third_party/freetype2",
487 ]
488 sources = [
489 "src/ports/SkFontHost_FreeType.cpp",
490 "src/ports/SkFontHost_FreeType_common.cpp",
491 ]
492}
493
mtklein457b42a2016-08-23 13:56:37 -0700494optional("webp") {
495 enabled = skia_use_libwebp
496 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
497
mtklein457b42a2016-08-23 13:56:37 -0700498 deps = [
499 "//third_party/libwebp",
500 ]
501 sources = [
502 "src/codec/SkWebpAdapterCodec.cpp",
503 "src/codec/SkWebpCodec.cpp",
504 "src/images/SkWEBPImageEncoder.cpp",
505 ]
mtkleineb3c4252016-08-23 07:38:09 -0700506}
507
mtklein63213812016-08-24 09:55:56 -0700508optional("xml") {
509 enabled = skia_use_expat
Florin Malita442fff92016-11-08 16:07:52 +0000510 public_defines = [ "SK_XML" ]
mtklein63213812016-08-24 09:55:56 -0700511
mtklein63213812016-08-24 09:55:56 -0700512 deps = [
513 "//third_party/expat",
514 ]
515 sources = [
516 "src/xml/SkDOM.cpp",
517 "src/xml/SkXMLParser.cpp",
518 "src/xml/SkXMLWriter.cpp",
519 ]
520}
521
mtkleinc04ff472016-06-23 10:29:30 -0700522component("skia") {
523 public_configs = [ ":skia_public" ]
524 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700525
526 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700527 ":arm64",
528 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700529 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700530 ":crc32",
mtklein349cece2016-08-26 08:13:04 -0700531 ":dsp",
mtkleina45be612016-08-29 15:22:10 -0700532 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700533 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700534 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700535 ":fontmgr_fuchsia",
mtklein06c35c02016-09-20 12:28:12 -0700536 ":gpu",
Mike Klein78d5a3b2016-09-30 10:48:01 -0400537 ":hsw",
mtklein63213812016-08-24 09:55:56 -0700538 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700539 ":none",
mtklein63213812016-08-24 09:55:56 -0700540 ":pdf",
541 ":png",
scroggof84ad642016-10-31 09:02:57 -0700542 ":raw",
mtklein9b8583d2016-08-24 17:32:30 -0700543 ":sse2",
544 ":sse41",
545 ":sse42",
546 ":ssse3",
mtklein3cc22182016-08-29 13:26:14 -0700547 ":typeface_freetype",
mtkleineb3c4252016-08-23 07:38:09 -0700548 ":webp",
mtklein63213812016-08-24 09:55:56 -0700549 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700550 ]
551
Chinmay Garde43f115c2016-11-16 15:04:12 -0800552 # This file (and all GN files in Skia) are designed to work with an
553 # empty sources assignment filter; we handle all that explicitly.
554 # We clear the filter here for clients who may have set up a global filter.
555 set_sources_assignment_filter([])
556
mtkleinc04ff472016-06-23 10:29:30 -0700557 sources = []
brettwb9447282016-09-01 14:24:39 -0700558 sources += skia_core_sources
559 sources += skia_effects_sources
brettwb9447282016-09-01 14:24:39 -0700560 sources += skia_sksl_sources
561 sources += skia_utils_sources
mtkleinc04ff472016-06-23 10:29:30 -0700562 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700563 "src/android/SkBitmapRegionCodec.cpp",
564 "src/android/SkBitmapRegionDecoder.cpp",
565 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700566 "src/codec/SkBmpCodec.cpp",
567 "src/codec/SkBmpMaskCodec.cpp",
568 "src/codec/SkBmpRLECodec.cpp",
569 "src/codec/SkBmpStandardCodec.cpp",
570 "src/codec/SkCodec.cpp",
571 "src/codec/SkCodecImageGenerator.cpp",
scroggo19b91532016-10-24 09:03:26 -0700572 "src/codec/SkGifCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700573 "src/codec/SkMaskSwizzler.cpp",
574 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700575 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700576 "src/codec/SkSampler.cpp",
scroggo19b91532016-10-24 09:03:26 -0700577 "src/codec/SkStreamBuffer.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700578 "src/codec/SkSwizzler.cpp",
579 "src/codec/SkWbmpCodec.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700580 "src/images/SkImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700581 "src/ports/SkDiscardableMemory_none.cpp",
582 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700583 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700584 "src/ports/SkMemory_malloc.cpp",
585 "src/ports/SkOSFile_stdio.cpp",
586 "src/sfnt/SkOTTable_name.cpp",
587 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700588 "src/svg/SkSVGCanvas.cpp",
589 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700590 "src/utils/mac/SkStream_mac.cpp",
591 "third_party/etc1/etc1.cpp",
scroggo3d3a65c2016-10-24 12:28:30 -0700592 "third_party/gif/SkGifImageReader.cpp",
Leon Scroggins427da6f2016-12-16 13:51:59 +0000593 "third_party/ktx/ktx.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700594 ]
brettwb9447282016-09-01 14:24:39 -0700595
mtklein7d6fb2c2016-08-25 14:50:44 -0700596 libs = []
597
mtkleinc04ff472016-06-23 10:29:30 -0700598 if (is_win) {
599 sources += [
Mike Kleinae7e6712016-10-11 17:49:33 -0400600 "src/fonts/SkFontMgr_indirect.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700601 "src/ports/SkDebug_win.cpp",
602 "src/ports/SkFontHost_win.cpp",
603 "src/ports/SkFontMgr_win_dw.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700604 "src/ports/SkImageEncoder_WIC.cpp",
605 "src/ports/SkImageGeneratorWIC.cpp",
606 "src/ports/SkOSFile_win.cpp",
mtklein605d9522016-09-21 14:01:32 -0700607 "src/ports/SkOSLibrary_win.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700608 "src/ports/SkScalerContext_win_dw.cpp",
609 "src/ports/SkTLS_win.cpp",
610 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700611 "src/xps/SkDocument_XPS.cpp",
Mike Klein4b167fc2016-10-11 18:13:53 -0400612 "src/xps/SkXPSDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700613 ]
Mike Klein69f6ed42016-10-13 15:45:07 -0400614 if (skia_use_gdi) {
615 sources += [ "src/ports/SkFontMgr_win_gdi_factory.cpp" ]
616 libs += [
617 "Gdi32.lib",
618 "Usp10.lib",
619 ]
620 } else {
621 sources += [ "src/ports/SkFontMgr_win_dw_factory.cpp" ]
622 }
mtkleinb9be9792016-09-16 14:44:18 -0700623 sources -=
624 [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
Mike Klein4b167fc2016-10-11 18:13:53 -0400625 libs += [
626 "FontSub.lib",
627 "Ole32.lib",
628 "OleAut32.lib",
629 "User32.lib",
630 ]
mtkleinc04ff472016-06-23 10:29:30 -0700631 } else {
632 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700633 "src/ports/SkOSFile_posix.cpp",
mtklein605d9522016-09-21 14:01:32 -0700634 "src/ports/SkOSLibrary_posix.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700635 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700636 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700637 ]
638 }
639
mtklein7d6fb2c2016-08-25 14:50:44 -0700640 if (is_android) {
Mike Kleinc3083332016-12-12 09:03:56 -0500641 deps += [ "//third_party/expat" ]
mtklein06c35c02016-09-20 12:28:12 -0700642 sources += [ "src/ports/SkDebug_android.cpp" ]
mtklein7d6fb2c2016-08-25 14:50:44 -0700643 libs += [
644 "EGL",
645 "GLESv2",
646 "log",
647 ]
648 }
649
mtkleinc04ff472016-06-23 10:29:30 -0700650 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700651 libs += [
652 "GL",
653 "GLU",
654 "X11",
655 ]
mtklein06c35c02016-09-20 12:28:12 -0700656 sources += [ "src/ports/SkDebug_stdio.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700657 }
658
659 if (is_mac) {
660 sources += [
mtklein7d6fb2c2016-08-25 14:50:44 -0700661 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700662 "src/ports/SkFontHost_mac.cpp",
663 "src/ports/SkImageEncoder_CG.cpp",
664 "src/ports/SkImageGeneratorCG.cpp",
665 ]
mtklein09e61f72016-08-23 13:35:28 -0700666 libs += [
667 "ApplicationServices.framework",
668 "OpenGL.framework",
669 ]
mtkleinc04ff472016-06-23 10:29:30 -0700670 }
abarth6fc8ff02016-07-15 15:15:15 -0700671
Mike Klein7d302882016-11-03 14:06:31 -0400672 if (is_ios) {
673 sources += [
674 "src/ports/SkDebug_stdio.cpp",
675 "src/ports/SkFontHost_mac.cpp",
676 "src/ports/SkImageEncoder_CG.cpp",
677 "src/ports/SkImageGeneratorCG.cpp",
678 ]
679 libs += [
680 "CoreFoundation.framework",
681 "CoreGraphics.framework",
682 "CoreText.framework",
683 "ImageIO.framework",
684 "MobileCoreServices.framework",
685 ]
686 }
687
abarth6fc8ff02016-07-15 15:15:15 -0700688 if (is_fuchsia) {
mtklein06c35c02016-09-20 12:28:12 -0700689 sources += [ "src/ports/SkDebug_stdio.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700690 }
mtkleinc04ff472016-06-23 10:29:30 -0700691}
692
mtkleinc095df52016-08-24 12:23:52 -0700693# Targets guarded by skia_enable_tools may use //third_party freely.
694if (skia_enable_tools) {
Mike Klein308b5ac2016-12-06 16:03:52 -0500695 # Used by gn_to_bp.py to list our public include dirs.
696 source_set("public") {
697 configs += [ ":skia_public" ]
698 }
699
Mike Kleinc36dedf2016-11-18 09:35:28 -0500700 config("skia.h_config") {
701 include_dirs = [ "$target_gen_dir" ]
702 }
703 action("skia.h") {
704 public_configs = [ ":skia.h_config" ]
705 skia_h = "$target_gen_dir/skia.h"
706 script = "gn/find_headers.py"
707 args = [ rebase_path(skia_h, root_build_dir) ] +
708 rebase_path(skia_public_includes)
709 depfile = "$skia_h.deps"
710 outputs = [
711 skia_h,
712 ]
713 }
714
715 if (skia_enable_gpu && target_cpu == "x64") {
716 # Our bots only have 64-bit libOSMesa installed.
717 # TODO: worth fixing?
718 executable("fiddle") {
719 libs = []
720 if (is_linux) {
721 libs += [ "OSMesa" ]
722 }
723
724 sources = [
Mike Kleinc36dedf2016-11-18 09:35:28 -0500725 "tools/fiddle/draw.cpp",
726 "tools/fiddle/fiddle_main.cpp",
727 ]
728 deps = [
729 ":skia",
730 ":skia.h",
731 ]
732 }
733 }
734
735 if (skia_enable_gpu) {
736 source_set("public_headers_warnings_check") {
737 sources = [
738 "tools/public_headers_warnings_check.cpp",
739 ]
740 configs -= [ "//gn:warnings_except_public_headers" ]
741 deps = [
742 ":skia",
743 ":skia.h",
744 ]
745 }
746 }
747
mtkleinc095df52016-08-24 12:23:52 -0700748 template("test_lib") {
749 config(target_name + "_config") {
750 include_dirs = invoker.public_include_dirs
mtkleina627b5c2016-09-20 13:36:47 -0700751 if (defined(invoker.public_defines)) {
752 defines = invoker.public_defines
753 }
mtklein25c81d42016-07-27 13:55:26 -0700754 }
mtkleinc095df52016-08-24 12:23:52 -0700755 source_set(target_name) {
756 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
757 public_configs = [
758 ":" + target_name + "_config",
759 ":skia_private",
760 ]
761
762 if (!defined(deps)) {
763 deps = []
764 }
765 deps += [ ":skia" ]
766 testonly = true
767 }
mtklein25c81d42016-07-27 13:55:26 -0700768 }
mtklein25c81d42016-07-27 13:55:26 -0700769
mtkleinc095df52016-08-24 12:23:52 -0700770 test_lib("gpu_tool_utils") {
mtklein38925aa2016-09-21 10:11:25 -0700771 public_include_dirs = []
772 if (skia_enable_gpu) {
773 public_defines = []
774 public_include_dirs += [ "tools/gpu" ]
mtkleind68f9b02016-09-23 13:18:41 -0700775
776 deps = []
mtklein38925aa2016-09-21 10:11:25 -0700777 sources = [
778 "tools/gpu/GrContextFactory.cpp",
779 "tools/gpu/GrTest.cpp",
780 "tools/gpu/TestContext.cpp",
781 "tools/gpu/gl/GLTestContext.cpp",
mtklein605d9522016-09-21 14:01:32 -0700782 "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
mtklein38925aa2016-09-21 10:11:25 -0700783 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
784 "tools/gpu/gl/debug/GrBufferObj.cpp",
785 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
786 "tools/gpu/gl/debug/GrProgramObj.cpp",
787 "tools/gpu/gl/debug/GrShaderObj.cpp",
788 "tools/gpu/gl/debug/GrTextureObj.cpp",
789 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
790 "tools/gpu/gl/null/NullGLTestContext.cpp",
791 ]
792 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700793
mtklein38925aa2016-09-21 10:11:25 -0700794 if (is_android) {
795 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
Mike Klein7d302882016-11-03 14:06:31 -0400796 } else if (is_ios) {
797 sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
798 libs += [ "OpenGLES.framework" ]
mtklein38925aa2016-09-21 10:11:25 -0700799 } else if (is_linux) {
800 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
801 } else if (is_mac) {
802 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
Mike Klein4b167fc2016-10-11 18:13:53 -0400803 } else if (is_win) {
804 sources += [ "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp" ]
805 libs += [
806 "Gdi32.lib",
807 "OpenGL32.lib",
808 ]
mtklein38925aa2016-09-21 10:11:25 -0700809 }
mtklein6ef69992016-09-14 06:12:09 -0700810
Mike Kleinc168a3a2016-11-14 14:53:13 +0000811 if (skia_use_angle) {
Mike Kleinc168a3a2016-11-14 14:53:13 +0000812 deps += [ "//third_party/angle2" ]
813 sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
814 }
mtklein38925aa2016-09-21 10:11:25 -0700815 if (skia_use_mesa) {
816 public_defines += [ "SK_MESA" ]
817 sources += [ "tools/gpu/gl/mesa/GLTestContext_mesa.cpp" ]
818 libs += [ "OSMesa" ]
819 }
mtkleind68f9b02016-09-23 13:18:41 -0700820 if (skia_use_vulkan) {
821 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
822 }
mtkleina627b5c2016-09-20 13:36:47 -0700823 }
mtklein25c81d42016-07-27 13:55:26 -0700824 }
mtklein25c81d42016-07-27 13:55:26 -0700825
mtkleinc095df52016-08-24 12:23:52 -0700826 test_lib("flags") {
827 public_include_dirs = [ "tools/flags" ]
828 sources = [
829 "tools/flags/SkCommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -0700830 ]
831 }
832 test_lib("common_flags") {
833 public_include_dirs = [ "tools/flags" ]
834 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700835 "tools/flags/SkCommonFlags.cpp",
836 "tools/flags/SkCommonFlagsConfig.cpp",
837 ]
838 deps = [
mtklein046cb562016-09-16 10:23:12 -0700839 ":flags",
mtkleinc095df52016-08-24 12:23:52 -0700840 ":gpu_tool_utils",
841 ]
842 }
mtklein25c81d42016-07-27 13:55:26 -0700843
mtkleinc095df52016-08-24 12:23:52 -0700844 test_lib("tool_utils") {
845 public_include_dirs = [
846 "tools",
847 "tools/debugger",
848 "tools/timer",
849 ]
850 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700851 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700852 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700853 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700854 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700855 "tools/ProcStats.cpp",
856 "tools/Resources.cpp",
857 "tools/ThermalManager.cpp",
858 "tools/UrlDataManager.cpp",
859 "tools/debugger/SkDebugCanvas.cpp",
860 "tools/debugger/SkDrawCommand.cpp",
861 "tools/debugger/SkJsonWriteBuffer.cpp",
862 "tools/debugger/SkObjectParser.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700863 "tools/picture_utils.cpp",
864 "tools/random_parse_path.cpp",
865 "tools/sk_tool_utils.cpp",
866 "tools/sk_tool_utils_font.cpp",
867 "tools/timer/Timer.cpp",
868 ]
869 deps = [
mtklein046cb562016-09-16 10:23:12 -0700870 ":common_flags",
mtkleinc095df52016-08-24 12:23:52 -0700871 ":flags",
872 "//third_party/libpng",
873 ]
874 public_deps = [
875 "//third_party/jsoncpp",
876 ]
877 }
mtklein25c81d42016-07-27 13:55:26 -0700878
Mike Klein6e744122016-10-27 12:21:40 -0400879 import("gn/gm.gni")
mtkleinc095df52016-08-24 12:23:52 -0700880 test_lib("gm") {
881 public_include_dirs = [ "gm" ]
882 sources = gm_sources
883 deps = [
scroggo19b91532016-10-24 09:03:26 -0700884 ":flags",
mtkleinc095df52016-08-24 12:23:52 -0700885 ":gpu_tool_utils",
886 ":skia",
887 ":tool_utils",
888 ]
889 }
mtklein25c81d42016-07-27 13:55:26 -0700890
Mike Klein6e744122016-10-27 12:21:40 -0400891 import("gn/tests.gni")
mtkleinc095df52016-08-24 12:23:52 -0700892 test_lib("tests") {
893 public_include_dirs = [ "tests" ]
Mike Klein6e744122016-10-27 12:21:40 -0400894 sources = tests_sources + pathops_tests_sources
mtkleina45be612016-08-29 15:22:10 -0700895 if (!fontmgr_android_enabled) {
Mike Klein6e744122016-10-27 12:21:40 -0400896 sources -= [ "//tests/FontMgrAndroidParserTest.cpp" ]
mtkleina45be612016-08-29 15:22:10 -0700897 }
mtkleinc095df52016-08-24 12:23:52 -0700898 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700899 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700900 ":flags",
901 ":gpu_tool_utils",
902 ":skia",
903 ":tool_utils",
904 "//third_party/libpng",
905 "//third_party/zlib",
906 ]
907 }
mtklein2f3416d2016-08-02 16:02:05 -0700908
Mike Klein6e744122016-10-27 12:21:40 -0400909 import("gn/bench.gni")
mtkleinc095df52016-08-24 12:23:52 -0700910 test_lib("bench") {
911 public_include_dirs = [ "bench" ]
912 sources = bench_sources
mtkleinc095df52016-08-24 12:23:52 -0700913 deps = [
914 ":flags",
915 ":gm",
916 ":gpu_tool_utils",
917 ":skia",
918 ":tool_utils",
919 ]
920 }
mtklein2b6870c2016-07-28 14:17:33 -0700921
mtkleinc095df52016-08-24 12:23:52 -0700922 test_lib("experimental_svg_model") {
923 public_include_dirs = [ "experimental/svg/model" ]
924 sources = [
925 "experimental/svg/model/SkSVGAttribute.cpp",
926 "experimental/svg/model/SkSVGAttributeParser.cpp",
927 "experimental/svg/model/SkSVGCircle.cpp",
Florin Malitace8840e2016-12-08 09:26:47 -0500928 "experimental/svg/model/SkSVGClipPath.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700929 "experimental/svg/model/SkSVGContainer.cpp",
930 "experimental/svg/model/SkSVGDOM.cpp",
931 "experimental/svg/model/SkSVGEllipse.cpp",
932 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700933 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700934 "experimental/svg/model/SkSVGNode.cpp",
935 "experimental/svg/model/SkSVGPath.cpp",
936 "experimental/svg/model/SkSVGPoly.cpp",
937 "experimental/svg/model/SkSVGRect.cpp",
938 "experimental/svg/model/SkSVGRenderContext.cpp",
939 "experimental/svg/model/SkSVGSVG.cpp",
940 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700941 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700942 "experimental/svg/model/SkSVGTransformableNode.cpp",
943 "experimental/svg/model/SkSVGValue.cpp",
944 ]
945 deps = [
946 ":skia",
947 ]
948 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700949
Brian Osman16adfa32016-10-18 14:42:44 -0400950 test_lib("views") {
951 public_include_dirs = [ "include/views" ]
952 sources = [
953 "src/views/SkEvent.cpp",
954 "src/views/SkEventSink.cpp",
955 "src/views/SkOSMenu.cpp",
956 "src/views/SkTagList.cpp",
957 "src/views/SkTouchGesture.cpp",
958 "src/views/SkView.cpp",
959 "src/views/SkViewPriv.cpp",
960 ]
961 libs = []
Brian Osman34755e22016-12-05 09:46:02 -0500962 deps = []
Brian Osman16adfa32016-10-18 14:42:44 -0400963 if (!is_android) {
964 sources += [ "src/views/SkWindow.cpp" ]
965 }
Jim Van Verth4e56a912016-10-21 10:58:52 -0400966 if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -0400967 public_include_dirs += [ "src/views/unix" ]
968 sources += [
969 "src/views/unix/SkOSWindow_Unix.cpp",
970 "src/views/unix/keysym2ucs.c",
971 ]
Brian Osman16adfa32016-10-18 14:42:44 -0400972 } else if (is_mac) {
973 sources += [
974 "src/views/mac/SkEventNotifier.mm",
975 "src/views/mac/SkNSView.mm",
976 "src/views/mac/SkOSWindow_Mac.mm",
977 "src/views/mac/SkTextFieldCell.m",
978 ]
979 libs += [
980 "QuartzCore.framework",
981 "Cocoa.framework",
982 "Foundation.framework",
983 ]
984 } else if (is_win) {
985 sources += [ "src/views/win/SkOSWindow_win.cpp" ]
986 }
Brian Osman34755e22016-12-05 09:46:02 -0500987 if (skia_use_angle) {
988 deps += [ "//third_party/angle2" ]
989 }
Brian Osman16adfa32016-10-18 14:42:44 -0400990 }
991
Mike Klein38af9432016-11-11 11:39:44 -0500992 if (skia_use_lua) {
993 test_lib("lua") {
994 public_include_dirs = []
995 sources = [
996 "src/utils/SkLua.cpp",
997 "src/utils/SkLuaCanvas.cpp",
998 ]
999 deps = [
1000 "//third_party/lua",
1001 ]
1002 }
1003
1004 executable("lua_app") {
1005 sources = [
1006 "tools/lua/lua_app.cpp",
1007 ]
1008 deps = [
1009 ":lua",
1010 ":skia",
1011 "//third_party/lua",
1012 ]
1013 testonly = true
1014 }
1015
1016 executable("lua_pictures") {
1017 sources = [
1018 "tools/lua/lua_pictures.cpp",
1019 ]
1020 deps = [
1021 ":flags",
1022 ":lua",
1023 ":skia",
1024 ":tool_utils",
1025 "//third_party/lua",
1026 ]
1027 testonly = true
1028 }
1029 }
1030
Mike Klein6e744122016-10-27 12:21:40 -04001031 import("gn/samples.gni")
Brian Osman16adfa32016-10-18 14:42:44 -04001032 test_lib("samples") {
Brian Osman16adfa32016-10-18 14:42:44 -04001033 public_include_dirs = [ "samplecode" ]
Mike Klein6e744122016-10-27 12:21:40 -04001034 include_dirs = [ "experimental" ]
1035 sources = samples_sources + [
1036 "experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp",
1037 "experimental/SkSetPoly3To3.cpp",
1038 "experimental/SkSetPoly3To3_A.cpp",
1039 "experimental/SkSetPoly3To3_D.cpp",
1040 ]
Brian Osman16adfa32016-10-18 14:42:44 -04001041 deps = [
1042 ":experimental_svg_model",
Mike Klein6e744122016-10-27 12:21:40 -04001043 ":gm",
Brian Osman16adfa32016-10-18 14:42:44 -04001044 ":tool_utils",
1045 ":views",
1046 ":xml",
1047 ]
Mike Klein38af9432016-11-11 11:39:44 -05001048
1049 if (skia_use_lua) {
1050 sources += [ "samplecode/SampleLua.cpp" ]
1051 deps += [
1052 ":lua",
1053 "//third_party/lua",
1054 ]
1055 }
Brian Osman16adfa32016-10-18 14:42:44 -04001056 }
1057
mtklein2b6870c2016-07-28 14:17:33 -07001058 executable("dm") {
1059 sources = [
1060 "dm/DM.cpp",
1061 "dm/DMJsonWriter.cpp",
1062 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -07001063 ]
1064 include_dirs = [ "tests" ]
1065 deps = [
mtklein046cb562016-09-16 10:23:12 -07001066 ":common_flags",
fmalitaa2b9fdf2016-08-03 19:53:36 -07001067 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -07001068 ":flags",
1069 ":gm",
1070 ":gpu_tool_utils",
1071 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -07001072 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -07001073 ":tool_utils",
1074 "//third_party/jsoncpp",
1075 "//third_party/libpng",
1076 ]
1077 testonly = true
1078 }
1079
Mike Kleina3430172016-09-27 16:46:29 -04001080 if (!is_debug) { # I've benchmarked debug code once too many times...
1081 executable("monobench") {
1082 sources = [
1083 "tools/monobench.cpp",
1084 ]
1085 deps = [
1086 ":bench",
1087 ":skia",
1088 ]
1089 testonly = true
1090 }
mtklein2b6870c2016-07-28 14:17:33 -07001091 }
1092
1093 executable("nanobench") {
1094 sources = [
1095 "bench/nanobench.cpp",
1096 ]
1097 deps = [
1098 ":bench",
mtklein046cb562016-09-16 10:23:12 -07001099 ":common_flags",
fmalita6519c212016-09-14 08:05:17 -07001100 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -07001101 ":flags",
1102 ":gm",
1103 ":gpu_tool_utils",
1104 ":skia",
1105 ":tool_utils",
1106 "//third_party/jsoncpp",
1107 ]
1108 testonly = true
1109 }
halcanary19a97202016-08-03 15:08:04 -07001110
Jim Van Verth57a98fc2016-10-28 13:35:50 -04001111 if (is_linux || is_win || is_mac) {
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001112 executable("SampleApp") {
mtklein38925aa2016-09-21 10:11:25 -07001113 sources = [
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001114 "samplecode/SampleApp.cpp",
1115 "samplecode/SamplePictFile.cpp",
mtklein38925aa2016-09-21 10:11:25 -07001116 ]
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001117 if (is_mac) {
1118 sources += [ "src/views/mac/skia_mac.mm" ]
1119 } else if (is_win) {
1120 sources += [ "src/views/win/skia_win.cpp" ]
1121 } else if (is_linux) {
1122 sources += [ "src/views/unix/skia_unix.cpp" ]
1123 }
mtklein38925aa2016-09-21 10:11:25 -07001124 deps = [
1125 ":flags",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001126 ":gm",
mtklein38925aa2016-09-21 10:11:25 -07001127 ":gpu_tool_utils",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001128 ":samples",
mtklein38925aa2016-09-21 10:11:25 -07001129 ":skia",
1130 ":tool_utils",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001131 ":views",
mtklein38925aa2016-09-21 10:11:25 -07001132 ]
Mike Kleinc168a3a2016-11-14 14:53:13 +00001133 if (skia_use_angle) {
1134 deps += [ "//third_party/angle2" ]
1135 }
mtklein38925aa2016-09-21 10:11:25 -07001136 testonly = true
1137 }
Jim Van Verth8f5468f2016-10-31 09:52:33 -04001138 }
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001139
Jim Van Verth8f5468f2016-10-31 09:52:33 -04001140 if (skia_enable_gpu) {
1141 executable("skpbench") {
1142 sources = [
1143 "tools/skpbench/skpbench.cpp",
1144 ]
1145 deps = [
1146 ":flags",
1147 ":gpu_tool_utils",
1148 ":skia",
1149 ":tool_utils",
1150 ]
1151 testonly = true
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001152 }
csmartdalton4b5179b2016-09-19 11:03:58 -07001153 }
1154
Mike Klein7d302882016-11-03 14:06:31 -04001155 # We can't yet build ICU on iOS or Windows.
1156 if (!is_ios && !is_win) {
halcanary3eee9d92016-09-10 07:01:53 -07001157 executable("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -07001158 sources = [
1159 "tools/SkShaper_harfbuzz.cpp",
1160 "tools/using_skia_and_harfbuzz.cpp",
1161 ]
1162 deps = [
1163 ":skia",
1164 "//third_party/harfbuzz",
1165 ]
1166 testonly = true
1167 }
halcanary19a97202016-08-03 15:08:04 -07001168 }
halcanary3eee9d92016-09-10 07:01:53 -07001169 executable("sktexttopdf") {
1170 sources = [
1171 "tools/SkShaper_primitive.cpp",
1172 "tools/using_skia_and_harfbuzz.cpp",
1173 ]
1174 deps = [
1175 ":skia",
1176 ]
1177 testonly = true
1178 }
mtklein046cb562016-09-16 10:23:12 -07001179
1180 executable("get_images_from_skps") {
1181 sources = [
1182 "tools/get_images_from_skps.cpp",
1183 ]
1184 deps = [
1185 ":flags",
1186 ":skia",
1187 "//third_party/jsoncpp",
1188 ]
1189 testonly = true
1190 }
mtkleinecbc5262016-09-22 11:51:24 -07001191
Matt Sarett8740d582016-11-11 13:59:14 -05001192 executable("colorspaceinfo") {
1193 sources = [
1194 "tools/colorspaceinfo.cpp",
1195 ]
1196 deps = [
1197 ":flags",
1198 ":skia",
1199 ":tool_utils",
1200 ]
1201 testonly = true
1202 }
1203
Mike Klein7d302882016-11-03 14:06:31 -04001204 if (!is_ios) {
1205 executable("skiaserve") {
1206 sources = [
1207 "tools/skiaserve/Request.cpp",
1208 "tools/skiaserve/Response.cpp",
1209 "tools/skiaserve/skiaserve.cpp",
1210 "tools/skiaserve/urlhandlers/BatchBoundsHandler.cpp",
1211 "tools/skiaserve/urlhandlers/BatchesHandler.cpp",
1212 "tools/skiaserve/urlhandlers/BreakHandler.cpp",
1213 "tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp",
1214 "tools/skiaserve/urlhandlers/CmdHandler.cpp",
1215 "tools/skiaserve/urlhandlers/ColorModeHandler.cpp",
1216 "tools/skiaserve/urlhandlers/DataHandler.cpp",
1217 "tools/skiaserve/urlhandlers/DownloadHandler.cpp",
1218 "tools/skiaserve/urlhandlers/EnableGPUHandler.cpp",
1219 "tools/skiaserve/urlhandlers/ImgHandler.cpp",
1220 "tools/skiaserve/urlhandlers/InfoHandler.cpp",
1221 "tools/skiaserve/urlhandlers/OverdrawHandler.cpp",
1222 "tools/skiaserve/urlhandlers/PostHandler.cpp",
1223 "tools/skiaserve/urlhandlers/QuitHandler.cpp",
1224 "tools/skiaserve/urlhandlers/RootHandler.cpp",
1225 ]
1226 deps = [
1227 ":flags",
1228 ":gpu_tool_utils",
1229 ":skia",
1230 ":tool_utils",
1231 "//third_party/jsoncpp",
1232 "//third_party/libmicrohttpd",
1233 "//third_party/libpng",
1234 ]
1235 testonly = true
1236 }
mtkleinecbc5262016-09-22 11:51:24 -07001237 }
kjlubick14f984b2016-10-03 11:49:45 -07001238
1239 executable("fuzz") {
1240 sources = [
1241 "fuzz/FilterFuzz.cpp",
Kevin Lubickfec1dea2016-11-22 13:57:18 -05001242 "fuzz/FuzzDrawFunctions.cpp",
kjlubick14f984b2016-10-03 11:49:45 -07001243 "fuzz/FuzzGradients.cpp",
1244 "fuzz/FuzzParsePath.cpp",
1245 "fuzz/FuzzPathop.cpp",
1246 "fuzz/FuzzScaleToSides.cpp",
1247 "fuzz/fuzz.cpp",
1248 ]
1249 deps = [
1250 ":flags",
1251 ":skia",
Hal Canarydb683012016-11-23 08:55:18 -07001252 ":tool_utils",
kjlubick14f984b2016-10-03 11:49:45 -07001253 ]
1254 testonly = true
1255 }
Mike Klein38312422016-10-05 15:41:01 -04001256
caryclark9feb6322016-10-25 08:58:26 -07001257 executable("pathops_unittest") {
Mike Klein6e744122016-10-27 12:21:40 -04001258 sources = pathops_tests_sources + [
Mike Klein6e55fef2016-10-26 11:41:47 -04001259 rebase_path("tests/skia_test.cpp"),
1260 rebase_path("tests/Test.cpp"),
1261 ]
caryclark9feb6322016-10-25 08:58:26 -07001262 deps = [
1263 ":flags",
1264 ":gpu_tool_utils",
1265 ":skia",
1266 ":tool_utils",
1267 ]
1268 testonly = true
1269 }
1270
Mike Klein38312422016-10-05 15:41:01 -04001271 executable("dump_record") {
1272 sources = [
1273 "tools/DumpRecord.cpp",
1274 "tools/dump_record.cpp",
1275 ]
1276 deps = [
1277 ":flags",
1278 ":skia",
1279 ]
1280 testonly = true
1281 }
bungemanfe917272016-10-13 17:36:40 -04001282
1283 executable("skdiff") {
1284 sources = [
1285 "tools/skdiff/skdiff.cpp",
1286 "tools/skdiff/skdiff_html.cpp",
1287 "tools/skdiff/skdiff_main.cpp",
1288 "tools/skdiff/skdiff_utils.cpp",
1289 ]
1290 deps = [
1291 ":skia",
1292 ":tool_utils",
1293 ]
1294 testonly = true
1295 }
halcanarya73d76a2016-10-17 13:19:02 -07001296
1297 executable("skp_parser") {
1298 sources = [
1299 "tools/skp_parser.cpp",
1300 ]
1301 deps = [
1302 ":skia",
1303 ":tool_utils",
1304 "//third_party/jsoncpp",
1305 ]
1306 testonly = true
1307 }
Brian Osman16adfa32016-10-18 14:42:44 -04001308
Mike Kleina92c3832016-12-08 09:49:39 -05001309 if (skia_enable_gpu && (is_android || is_linux || is_win || is_mac)) {
1310 source_set("viewer_sources") {
Brian Osman16adfa32016-10-18 14:42:44 -04001311 sources = [
1312 "tools/viewer/GMSlide.cpp",
1313 "tools/viewer/ImageSlide.cpp",
1314 "tools/viewer/SKPSlide.cpp",
1315 "tools/viewer/SampleSlide.cpp",
1316 "tools/viewer/Viewer.cpp",
1317 "tools/viewer/sk_app/CommandSet.cpp",
1318 "tools/viewer/sk_app/GLWindowContext.cpp",
1319 "tools/viewer/sk_app/Window.cpp",
1320 "tools/viewer/sk_app/WindowContext.cpp",
1321 ]
Brian Osman2dd96932016-10-18 15:33:53 -04001322 libs = []
Brian Osman16adfa32016-10-18 14:42:44 -04001323
Jim Van Verth4e56a912016-10-21 10:58:52 -04001324 if (is_android) {
1325 sources += [
1326 "tools/viewer/sk_app/android/GLWindowContext_android.cpp",
1327 "tools/viewer/sk_app/android/RasterWindowContext_android.cpp",
1328 "tools/viewer/sk_app/android/Window_android.cpp",
1329 "tools/viewer/sk_app/android/main_android.cpp",
1330 "tools/viewer/sk_app/android/surface_glue_android.cpp",
1331 ]
1332 } else if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -04001333 sources += [
1334 "tools/viewer/sk_app/unix/GLWindowContext_unix.cpp",
1335 "tools/viewer/sk_app/unix/RasterWindowContext_unix.cpp",
1336 "tools/viewer/sk_app/unix/Window_unix.cpp",
1337 "tools/viewer/sk_app/unix/main_unix.cpp",
1338 ]
1339 } else if (is_win) {
Brian Osman16adfa32016-10-18 14:42:44 -04001340 sources += [
1341 "tools/viewer/sk_app/win/GLWindowContext_win.cpp",
1342 "tools/viewer/sk_app/win/RasterWindowContext_win.cpp",
1343 "tools/viewer/sk_app/win/Window_win.cpp",
1344 "tools/viewer/sk_app/win/main_win.cpp",
1345 ]
Mike Klein43c25262016-10-20 10:17:47 -04001346 } else if (is_mac) {
1347 sources += [
1348 "tools/viewer/sk_app/mac/GLWindowContext_mac.cpp",
1349 "tools/viewer/sk_app/mac/RasterWindowContext_mac.cpp",
1350 "tools/viewer/sk_app/mac/Window_mac.cpp",
1351 "tools/viewer/sk_app/mac/main_mac.cpp",
1352 ]
Brian Osman16adfa32016-10-18 14:42:44 -04001353 }
1354
1355 if (skia_use_vulkan) {
1356 sources += [ "tools/viewer/sk_app/VulkanWindowContext.cpp" ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001357 if (is_android) {
1358 sources +=
1359 [ "tools/viewer/sk_app/android/VulkanWindowContext_android.cpp" ]
1360 libs += [ "android" ]
1361 } else if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -04001362 sources += [ "tools/viewer/sk_app/unix/VulkanWindowContext_unix.cpp" ]
1363 libs += [ "X11-xcb" ]
1364 } else if (is_win) {
Brian Osman16adfa32016-10-18 14:42:44 -04001365 sources += [ "tools/viewer/sk_app/win/VulkanWindowContext_win.cpp" ]
1366 }
1367 }
1368
1369 include_dirs = []
1370 deps = [
1371 ":flags",
1372 ":gm",
1373 ":gpu_tool_utils",
1374 ":samples",
1375 ":skia",
1376 ":tool_utils",
1377 ":views",
1378 "//third_party/jsoncpp",
1379 ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001380 if (is_android) {
1381 deps += [ "//third_party/native_app_glue" ]
1382 } else if (is_mac) {
Mike Klein43c25262016-10-20 10:17:47 -04001383 deps += [ "//third_party/libsdl" ]
1384 }
Brian Osman16adfa32016-10-18 14:42:44 -04001385 testonly = true
1386 }
Mike Kleina92c3832016-12-08 09:49:39 -05001387
1388 if (is_android) {
1389 shared_library("libviewer") {
1390 deps = [
1391 ":viewer_sources",
1392 ]
1393 testonly = true
1394 }
1395 } else {
1396 executable("viewer") {
1397 deps = [
1398 ":viewer_sources",
1399 ]
1400 testonly = true
1401 }
1402 }
Brian Osman16adfa32016-10-18 14:42:44 -04001403 }
Ethan Nicholas4f3985c2016-11-14 11:16:37 -05001404
1405 if (skia_enable_gpu) {
1406 executable("skslc") {
1407 sources = [
1408 "src/sksl/SkSLMain.cpp",
1409 ]
1410 deps = [
1411 ":flags",
1412 ":skia",
1413 ]
1414 testonly = true
1415 }
1416 }
mtklein25c81d42016-07-27 13:55:26 -07001417}