blob: c4158c622e2ce82ef08de775817651207c5d7269 [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
Hal Canary43fb7a02016-12-30 13:09:03 -050031 skia_enable_pdf = true
mtklein3e8012e2016-09-21 09:14:19 -070032 skia_enable_tools = is_skia_standalone
33 skia_enable_vulkan_debug_layers = is_skia_standalone && is_debug
Greg Daniel686bb212016-10-27 10:48:48 -040034 skia_vulkan_sdk = getenv("VULKAN_SDK")
mtkleinc04ff472016-06-23 10:29:30 -070035}
Brian Salomon23d73ea2016-10-27 13:31:37 -040036declare_args() {
James Robinson14b748d2016-11-12 18:29:39 -080037 skia_use_dng_sdk =
38 !is_fuchsia && !is_win && skia_use_libjpeg_turbo && skia_use_zlib
Mike Klein10d665d2016-11-01 11:46:10 -040039 skia_use_sfntly = skia_use_icu
40
Mike Klein4d598a32016-10-31 13:44:49 -040041 if (is_android) {
42 skia_use_vulkan = defined(ndk_api) && ndk_api >= 24
43 } else {
44 skia_use_vulkan = skia_vulkan_sdk != ""
45 }
Brian Salomon23d73ea2016-10-27 13:31:37 -040046}
Brian Salomon789e25e2016-09-30 13:41:03 -040047
mtklein38925aa2016-09-21 10:11:25 -070048# Our tools require static linking (they use non-exported symbols).
49skia_enable_tools = skia_enable_tools && !is_component_build
mtklein06c35c02016-09-20 12:28:12 -070050
mtkleina45be612016-08-29 15:22:10 -070051fontmgr_android_enabled = skia_use_expat && skia_use_freetype
52
mtklein1211e0c2016-07-26 13:55:45 -070053skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070054 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070055 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070056 "include/codec",
57 "include/config",
58 "include/core",
59 "include/effects",
60 "include/gpu",
61 "include/gpu/gl",
62 "include/images",
63 "include/pathops",
64 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070065 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070066 "include/utils",
67 "include/utils/mac",
mtklein25c81d42016-07-27 13:55:26 -070068 "include/xml",
mtklein1211e0c2016-07-26 13:55:45 -070069]
70
mtkleinc04ff472016-06-23 10:29:30 -070071# Skia public API, generally provided by :skia.
72config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -070073 include_dirs = skia_public_includes
Mike Kleinae7e6712016-10-11 17:49:33 -040074 defines = []
75 if (is_component_build) {
76 defines += [ "SKIA_DLL" ]
77 }
Mike Kleinc4cbd742016-09-26 21:37:09 -040078 if (is_fuchsia || is_linux) {
jcgregorio5561e3d2016-08-25 09:25:11 -070079 defines += [ "SK_SAMPLES_FOR_X" ]
80 }
mtkleincae1be52016-09-20 08:24:34 -070081 if (skia_enable_android_framework_defines) {
Mike Kleincfc4f442016-10-26 17:19:03 -040082 defines += android_framework_defines
mtkleincae1be52016-09-20 08:24:34 -070083 }
mtklein06c35c02016-09-20 12:28:12 -070084 if (!skia_enable_gpu) {
85 defines += [ "SK_SUPPORT_GPU=0" ]
86 }
mtkleinc04ff472016-06-23 10:29:30 -070087}
88
89# Skia internal APIs, used by Skia itself and a few test tools.
90config("skia_private") {
91 visibility = [ ":*" ]
92
93 include_dirs = [
94 "include/private",
95 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -070096 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -070097 "src/core",
98 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -070099 "src/effects/gradients",
100 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -0700101 "src/gpu",
102 "src/image",
103 "src/images",
104 "src/lazy",
105 "src/opts",
106 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -0700107 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -0700108 "src/ports",
109 "src/sfnt",
mtklein9e0d9dd2016-08-30 10:37:19 -0700110 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -0700111 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -0700112 "src/utils/win",
mtkleinc04ff472016-06-23 10:29:30 -0700113 "third_party/etc1",
scroggo19b91532016-10-24 09:03:26 -0700114 "third_party/gif",
Leon Scroggins427da6f2016-12-16 13:51:59 +0000115 "third_party/ktx",
mtkleinc04ff472016-06-23 10:29:30 -0700116 ]
mtklein150d1132016-08-01 06:56:40 -0700117
Jim Van Verthb6c5e532016-10-28 10:38:08 -0400118 defines = [
119 "SK_GAMMA_APPLY_TO_A8",
120 "SK_INTERNAL",
121 ]
mtkleinb37c0342016-09-09 11:07:45 -0700122 if (is_android) {
123 defines += [
124 "SK_GAMMA_EXPONENT=1.4",
125 "SK_GAMMA_CONTRAST=0.0",
126 ]
127 }
mtklein88a7ac02016-09-14 11:16:49 -0700128 if (is_official_build || is_android) {
129 # TODO(bsalomon): it'd be nice to make Android normal.
130 defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
131 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400132 libs = []
133 lib_dirs = []
134 if (skia_use_vulkan) {
Greg Danielab563d42016-10-31 11:19:59 -0400135 if (skia_vulkan_sdk != "" && !is_android) {
Mike Klein487bfc22016-10-14 14:04:56 -0400136 if (is_win) {
137 include_dirs += [ "$skia_vulkan_sdk/Include/" ]
138 lib_dirs += [ "$skia_vulkan_sdk/Bin" ]
139 } else {
Greg Daniel686bb212016-10-27 10:48:48 -0400140 include_dirs += [ "$skia_vulkan_sdk/include/" ]
141 lib_dirs += [ "$skia_vulkan_sdk/lib/" ]
Mike Klein487bfc22016-10-14 14:04:56 -0400142 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400143 }
Mike Klein487bfc22016-10-14 14:04:56 -0400144 if (is_win) {
145 libs += [ "vulkan-1.lib" ]
146 } else {
147 libs += [ "vulkan" ]
148 }
Brian Salomon789e25e2016-09-30 13:41:03 -0400149 }
Brian Osman34755e22016-12-05 09:46:02 -0500150 if (skia_use_angle) {
151 defines += [ "SK_ANGLE" ]
152 }
Brian Osman3f375d02016-12-28 11:19:22 -0500153 if (skia_enable_discrete_gpu) {
154 defines += [ "SK_ENABLE_DISCRETE_GPU" ]
155 }
mtkleinc04ff472016-06-23 10:29:30 -0700156}
157
158# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
159config("skia_library") {
160 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -0700161 defines = [ "SKIA_IMPLEMENTATION=1" ]
162}
163
164skia_library_configs = [
165 ":skia_public",
166 ":skia_private",
167 ":skia_library",
168]
169
mtklein9b8583d2016-08-24 17:32:30 -0700170# Use for CPU-specific Skia code that needs particular compiler flags.
171template("opts") {
172 if (invoker.enabled) {
173 source_set(target_name) {
174 forward_variables_from(invoker, "*")
175 configs += skia_library_configs
176 }
177 } else {
178 # If not enabled, a phony empty target that swallows all otherwise unused variables.
179 source_set(target_name) {
180 forward_variables_from(invoker,
181 "*",
182 [
183 "sources",
184 "cflags",
185 ])
186 }
187 }
anmittala7eaf2e2016-08-17 13:57:26 -0700188}
189
mtklein422310d2016-08-16 18:28:43 -0700190is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700191
mtklein7d6fb2c2016-08-25 14:50:44 -0700192opts("none") {
193 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700194 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700195 cflags = []
196}
197
mtklein7d6fb2c2016-08-25 14:50:44 -0700198opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700199 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700200 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700201 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700202}
203
204opts("arm64") {
205 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700206 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700207 cflags = []
208}
209
210opts("crc32") {
211 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700212 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700213 cflags = [ "-march=armv8-a+crc" ]
214}
215
mtklein9b8583d2016-08-24 17:32:30 -0700216opts("sse2") {
217 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700218 sources = skia_opts.sse2_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400219 if (is_win) {
220 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE2" ]
221 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400222 cflags = [ "-msse2" ]
223 }
mtklein9b8583d2016-08-24 17:32:30 -0700224}
mtkleinc04ff472016-06-23 10:29:30 -0700225
mtklein9b8583d2016-08-24 17:32:30 -0700226opts("ssse3") {
227 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700228 sources = skia_opts.ssse3_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400229 if (is_win) {
230 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSSE3" ]
231 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400232 cflags = [ "-mssse3" ]
233 }
mtklein9b8583d2016-08-24 17:32:30 -0700234}
mtkleinc04ff472016-06-23 10:29:30 -0700235
mtklein9b8583d2016-08-24 17:32:30 -0700236opts("sse41") {
237 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700238 sources = skia_opts.sse41_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400239 if (is_win) {
240 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE41" ]
241 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400242 cflags = [ "-msse4.1" ]
243 }
mtklein9b8583d2016-08-24 17:32:30 -0700244}
mtklein4e976072016-08-08 09:06:27 -0700245
mtklein9b8583d2016-08-24 17:32:30 -0700246opts("sse42") {
247 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700248 sources = skia_opts.sse42_sources
Mike Kleind8765e32016-10-19 13:39:13 -0400249 if (is_win) {
250 defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE42" ]
251 } else {
Mike Klein3eb71212016-10-11 17:08:53 -0400252 cflags = [ "-msse4.2" ]
253 }
mtklein9b8583d2016-08-24 17:32:30 -0700254}
255
256opts("avx") {
257 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700258 sources = skia_opts.avx_sources
Mike Klein3eb71212016-10-11 17:08:53 -0400259 if (is_win) {
Mike Klein17b6e482016-11-18 22:11:41 +0000260 cflags = [ "/arch:AVX" ]
Mike Klein3eb71212016-10-11 17:08:53 -0400261 } else {
262 cflags = [ "-mavx" ]
263 }
mtkleinc04ff472016-06-23 10:29:30 -0700264}
265
Mike Klein78d5a3b2016-09-30 10:48:01 -0400266opts("hsw") {
267 enabled = is_x86
268 sources = skia_opts.hsw_sources
Mike Klein3eb71212016-10-11 17:08:53 -0400269 if (is_win) {
Mike Klein17b6e482016-11-18 22:11:41 +0000270 cflags = [ "/arch:AVX2" ]
Mike Klein3eb71212016-10-11 17:08:53 -0400271 } else {
272 cflags = [
273 "-mavx2",
274 "-mbmi",
275 "-mbmi2",
276 "-mf16c",
277 "-mfma",
278 ]
279 }
Mike Klein78d5a3b2016-09-30 10:48:01 -0400280}
281
mtkleinc095df52016-08-24 12:23:52 -0700282# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700283template("optional") {
284 if (invoker.enabled) {
285 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700286 if (defined(invoker.public_defines)) {
287 defines = invoker.public_defines
288 }
mtklein457b42a2016-08-23 13:56:37 -0700289 }
290 source_set(target_name) {
mtkleincd01b032016-08-31 04:58:19 -0700291 forward_variables_from(invoker,
292 "*",
293 [
294 "public_defines",
295 "sources_when_disabled",
scroggof84ad642016-10-31 09:02:57 -0700296 "configs_to_remove",
mtkleincd01b032016-08-31 04:58:19 -0700297 ])
mtklein457b42a2016-08-23 13:56:37 -0700298 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700299 configs += skia_library_configs
scroggof84ad642016-10-31 09:02:57 -0700300 if (defined(invoker.configs_to_remove)) {
301 configs -= invoker.configs_to_remove
302 }
mtklein457b42a2016-08-23 13:56:37 -0700303 }
304 } else {
mtklein457b42a2016-08-23 13:56:37 -0700305 source_set(target_name) {
306 forward_variables_from(invoker,
307 "*",
308 [
309 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700310 "deps",
mtklein6ef69992016-09-14 06:12:09 -0700311 "libs",
mtklein457b42a2016-08-23 13:56:37 -0700312 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700313 "sources_when_disabled",
scroggof84ad642016-10-31 09:02:57 -0700314 "configs_to_remove",
mtklein457b42a2016-08-23 13:56:37 -0700315 ])
mtkleincd01b032016-08-31 04:58:19 -0700316 if (defined(invoker.sources_when_disabled)) {
317 sources = invoker.sources_when_disabled
318 }
319 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700320 }
mtkleineb3c4252016-08-23 07:38:09 -0700321 }
mtklein457b42a2016-08-23 13:56:37 -0700322}
mtklein457b42a2016-08-23 13:56:37 -0700323
mtkleina45be612016-08-29 15:22:10 -0700324optional("fontmgr_android") {
325 enabled = fontmgr_android_enabled
mtkleina45be612016-08-29 15:22:10 -0700326
327 deps = [
328 "//third_party/expat",
329 "//third_party/freetype2",
330 ]
331 sources = [
332 "src/ports/SkFontMgr_android.cpp",
333 "src/ports/SkFontMgr_android_factory.cpp",
334 "src/ports/SkFontMgr_android_parser.cpp",
335 ]
336}
337
mtkleind2e39db2016-09-07 07:52:55 -0700338optional("fontmgr_custom") {
339 enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
340
341 deps = [
342 "//third_party/freetype2",
343 ]
344 sources = [
345 "src/ports/SkFontMgr_custom.cpp",
346 "src/ports/SkFontMgr_custom_directory_factory.cpp",
347 ]
348}
349
mtklein3cc22182016-08-29 13:26:14 -0700350optional("fontmgr_fontconfig") {
351 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700352
353 deps = [
354 "//third_party:fontconfig",
355 "//third_party/freetype2",
356 ]
357 sources = [
bungeman1ae0e012016-09-19 12:13:16 -0700358 "src/ports/SkFontConfigInterface.cpp",
mtklein3cc22182016-08-29 13:26:14 -0700359 "src/ports/SkFontConfigInterface_direct.cpp",
360 "src/ports/SkFontConfigInterface_direct_factory.cpp",
361 "src/ports/SkFontMgr_FontConfigInterface.cpp",
362 "src/ports/SkFontMgr_fontconfig.cpp",
363 "src/ports/SkFontMgr_fontconfig_factory.cpp",
364 ]
365}
366
mtkleincdedd0e2016-09-12 15:15:44 -0700367optional("fontmgr_fuchsia") {
368 enabled = is_fuchsia && skia_use_freetype
369
370 deps = [
371 "//third_party/freetype2",
372 ]
373 sources = [
374 "src/ports/SkFontMgr_custom.cpp",
375 "src/ports/SkFontMgr_custom_empty_factory.cpp",
376 ]
377}
378
mtklein06c35c02016-09-20 12:28:12 -0700379optional("gpu") {
380 enabled = skia_enable_gpu
mtkleine9fb3d52016-09-20 15:11:46 -0700381 public_defines = []
382
mtklein06c35c02016-09-20 12:28:12 -0700383 sources = skia_gpu_sources + [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ]
384
385 # These paths need to be absolute to match the ones produced by shared_sources.gni.
386 sources -= get_path_info([
387 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
388 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
389 ],
390 "abspath")
Mike Klein703cf5a2016-10-13 17:18:04 -0400391 libs = []
mtklein06c35c02016-09-20 12:28:12 -0700392 if (is_android) {
393 sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
394 } else if (is_linux) {
395 sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
396 } else if (is_mac) {
397 sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
Chinmay Garde130a1182016-11-23 11:43:56 -0800398 } else if (is_ios) {
399 sources += [ "src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp" ]
Mike Klein703cf5a2016-10-13 17:18:04 -0400400 } else if (is_win) {
401 sources += [ "src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp" ]
402 libs += [ "OpenGL32.lib" ]
mtklein06c35c02016-09-20 12:28:12 -0700403 } else {
404 sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
405 }
mtkleine9fb3d52016-09-20 15:11:46 -0700406
407 if (skia_use_vulkan) {
408 public_defines += [ "SK_VULKAN" ]
409 sources += skia_vk_sources
egdaniele4a9bd72016-09-21 07:36:14 -0700410 if (skia_enable_vulkan_debug_layers) {
411 public_defines += [ "SK_ENABLE_VK_LAYERS" ]
412 }
mtkleine9fb3d52016-09-20 15:11:46 -0700413 }
mtklein06c35c02016-09-20 12:28:12 -0700414}
415
mtklein63213812016-08-24 09:55:56 -0700416optional("jpeg") {
417 enabled = skia_use_libjpeg_turbo
418 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
419
mtklein63213812016-08-24 09:55:56 -0700420 deps = [
421 "//third_party/libjpeg-turbo:libjpeg",
422 ]
423 sources = [
424 "src/codec/SkJpegCodec.cpp",
425 "src/codec/SkJpegDecoderMgr.cpp",
426 "src/codec/SkJpegUtility.cpp",
427 "src/images/SkJPEGImageEncoder.cpp",
428 "src/images/SkJPEGWriteUtility.cpp",
429 ]
430}
431
432optional("pdf") {
Hal Canary43fb7a02016-12-30 13:09:03 -0500433 enabled = skia_use_zlib && skia_enable_pdf
434 public_defines = [ "SK_SUPPORT_PDF" ]
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" ]
Hal Canary43fb7a02016-12-30 13:09:03 -0500444 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",
mtkleina45be612016-08-29 15:22:10 -0700531 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700532 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700533 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700534 ":fontmgr_fuchsia",
mtklein06c35c02016-09-20 12:28:12 -0700535 ":gpu",
Mike Klein78d5a3b2016-09-30 10:48:01 -0400536 ":hsw",
mtklein63213812016-08-24 09:55:56 -0700537 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700538 ":none",
mtklein63213812016-08-24 09:55:56 -0700539 ":pdf",
540 ":png",
scroggof84ad642016-10-31 09:02:57 -0700541 ":raw",
mtklein9b8583d2016-08-24 17:32:30 -0700542 ":sse2",
543 ":sse41",
544 ":sse42",
545 ":ssse3",
mtklein3cc22182016-08-29 13:26:14 -0700546 ":typeface_freetype",
mtkleineb3c4252016-08-23 07:38:09 -0700547 ":webp",
mtklein63213812016-08-24 09:55:56 -0700548 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700549 ]
550
Chinmay Garde43f115c2016-11-16 15:04:12 -0800551 # This file (and all GN files in Skia) are designed to work with an
552 # empty sources assignment filter; we handle all that explicitly.
553 # We clear the filter here for clients who may have set up a global filter.
554 set_sources_assignment_filter([])
555
mtkleinc04ff472016-06-23 10:29:30 -0700556 sources = []
brettwb9447282016-09-01 14:24:39 -0700557 sources += skia_core_sources
558 sources += skia_effects_sources
brettwb9447282016-09-01 14:24:39 -0700559 sources += skia_sksl_sources
560 sources += skia_utils_sources
Hal Canary6ad3d2f2016-12-20 16:15:56 -0500561 sources += skia_xps_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",
611 ]
Mike Klein69f6ed42016-10-13 15:45:07 -0400612 if (skia_use_gdi) {
613 sources += [ "src/ports/SkFontMgr_win_gdi_factory.cpp" ]
614 libs += [
615 "Gdi32.lib",
616 "Usp10.lib",
617 ]
618 } else {
619 sources += [ "src/ports/SkFontMgr_win_dw_factory.cpp" ]
620 }
mtkleinb9be9792016-09-16 14:44:18 -0700621 sources -=
622 [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
Mike Klein4b167fc2016-10-11 18:13:53 -0400623 libs += [
624 "FontSub.lib",
625 "Ole32.lib",
626 "OleAut32.lib",
627 "User32.lib",
628 ]
mtkleinc04ff472016-06-23 10:29:30 -0700629 } else {
630 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700631 "src/ports/SkOSFile_posix.cpp",
mtklein605d9522016-09-21 14:01:32 -0700632 "src/ports/SkOSLibrary_posix.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700633 "src/ports/SkTLS_pthread.cpp",
634 ]
635 }
636
mtklein7d6fb2c2016-08-25 14:50:44 -0700637 if (is_android) {
Mike Kleinc3083332016-12-12 09:03:56 -0500638 deps += [ "//third_party/expat" ]
mtklein06c35c02016-09-20 12:28:12 -0700639 sources += [ "src/ports/SkDebug_android.cpp" ]
mtklein7d6fb2c2016-08-25 14:50:44 -0700640 libs += [
641 "EGL",
642 "GLESv2",
643 "log",
644 ]
645 }
646
mtkleinc04ff472016-06-23 10:29:30 -0700647 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700648 libs += [
649 "GL",
650 "GLU",
651 "X11",
652 ]
mtklein06c35c02016-09-20 12:28:12 -0700653 sources += [ "src/ports/SkDebug_stdio.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700654 }
655
656 if (is_mac) {
657 sources += [
mtklein7d6fb2c2016-08-25 14:50:44 -0700658 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700659 "src/ports/SkFontHost_mac.cpp",
660 "src/ports/SkImageEncoder_CG.cpp",
661 "src/ports/SkImageGeneratorCG.cpp",
662 ]
mtklein09e61f72016-08-23 13:35:28 -0700663 libs += [
664 "ApplicationServices.framework",
665 "OpenGL.framework",
666 ]
mtkleinc04ff472016-06-23 10:29:30 -0700667 }
abarth6fc8ff02016-07-15 15:15:15 -0700668
Mike Klein7d302882016-11-03 14:06:31 -0400669 if (is_ios) {
670 sources += [
671 "src/ports/SkDebug_stdio.cpp",
672 "src/ports/SkFontHost_mac.cpp",
673 "src/ports/SkImageEncoder_CG.cpp",
674 "src/ports/SkImageGeneratorCG.cpp",
675 ]
676 libs += [
677 "CoreFoundation.framework",
678 "CoreGraphics.framework",
679 "CoreText.framework",
680 "ImageIO.framework",
681 "MobileCoreServices.framework",
682 ]
683 }
684
abarth6fc8ff02016-07-15 15:15:15 -0700685 if (is_fuchsia) {
mtklein06c35c02016-09-20 12:28:12 -0700686 sources += [ "src/ports/SkDebug_stdio.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700687 }
mtkleinc04ff472016-06-23 10:29:30 -0700688}
689
mtkleinc095df52016-08-24 12:23:52 -0700690# Targets guarded by skia_enable_tools may use //third_party freely.
691if (skia_enable_tools) {
Mike Klein308b5ac2016-12-06 16:03:52 -0500692 # Used by gn_to_bp.py to list our public include dirs.
693 source_set("public") {
694 configs += [ ":skia_public" ]
695 }
696
Mike Kleinc36dedf2016-11-18 09:35:28 -0500697 config("skia.h_config") {
698 include_dirs = [ "$target_gen_dir" ]
699 }
700 action("skia.h") {
701 public_configs = [ ":skia.h_config" ]
702 skia_h = "$target_gen_dir/skia.h"
703 script = "gn/find_headers.py"
704 args = [ rebase_path(skia_h, root_build_dir) ] +
705 rebase_path(skia_public_includes)
706 depfile = "$skia_h.deps"
707 outputs = [
708 skia_h,
709 ]
710 }
711
712 if (skia_enable_gpu && target_cpu == "x64") {
713 # Our bots only have 64-bit libOSMesa installed.
714 # TODO: worth fixing?
715 executable("fiddle") {
716 libs = []
717 if (is_linux) {
718 libs += [ "OSMesa" ]
719 }
720
721 sources = [
Mike Kleinc36dedf2016-11-18 09:35:28 -0500722 "tools/fiddle/draw.cpp",
723 "tools/fiddle/fiddle_main.cpp",
724 ]
725 deps = [
726 ":skia",
727 ":skia.h",
728 ]
729 }
730 }
731
732 if (skia_enable_gpu) {
733 source_set("public_headers_warnings_check") {
734 sources = [
735 "tools/public_headers_warnings_check.cpp",
736 ]
737 configs -= [ "//gn:warnings_except_public_headers" ]
738 deps = [
739 ":skia",
740 ":skia.h",
741 ]
742 }
743 }
744
mtkleinc095df52016-08-24 12:23:52 -0700745 template("test_lib") {
746 config(target_name + "_config") {
747 include_dirs = invoker.public_include_dirs
mtkleina627b5c2016-09-20 13:36:47 -0700748 if (defined(invoker.public_defines)) {
749 defines = invoker.public_defines
750 }
mtklein25c81d42016-07-27 13:55:26 -0700751 }
mtkleinc095df52016-08-24 12:23:52 -0700752 source_set(target_name) {
753 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
754 public_configs = [
755 ":" + target_name + "_config",
756 ":skia_private",
757 ]
758
759 if (!defined(deps)) {
760 deps = []
761 }
762 deps += [ ":skia" ]
763 testonly = true
764 }
mtklein25c81d42016-07-27 13:55:26 -0700765 }
mtklein25c81d42016-07-27 13:55:26 -0700766
mtkleinc095df52016-08-24 12:23:52 -0700767 test_lib("gpu_tool_utils") {
mtklein38925aa2016-09-21 10:11:25 -0700768 public_include_dirs = []
769 if (skia_enable_gpu) {
770 public_defines = []
771 public_include_dirs += [ "tools/gpu" ]
mtkleind68f9b02016-09-23 13:18:41 -0700772
773 deps = []
mtklein38925aa2016-09-21 10:11:25 -0700774 sources = [
775 "tools/gpu/GrContextFactory.cpp",
776 "tools/gpu/GrTest.cpp",
777 "tools/gpu/TestContext.cpp",
778 "tools/gpu/gl/GLTestContext.cpp",
mtklein605d9522016-09-21 14:01:32 -0700779 "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
mtklein38925aa2016-09-21 10:11:25 -0700780 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
781 "tools/gpu/gl/debug/GrBufferObj.cpp",
782 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
783 "tools/gpu/gl/debug/GrProgramObj.cpp",
784 "tools/gpu/gl/debug/GrShaderObj.cpp",
785 "tools/gpu/gl/debug/GrTextureObj.cpp",
786 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
787 "tools/gpu/gl/null/NullGLTestContext.cpp",
788 ]
789 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700790
mtklein38925aa2016-09-21 10:11:25 -0700791 if (is_android) {
792 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
Mike Klein7d302882016-11-03 14:06:31 -0400793 } else if (is_ios) {
794 sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
795 libs += [ "OpenGLES.framework" ]
mtklein38925aa2016-09-21 10:11:25 -0700796 } else if (is_linux) {
797 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
798 } else if (is_mac) {
799 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
Mike Klein4b167fc2016-10-11 18:13:53 -0400800 } else if (is_win) {
801 sources += [ "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp" ]
802 libs += [
803 "Gdi32.lib",
804 "OpenGL32.lib",
805 ]
mtklein38925aa2016-09-21 10:11:25 -0700806 }
mtklein6ef69992016-09-14 06:12:09 -0700807
Mike Kleinc168a3a2016-11-14 14:53:13 +0000808 if (skia_use_angle) {
Mike Kleinc168a3a2016-11-14 14:53:13 +0000809 deps += [ "//third_party/angle2" ]
810 sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
811 }
mtklein38925aa2016-09-21 10:11:25 -0700812 if (skia_use_mesa) {
813 public_defines += [ "SK_MESA" ]
814 sources += [ "tools/gpu/gl/mesa/GLTestContext_mesa.cpp" ]
815 libs += [ "OSMesa" ]
816 }
mtkleind68f9b02016-09-23 13:18:41 -0700817 if (skia_use_vulkan) {
818 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
819 }
mtkleina627b5c2016-09-20 13:36:47 -0700820 }
mtklein25c81d42016-07-27 13:55:26 -0700821 }
mtklein25c81d42016-07-27 13:55:26 -0700822
mtkleinc095df52016-08-24 12:23:52 -0700823 test_lib("flags") {
824 public_include_dirs = [ "tools/flags" ]
825 sources = [
826 "tools/flags/SkCommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -0700827 ]
828 }
829 test_lib("common_flags") {
830 public_include_dirs = [ "tools/flags" ]
831 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700832 "tools/flags/SkCommonFlags.cpp",
833 "tools/flags/SkCommonFlagsConfig.cpp",
834 ]
835 deps = [
mtklein046cb562016-09-16 10:23:12 -0700836 ":flags",
mtkleinc095df52016-08-24 12:23:52 -0700837 ":gpu_tool_utils",
838 ]
839 }
mtklein25c81d42016-07-27 13:55:26 -0700840
mtkleinc095df52016-08-24 12:23:52 -0700841 test_lib("tool_utils") {
842 public_include_dirs = [
843 "tools",
844 "tools/debugger",
845 "tools/timer",
846 ]
847 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700848 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700849 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700850 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700851 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700852 "tools/ProcStats.cpp",
853 "tools/Resources.cpp",
854 "tools/ThermalManager.cpp",
855 "tools/UrlDataManager.cpp",
856 "tools/debugger/SkDebugCanvas.cpp",
857 "tools/debugger/SkDrawCommand.cpp",
858 "tools/debugger/SkJsonWriteBuffer.cpp",
859 "tools/debugger/SkObjectParser.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700860 "tools/picture_utils.cpp",
861 "tools/random_parse_path.cpp",
862 "tools/sk_tool_utils.cpp",
863 "tools/sk_tool_utils_font.cpp",
864 "tools/timer/Timer.cpp",
865 ]
866 deps = [
mtklein046cb562016-09-16 10:23:12 -0700867 ":common_flags",
mtkleinc095df52016-08-24 12:23:52 -0700868 ":flags",
869 "//third_party/libpng",
870 ]
871 public_deps = [
872 "//third_party/jsoncpp",
873 ]
874 }
mtklein25c81d42016-07-27 13:55:26 -0700875
Mike Klein6e744122016-10-27 12:21:40 -0400876 import("gn/gm.gni")
mtkleinc095df52016-08-24 12:23:52 -0700877 test_lib("gm") {
878 public_include_dirs = [ "gm" ]
879 sources = gm_sources
880 deps = [
scroggo19b91532016-10-24 09:03:26 -0700881 ":flags",
mtkleinc095df52016-08-24 12:23:52 -0700882 ":gpu_tool_utils",
883 ":skia",
884 ":tool_utils",
885 ]
886 }
mtklein25c81d42016-07-27 13:55:26 -0700887
Mike Klein6e744122016-10-27 12:21:40 -0400888 import("gn/tests.gni")
mtkleinc095df52016-08-24 12:23:52 -0700889 test_lib("tests") {
890 public_include_dirs = [ "tests" ]
Mike Klein6e744122016-10-27 12:21:40 -0400891 sources = tests_sources + pathops_tests_sources
mtkleina45be612016-08-29 15:22:10 -0700892 if (!fontmgr_android_enabled) {
Mike Klein6e744122016-10-27 12:21:40 -0400893 sources -= [ "//tests/FontMgrAndroidParserTest.cpp" ]
mtkleina45be612016-08-29 15:22:10 -0700894 }
mtkleinc095df52016-08-24 12:23:52 -0700895 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700896 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700897 ":flags",
898 ":gpu_tool_utils",
899 ":skia",
900 ":tool_utils",
901 "//third_party/libpng",
902 "//third_party/zlib",
903 ]
904 }
mtklein2f3416d2016-08-02 16:02:05 -0700905
Mike Klein6e744122016-10-27 12:21:40 -0400906 import("gn/bench.gni")
mtkleinc095df52016-08-24 12:23:52 -0700907 test_lib("bench") {
908 public_include_dirs = [ "bench" ]
909 sources = bench_sources
mtkleinc095df52016-08-24 12:23:52 -0700910 deps = [
911 ":flags",
912 ":gm",
913 ":gpu_tool_utils",
914 ":skia",
915 ":tool_utils",
916 ]
917 }
mtklein2b6870c2016-07-28 14:17:33 -0700918
mtkleinc095df52016-08-24 12:23:52 -0700919 test_lib("experimental_svg_model") {
920 public_include_dirs = [ "experimental/svg/model" ]
921 sources = [
922 "experimental/svg/model/SkSVGAttribute.cpp",
923 "experimental/svg/model/SkSVGAttributeParser.cpp",
924 "experimental/svg/model/SkSVGCircle.cpp",
Florin Malitace8840e2016-12-08 09:26:47 -0500925 "experimental/svg/model/SkSVGClipPath.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700926 "experimental/svg/model/SkSVGContainer.cpp",
927 "experimental/svg/model/SkSVGDOM.cpp",
928 "experimental/svg/model/SkSVGEllipse.cpp",
929 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700930 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700931 "experimental/svg/model/SkSVGNode.cpp",
932 "experimental/svg/model/SkSVGPath.cpp",
933 "experimental/svg/model/SkSVGPoly.cpp",
934 "experimental/svg/model/SkSVGRect.cpp",
935 "experimental/svg/model/SkSVGRenderContext.cpp",
936 "experimental/svg/model/SkSVGSVG.cpp",
937 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700938 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700939 "experimental/svg/model/SkSVGTransformableNode.cpp",
940 "experimental/svg/model/SkSVGValue.cpp",
941 ]
942 deps = [
943 ":skia",
944 ]
945 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700946
Brian Osman16adfa32016-10-18 14:42:44 -0400947 test_lib("views") {
948 public_include_dirs = [ "include/views" ]
949 sources = [
950 "src/views/SkEvent.cpp",
951 "src/views/SkEventSink.cpp",
952 "src/views/SkOSMenu.cpp",
953 "src/views/SkTagList.cpp",
954 "src/views/SkTouchGesture.cpp",
955 "src/views/SkView.cpp",
956 "src/views/SkViewPriv.cpp",
957 ]
958 libs = []
Brian Osman34755e22016-12-05 09:46:02 -0500959 deps = []
Brian Osman16adfa32016-10-18 14:42:44 -0400960 if (!is_android) {
961 sources += [ "src/views/SkWindow.cpp" ]
962 }
Jim Van Verth4e56a912016-10-21 10:58:52 -0400963 if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -0400964 public_include_dirs += [ "src/views/unix" ]
965 sources += [
966 "src/views/unix/SkOSWindow_Unix.cpp",
967 "src/views/unix/keysym2ucs.c",
968 ]
Brian Osman16adfa32016-10-18 14:42:44 -0400969 } else if (is_mac) {
970 sources += [
971 "src/views/mac/SkEventNotifier.mm",
972 "src/views/mac/SkNSView.mm",
973 "src/views/mac/SkOSWindow_Mac.mm",
974 "src/views/mac/SkTextFieldCell.m",
975 ]
976 libs += [
977 "QuartzCore.framework",
978 "Cocoa.framework",
979 "Foundation.framework",
980 ]
981 } else if (is_win) {
982 sources += [ "src/views/win/SkOSWindow_win.cpp" ]
983 }
Brian Osman34755e22016-12-05 09:46:02 -0500984 if (skia_use_angle) {
985 deps += [ "//third_party/angle2" ]
986 }
Brian Osman16adfa32016-10-18 14:42:44 -0400987 }
988
Mike Klein38af9432016-11-11 11:39:44 -0500989 if (skia_use_lua) {
990 test_lib("lua") {
991 public_include_dirs = []
992 sources = [
993 "src/utils/SkLua.cpp",
994 "src/utils/SkLuaCanvas.cpp",
995 ]
996 deps = [
997 "//third_party/lua",
998 ]
999 }
1000
1001 executable("lua_app") {
1002 sources = [
1003 "tools/lua/lua_app.cpp",
1004 ]
1005 deps = [
1006 ":lua",
1007 ":skia",
1008 "//third_party/lua",
1009 ]
1010 testonly = true
1011 }
1012
1013 executable("lua_pictures") {
1014 sources = [
1015 "tools/lua/lua_pictures.cpp",
1016 ]
1017 deps = [
1018 ":flags",
1019 ":lua",
1020 ":skia",
1021 ":tool_utils",
1022 "//third_party/lua",
1023 ]
1024 testonly = true
1025 }
1026 }
1027
Mike Klein6e744122016-10-27 12:21:40 -04001028 import("gn/samples.gni")
Brian Osman16adfa32016-10-18 14:42:44 -04001029 test_lib("samples") {
Brian Osman16adfa32016-10-18 14:42:44 -04001030 public_include_dirs = [ "samplecode" ]
Mike Klein6e744122016-10-27 12:21:40 -04001031 include_dirs = [ "experimental" ]
1032 sources = samples_sources + [
1033 "experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp",
1034 "experimental/SkSetPoly3To3.cpp",
1035 "experimental/SkSetPoly3To3_A.cpp",
1036 "experimental/SkSetPoly3To3_D.cpp",
1037 ]
Brian Osman16adfa32016-10-18 14:42:44 -04001038 deps = [
1039 ":experimental_svg_model",
Mike Klein6e744122016-10-27 12:21:40 -04001040 ":gm",
Brian Osman16adfa32016-10-18 14:42:44 -04001041 ":tool_utils",
1042 ":views",
1043 ":xml",
1044 ]
Mike Klein38af9432016-11-11 11:39:44 -05001045
1046 if (skia_use_lua) {
1047 sources += [ "samplecode/SampleLua.cpp" ]
1048 deps += [
1049 ":lua",
1050 "//third_party/lua",
1051 ]
1052 }
Brian Osman16adfa32016-10-18 14:42:44 -04001053 }
1054
mtklein2b6870c2016-07-28 14:17:33 -07001055 executable("dm") {
1056 sources = [
1057 "dm/DM.cpp",
1058 "dm/DMJsonWriter.cpp",
1059 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -07001060 ]
1061 include_dirs = [ "tests" ]
1062 deps = [
mtklein046cb562016-09-16 10:23:12 -07001063 ":common_flags",
fmalitaa2b9fdf2016-08-03 19:53:36 -07001064 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -07001065 ":flags",
1066 ":gm",
1067 ":gpu_tool_utils",
1068 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -07001069 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -07001070 ":tool_utils",
1071 "//third_party/jsoncpp",
1072 "//third_party/libpng",
1073 ]
1074 testonly = true
1075 }
1076
Mike Kleina3430172016-09-27 16:46:29 -04001077 if (!is_debug) { # I've benchmarked debug code once too many times...
1078 executable("monobench") {
1079 sources = [
1080 "tools/monobench.cpp",
1081 ]
1082 deps = [
1083 ":bench",
1084 ":skia",
1085 ]
1086 testonly = true
1087 }
mtklein2b6870c2016-07-28 14:17:33 -07001088 }
1089
1090 executable("nanobench") {
1091 sources = [
1092 "bench/nanobench.cpp",
1093 ]
1094 deps = [
1095 ":bench",
mtklein046cb562016-09-16 10:23:12 -07001096 ":common_flags",
fmalita6519c212016-09-14 08:05:17 -07001097 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -07001098 ":flags",
1099 ":gm",
1100 ":gpu_tool_utils",
1101 ":skia",
1102 ":tool_utils",
1103 "//third_party/jsoncpp",
1104 ]
1105 testonly = true
1106 }
halcanary19a97202016-08-03 15:08:04 -07001107
Jim Van Verth57a98fc2016-10-28 13:35:50 -04001108 if (is_linux || is_win || is_mac) {
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001109 executable("SampleApp") {
mtklein38925aa2016-09-21 10:11:25 -07001110 sources = [
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001111 "samplecode/SampleApp.cpp",
1112 "samplecode/SamplePictFile.cpp",
mtklein38925aa2016-09-21 10:11:25 -07001113 ]
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001114 if (is_mac) {
1115 sources += [ "src/views/mac/skia_mac.mm" ]
1116 } else if (is_win) {
1117 sources += [ "src/views/win/skia_win.cpp" ]
1118 } else if (is_linux) {
1119 sources += [ "src/views/unix/skia_unix.cpp" ]
1120 }
mtklein38925aa2016-09-21 10:11:25 -07001121 deps = [
1122 ":flags",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001123 ":gm",
mtklein38925aa2016-09-21 10:11:25 -07001124 ":gpu_tool_utils",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001125 ":samples",
mtklein38925aa2016-09-21 10:11:25 -07001126 ":skia",
1127 ":tool_utils",
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001128 ":views",
mtklein38925aa2016-09-21 10:11:25 -07001129 ]
Mike Kleinc168a3a2016-11-14 14:53:13 +00001130 if (skia_use_angle) {
1131 deps += [ "//third_party/angle2" ]
1132 }
mtklein38925aa2016-09-21 10:11:25 -07001133 testonly = true
1134 }
Jim Van Verth8f5468f2016-10-31 09:52:33 -04001135 }
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001136
Jim Van Verth8f5468f2016-10-31 09:52:33 -04001137 if (skia_enable_gpu) {
1138 executable("skpbench") {
1139 sources = [
1140 "tools/skpbench/skpbench.cpp",
1141 ]
1142 deps = [
1143 ":flags",
1144 ":gpu_tool_utils",
1145 ":skia",
1146 ":tool_utils",
1147 ]
1148 testonly = true
Jim Van Verthb6c5e532016-10-28 10:38:08 -04001149 }
csmartdalton4b5179b2016-09-19 11:03:58 -07001150 }
1151
Mike Klein7d302882016-11-03 14:06:31 -04001152 # We can't yet build ICU on iOS or Windows.
1153 if (!is_ios && !is_win) {
halcanary3eee9d92016-09-10 07:01:53 -07001154 executable("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -07001155 sources = [
1156 "tools/SkShaper_harfbuzz.cpp",
1157 "tools/using_skia_and_harfbuzz.cpp",
1158 ]
1159 deps = [
1160 ":skia",
1161 "//third_party/harfbuzz",
1162 ]
1163 testonly = true
1164 }
halcanary19a97202016-08-03 15:08:04 -07001165 }
halcanary3eee9d92016-09-10 07:01:53 -07001166 executable("sktexttopdf") {
1167 sources = [
1168 "tools/SkShaper_primitive.cpp",
1169 "tools/using_skia_and_harfbuzz.cpp",
1170 ]
1171 deps = [
1172 ":skia",
1173 ]
1174 testonly = true
1175 }
mtklein046cb562016-09-16 10:23:12 -07001176
1177 executable("get_images_from_skps") {
1178 sources = [
1179 "tools/get_images_from_skps.cpp",
1180 ]
1181 deps = [
1182 ":flags",
1183 ":skia",
1184 "//third_party/jsoncpp",
1185 ]
1186 testonly = true
1187 }
mtkleinecbc5262016-09-22 11:51:24 -07001188
Matt Sarett8740d582016-11-11 13:59:14 -05001189 executable("colorspaceinfo") {
1190 sources = [
1191 "tools/colorspaceinfo.cpp",
1192 ]
1193 deps = [
1194 ":flags",
1195 ":skia",
1196 ":tool_utils",
1197 ]
1198 testonly = true
1199 }
1200
Mike Klein7d302882016-11-03 14:06:31 -04001201 if (!is_ios) {
1202 executable("skiaserve") {
1203 sources = [
1204 "tools/skiaserve/Request.cpp",
1205 "tools/skiaserve/Response.cpp",
1206 "tools/skiaserve/skiaserve.cpp",
Mike Klein7d302882016-11-03 14:06:31 -04001207 "tools/skiaserve/urlhandlers/BreakHandler.cpp",
1208 "tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp",
1209 "tools/skiaserve/urlhandlers/CmdHandler.cpp",
1210 "tools/skiaserve/urlhandlers/ColorModeHandler.cpp",
1211 "tools/skiaserve/urlhandlers/DataHandler.cpp",
1212 "tools/skiaserve/urlhandlers/DownloadHandler.cpp",
1213 "tools/skiaserve/urlhandlers/EnableGPUHandler.cpp",
1214 "tools/skiaserve/urlhandlers/ImgHandler.cpp",
1215 "tools/skiaserve/urlhandlers/InfoHandler.cpp",
Brian Salomon144a5c52016-12-20 16:48:59 -05001216 "tools/skiaserve/urlhandlers/OpBoundsHandler.cpp",
1217 "tools/skiaserve/urlhandlers/OpsHandler.cpp",
Mike Klein7d302882016-11-03 14:06:31 -04001218 "tools/skiaserve/urlhandlers/OverdrawHandler.cpp",
1219 "tools/skiaserve/urlhandlers/PostHandler.cpp",
1220 "tools/skiaserve/urlhandlers/QuitHandler.cpp",
1221 "tools/skiaserve/urlhandlers/RootHandler.cpp",
1222 ]
1223 deps = [
1224 ":flags",
1225 ":gpu_tool_utils",
1226 ":skia",
1227 ":tool_utils",
1228 "//third_party/jsoncpp",
1229 "//third_party/libmicrohttpd",
1230 "//third_party/libpng",
1231 ]
1232 testonly = true
1233 }
mtkleinecbc5262016-09-22 11:51:24 -07001234 }
kjlubick14f984b2016-10-03 11:49:45 -07001235
1236 executable("fuzz") {
1237 sources = [
1238 "fuzz/FilterFuzz.cpp",
Kevin Lubickfec1dea2016-11-22 13:57:18 -05001239 "fuzz/FuzzDrawFunctions.cpp",
kjlubick14f984b2016-10-03 11:49:45 -07001240 "fuzz/FuzzGradients.cpp",
1241 "fuzz/FuzzParsePath.cpp",
1242 "fuzz/FuzzPathop.cpp",
1243 "fuzz/FuzzScaleToSides.cpp",
1244 "fuzz/fuzz.cpp",
1245 ]
1246 deps = [
1247 ":flags",
1248 ":skia",
Hal Canarydb683012016-11-23 08:55:18 -07001249 ":tool_utils",
kjlubick14f984b2016-10-03 11:49:45 -07001250 ]
1251 testonly = true
1252 }
Mike Klein38312422016-10-05 15:41:01 -04001253
caryclark9feb6322016-10-25 08:58:26 -07001254 executable("pathops_unittest") {
Mike Klein6e744122016-10-27 12:21:40 -04001255 sources = pathops_tests_sources + [
Mike Klein6e55fef2016-10-26 11:41:47 -04001256 rebase_path("tests/skia_test.cpp"),
1257 rebase_path("tests/Test.cpp"),
1258 ]
caryclark9feb6322016-10-25 08:58:26 -07001259 deps = [
1260 ":flags",
1261 ":gpu_tool_utils",
1262 ":skia",
1263 ":tool_utils",
1264 ]
1265 testonly = true
1266 }
1267
Mike Klein38312422016-10-05 15:41:01 -04001268 executable("dump_record") {
1269 sources = [
1270 "tools/DumpRecord.cpp",
1271 "tools/dump_record.cpp",
1272 ]
1273 deps = [
1274 ":flags",
1275 ":skia",
1276 ]
1277 testonly = true
1278 }
bungemanfe917272016-10-13 17:36:40 -04001279
1280 executable("skdiff") {
1281 sources = [
1282 "tools/skdiff/skdiff.cpp",
1283 "tools/skdiff/skdiff_html.cpp",
1284 "tools/skdiff/skdiff_main.cpp",
1285 "tools/skdiff/skdiff_utils.cpp",
1286 ]
1287 deps = [
1288 ":skia",
1289 ":tool_utils",
1290 ]
1291 testonly = true
1292 }
halcanarya73d76a2016-10-17 13:19:02 -07001293
1294 executable("skp_parser") {
1295 sources = [
1296 "tools/skp_parser.cpp",
1297 ]
1298 deps = [
1299 ":skia",
1300 ":tool_utils",
1301 "//third_party/jsoncpp",
1302 ]
1303 testonly = true
1304 }
Brian Osman16adfa32016-10-18 14:42:44 -04001305
Mike Kleina92c3832016-12-08 09:49:39 -05001306 if (skia_enable_gpu && (is_android || is_linux || is_win || is_mac)) {
1307 source_set("viewer_sources") {
Brian Osman16adfa32016-10-18 14:42:44 -04001308 sources = [
1309 "tools/viewer/GMSlide.cpp",
1310 "tools/viewer/ImageSlide.cpp",
1311 "tools/viewer/SKPSlide.cpp",
1312 "tools/viewer/SampleSlide.cpp",
1313 "tools/viewer/Viewer.cpp",
1314 "tools/viewer/sk_app/CommandSet.cpp",
1315 "tools/viewer/sk_app/GLWindowContext.cpp",
1316 "tools/viewer/sk_app/Window.cpp",
1317 "tools/viewer/sk_app/WindowContext.cpp",
1318 ]
Brian Osman2dd96932016-10-18 15:33:53 -04001319 libs = []
Brian Osman16adfa32016-10-18 14:42:44 -04001320
Jim Van Verth4e56a912016-10-21 10:58:52 -04001321 if (is_android) {
1322 sources += [
1323 "tools/viewer/sk_app/android/GLWindowContext_android.cpp",
1324 "tools/viewer/sk_app/android/RasterWindowContext_android.cpp",
1325 "tools/viewer/sk_app/android/Window_android.cpp",
1326 "tools/viewer/sk_app/android/main_android.cpp",
1327 "tools/viewer/sk_app/android/surface_glue_android.cpp",
1328 ]
1329 } else if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -04001330 sources += [
1331 "tools/viewer/sk_app/unix/GLWindowContext_unix.cpp",
1332 "tools/viewer/sk_app/unix/RasterWindowContext_unix.cpp",
1333 "tools/viewer/sk_app/unix/Window_unix.cpp",
1334 "tools/viewer/sk_app/unix/main_unix.cpp",
1335 ]
1336 } else if (is_win) {
Brian Osman16adfa32016-10-18 14:42:44 -04001337 sources += [
1338 "tools/viewer/sk_app/win/GLWindowContext_win.cpp",
1339 "tools/viewer/sk_app/win/RasterWindowContext_win.cpp",
1340 "tools/viewer/sk_app/win/Window_win.cpp",
1341 "tools/viewer/sk_app/win/main_win.cpp",
1342 ]
Mike Klein43c25262016-10-20 10:17:47 -04001343 } else if (is_mac) {
1344 sources += [
1345 "tools/viewer/sk_app/mac/GLWindowContext_mac.cpp",
1346 "tools/viewer/sk_app/mac/RasterWindowContext_mac.cpp",
1347 "tools/viewer/sk_app/mac/Window_mac.cpp",
1348 "tools/viewer/sk_app/mac/main_mac.cpp",
1349 ]
Brian Osman16adfa32016-10-18 14:42:44 -04001350 }
1351
1352 if (skia_use_vulkan) {
1353 sources += [ "tools/viewer/sk_app/VulkanWindowContext.cpp" ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001354 if (is_android) {
1355 sources +=
1356 [ "tools/viewer/sk_app/android/VulkanWindowContext_android.cpp" ]
1357 libs += [ "android" ]
1358 } else if (is_linux) {
Brian Osman2dd96932016-10-18 15:33:53 -04001359 sources += [ "tools/viewer/sk_app/unix/VulkanWindowContext_unix.cpp" ]
1360 libs += [ "X11-xcb" ]
1361 } else if (is_win) {
Brian Osman16adfa32016-10-18 14:42:44 -04001362 sources += [ "tools/viewer/sk_app/win/VulkanWindowContext_win.cpp" ]
1363 }
1364 }
1365
1366 include_dirs = []
1367 deps = [
1368 ":flags",
1369 ":gm",
1370 ":gpu_tool_utils",
1371 ":samples",
1372 ":skia",
1373 ":tool_utils",
1374 ":views",
1375 "//third_party/jsoncpp",
1376 ]
Jim Van Verth4e56a912016-10-21 10:58:52 -04001377 if (is_android) {
1378 deps += [ "//third_party/native_app_glue" ]
1379 } else if (is_mac) {
Mike Klein43c25262016-10-20 10:17:47 -04001380 deps += [ "//third_party/libsdl" ]
1381 }
Brian Osman16adfa32016-10-18 14:42:44 -04001382 testonly = true
1383 }
Mike Kleina92c3832016-12-08 09:49:39 -05001384
1385 if (is_android) {
1386 shared_library("libviewer") {
1387 deps = [
1388 ":viewer_sources",
1389 ]
1390 testonly = true
1391 }
1392 } else {
1393 executable("viewer") {
1394 deps = [
1395 ":viewer_sources",
1396 ]
1397 testonly = true
1398 }
1399 }
Brian Osman16adfa32016-10-18 14:42:44 -04001400 }
Ethan Nicholas4f3985c2016-11-14 11:16:37 -05001401
1402 if (skia_enable_gpu) {
1403 executable("skslc") {
1404 sources = [
1405 "src/sksl/SkSLMain.cpp",
1406 ]
1407 deps = [
1408 ":flags",
1409 ":skia",
1410 ]
1411 testonly = true
1412 }
1413 }
mtklein25c81d42016-07-27 13:55:26 -07001414}