blob: 24651c75bf49f7959207a2a8518232306ba6a394 [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
Brian Osman3f375d02016-12-28 11:19:22 -050029 skia_enable_discrete_gpu = true
mtklein06c35c02016-09-20 12:28:12 -070030 skia_enable_gpu = true
mtklein3e8012e2016-09-21 09:14:19 -070031 skia_enable_tools = is_skia_standalone
32 skia_enable_vulkan_debug_layers = is_skia_standalone && is_debug
Greg Daniel686bb212016-10-27 10:48:48 -040033 skia_vulkan_sdk = getenv("VULKAN_SDK")
mtkleinc04ff472016-06-23 10:29:30 -070034}
Brian Salomon23d73ea2016-10-27 13:31:37 -040035declare_args() {
James Robinson14b748d2016-11-12 18:29:39 -080036 skia_use_dng_sdk =
37 !is_fuchsia && !is_win && skia_use_libjpeg_turbo && skia_use_zlib
Mike Klein10d665d2016-11-01 11:46:10 -040038 skia_use_sfntly = skia_use_icu
39
Mike Klein4d598a32016-10-31 13:44:49 -040040 if (is_android) {
41 skia_use_vulkan = defined(ndk_api) && ndk_api >= 24
42 } else {
43 skia_use_vulkan = skia_vulkan_sdk != ""
44 }
Brian Salomon23d73ea2016-10-27 13:31:37 -040045}
Brian Salomon789e25e2016-09-30 13:41:03 -040046
mtklein38925aa2016-09-21 10:11:25 -070047# Our tools require static linking (they use non-exported symbols).
48skia_enable_tools = skia_enable_tools && !is_component_build
mtklein06c35c02016-09-20 12:28:12 -070049
mtkleina45be612016-08-29 15:22:10 -070050fontmgr_android_enabled = skia_use_expat && skia_use_freetype
51
mtklein1211e0c2016-07-26 13:55:45 -070052skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070053 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070054 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070055 "include/codec",
56 "include/config",
57 "include/core",
58 "include/effects",
59 "include/gpu",
60 "include/gpu/gl",
61 "include/images",
62 "include/pathops",
63 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070064 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070065 "include/utils",
66 "include/utils/mac",
mtklein25c81d42016-07-27 13:55:26 -070067 "include/xml",
mtklein1211e0c2016-07-26 13:55:45 -070068]
69
mtkleinc04ff472016-06-23 10:29:30 -070070# Skia public API, generally provided by :skia.
71config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -070072 include_dirs = skia_public_includes
Mike Kleinae7e6712016-10-11 17:49:33 -040073 defines = []
74 if (is_component_build) {
75 defines += [ "SKIA_DLL" ]
76 }
Mike Kleinc4cbd742016-09-26 21:37:09 -040077 if (is_fuchsia || is_linux) {
jcgregorio5561e3d2016-08-25 09:25:11 -070078 defines += [ "SK_SAMPLES_FOR_X" ]
79 }
mtkleincae1be52016-09-20 08:24:34 -070080 if (skia_enable_android_framework_defines) {
Mike Kleincfc4f442016-10-26 17:19:03 -040081 defines += android_framework_defines
mtkleincae1be52016-09-20 08:24:34 -070082 }
mtklein06c35c02016-09-20 12:28:12 -070083 if (!skia_enable_gpu) {
84 defines += [ "SK_SUPPORT_GPU=0" ]
85 }
mtkleinc04ff472016-06-23 10:29:30 -070086}
87
88# Skia internal APIs, used by Skia itself and a few test tools.
89config("skia_private") {
90 visibility = [ ":*" ]
91
92 include_dirs = [
93 "include/private",
94 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -070095 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -070096 "src/core",
97 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -070098 "src/effects/gradients",
99 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -0700100 "src/gpu",
101 "src/image",
102 "src/images",
103 "src/lazy",
104 "src/opts",
105 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -0700106 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -0700107 "src/ports",
108 "src/sfnt",
mtklein9e0d9dd2016-08-30 10:37:19 -0700109 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -0700110 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -0700111 "src/utils/win",
mtkleinc04ff472016-06-23 10:29:30 -0700112 "third_party/etc1",
scroggo19b91532016-10-24 09:03:26 -0700113 "third_party/gif",
Leon Scroggins427da6f2016-12-16 13:51:59 +0000114 "third_party/ktx",
mtkleinc04ff472016-06-23 10:29:30 -0700115 ]
mtklein150d1132016-08-01 06:56:40 -0700116
Jim Van Verthb6c5e532016-10-28 10:38:08 -0400117 defines = [
118 "SK_GAMMA_APPLY_TO_A8",
119 "SK_INTERNAL",
120 ]
mtkleinb37c0342016-09-09 11:07:45 -0700121 if (is_android) {
122 defines += [
123 "SK_GAMMA_EXPONENT=1.4",
124 "SK_GAMMA_CONTRAST=0.0",
125 ]
126 }
mtklein88a7ac02016-09-14 11:16:49 -0700127 if (is_official_build || is_android) {
128 # TODO(bsalomon): it'd be nice to make Android normal.
129 defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
130 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400131 libs = []
132 lib_dirs = []
133 if (skia_use_vulkan) {
Greg Danielab563d42016-10-31 11:19:59 -0400134 if (skia_vulkan_sdk != "" && !is_android) {
Mike Klein487bfc22016-10-14 14:04:56 -0400135 if (is_win) {
136 include_dirs += [ "$skia_vulkan_sdk/Include/" ]
137 lib_dirs += [ "$skia_vulkan_sdk/Bin" ]
138 } else {
Greg Daniel686bb212016-10-27 10:48:48 -0400139 include_dirs += [ "$skia_vulkan_sdk/include/" ]
140 lib_dirs += [ "$skia_vulkan_sdk/lib/" ]
Mike Klein487bfc22016-10-14 14:04:56 -0400141 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400142 }
Mike Klein487bfc22016-10-14 14:04:56 -0400143 if (is_win) {
144 libs += [ "vulkan-1.lib" ]
145 } else {
146 libs += [ "vulkan" ]
147 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400148 }
Brian Osman34755e22016-12-05 09:46:02 -0500149 if (skia_use_angle) {
150 defines += [ "SK_ANGLE" ]
151 }
Brian Osman3f375d02016-12-28 11:19:22 -0500152 if (skia_enable_discrete_gpu) {
153 defines += [ "SK_ENABLE_DISCRETE_GPU" ]
154 }
mtkleinc04ff472016-06-23 10:29:30 -0700155}
156
157# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
158config("skia_library") {
159 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -0700160 defines = [ "SKIA_IMPLEMENTATION=1" ]
161}
162
163skia_library_configs = [
164 ":skia_public",
165 ":skia_private",
166 ":skia_library",
167]
168
mtklein9b8583d2016-08-24 17:32:30 -0700169# Use for CPU-specific Skia code that needs particular compiler flags.
170template("opts") {
171 if (invoker.enabled) {
172 source_set(target_name) {
173 forward_variables_from(invoker, "*")
174 configs += skia_library_configs
175 }
176 } else {
177 # If not enabled, a phony empty target that swallows all otherwise unused variables.
178 source_set(target_name) {
179 forward_variables_from(invoker,
180 "*",
181 [
182 "sources",
183 "cflags",
184 ])
185 }
186 }
anmittala7eaf2e2016-08-17 13:57:26 -0700187}
188
mtklein422310d2016-08-16 18:28:43 -0700189is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700190
mtklein7d6fb2c2016-08-25 14:50:44 -0700191opts("none") {
192 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700193 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700194 cflags = []
195}
196
mtklein7d6fb2c2016-08-25 14:50:44 -0700197opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700198 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700199 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700200 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700201}
202
203opts("arm64") {
204 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700205 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700206 cflags = []
207}
208
209opts("crc32") {
210 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700211 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700212 cflags = [ "-march=armv8-a+crc" ]
213}
214
mtklein9b8583d2016-08-24 17:32:30 -0700215opts("sse2") {
216 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700217 sources = skia_opts.sse2_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400218 if (is_win) {
219 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE2" ]
220 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400221 cflags = [ "-msse2" ]
222 }
mtklein9b8583d2016-08-24 17:32:30 -0700223}
mtkleinc04ff472016-06-23 10:29:30 -0700224
mtklein9b8583d2016-08-24 17:32:30 -0700225opts("ssse3") {
226 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700227 sources = skia_opts.ssse3_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400228 if (is_win) {
229 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSSE3" ]
230 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400231 cflags = [ "-mssse3" ]
232 }
mtklein9b8583d2016-08-24 17:32:30 -0700233}
mtkleinc04ff472016-06-23 10:29:30 -0700234
mtklein9b8583d2016-08-24 17:32:30 -0700235opts("sse41") {
236 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700237 sources = skia_opts.sse41_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400238 if (is_win) {
239 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE41" ]
240 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400241 cflags = [ "-msse4.1" ]
242 }
mtklein9b8583d2016-08-24 17:32:30 -0700243}
mtklein4e976072016-08-08 09:06:27 -0700244
mtklein9b8583d2016-08-24 17:32:30 -0700245opts("sse42") {
246 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700247 sources = skia_opts.sse42_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400248 if (is_win) {
249 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE42" ]
250 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400251 cflags = [ "-msse4.2" ]
252 }
mtklein9b8583d2016-08-24 17:32:30 -0700253}
254
255opts("avx") {
256 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700257 sources = skia_opts.avx_sources
Mike Klein3eb71212016-10-11 17:08:53 -0400258 if (is_win) {
Mike Klein17b6e482016-11-18 22:11:41 +0000259 cflags = [ "/arch:AVX" ]
Mike Klein3eb71212016-10-11 17:08:53 -0400260 } else {
261 cflags = [ "-mavx" ]
262 }
mtkleinc04ff472016-06-23 10:29:30 -0700263}
264
Mike Klein78d5a3b2016-09-30 10:48:01 -0400265opts("hsw") {
266 enabled = is_x86
267 sources = skia_opts.hsw_sources
Mike Klein3eb71212016-10-11 17:08:53 -0400268 if (is_win) {
Mike Klein17b6e482016-11-18 22:11:41 +0000269 cflags = [ "/arch:AVX2" ]
Mike Klein3eb71212016-10-11 17:08:53 -0400270 } else {
271 cflags = [
272 "-mavx2",
273 "-mbmi",
274 "-mbmi2",
275 "-mf16c",
276 "-mfma",
277 ]
278 }
Mike Klein78d5a3b2016-09-30 10:48:01 -0400279}
280
mtkleinc095df52016-08-24 12:23:52 -0700281# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700282template("optional") {
283 if (invoker.enabled) {
284 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700285 if (defined(invoker.public_defines)) {
286 defines = invoker.public_defines
287 }
mtklein457b42a2016-08-23 13:56:37 -0700288 }
289 source_set(target_name) {
mtkleincd01b032016-08-31 04:58:19 -0700290 forward_variables_from(invoker,
291 "*",
292 [
293 "public_defines",
294 "sources_when_disabled",
scroggof84ad642016-10-31 09:02:57 -0700295 "configs_to_remove",
mtkleincd01b032016-08-31 04:58:19 -0700296 ])
mtklein457b42a2016-08-23 13:56:37 -0700297 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700298 configs += skia_library_configs
scroggof84ad642016-10-31 09:02:57 -0700299 if (defined(invoker.configs_to_remove)) {
300 configs -= invoker.configs_to_remove
301 }
mtklein457b42a2016-08-23 13:56:37 -0700302 }
303 } else {
mtklein457b42a2016-08-23 13:56:37 -0700304 source_set(target_name) {
305 forward_variables_from(invoker,
306 "*",
307 [
308 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700309 "deps",
mtklein6ef69992016-09-14 06:12:09 -0700310 "libs",
mtklein457b42a2016-08-23 13:56:37 -0700311 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700312 "sources_when_disabled",
scroggof84ad642016-10-31 09:02:57 -0700313 "configs_to_remove",
mtklein457b42a2016-08-23 13:56:37 -0700314 ])
mtkleincd01b032016-08-31 04:58:19 -0700315 if (defined(invoker.sources_when_disabled)) {
316 sources = invoker.sources_when_disabled
317 }
318 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700319 }
mtkleineb3c4252016-08-23 07:38:09 -0700320 }
mtklein457b42a2016-08-23 13:56:37 -0700321}
mtklein457b42a2016-08-23 13:56:37 -0700322
mtkleina45be612016-08-29 15:22:10 -0700323optional("fontmgr_android") {
324 enabled = fontmgr_android_enabled
mtkleina45be612016-08-29 15:22:10 -0700325
326 deps = [
327 "//third_party/expat",
328 "//third_party/freetype2",
329 ]
330 sources = [
331 "src/ports/SkFontMgr_android.cpp",
332 "src/ports/SkFontMgr_android_factory.cpp",
333 "src/ports/SkFontMgr_android_parser.cpp",
334 ]
335}
336
mtkleind2e39db2016-09-07 07:52:55 -0700337optional("fontmgr_custom") {
338 enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
339
340 deps = [
341 "//third_party/freetype2",
342 ]
343 sources = [
344 "src/ports/SkFontMgr_custom.cpp",
345 "src/ports/SkFontMgr_custom_directory_factory.cpp",
346 ]
347}
348
mtklein3cc22182016-08-29 13:26:14 -0700349optional("fontmgr_fontconfig") {
350 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700351
352 deps = [
353 "//third_party:fontconfig",
354 "//third_party/freetype2",
355 ]
356 sources = [
bungeman1ae0e012016-09-19 12:13:16 -0700357 "src/ports/SkFontConfigInterface.cpp",
mtklein3cc22182016-08-29 13:26:14 -0700358 "src/ports/SkFontConfigInterface_direct.cpp",
359 "src/ports/SkFontConfigInterface_direct_factory.cpp",
360 "src/ports/SkFontMgr_FontConfigInterface.cpp",
361 "src/ports/SkFontMgr_fontconfig.cpp",
362 "src/ports/SkFontMgr_fontconfig_factory.cpp",
363 ]
364}
365
mtkleincdedd0e2016-09-12 15:15:44 -0700366optional("fontmgr_fuchsia") {
367 enabled = is_fuchsia && skia_use_freetype
368
369 deps = [
370 "//third_party/freetype2",
371 ]
372 sources = [
373 "src/ports/SkFontMgr_custom.cpp",
374 "src/ports/SkFontMgr_custom_empty_factory.cpp",
375 ]
376}
377
mtklein06c35c02016-09-20 12:28:12 -0700378optional("gpu") {
379 enabled = skia_enable_gpu
mtkleine9fb3d52016-09-20 15:11:46 -0700380 public_defines = []
381
mtklein06c35c02016-09-20 12:28:12 -0700382 sources = skia_gpu_sources + [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ]
383
384 # These paths need to be absolute to match the ones produced by shared_sources.gni.
385 sources -= get_path_info([
386 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
387 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
388 ],
389 "abspath")
Mike Klein703cf5a2016-10-13 17:18:04 -0400390 libs = []
mtklein06c35c02016-09-20 12:28:12 -0700391 if (is_android) {
392 sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
393 } else if (is_linux) {
394 sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
395 } else if (is_mac) {
396 sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
Chinmay Garde130a1182016-11-23 11:43:56 -0800397 } else if (is_ios) {
398 sources += [ "src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp" ]
Mike Klein703cf5a2016-10-13 17:18:04 -0400399 } else if (is_win) {
400 sources += [ "src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp" ]
401 libs += [ "OpenGL32.lib" ]
mtklein06c35c02016-09-20 12:28:12 -0700402 } else {
403 sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
404 }
mtkleine9fb3d52016-09-20 15:11:46 -0700405
406 if (skia_use_vulkan) {
407 public_defines += [ "SK_VULKAN" ]
408 sources += skia_vk_sources
egdaniele4a9bd72016-09-21 07:36:14 -0700409 if (skia_enable_vulkan_debug_layers) {
410 public_defines += [ "SK_ENABLE_VK_LAYERS" ]
411 }
mtkleine9fb3d52016-09-20 15:11:46 -0700412 }
mtklein06c35c02016-09-20 12:28:12 -0700413}
414
mtklein63213812016-08-24 09:55:56 -0700415optional("jpeg") {
416 enabled = skia_use_libjpeg_turbo
417 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
418
mtklein63213812016-08-24 09:55:56 -0700419 deps = [
420 "//third_party/libjpeg-turbo:libjpeg",
421 ]
422 sources = [
423 "src/codec/SkJpegCodec.cpp",
424 "src/codec/SkJpegDecoderMgr.cpp",
425 "src/codec/SkJpegUtility.cpp",
426 "src/images/SkJPEGImageEncoder.cpp",
427 "src/images/SkJPEGWriteUtility.cpp",
428 ]
429}
430
431optional("pdf") {
432 enabled = skia_use_zlib
mtklein63213812016-08-24 09:55:56 -0700433
mtklein63213812016-08-24 09:55:56 -0700434 deps = [
435 "//third_party/zlib",
436 ]
brettwb9447282016-09-01 14:24:39 -0700437 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700438 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700439
440 if (skia_use_sfntly) {
441 deps += [ "//third_party/sfntly" ]
mtkleincd01b032016-08-31 04:58:19 -0700442 public_defines = [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700443 }
444}
445
446optional("png") {
447 enabled = skia_use_libpng
448 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
449
mtklein63213812016-08-24 09:55:56 -0700450 deps = [
451 "//third_party/libpng",
452 ]
453 sources = [
454 "src/codec/SkIcoCodec.cpp",
455 "src/codec/SkPngCodec.cpp",
456 "src/images/SkPNGImageEncoder.cpp",
457 ]
458}
459
scroggof84ad642016-10-31 09:02:57 -0700460optional("raw") {
Mike Klein10d665d2016-11-01 11:46:10 -0400461 enabled = skia_use_dng_sdk && skia_use_libjpeg_turbo && skia_use_piex
scroggof84ad642016-10-31 09:02:57 -0700462 public_defines = [ "SK_CODEC_DECODES_RAW" ]
463
464 deps = [
465 "//third_party/dng_sdk",
466 "//third_party/libjpeg-turbo:libjpeg",
467 "//third_party/piex",
468 ]
469
470 # SkRawCodec catches any exceptions thrown by dng_sdk, insulating the rest of
471 # Skia.
472 configs_to_remove = [ "//gn:no_exceptions" ]
473
474 sources = [
475 "src/codec/SkRawAdapterCodec.cpp",
476 "src/codec/SkRawCodec.cpp",
477 ]
478}
479
mtklein3cc22182016-08-29 13:26:14 -0700480optional("typeface_freetype") {
481 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700482
483 deps = [
484 "//third_party/freetype2",
485 ]
486 sources = [
487 "src/ports/SkFontHost_FreeType.cpp",
488 "src/ports/SkFontHost_FreeType_common.cpp",
489 ]
490}
491
mtklein457b42a2016-08-23 13:56:37 -0700492optional("webp") {
493 enabled = skia_use_libwebp
494 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
495
mtklein457b42a2016-08-23 13:56:37 -0700496 deps = [
497 "//third_party/libwebp",
498 ]
499 sources = [
500 "src/codec/SkWebpAdapterCodec.cpp",
501 "src/codec/SkWebpCodec.cpp",
502 "src/images/SkWEBPImageEncoder.cpp",
503 ]
mtkleineb3c4252016-08-23 07:38:09 -0700504}
505
mtklein63213812016-08-24 09:55:56 -0700506optional("xml") {
507 enabled = skia_use_expat
Florin Malita442fff92016-11-08 16:07:52 +0000508 public_defines = [ "SK_XML" ]
mtklein63213812016-08-24 09:55:56 -0700509
mtklein63213812016-08-24 09:55:56 -0700510 deps = [
511 "//third_party/expat",
512 ]
513 sources = [
514 "src/xml/SkDOM.cpp",
515 "src/xml/SkXMLParser.cpp",
516 "src/xml/SkXMLWriter.cpp",
517 ]
518}
519
mtkleinc04ff472016-06-23 10:29:30 -0700520component("skia") {
521 public_configs = [ ":skia_public" ]
522 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700523
524 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700525 ":arm64",
526 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700527 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700528 ":crc32",
mtkleina45be612016-08-29 15:22:10 -0700529 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700530 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700531 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700532 ":fontmgr_fuchsia",
mtklein06c35c02016-09-20 12:28:12 -0700533 ":gpu",
Mike Klein78d5a3b2016-09-30 10:48:01 -0400534 ":hsw",
mtklein63213812016-08-24 09:55:56 -0700535 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700536 ":none",
mtklein63213812016-08-24 09:55:56 -0700537 ":pdf",
538 ":png",
scroggof84ad642016-10-31 09:02:57 -0700539 ":raw",
mtklein9b8583d2016-08-24 17:32:30 -0700540 ":sse2",
541 ":sse41",
542 ":sse42",
543 ":ssse3",
mtklein3cc22182016-08-29 13:26:14 -0700544 ":typeface_freetype",
mtkleineb3c4252016-08-23 07:38:09 -0700545 ":webp",
mtklein63213812016-08-24 09:55:56 -0700546 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700547 ]
548
Chinmay Garde43f115c2016-11-16 15:04:12 -0800549 # This file (and all GN files in Skia) are designed to work with an
550 # empty sources assignment filter; we handle all that explicitly.
551 # We clear the filter here for clients who may have set up a global filter.
552 set_sources_assignment_filter([])
553
mtkleinc04ff472016-06-23 10:29:30 -0700554 sources = []
brettwb9447282016-09-01 14:24:39 -0700555 sources += skia_core_sources
556 sources += skia_effects_sources
brettwb9447282016-09-01 14:24:39 -0700557 sources += skia_sksl_sources
558 sources += skia_utils_sources
Hal Canary6ad3d2f2016-12-20 16:15:56 -0500559 sources += skia_xps_sources
mtkleinc04ff472016-06-23 10:29:30 -0700560 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700561 "src/android/SkBitmapRegionCodec.cpp",
562 "src/android/SkBitmapRegionDecoder.cpp",
563 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700564 "src/codec/SkBmpCodec.cpp",
565 "src/codec/SkBmpMaskCodec.cpp",
566 "src/codec/SkBmpRLECodec.cpp",
567 "src/codec/SkBmpStandardCodec.cpp",
568 "src/codec/SkCodec.cpp",
569 "src/codec/SkCodecImageGenerator.cpp",
scroggo19b91532016-10-24 09:03:26 -0700570 "src/codec/SkGifCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700571 "src/codec/SkMaskSwizzler.cpp",
572 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700573 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700574 "src/codec/SkSampler.cpp",
scroggo19b91532016-10-24 09:03:26 -0700575 "src/codec/SkStreamBuffer.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700576 "src/codec/SkSwizzler.cpp",
577 "src/codec/SkWbmpCodec.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700578 "src/images/SkImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700579 "src/ports/SkDiscardableMemory_none.cpp",
580 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700581 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700582 "src/ports/SkMemory_malloc.cpp",
583 "src/ports/SkOSFile_stdio.cpp",
584 "src/sfnt/SkOTTable_name.cpp",
585 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700586 "src/svg/SkSVGCanvas.cpp",
587 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700588 "src/utils/mac/SkStream_mac.cpp",
589 "third_party/etc1/etc1.cpp",
scroggo3d3a65c2016-10-24 12:28:30 -0700590 "third_party/gif/SkGifImageReader.cpp",
Leon Scroggins427da6f2016-12-16 13:51:59 +0000591 "third_party/ktx/ktx.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700592 ]
brettwb9447282016-09-01 14:24:39 -0700593
mtklein7d6fb2c2016-08-25 14:50:44 -0700594 libs = []
595
mtkleinc04ff472016-06-23 10:29:30 -0700596 if (is_win) {
597 sources += [
Mike Kleinae7e6712016-10-11 17:49:33 -0400598 "src/fonts/SkFontMgr_indirect.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700599 "src/ports/SkDebug_win.cpp",
600 "src/ports/SkFontHost_win.cpp",
601 "src/ports/SkFontMgr_win_dw.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700602 "src/ports/SkImageEncoder_WIC.cpp",
603 "src/ports/SkImageGeneratorWIC.cpp",
604 "src/ports/SkOSFile_win.cpp",
mtklein605d9522016-09-21 14:01:32 -0700605 "src/ports/SkOSLibrary_win.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700606 "src/ports/SkScalerContext_win_dw.cpp",
607 "src/ports/SkTLS_win.cpp",
608 "src/ports/SkTypeface_win_dw.cpp",
609 ]
Mike Klein69f6ed42016-10-13 15:45:07 -0400610 if (skia_use_gdi) {
611 sources += [ "src/ports/SkFontMgr_win_gdi_factory.cpp" ]
612 libs += [
613 "Gdi32.lib",
614 "Usp10.lib",
615 ]
616 } else {
617 sources += [ "src/ports/SkFontMgr_win_dw_factory.cpp" ]
618 }
mtkleinb9be9792016-09-16 14:44:18 -0700619 sources -=
620 [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
Mike Klein4b167fc2016-10-11 18:13:53 -0400621 libs += [
622 "FontSub.lib",
623 "Ole32.lib",
624 "OleAut32.lib",
625 "User32.lib",
626 ]
mtkleinc04ff472016-06-23 10:29:30 -0700627 } else {
628 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700629 "src/ports/SkOSFile_posix.cpp",
mtklein605d9522016-09-21 14:01:32 -0700630 "src/ports/SkOSLibrary_posix.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700631 "src/ports/SkTLS_pthread.cpp",
632 ]
633 }
634
mtklein7d6fb2c2016-08-25 14:50:44 -0700635 if (is_android) {
Mike Kleinc3083332016-12-12 09:03:56 -0500636 deps += [ "//third_party/expat" ]
mtklein06c35c02016-09-20 12:28:12 -0700637 sources += [ "src/ports/SkDebug_android.cpp" ]
mtklein7d6fb2c2016-08-25 14:50:44 -0700638 libs += [
639 "EGL",
640 "GLESv2",
641 "log",
642 ]
643 }
644
mtkleinc04ff472016-06-23 10:29:30 -0700645 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700646 libs += [
647 "GL",
648 "GLU",
649 "X11",
650 ]
mtklein06c35c02016-09-20 12:28:12 -0700651 sources += [ "src/ports/SkDebug_stdio.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700652 }
653
654 if (is_mac) {
655 sources += [
mtklein7d6fb2c2016-08-25 14:50:44 -0700656 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700657 "src/ports/SkFontHost_mac.cpp",
658 "src/ports/SkImageEncoder_CG.cpp",
659 "src/ports/SkImageGeneratorCG.cpp",
660 ]
mtklein09e61f72016-08-23 13:35:28 -0700661 libs += [
662 "ApplicationServices.framework",
663 "OpenGL.framework",
664 ]
mtkleinc04ff472016-06-23 10:29:30 -0700665 }
abarth6fc8ff02016-07-15 15:15:15 -0700666
Mike Klein7d302882016-11-03 14:06:31 -0400667 if (is_ios) {
668 sources += [
669 "src/ports/SkDebug_stdio.cpp",
670 "src/ports/SkFontHost_mac.cpp",
671 "src/ports/SkImageEncoder_CG.cpp",
672 "src/ports/SkImageGeneratorCG.cpp",
673 ]
674 libs += [
675 "CoreFoundation.framework",
676 "CoreGraphics.framework",
677 "CoreText.framework",
678 "ImageIO.framework",
679 "MobileCoreServices.framework",
680 ]
681 }
682
abarth6fc8ff02016-07-15 15:15:15 -0700683 if (is_fuchsia) {
mtklein06c35c02016-09-20 12:28:12 -0700684 sources += [ "src/ports/SkDebug_stdio.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700685 }
mtkleinc04ff472016-06-23 10:29:30 -0700686}
687
mtkleinc095df52016-08-24 12:23:52 -0700688# Targets guarded by skia_enable_tools may use //third_party freely.
689if (skia_enable_tools) {
Mike Klein308b5ac2016-12-06 16:03:52 -0500690 # Used by gn_to_bp.py to list our public include dirs.
691 source_set("public") {
692 configs += [ ":skia_public" ]
693 }
694
Mike Kleinc36dedf2016-11-18 09:35:28 -0500695 config("skia.h_config") {
696 include_dirs = [ "$target_gen_dir" ]
697 }
698 action("skia.h") {
699 public_configs = [ ":skia.h_config" ]
700 skia_h = "$target_gen_dir/skia.h"
701 script = "gn/find_headers.py"
702 args = [ rebase_path(skia_h, root_build_dir) ] +
703 rebase_path(skia_public_includes)
704 depfile = "$skia_h.deps"
705 outputs = [
706 skia_h,
707 ]
708 }
709
710 if (skia_enable_gpu && target_cpu == "x64") {
711 # Our bots only have 64-bit libOSMesa installed.
712 # TODO: worth fixing?
713 executable("fiddle") {
714 libs = []
715 if (is_linux) {
716 libs += [ "OSMesa" ]
717 }
718
719 sources = [
Mike Kleinc36dedf2016-11-18 09:35:28 -0500720 "tools/fiddle/draw.cpp",
721 "tools/fiddle/fiddle_main.cpp",
722 ]
723 deps = [
724 ":skia",
725 ":skia.h",
726 ]
727 }
728 }
729
730 if (skia_enable_gpu) {
731 source_set("public_headers_warnings_check") {
732 sources = [
733 "tools/public_headers_warnings_check.cpp",
734 ]
735 configs -= [ "//gn:warnings_except_public_headers" ]
736 deps = [
737 ":skia",
738 ":skia.h",
739 ]
740 }
741 }
742
mtkleinc095df52016-08-24 12:23:52 -0700743 template("test_lib") {
744 config(target_name + "_config") {
745 include_dirs = invoker.public_include_dirs
mtkleina627b5c2016-09-20 13:36:47 -0700746 if (defined(invoker.public_defines)) {
747 defines = invoker.public_defines
748 }
mtklein25c81d42016-07-27 13:55:26 -0700749 }
mtkleinc095df52016-08-24 12:23:52 -0700750 source_set(target_name) {
751 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
752 public_configs = [
753 ":" + target_name + "_config",
754 ":skia_private",
755 ]
756
757 if (!defined(deps)) {
758 deps = []
759 }
760 deps += [ ":skia" ]
761 testonly = true
762 }
mtklein25c81d42016-07-27 13:55:26 -0700763 }
mtklein25c81d42016-07-27 13:55:26 -0700764
mtkleinc095df52016-08-24 12:23:52 -0700765 test_lib("gpu_tool_utils") {
mtklein38925aa2016-09-21 10:11:25 -0700766 public_include_dirs = []
767 if (skia_enable_gpu) {
768 public_defines = []
769 public_include_dirs += [ "tools/gpu" ]
mtkleind68f9b02016-09-23 13:18:41 -0700770
771 deps = []
mtklein38925aa2016-09-21 10:11:25 -0700772 sources = [
773 "tools/gpu/GrContextFactory.cpp",
774 "tools/gpu/GrTest.cpp",
775 "tools/gpu/TestContext.cpp",
776 "tools/gpu/gl/GLTestContext.cpp",
mtklein605d9522016-09-21 14:01:32 -0700777 "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
mtklein38925aa2016-09-21 10:11:25 -0700778 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
779 "tools/gpu/gl/debug/GrBufferObj.cpp",
780 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
781 "tools/gpu/gl/debug/GrProgramObj.cpp",
782 "tools/gpu/gl/debug/GrShaderObj.cpp",
783 "tools/gpu/gl/debug/GrTextureObj.cpp",
784 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
785 "tools/gpu/gl/null/NullGLTestContext.cpp",
786 ]
787 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700788
mtklein38925aa2016-09-21 10:11:25 -0700789 if (is_android) {
790 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
Mike Klein7d302882016-11-03 14:06:31 -0400791 } else if (is_ios) {
792 sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
793 libs += [ "OpenGLES.framework" ]
mtklein38925aa2016-09-21 10:11:25 -0700794 } else if (is_linux) {
795 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
796 } else if (is_mac) {
797 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
Mike Klein4b167fc2016-10-11 18:13:53 -0400798 } else if (is_win) {
799 sources += [ "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp" ]
800 libs += [
801 "Gdi32.lib",
802 "OpenGL32.lib",
803 ]
mtklein38925aa2016-09-21 10:11:25 -0700804 }
mtklein6ef69992016-09-14 06:12:09 -0700805
Mike Kleinc168a3a2016-11-14 14:53:13 +0000806 if (skia_use_angle) {
Mike Kleinc168a3a2016-11-14 14:53:13 +0000807 deps += [ "//third_party/angle2" ]
808 sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
809 }
mtklein38925aa2016-09-21 10:11:25 -0700810 if (skia_use_mesa) {
811 public_defines += [ "SK_MESA" ]
812 sources += [ "tools/gpu/gl/mesa/GLTestContext_mesa.cpp" ]
813 libs += [ "OSMesa" ]
814 }
mtkleind68f9b02016-09-23 13:18:41 -0700815 if (skia_use_vulkan) {
816 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
817 }
mtkleina627b5c2016-09-20 13:36:47 -0700818 }
mtklein25c81d42016-07-27 13:55:26 -0700819 }
mtklein25c81d42016-07-27 13:55:26 -0700820
mtkleinc095df52016-08-24 12:23:52 -0700821 test_lib("flags") {
822 public_include_dirs = [ "tools/flags" ]
823 sources = [
824 "tools/flags/SkCommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -0700825 ]
826 }
827 test_lib("common_flags") {
828 public_include_dirs = [ "tools/flags" ]
829 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700830 "tools/flags/SkCommonFlags.cpp",
831 "tools/flags/SkCommonFlagsConfig.cpp",
832 ]
833 deps = [
mtklein046cb562016-09-16 10:23:12 -0700834 ":flags",
mtkleinc095df52016-08-24 12:23:52 -0700835 ":gpu_tool_utils",
836 ]
837 }
mtklein25c81d42016-07-27 13:55:26 -0700838
mtkleinc095df52016-08-24 12:23:52 -0700839 test_lib("tool_utils") {
840 public_include_dirs = [
841 "tools",
842 "tools/debugger",
843 "tools/timer",
844 ]
845 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700846 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700847 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700848 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700849 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700850 "tools/ProcStats.cpp",
851 "tools/Resources.cpp",
852 "tools/ThermalManager.cpp",
853 "tools/UrlDataManager.cpp",
854 "tools/debugger/SkDebugCanvas.cpp",
855 "tools/debugger/SkDrawCommand.cpp",
856 "tools/debugger/SkJsonWriteBuffer.cpp",
857 "tools/debugger/SkObjectParser.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700858 "tools/picture_utils.cpp",
859 "tools/random_parse_path.cpp",
860 "tools/sk_tool_utils.cpp",
861 "tools/sk_tool_utils_font.cpp",
862 "tools/timer/Timer.cpp",
863 ]
864 deps = [
mtklein046cb562016-09-16 10:23:12 -0700865 ":common_flags",
mtkleinc095df52016-08-24 12:23:52 -0700866 ":flags",
867 "//third_party/libpng",
868 ]
869 public_deps = [
870 "//third_party/jsoncpp",
871 ]
872 }
mtklein25c81d42016-07-27 13:55:26 -0700873
Mike Klein6e744122016-10-27 12:21:40 -0400874 import("gn/gm.gni")
mtkleinc095df52016-08-24 12:23:52 -0700875 test_lib("gm") {
876 public_include_dirs = [ "gm" ]
877 sources = gm_sources
878 deps = [
scroggo19b91532016-10-24 09:03:26 -0700879 ":flags",
mtkleinc095df52016-08-24 12:23:52 -0700880 ":gpu_tool_utils",
881 ":skia",
882 ":tool_utils",
883 ]
884 }
mtklein25c81d42016-07-27 13:55:26 -0700885
Mike Klein6e744122016-10-27 12:21:40 -0400886 import("gn/tests.gni")
mtkleinc095df52016-08-24 12:23:52 -0700887 test_lib("tests") {
888 public_include_dirs = [ "tests" ]
Mike Klein6e744122016-10-27 12:21:40 -0400889 sources = tests_sources + pathops_tests_sources
mtkleina45be612016-08-29 15:22:10 -0700890 if (!fontmgr_android_enabled) {
Mike Klein6e744122016-10-27 12:21:40 -0400891 sources -= [ "//tests/FontMgrAndroidParserTest.cpp" ]
mtkleina45be612016-08-29 15:22:10 -0700892 }
mtkleinc095df52016-08-24 12:23:52 -0700893 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700894 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700895 ":flags",
896 ":gpu_tool_utils",
897 ":skia",
898 ":tool_utils",
899 "//third_party/libpng",
900 "//third_party/zlib",
901 ]
902 }
mtklein2f3416d2016-08-02 16:02:05 -0700903
Mike Klein6e744122016-10-27 12:21:40 -0400904 import("gn/bench.gni")
mtkleinc095df52016-08-24 12:23:52 -0700905 test_lib("bench") {
906 public_include_dirs = [ "bench" ]
907 sources = bench_sources
mtkleinc095df52016-08-24 12:23:52 -0700908 deps = [
909 ":flags",
910 ":gm",
911 ":gpu_tool_utils",
912 ":skia",
913 ":tool_utils",
914 ]
915 }
mtklein2b6870c2016-07-28 14:17:33 -0700916
mtkleinc095df52016-08-24 12:23:52 -0700917 test_lib("experimental_svg_model") {
918 public_include_dirs = [ "experimental/svg/model" ]
919 sources = [
920 "experimental/svg/model/SkSVGAttribute.cpp",
921 "experimental/svg/model/SkSVGAttributeParser.cpp",
922 "experimental/svg/model/SkSVGCircle.cpp",
Florin Malitace8840e2016-12-08 09:26:47 -0500923 "experimental/svg/model/SkSVGClipPath.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700924 "experimental/svg/model/SkSVGContainer.cpp",
925 "experimental/svg/model/SkSVGDOM.cpp",
926 "experimental/svg/model/SkSVGEllipse.cpp",
927 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700928 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700929 "experimental/svg/model/SkSVGNode.cpp",
930 "experimental/svg/model/SkSVGPath.cpp",
931 "experimental/svg/model/SkSVGPoly.cpp",
932 "experimental/svg/model/SkSVGRect.cpp",
933 "experimental/svg/model/SkSVGRenderContext.cpp",
934 "experimental/svg/model/SkSVGSVG.cpp",
935 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700936 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700937 "experimental/svg/model/SkSVGTransformableNode.cpp",
938 "experimental/svg/model/SkSVGValue.cpp",
939 ]
940 deps = [
941 ":skia",
942 ]
943 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700944
Brian Osman16adfa32016-10-18 14:42:44 -0400945 test_lib("views") {
946 public_include_dirs = [ "include/views" ]
947 sources = [
948 "src/views/SkEvent.cpp",
949 "src/views/SkEventSink.cpp",
950 "src/views/SkOSMenu.cpp",
951 "src/views/SkTagList.cpp",
952 "src/views/SkTouchGesture.cpp",
953 "src/views/SkView.cpp",
954 "src/views/SkViewPriv.cpp",
955 ]
956 libs = []
Brian Osman34755e22016-12-05 09:46:02 -0500957 deps = []
Brian Osman16adfa32016-10-18 14:42:44 -0400958 if (!is_android) {
959 sources += [ "src/views/SkWindow.cpp" ]
960 }
Jim Van Verth4e56a912016-10-21 10:58:52 -0400961 if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -0400962 public_include_dirs += [ "src/views/unix" ]
963 sources += [
964 "src/views/unix/SkOSWindow_Unix.cpp",
965 "src/views/unix/keysym2ucs.c",
966 ]
Brian Osman16adfa32016-10-18 14:42:44 -0400967 } else if (is_mac) {
968 sources += [
969 "src/views/mac/SkEventNotifier.mm",
970 "src/views/mac/SkNSView.mm",
971 "src/views/mac/SkOSWindow_Mac.mm",
972 "src/views/mac/SkTextFieldCell.m",
973 ]
974 libs += [
975 "QuartzCore.framework",
976 "Cocoa.framework",
977 "Foundation.framework",
978 ]
979 } else if (is_win) {
980 sources += [ "src/views/win/SkOSWindow_win.cpp" ]
981 }
Brian Osman34755e22016-12-05 09:46:02 -0500982 if (skia_use_angle) {
983 deps += [ "//third_party/angle2" ]
984 }
Brian Osman16adfa32016-10-18 14:42:44 -0400985 }
986
Mike Klein38af9432016-11-11 11:39:44 -0500987 if (skia_use_lua) {
988 test_lib("lua") {
989 public_include_dirs = []
990 sources = [
991 "src/utils/SkLua.cpp",
992 "src/utils/SkLuaCanvas.cpp",
993 ]
994 deps = [
995 "//third_party/lua",
996 ]
997 }
998
999 executable("lua_app") {
1000 sources = [
1001 "tools/lua/lua_app.cpp",
1002 ]
1003 deps = [
1004 ":lua",
1005 ":skia",
1006 "//third_party/lua",
1007 ]
1008 testonly = true
1009 }
1010
1011 executable("lua_pictures") {
1012 sources = [
1013 "tools/lua/lua_pictures.cpp",
1014 ]
1015 deps = [
1016 ":flags",
1017 ":lua",
1018 ":skia",
1019 ":tool_utils",
1020 "//third_party/lua",
1021 ]
1022 testonly = true
1023 }
1024 }
1025
Mike Klein6e744122016-10-27 12:21:40 -04001026 import("gn/samples.gni")
Brian Osman16adfa32016-10-18 14:42:44 -04001027 test_lib("samples") {
Brian Osman16adfa32016-10-18 14:42:44 -04001028 public_include_dirs = [ "samplecode" ]
Mike Klein6e744122016-10-27 12:21:40 -04001029 include_dirs = [ "experimental" ]
1030 sources = samples_sources + [
1031 "experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp",
1032 "experimental/SkSetPoly3To3.cpp",
1033 "experimental/SkSetPoly3To3_A.cpp",
1034 "experimental/SkSetPoly3To3_D.cpp",
1035 ]
Brian Osman16adfa32016-10-18 14:42:44 -04001036 deps = [
1037 ":experimental_svg_model",
Mike Klein6e744122016-10-27 12:21:40 -04001038 ":gm",
Brian Osman16adfa32016-10-18 14:42:44 -04001039 ":tool_utils",
1040 ":views",
1041 ":xml",
1042 ]
Mike Klein38af9432016-11-11 11:39:44 -05001043
1044 if (skia_use_lua) {
1045 sources += [ "samplecode/SampleLua.cpp" ]
1046 deps += [
1047 ":lua",
1048 "//third_party/lua",
1049 ]
1050 }
Brian Osman16adfa32016-10-18 14:42:44 -04001051 }
1052
mtklein2b6870c2016-07-28 14:17:33 -07001053 executable("dm") {
1054 sources = [
1055 "dm/DM.cpp",
1056 "dm/DMJsonWriter.cpp",
1057 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -07001058 ]
1059 include_dirs = [ "tests" ]
1060 deps = [
mtklein046cb562016-09-16 10:23:12 -07001061 ":common_flags",
fmalitaa2b9fdf2016-08-03 19:53:36 -07001062 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -07001063 ":flags",
1064 ":gm",
1065 ":gpu_tool_utils",
1066 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -07001067 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -07001068 ":tool_utils",
1069 "//third_party/jsoncpp",
1070 "//third_party/libpng",
1071 ]
1072 testonly = true
1073 }
1074
Mike Kleina3430172016-09-27 16:46:29 -04001075 if (!is_debug) { # I've benchmarked debug code once too many times...
1076 executable("monobench") {
1077 sources = [
1078 "tools/monobench.cpp",
1079 ]
1080 deps = [
1081 ":bench",
1082 ":skia",
1083 ]
1084 testonly = true
1085 }
mtklein2b6870c2016-07-28 14:17:33 -07001086 }
1087
1088 executable("nanobench") {
1089 sources = [
1090 "bench/nanobench.cpp",
1091 ]
1092 deps = [
1093 ":bench",
mtklein046cb562016-09-16 10:23:12 -07001094 ":common_flags",
fmalita6519c212016-09-14 08:05:17 -07001095 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -07001096 ":flags",
1097 ":gm",
1098 ":gpu_tool_utils",
1099 ":skia",
1100 ":tool_utils",
1101 "//third_party/jsoncpp",
1102 ]
1103 testonly = true
1104 }
halcanary19a97202016-08-03 15:08:04 -07001105
Jim Van Verth57a98fc2016-10-28 13:35:50 -04001106 if (is_linux || is_win || is_mac) {
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001107 executable("SampleApp") {
mtklein38925aa2016-09-21 10:11:25 -07001108 sources = [
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001109 "samplecode/SampleApp.cpp",
1110 "samplecode/SamplePictFile.cpp",
mtklein38925aa2016-09-21 10:11:25 -07001111 ]
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001112 if (is_mac) {
1113 sources += [ "src/views/mac/skia_mac.mm" ]
1114 } else if (is_win) {
1115 sources += [ "src/views/win/skia_win.cpp" ]
1116 } else if (is_linux) {
1117 sources += [ "src/views/unix/skia_unix.cpp" ]
1118 }
mtklein38925aa2016-09-21 10:11:25 -07001119 deps = [
1120 ":flags",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001121 ":gm",
mtklein38925aa2016-09-21 10:11:25 -07001122 ":gpu_tool_utils",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001123 ":samples",
mtklein38925aa2016-09-21 10:11:25 -07001124 ":skia",
1125 ":tool_utils",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001126 ":views",
mtklein38925aa2016-09-21 10:11:25 -07001127 ]
Mike Kleinc168a3a2016-11-14 14:53:13 +00001128 if (skia_use_angle) {
1129 deps += [ "//third_party/angle2" ]
1130 }
mtklein38925aa2016-09-21 10:11:25 -07001131 testonly = true
1132 }
Jim Van Verth8f5468f2016-10-31 09:52:33 -04001133 }
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001134
Jim Van Verth8f5468f2016-10-31 09:52:33 -04001135 if (skia_enable_gpu) {
1136 executable("skpbench") {
1137 sources = [
1138 "tools/skpbench/skpbench.cpp",
1139 ]
1140 deps = [
1141 ":flags",
1142 ":gpu_tool_utils",
1143 ":skia",
1144 ":tool_utils",
1145 ]
1146 testonly = true
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001147 }
csmartdalton4b5179b2016-09-19 11:03:58 -07001148 }
1149
Mike Klein7d302882016-11-03 14:06:31 -04001150 # We can't yet build ICU on iOS or Windows.
1151 if (!is_ios && !is_win) {
halcanary3eee9d92016-09-10 07:01:53 -07001152 executable("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -07001153 sources = [
1154 "tools/SkShaper_harfbuzz.cpp",
1155 "tools/using_skia_and_harfbuzz.cpp",
1156 ]
1157 deps = [
1158 ":skia",
1159 "//third_party/harfbuzz",
1160 ]
1161 testonly = true
1162 }
halcanary19a97202016-08-03 15:08:04 -07001163 }
halcanary3eee9d92016-09-10 07:01:53 -07001164 executable("sktexttopdf") {
1165 sources = [
1166 "tools/SkShaper_primitive.cpp",
1167 "tools/using_skia_and_harfbuzz.cpp",
1168 ]
1169 deps = [
1170 ":skia",
1171 ]
1172 testonly = true
1173 }
mtklein046cb562016-09-16 10:23:12 -07001174
1175 executable("get_images_from_skps") {
1176 sources = [
1177 "tools/get_images_from_skps.cpp",
1178 ]
1179 deps = [
1180 ":flags",
1181 ":skia",
1182 "//third_party/jsoncpp",
1183 ]
1184 testonly = true
1185 }
mtkleinecbc5262016-09-22 11:51:24 -07001186
Matt Sarett8740d582016-11-11 13:59:14 -05001187 executable("colorspaceinfo") {
1188 sources = [
1189 "tools/colorspaceinfo.cpp",
1190 ]
1191 deps = [
1192 ":flags",
1193 ":skia",
1194 ":tool_utils",
1195 ]
1196 testonly = true
1197 }
1198
Mike Klein7d302882016-11-03 14:06:31 -04001199 if (!is_ios) {
1200 executable("skiaserve") {
1201 sources = [
1202 "tools/skiaserve/Request.cpp",
1203 "tools/skiaserve/Response.cpp",
1204 "tools/skiaserve/skiaserve.cpp",
Mike Klein7d302882016-11-03 14:06:31 -04001205 "tools/skiaserve/urlhandlers/BreakHandler.cpp",
1206 "tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp",
1207 "tools/skiaserve/urlhandlers/CmdHandler.cpp",
1208 "tools/skiaserve/urlhandlers/ColorModeHandler.cpp",
1209 "tools/skiaserve/urlhandlers/DataHandler.cpp",
1210 "tools/skiaserve/urlhandlers/DownloadHandler.cpp",
1211 "tools/skiaserve/urlhandlers/EnableGPUHandler.cpp",
1212 "tools/skiaserve/urlhandlers/ImgHandler.cpp",
1213 "tools/skiaserve/urlhandlers/InfoHandler.cpp",
Brian Salomon144a5c52016-12-20 16:48:59 -05001214 "tools/skiaserve/urlhandlers/OpBoundsHandler.cpp",
1215 "tools/skiaserve/urlhandlers/OpsHandler.cpp",
Mike Klein7d302882016-11-03 14:06:31 -04001216 "tools/skiaserve/urlhandlers/OverdrawHandler.cpp",
1217 "tools/skiaserve/urlhandlers/PostHandler.cpp",
1218 "tools/skiaserve/urlhandlers/QuitHandler.cpp",
1219 "tools/skiaserve/urlhandlers/RootHandler.cpp",
1220 ]
1221 deps = [
1222 ":flags",
1223 ":gpu_tool_utils",
1224 ":skia",
1225 ":tool_utils",
1226 "//third_party/jsoncpp",
1227 "//third_party/libmicrohttpd",
1228 "//third_party/libpng",
1229 ]
1230 testonly = true
1231 }
mtkleinecbc5262016-09-22 11:51:24 -07001232 }
kjlubick14f984b2016-10-03 11:49:45 -07001233
1234 executable("fuzz") {
1235 sources = [
1236 "fuzz/FilterFuzz.cpp",
Kevin Lubickfec1dea2016-11-22 13:57:18 -05001237 "fuzz/FuzzDrawFunctions.cpp",
kjlubick14f984b2016-10-03 11:49:45 -07001238 "fuzz/FuzzGradients.cpp",
1239 "fuzz/FuzzParsePath.cpp",
1240 "fuzz/FuzzPathop.cpp",
1241 "fuzz/FuzzScaleToSides.cpp",
1242 "fuzz/fuzz.cpp",
1243 ]
1244 deps = [
1245 ":flags",
1246 ":skia",
Hal Canarydb683012016-11-23 08:55:18 -07001247 ":tool_utils",
kjlubick14f984b2016-10-03 11:49:45 -07001248 ]
1249 testonly = true
1250 }
Mike Klein38312422016-10-05 15:41:01 -04001251
caryclark9feb6322016-10-25 08:58:26 -07001252 executable("pathops_unittest") {
Mike Klein6e744122016-10-27 12:21:40 -04001253 sources = pathops_tests_sources + [
Mike Klein6e55fef2016-10-26 11:41:47 -04001254 rebase_path("tests/skia_test.cpp"),
1255 rebase_path("tests/Test.cpp"),
1256 ]
caryclark9feb6322016-10-25 08:58:26 -07001257 deps = [
1258 ":flags",
1259 ":gpu_tool_utils",
1260 ":skia",
1261 ":tool_utils",
1262 ]
1263 testonly = true
1264 }
1265
Mike Klein38312422016-10-05 15:41:01 -04001266 executable("dump_record") {
1267 sources = [
1268 "tools/DumpRecord.cpp",
1269 "tools/dump_record.cpp",
1270 ]
1271 deps = [
1272 ":flags",
1273 ":skia",
1274 ]
1275 testonly = true
1276 }
bungemanfe917272016-10-13 17:36:40 -04001277
1278 executable("skdiff") {
1279 sources = [
1280 "tools/skdiff/skdiff.cpp",
1281 "tools/skdiff/skdiff_html.cpp",
1282 "tools/skdiff/skdiff_main.cpp",
1283 "tools/skdiff/skdiff_utils.cpp",
1284 ]
1285 deps = [
1286 ":skia",
1287 ":tool_utils",
1288 ]
1289 testonly = true
1290 }
halcanarya73d76a2016-10-17 13:19:02 -07001291
1292 executable("skp_parser") {
1293 sources = [
1294 "tools/skp_parser.cpp",
1295 ]
1296 deps = [
1297 ":skia",
1298 ":tool_utils",
1299 "//third_party/jsoncpp",
1300 ]
1301 testonly = true
1302 }
Brian Osman16adfa32016-10-18 14:42:44 -04001303
Mike Kleina92c3832016-12-08 09:49:39 -05001304 if (skia_enable_gpu && (is_android || is_linux || is_win || is_mac)) {
1305 source_set("viewer_sources") {
Brian Osman16adfa32016-10-18 14:42:44 -04001306 sources = [
1307 "tools/viewer/GMSlide.cpp",
1308 "tools/viewer/ImageSlide.cpp",
1309 "tools/viewer/SKPSlide.cpp",
1310 "tools/viewer/SampleSlide.cpp",
1311 "tools/viewer/Viewer.cpp",
1312 "tools/viewer/sk_app/CommandSet.cpp",
1313 "tools/viewer/sk_app/GLWindowContext.cpp",
1314 "tools/viewer/sk_app/Window.cpp",
1315 "tools/viewer/sk_app/WindowContext.cpp",
1316 ]
Brian Osman2dd96932016-10-18 15:33:53 -04001317 libs = []
Brian Osman16adfa32016-10-18 14:42:44 -04001318
Jim Van Verth4e56a912016-10-21 10:58:52 -04001319 if (is_android) {
1320 sources += [
1321 "tools/viewer/sk_app/android/GLWindowContext_android.cpp",
1322 "tools/viewer/sk_app/android/RasterWindowContext_android.cpp",
1323 "tools/viewer/sk_app/android/Window_android.cpp",
1324 "tools/viewer/sk_app/android/main_android.cpp",
1325 "tools/viewer/sk_app/android/surface_glue_android.cpp",
1326 ]
1327 } else if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -04001328 sources += [
1329 "tools/viewer/sk_app/unix/GLWindowContext_unix.cpp",
1330 "tools/viewer/sk_app/unix/RasterWindowContext_unix.cpp",
1331 "tools/viewer/sk_app/unix/Window_unix.cpp",
1332 "tools/viewer/sk_app/unix/main_unix.cpp",
1333 ]
1334 } else if (is_win) {
Brian Osman16adfa32016-10-18 14:42:44 -04001335 sources += [
1336 "tools/viewer/sk_app/win/GLWindowContext_win.cpp",
1337 "tools/viewer/sk_app/win/RasterWindowContext_win.cpp",
1338 "tools/viewer/sk_app/win/Window_win.cpp",
1339 "tools/viewer/sk_app/win/main_win.cpp",
1340 ]
Mike Klein43c25262016-10-20 10:17:47 -04001341 } else if (is_mac) {
1342 sources += [
1343 "tools/viewer/sk_app/mac/GLWindowContext_mac.cpp",
1344 "tools/viewer/sk_app/mac/RasterWindowContext_mac.cpp",
1345 "tools/viewer/sk_app/mac/Window_mac.cpp",
1346 "tools/viewer/sk_app/mac/main_mac.cpp",
1347 ]
Brian Osman16adfa32016-10-18 14:42:44 -04001348 }
1349
1350 if (skia_use_vulkan) {
1351 sources += [ "tools/viewer/sk_app/VulkanWindowContext.cpp" ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001352 if (is_android) {
1353 sources +=
1354 [ "tools/viewer/sk_app/android/VulkanWindowContext_android.cpp" ]
1355 libs += [ "android" ]
1356 } else if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -04001357 sources += [ "tools/viewer/sk_app/unix/VulkanWindowContext_unix.cpp" ]
1358 libs += [ "X11-xcb" ]
1359 } else if (is_win) {
Brian Osman16adfa32016-10-18 14:42:44 -04001360 sources += [ "tools/viewer/sk_app/win/VulkanWindowContext_win.cpp" ]
1361 }
1362 }
1363
1364 include_dirs = []
1365 deps = [
1366 ":flags",
1367 ":gm",
1368 ":gpu_tool_utils",
1369 ":samples",
1370 ":skia",
1371 ":tool_utils",
1372 ":views",
1373 "//third_party/jsoncpp",
1374 ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001375 if (is_android) {
1376 deps += [ "//third_party/native_app_glue" ]
1377 } else if (is_mac) {
Mike Klein43c25262016-10-20 10:17:47 -04001378 deps += [ "//third_party/libsdl" ]
1379 }
Brian Osman16adfa32016-10-18 14:42:44 -04001380 testonly = true
1381 }
Mike Kleina92c3832016-12-08 09:49:39 -05001382
1383 if (is_android) {
1384 shared_library("libviewer") {
1385 deps = [
1386 ":viewer_sources",
1387 ]
1388 testonly = true
1389 }
1390 } else {
1391 executable("viewer") {
1392 deps = [
1393 ":viewer_sources",
1394 ]
1395 testonly = true
1396 }
1397 }
Brian Osman16adfa32016-10-18 14:42:44 -04001398 }
Ethan Nicholas4f3985c2016-11-14 11:16:37 -05001399
1400 if (skia_enable_gpu) {
1401 executable("skslc") {
1402 sources = [
1403 "src/sksl/SkSLMain.cpp",
1404 ]
1405 deps = [
1406 ":flags",
1407 ":skia",
1408 ]
1409 testonly = true
1410 }
1411 }
mtklein25c81d42016-07-27 13:55:26 -07001412}