blob: c138492e16ab4051ab366874eed3f3420ef398b4 [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
mikejurka8c24f4f2016-09-12 16:51:58 -07006import("gn/shared_sources.gni")
brettwb9447282016-09-01 14:24:39 -07007
mtklein3e8012e2016-09-21 09:14:19 -07008if (!defined(is_skia_standalone)) {
9 is_skia_standalone = false
10}
11
mtkleinc04ff472016-06-23 10:29:30 -070012declare_args() {
mtkleind68f9b02016-09-23 13:18:41 -070013 skia_use_angle = false
mtklein63213812016-08-24 09:55:56 -070014 skia_use_expat = true
mtklein3cc22182016-08-29 13:26:14 -070015 skia_use_fontconfig = is_linux
mtkleincdedd0e2016-09-12 15:15:44 -070016 skia_use_freetype = is_android || is_fuchsia || is_linux
mtklein457b42a2016-08-23 13:56:37 -070017 skia_use_giflib = !is_fuchsia
mtklein63213812016-08-24 09:55:56 -070018 skia_use_libjpeg_turbo = true
19 skia_use_libpng = true
mtkleineb3c4252016-08-23 07:38:09 -070020 skia_use_libwebp = !is_fuchsia
mtkleina627b5c2016-09-20 13:36:47 -070021 skia_use_mesa = false
mtklein63213812016-08-24 09:55:56 -070022 skia_use_sfntly = !is_fuchsia
mtkleinf29180e2016-09-16 07:01:17 -070023 skia_use_vulkan = is_android && defined(ndk_api) && ndk_api >= 24
mtklein63213812016-08-24 09:55:56 -070024 skia_use_zlib = true
mtklein1bd72ba2016-09-16 07:45:52 -070025
26 skia_enable_android_framework_defines = false
mtklein06c35c02016-09-20 12:28:12 -070027 skia_enable_gpu = true
mtklein3e8012e2016-09-21 09:14:19 -070028 skia_enable_tools = is_skia_standalone
29 skia_enable_vulkan_debug_layers = is_skia_standalone && is_debug
mtkleinc04ff472016-06-23 10:29:30 -070030}
31
mtklein38925aa2016-09-21 10:11:25 -070032# Our tools require static linking (they use non-exported symbols).
33skia_enable_tools = skia_enable_tools && !is_component_build
mtklein06c35c02016-09-20 12:28:12 -070034
mtkleina45be612016-08-29 15:22:10 -070035fontmgr_android_enabled = skia_use_expat && skia_use_freetype
36
mtklein1211e0c2016-07-26 13:55:45 -070037skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070038 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070039 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070040 "include/codec",
41 "include/config",
42 "include/core",
43 "include/effects",
44 "include/gpu",
45 "include/gpu/gl",
46 "include/images",
47 "include/pathops",
48 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070049 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070050 "include/utils",
51 "include/utils/mac",
mtklein25c81d42016-07-27 13:55:26 -070052 "include/xml",
mtklein1211e0c2016-07-26 13:55:45 -070053]
54
mtkleinc04ff472016-06-23 10:29:30 -070055# Skia public API, generally provided by :skia.
56config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -070057 include_dirs = skia_public_includes
mtkleinc04ff472016-06-23 10:29:30 -070058 defines = [ "SKIA_DLL" ]
Mike Kleinc4cbd742016-09-26 21:37:09 -040059 if (is_fuchsia || is_linux) {
jcgregorio5561e3d2016-08-25 09:25:11 -070060 defines += [ "SK_SAMPLES_FOR_X" ]
61 }
mtkleincae1be52016-09-20 08:24:34 -070062 if (skia_enable_android_framework_defines) {
63 defines += skia_android_framework_defines
64 }
mtklein06c35c02016-09-20 12:28:12 -070065 if (!skia_enable_gpu) {
66 defines += [ "SK_SUPPORT_GPU=0" ]
67 }
mtkleinc04ff472016-06-23 10:29:30 -070068}
69
70# Skia internal APIs, used by Skia itself and a few test tools.
71config("skia_private") {
72 visibility = [ ":*" ]
73
74 include_dirs = [
75 "include/private",
76 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -070077 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -070078 "src/config",
79 "src/core",
80 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -070081 "src/effects/gradients",
82 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -070083 "src/gpu",
84 "src/image",
85 "src/images",
86 "src/lazy",
87 "src/opts",
88 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -070089 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -070090 "src/ports",
91 "src/sfnt",
mtklein9e0d9dd2016-08-30 10:37:19 -070092 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -070093 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -070094 "src/utils/win",
mtkleinc04ff472016-06-23 10:29:30 -070095 "third_party/etc1",
96 "third_party/ktx",
97 ]
mtklein150d1132016-08-01 06:56:40 -070098
mtklein63213812016-08-24 09:55:56 -070099 defines = [ "SK_GAMMA_APPLY_TO_A8" ]
mtkleinb37c0342016-09-09 11:07:45 -0700100 if (is_android) {
101 defines += [
102 "SK_GAMMA_EXPONENT=1.4",
103 "SK_GAMMA_CONTRAST=0.0",
104 ]
105 }
mtklein88a7ac02016-09-14 11:16:49 -0700106 if (is_official_build || is_android) {
107 # TODO(bsalomon): it'd be nice to make Android normal.
108 defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
109 }
mtkleinc04ff472016-06-23 10:29:30 -0700110}
111
112# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
113config("skia_library") {
114 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -0700115 defines = [ "SKIA_IMPLEMENTATION=1" ]
116}
117
118skia_library_configs = [
119 ":skia_public",
120 ":skia_private",
121 ":skia_library",
122]
123
mtklein9b8583d2016-08-24 17:32:30 -0700124# Use for CPU-specific Skia code that needs particular compiler flags.
125template("opts") {
126 if (invoker.enabled) {
127 source_set(target_name) {
128 forward_variables_from(invoker, "*")
129 configs += skia_library_configs
130 }
131 } else {
132 # If not enabled, a phony empty target that swallows all otherwise unused variables.
133 source_set(target_name) {
134 forward_variables_from(invoker,
135 "*",
136 [
137 "sources",
138 "cflags",
139 ])
140 }
141 }
anmittala7eaf2e2016-08-17 13:57:26 -0700142}
143
mtklein422310d2016-08-16 18:28:43 -0700144is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700145
mtklein7d6fb2c2016-08-25 14:50:44 -0700146opts("none") {
147 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700148 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700149 cflags = []
150}
151
mtklein7d6fb2c2016-08-25 14:50:44 -0700152opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700153 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700154 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700155 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700156}
157
158opts("arm64") {
159 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700160 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700161 cflags = []
162}
163
164opts("crc32") {
165 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700166 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700167 cflags = [ "-march=armv8-a+crc" ]
168}
169
mtklein9b8583d2016-08-24 17:32:30 -0700170opts("sse2") {
171 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700172 sources = skia_opts.sse2_sources
mtklein9b8583d2016-08-24 17:32:30 -0700173 cflags = [ "-msse2" ]
174}
mtkleinc04ff472016-06-23 10:29:30 -0700175
mtklein9b8583d2016-08-24 17:32:30 -0700176opts("ssse3") {
177 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700178 sources = skia_opts.ssse3_sources
mtklein9b8583d2016-08-24 17:32:30 -0700179 cflags = [ "-mssse3" ]
180}
mtkleinc04ff472016-06-23 10:29:30 -0700181
mtklein9b8583d2016-08-24 17:32:30 -0700182opts("sse41") {
183 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700184 sources = skia_opts.sse41_sources
mtklein9b8583d2016-08-24 17:32:30 -0700185 cflags = [ "-msse4.1" ]
186}
mtklein4e976072016-08-08 09:06:27 -0700187
mtklein9b8583d2016-08-24 17:32:30 -0700188opts("sse42") {
189 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700190 sources = skia_opts.sse42_sources
mtklein9b8583d2016-08-24 17:32:30 -0700191 cflags = [ "-msse4.2" ]
192}
193
194opts("avx") {
195 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700196 sources = skia_opts.avx_sources
mtklein9b8583d2016-08-24 17:32:30 -0700197 cflags = [ "-mavx" ]
mtkleinc04ff472016-06-23 10:29:30 -0700198}
199
Mike Klein78d5a3b2016-09-30 10:48:01 -0400200opts("hsw") {
201 enabled = is_x86
202 sources = skia_opts.hsw_sources
203 cflags = [
204 "-mavx2",
205 "-mbmi",
206 "-mbmi2",
207 "-mf16c",
208 "-mfma",
209 ]
210}
211
mtklein349cece2016-08-26 08:13:04 -0700212opts("dsp") {
213 enabled = current_cpu == "mipsel"
brettwb9447282016-09-01 14:24:39 -0700214 sources = skia_opts.mips_dsp_sources
mtkleinb6064ef2016-08-30 11:49:24 -0700215 cflags = []
mtklein349cece2016-08-26 08:13:04 -0700216}
217
mtkleinc095df52016-08-24 12:23:52 -0700218# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700219template("optional") {
220 if (invoker.enabled) {
221 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700222 if (defined(invoker.public_defines)) {
223 defines = invoker.public_defines
224 }
mtklein457b42a2016-08-23 13:56:37 -0700225 }
226 source_set(target_name) {
mtkleincd01b032016-08-31 04:58:19 -0700227 forward_variables_from(invoker,
228 "*",
229 [
230 "public_defines",
231 "sources_when_disabled",
232 ])
mtklein457b42a2016-08-23 13:56:37 -0700233 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700234 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700235 }
236 } else {
mtklein457b42a2016-08-23 13:56:37 -0700237 source_set(target_name) {
238 forward_variables_from(invoker,
239 "*",
240 [
241 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700242 "deps",
mtklein6ef69992016-09-14 06:12:09 -0700243 "libs",
mtklein457b42a2016-08-23 13:56:37 -0700244 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700245 "sources_when_disabled",
mtklein457b42a2016-08-23 13:56:37 -0700246 ])
mtkleincd01b032016-08-31 04:58:19 -0700247 if (defined(invoker.sources_when_disabled)) {
248 sources = invoker.sources_when_disabled
249 }
250 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700251 }
mtkleineb3c4252016-08-23 07:38:09 -0700252 }
mtklein457b42a2016-08-23 13:56:37 -0700253}
mtklein457b42a2016-08-23 13:56:37 -0700254
mtkleina45be612016-08-29 15:22:10 -0700255optional("fontmgr_android") {
256 enabled = fontmgr_android_enabled
mtkleina45be612016-08-29 15:22:10 -0700257
258 deps = [
259 "//third_party/expat",
260 "//third_party/freetype2",
261 ]
262 sources = [
263 "src/ports/SkFontMgr_android.cpp",
264 "src/ports/SkFontMgr_android_factory.cpp",
265 "src/ports/SkFontMgr_android_parser.cpp",
266 ]
267}
268
mtkleind2e39db2016-09-07 07:52:55 -0700269optional("fontmgr_custom") {
270 enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
271
272 deps = [
273 "//third_party/freetype2",
274 ]
275 sources = [
276 "src/ports/SkFontMgr_custom.cpp",
277 "src/ports/SkFontMgr_custom_directory_factory.cpp",
278 ]
279}
280
mtklein3cc22182016-08-29 13:26:14 -0700281optional("fontmgr_fontconfig") {
282 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700283
284 deps = [
285 "//third_party:fontconfig",
286 "//third_party/freetype2",
287 ]
288 sources = [
bungeman1ae0e012016-09-19 12:13:16 -0700289 "src/ports/SkFontConfigInterface.cpp",
mtklein3cc22182016-08-29 13:26:14 -0700290 "src/ports/SkFontConfigInterface_direct.cpp",
291 "src/ports/SkFontConfigInterface_direct_factory.cpp",
292 "src/ports/SkFontMgr_FontConfigInterface.cpp",
293 "src/ports/SkFontMgr_fontconfig.cpp",
294 "src/ports/SkFontMgr_fontconfig_factory.cpp",
295 ]
296}
297
mtkleincdedd0e2016-09-12 15:15:44 -0700298optional("fontmgr_fuchsia") {
299 enabled = is_fuchsia && skia_use_freetype
300
301 deps = [
302 "//third_party/freetype2",
303 ]
304 sources = [
305 "src/ports/SkFontMgr_custom.cpp",
306 "src/ports/SkFontMgr_custom_empty_factory.cpp",
307 ]
308}
309
mtklein457b42a2016-08-23 13:56:37 -0700310optional("gif") {
311 enabled = skia_use_giflib
312 public_defines = [ "SK_HAS_GIF_LIBRARY" ]
313
mtklein457b42a2016-08-23 13:56:37 -0700314 deps = [
315 "//third_party/giflib",
316 ]
317 sources = [
318 "src/codec/SkGifCodec.cpp",
319 ]
320}
321
mtklein06c35c02016-09-20 12:28:12 -0700322optional("gpu") {
323 enabled = skia_enable_gpu
mtkleine9fb3d52016-09-20 15:11:46 -0700324 public_defines = []
325
mtklein06c35c02016-09-20 12:28:12 -0700326 sources = skia_gpu_sources + [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ]
327
328 # These paths need to be absolute to match the ones produced by shared_sources.gni.
329 sources -= get_path_info([
330 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
331 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
332 ],
333 "abspath")
334 if (is_android) {
335 sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
336 } else if (is_linux) {
337 sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
338 } else if (is_mac) {
339 sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
340 } else {
341 sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
342 }
mtkleine9fb3d52016-09-20 15:11:46 -0700343 libs = []
344
345 if (skia_use_vulkan) {
346 public_defines += [ "SK_VULKAN" ]
347 sources += skia_vk_sources
348 libs += [ "vulkan" ]
egdaniele4a9bd72016-09-21 07:36:14 -0700349 if (skia_enable_vulkan_debug_layers) {
350 public_defines += [ "SK_ENABLE_VK_LAYERS" ]
351 }
mtkleine9fb3d52016-09-20 15:11:46 -0700352 }
mtklein06c35c02016-09-20 12:28:12 -0700353}
354
mtklein63213812016-08-24 09:55:56 -0700355optional("jpeg") {
356 enabled = skia_use_libjpeg_turbo
357 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
358
mtklein63213812016-08-24 09:55:56 -0700359 deps = [
360 "//third_party/libjpeg-turbo:libjpeg",
361 ]
362 sources = [
363 "src/codec/SkJpegCodec.cpp",
364 "src/codec/SkJpegDecoderMgr.cpp",
365 "src/codec/SkJpegUtility.cpp",
366 "src/images/SkJPEGImageEncoder.cpp",
367 "src/images/SkJPEGWriteUtility.cpp",
368 ]
369}
370
371optional("pdf") {
372 enabled = skia_use_zlib
mtklein63213812016-08-24 09:55:56 -0700373
mtklein63213812016-08-24 09:55:56 -0700374 deps = [
375 "//third_party/zlib",
376 ]
brettwb9447282016-09-01 14:24:39 -0700377 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700378 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700379
380 if (skia_use_sfntly) {
381 deps += [ "//third_party/sfntly" ]
mtkleincd01b032016-08-31 04:58:19 -0700382 public_defines = [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700383 }
384}
385
386optional("png") {
387 enabled = skia_use_libpng
388 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
389
mtklein63213812016-08-24 09:55:56 -0700390 deps = [
391 "//third_party/libpng",
392 ]
393 sources = [
394 "src/codec/SkIcoCodec.cpp",
395 "src/codec/SkPngCodec.cpp",
396 "src/images/SkPNGImageEncoder.cpp",
397 ]
398}
399
mtklein3cc22182016-08-29 13:26:14 -0700400optional("typeface_freetype") {
401 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700402
403 deps = [
404 "//third_party/freetype2",
405 ]
406 sources = [
407 "src/ports/SkFontHost_FreeType.cpp",
408 "src/ports/SkFontHost_FreeType_common.cpp",
409 ]
410}
411
mtklein457b42a2016-08-23 13:56:37 -0700412optional("webp") {
413 enabled = skia_use_libwebp
414 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
415
mtklein457b42a2016-08-23 13:56:37 -0700416 deps = [
417 "//third_party/libwebp",
418 ]
419 sources = [
420 "src/codec/SkWebpAdapterCodec.cpp",
421 "src/codec/SkWebpCodec.cpp",
422 "src/images/SkWEBPImageEncoder.cpp",
423 ]
mtkleineb3c4252016-08-23 07:38:09 -0700424}
425
mtklein63213812016-08-24 09:55:56 -0700426optional("xml") {
427 enabled = skia_use_expat
mtklein63213812016-08-24 09:55:56 -0700428
mtklein63213812016-08-24 09:55:56 -0700429 deps = [
430 "//third_party/expat",
431 ]
432 sources = [
433 "src/xml/SkDOM.cpp",
434 "src/xml/SkXMLParser.cpp",
435 "src/xml/SkXMLWriter.cpp",
436 ]
437}
438
mtkleinc04ff472016-06-23 10:29:30 -0700439component("skia") {
440 public_configs = [ ":skia_public" ]
441 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700442
443 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700444 ":arm64",
445 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700446 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700447 ":crc32",
mtklein349cece2016-08-26 08:13:04 -0700448 ":dsp",
mtkleina45be612016-08-29 15:22:10 -0700449 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700450 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700451 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700452 ":fontmgr_fuchsia",
mtklein457b42a2016-08-23 13:56:37 -0700453 ":gif",
mtklein06c35c02016-09-20 12:28:12 -0700454 ":gpu",
Mike Klein78d5a3b2016-09-30 10:48:01 -0400455 ":hsw",
mtklein63213812016-08-24 09:55:56 -0700456 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700457 ":none",
mtklein63213812016-08-24 09:55:56 -0700458 ":pdf",
459 ":png",
mtklein9b8583d2016-08-24 17:32:30 -0700460 ":sse2",
461 ":sse41",
462 ":sse42",
463 ":ssse3",
mtklein3cc22182016-08-29 13:26:14 -0700464 ":typeface_freetype",
mtkleineb3c4252016-08-23 07:38:09 -0700465 ":webp",
mtklein63213812016-08-24 09:55:56 -0700466 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700467 ]
468
mtkleinc04ff472016-06-23 10:29:30 -0700469 sources = []
brettwb9447282016-09-01 14:24:39 -0700470 sources += skia_core_sources
471 sources += skia_effects_sources
brettwb9447282016-09-01 14:24:39 -0700472 sources += skia_sksl_sources
473 sources += skia_utils_sources
mtkleinc04ff472016-06-23 10:29:30 -0700474 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700475 "src/android/SkBitmapRegionCodec.cpp",
476 "src/android/SkBitmapRegionDecoder.cpp",
477 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700478 "src/codec/SkBmpCodec.cpp",
479 "src/codec/SkBmpMaskCodec.cpp",
480 "src/codec/SkBmpRLECodec.cpp",
481 "src/codec/SkBmpStandardCodec.cpp",
482 "src/codec/SkCodec.cpp",
483 "src/codec/SkCodecImageGenerator.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700484 "src/codec/SkMaskSwizzler.cpp",
485 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700486 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700487 "src/codec/SkSampler.cpp",
488 "src/codec/SkSwizzler.cpp",
489 "src/codec/SkWbmpCodec.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700490 "src/images/SkImageEncoder.cpp",
491 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700492 "src/images/SkKTXImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700493 "src/ports/SkDiscardableMemory_none.cpp",
494 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700495 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700496 "src/ports/SkMemory_malloc.cpp",
497 "src/ports/SkOSFile_stdio.cpp",
498 "src/sfnt/SkOTTable_name.cpp",
499 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700500 "src/svg/SkSVGCanvas.cpp",
501 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700502 "src/utils/mac/SkStream_mac.cpp",
503 "third_party/etc1/etc1.cpp",
504 "third_party/ktx/ktx.cpp",
505 ]
brettwb9447282016-09-01 14:24:39 -0700506
mtklein7d6fb2c2016-08-25 14:50:44 -0700507 libs = []
508
mtkleinc04ff472016-06-23 10:29:30 -0700509 if (is_win) {
510 sources += [
511 "src/ports/SkDebug_win.cpp",
512 "src/ports/SkFontHost_win.cpp",
513 "src/ports/SkFontMgr_win_dw.cpp",
514 "src/ports/SkFontMgr_win_dw_factory.cpp",
515 "src/ports/SkImageEncoder_WIC.cpp",
516 "src/ports/SkImageGeneratorWIC.cpp",
517 "src/ports/SkOSFile_win.cpp",
mtklein605d9522016-09-21 14:01:32 -0700518 "src/ports/SkOSLibrary_win.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700519 "src/ports/SkScalerContext_win_dw.cpp",
520 "src/ports/SkTLS_win.cpp",
521 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700522 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700523 ]
mtkleinb9be9792016-09-16 14:44:18 -0700524 sources -=
525 [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
mtkleinc04ff472016-06-23 10:29:30 -0700526 } else {
527 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700528 "src/ports/SkOSFile_posix.cpp",
mtklein605d9522016-09-21 14:01:32 -0700529 "src/ports/SkOSLibrary_posix.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700530 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700531 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700532 ]
533 }
534
mtklein7d6fb2c2016-08-25 14:50:44 -0700535 if (is_android) {
536 deps += [
537 "//third_party/cpu-features",
538 "//third_party/expat",
mtklein7d6fb2c2016-08-25 14:50:44 -0700539 ]
mtklein06c35c02016-09-20 12:28:12 -0700540 sources += [ "src/ports/SkDebug_android.cpp" ]
mtklein7d6fb2c2016-08-25 14:50:44 -0700541 libs += [
542 "EGL",
543 "GLESv2",
544 "log",
545 ]
546 }
547
mtkleinc04ff472016-06-23 10:29:30 -0700548 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700549 libs += [
550 "GL",
551 "GLU",
552 "X11",
553 ]
mtklein06c35c02016-09-20 12:28:12 -0700554 sources += [ "src/ports/SkDebug_stdio.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700555 }
556
557 if (is_mac) {
558 sources += [
mtklein7d6fb2c2016-08-25 14:50:44 -0700559 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700560 "src/ports/SkFontHost_mac.cpp",
561 "src/ports/SkImageEncoder_CG.cpp",
562 "src/ports/SkImageGeneratorCG.cpp",
563 ]
mtklein09e61f72016-08-23 13:35:28 -0700564 libs += [
565 "ApplicationServices.framework",
566 "OpenGL.framework",
567 ]
mtkleinc04ff472016-06-23 10:29:30 -0700568 }
abarth6fc8ff02016-07-15 15:15:15 -0700569
570 if (is_fuchsia) {
mtklein06c35c02016-09-20 12:28:12 -0700571 sources += [ "src/ports/SkDebug_stdio.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700572 }
mtkleinc04ff472016-06-23 10:29:30 -0700573}
574
mtkleinada5a442016-08-02 14:28:26 -0700575skia_h_headers = exec_script("gyp/find.py",
576 [ "*.h" ] + rebase_path(skia_public_includes),
577 "list lines",
578 []) -
579 [
580 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
581 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
582 rebase_path("include/gpu/vk/GrVkDefines.h"),
583 rebase_path("include/gpu/vk/GrVkInterface.h"),
584 rebase_path("include/gpu/vk/GrVkTypes.h"),
585 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
586 ]
587
mtklein1211e0c2016-07-26 13:55:45 -0700588action("skia.h") {
589 script = "gn/echo_headers.py"
590 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinc095df52016-08-24 12:23:52 -0700591 rebase_path(skia_h_headers, target_gen_dir)
Ben Wagnerbc344042016-09-29 15:41:53 -0400592 inputs = skia_h_headers
mtklein1211e0c2016-07-26 13:55:45 -0700593 outputs = [
594 "$target_gen_dir/skia.h",
595 ]
596}
597
mtklein06c35c02016-09-20 12:28:12 -0700598if (skia_enable_gpu && target_cpu == "x64") {
mtklein1fbdf982016-09-15 12:07:48 -0700599 # Our bots only have 64-bit libOSMesa installed.
600 # TODO: worth fixing?
601 executable("fiddle") {
602 include_dirs = [ "$target_gen_dir" ]
603 libs = []
604 if (is_linux) {
605 libs += [ "OSMesa" ]
606 }
mtklein56d56692016-09-15 11:18:55 -0700607
mtklein1fbdf982016-09-15 12:07:48 -0700608 sources = [
609 "src/images/SkForceLinking.cpp",
610 "tools/fiddle/draw.cpp",
611 "tools/fiddle/fiddle_main.cpp",
612 ]
613 deps = [
614 ":skia",
615 ":skia.h",
616 ]
617 }
mtkleinc04ff472016-06-23 10:29:30 -0700618}
mtklein25c81d42016-07-27 13:55:26 -0700619
mtkleinc095df52016-08-24 12:23:52 -0700620# Targets guarded by skia_enable_tools may use //third_party freely.
621if (skia_enable_tools) {
622 template("test_lib") {
623 config(target_name + "_config") {
624 include_dirs = invoker.public_include_dirs
mtkleina627b5c2016-09-20 13:36:47 -0700625 if (defined(invoker.public_defines)) {
626 defines = invoker.public_defines
627 }
mtklein25c81d42016-07-27 13:55:26 -0700628 }
mtkleinc095df52016-08-24 12:23:52 -0700629 source_set(target_name) {
630 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
631 public_configs = [
632 ":" + target_name + "_config",
633 ":skia_private",
634 ]
635
636 if (!defined(deps)) {
637 deps = []
638 }
639 deps += [ ":skia" ]
640 testonly = true
641 }
mtklein25c81d42016-07-27 13:55:26 -0700642 }
mtklein25c81d42016-07-27 13:55:26 -0700643
mtkleinc095df52016-08-24 12:23:52 -0700644 test_lib("gpu_tool_utils") {
mtklein38925aa2016-09-21 10:11:25 -0700645 public_include_dirs = []
646 if (skia_enable_gpu) {
647 public_defines = []
648 public_include_dirs += [ "tools/gpu" ]
mtkleind68f9b02016-09-23 13:18:41 -0700649
650 deps = []
mtklein38925aa2016-09-21 10:11:25 -0700651 sources = [
652 "tools/gpu/GrContextFactory.cpp",
653 "tools/gpu/GrTest.cpp",
654 "tools/gpu/TestContext.cpp",
655 "tools/gpu/gl/GLTestContext.cpp",
mtklein605d9522016-09-21 14:01:32 -0700656 "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
mtklein38925aa2016-09-21 10:11:25 -0700657 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
658 "tools/gpu/gl/debug/GrBufferObj.cpp",
659 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
660 "tools/gpu/gl/debug/GrProgramObj.cpp",
661 "tools/gpu/gl/debug/GrShaderObj.cpp",
662 "tools/gpu/gl/debug/GrTextureObj.cpp",
663 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
664 "tools/gpu/gl/null/NullGLTestContext.cpp",
665 ]
666 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700667
mtklein38925aa2016-09-21 10:11:25 -0700668 if (is_android) {
669 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
670 } else if (is_linux) {
671 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
672 } else if (is_mac) {
673 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
674 }
mtklein6ef69992016-09-14 06:12:09 -0700675
mtkleind68f9b02016-09-23 13:18:41 -0700676 if (skia_use_angle) {
677 public_defines += [ "SK_ANGLE" ]
678 deps += [ "//third_party/angle2" ]
679 sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
mtklein38925aa2016-09-21 10:11:25 -0700680 }
681 if (skia_use_mesa) {
682 public_defines += [ "SK_MESA" ]
683 sources += [ "tools/gpu/gl/mesa/GLTestContext_mesa.cpp" ]
684 libs += [ "OSMesa" ]
685 }
mtkleind68f9b02016-09-23 13:18:41 -0700686 if (skia_use_vulkan) {
687 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
688 }
mtkleina627b5c2016-09-20 13:36:47 -0700689 }
mtklein25c81d42016-07-27 13:55:26 -0700690 }
mtklein25c81d42016-07-27 13:55:26 -0700691
mtkleinc095df52016-08-24 12:23:52 -0700692 test_lib("flags") {
693 public_include_dirs = [ "tools/flags" ]
694 sources = [
695 "tools/flags/SkCommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -0700696 ]
697 }
698 test_lib("common_flags") {
699 public_include_dirs = [ "tools/flags" ]
700 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700701 "tools/flags/SkCommonFlags.cpp",
702 "tools/flags/SkCommonFlagsConfig.cpp",
703 ]
704 deps = [
mtklein046cb562016-09-16 10:23:12 -0700705 ":flags",
mtkleinc095df52016-08-24 12:23:52 -0700706 ":gpu_tool_utils",
707 ]
708 }
mtklein25c81d42016-07-27 13:55:26 -0700709
mtkleinc095df52016-08-24 12:23:52 -0700710 test_lib("tool_utils") {
711 public_include_dirs = [
712 "tools",
713 "tools/debugger",
714 "tools/timer",
715 ]
716 sources = [
717 "src/images/SkForceLinking.cpp",
718 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700719 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700720 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700721 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700722 "tools/ProcStats.cpp",
723 "tools/Resources.cpp",
724 "tools/ThermalManager.cpp",
725 "tools/UrlDataManager.cpp",
726 "tools/debugger/SkDebugCanvas.cpp",
727 "tools/debugger/SkDrawCommand.cpp",
728 "tools/debugger/SkJsonWriteBuffer.cpp",
729 "tools/debugger/SkObjectParser.cpp",
730 "tools/debugger/SkOverdrawMode.cpp",
731 "tools/picture_utils.cpp",
732 "tools/random_parse_path.cpp",
733 "tools/sk_tool_utils.cpp",
734 "tools/sk_tool_utils_font.cpp",
735 "tools/timer/Timer.cpp",
736 ]
737 deps = [
mtklein046cb562016-09-16 10:23:12 -0700738 ":common_flags",
mtkleinc095df52016-08-24 12:23:52 -0700739 ":flags",
740 "//third_party/libpng",
741 ]
742 public_deps = [
743 "//third_party/jsoncpp",
744 ]
745 }
mtklein25c81d42016-07-27 13:55:26 -0700746
mtkleinc095df52016-08-24 12:23:52 -0700747 gm_sources = exec_script("gyp/find.py",
748 [
749 "*.c*",
750 rebase_path("gm"),
751 ],
752 "list lines",
753 [])
754 test_lib("gm") {
755 public_include_dirs = [ "gm" ]
756 sources = gm_sources
757 deps = [
758 ":gpu_tool_utils",
759 ":skia",
760 ":tool_utils",
761 ]
762 }
mtklein25c81d42016-07-27 13:55:26 -0700763
mtkleinc095df52016-08-24 12:23:52 -0700764 tests_sources = exec_script("gyp/find.py",
765 [
766 "*.c*",
767 rebase_path("tests"),
768 ],
769 "list lines",
770 [])
mtklein2f3416d2016-08-02 16:02:05 -0700771
mtkleinc095df52016-08-24 12:23:52 -0700772 test_lib("tests") {
773 public_include_dirs = [ "tests" ]
mtkleina45be612016-08-29 15:22:10 -0700774 sources = tests_sources - [
775 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
mtkleina45be612016-08-29 15:22:10 -0700776 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
777 rebase_path("tests/skia_test.cpp"), # alternate main
778 ]
779 if (!fontmgr_android_enabled) {
780 sources -= [ rebase_path("tests/FontMgrAndroidParserTest.cpp") ]
781 }
mtkleinc095df52016-08-24 12:23:52 -0700782 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700783 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700784 ":flags",
785 ":gpu_tool_utils",
786 ":skia",
787 ":tool_utils",
788 "//third_party/libpng",
789 "//third_party/zlib",
790 ]
791 }
mtklein2f3416d2016-08-02 16:02:05 -0700792
mtkleinc095df52016-08-24 12:23:52 -0700793 bench_sources = exec_script("gyp/find.py",
794 [
795 "*.c*",
796 rebase_path("bench"),
797 ],
798 "list lines",
799 [])
mtklein25c81d42016-07-27 13:55:26 -0700800
mtkleinc095df52016-08-24 12:23:52 -0700801 test_lib("bench") {
802 public_include_dirs = [ "bench" ]
803 sources = bench_sources
804 sources -= [
805 rebase_path("bench/nanobench.cpp"),
806 rebase_path("bench/nanobenchAndroid.cpp"),
807 ]
808 deps = [
809 ":flags",
810 ":gm",
811 ":gpu_tool_utils",
812 ":skia",
813 ":tool_utils",
814 ]
815 }
mtklein2b6870c2016-07-28 14:17:33 -0700816
mtkleinc095df52016-08-24 12:23:52 -0700817 test_lib("experimental_svg_model") {
818 public_include_dirs = [ "experimental/svg/model" ]
819 sources = [
820 "experimental/svg/model/SkSVGAttribute.cpp",
821 "experimental/svg/model/SkSVGAttributeParser.cpp",
822 "experimental/svg/model/SkSVGCircle.cpp",
823 "experimental/svg/model/SkSVGContainer.cpp",
824 "experimental/svg/model/SkSVGDOM.cpp",
825 "experimental/svg/model/SkSVGEllipse.cpp",
826 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700827 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700828 "experimental/svg/model/SkSVGNode.cpp",
829 "experimental/svg/model/SkSVGPath.cpp",
830 "experimental/svg/model/SkSVGPoly.cpp",
831 "experimental/svg/model/SkSVGRect.cpp",
832 "experimental/svg/model/SkSVGRenderContext.cpp",
833 "experimental/svg/model/SkSVGSVG.cpp",
834 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700835 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700836 "experimental/svg/model/SkSVGTransformableNode.cpp",
837 "experimental/svg/model/SkSVGValue.cpp",
838 ]
839 deps = [
840 ":skia",
841 ]
842 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700843
mtklein2b6870c2016-07-28 14:17:33 -0700844 executable("dm") {
845 sources = [
846 "dm/DM.cpp",
847 "dm/DMJsonWriter.cpp",
848 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700849 ]
850 include_dirs = [ "tests" ]
851 deps = [
mtklein046cb562016-09-16 10:23:12 -0700852 ":common_flags",
fmalitaa2b9fdf2016-08-03 19:53:36 -0700853 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700854 ":flags",
855 ":gm",
856 ":gpu_tool_utils",
857 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700858 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700859 ":tool_utils",
860 "//third_party/jsoncpp",
861 "//third_party/libpng",
862 ]
863 testonly = true
864 }
865
Mike Kleina3430172016-09-27 16:46:29 -0400866 if (!is_debug) { # I've benchmarked debug code once too many times...
867 executable("monobench") {
868 sources = [
869 "tools/monobench.cpp",
870 ]
871 deps = [
872 ":bench",
873 ":skia",
874 ]
875 testonly = true
876 }
mtklein2b6870c2016-07-28 14:17:33 -0700877 }
878
879 executable("nanobench") {
880 sources = [
881 "bench/nanobench.cpp",
882 ]
883 deps = [
884 ":bench",
mtklein046cb562016-09-16 10:23:12 -0700885 ":common_flags",
fmalita6519c212016-09-14 08:05:17 -0700886 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700887 ":flags",
888 ":gm",
889 ":gpu_tool_utils",
890 ":skia",
891 ":tool_utils",
892 "//third_party/jsoncpp",
893 ]
894 testonly = true
895 }
halcanary19a97202016-08-03 15:08:04 -0700896
mtklein38925aa2016-09-21 10:11:25 -0700897 if (skia_enable_gpu) {
898 executable("skpbench") {
899 sources = [
900 "tools/skpbench/skpbench.cpp",
901 ]
902 deps = [
903 ":flags",
904 ":gpu_tool_utils",
905 ":skia",
906 ":tool_utils",
907 ]
908 testonly = true
909 }
csmartdalton4b5179b2016-09-19 11:03:58 -0700910 }
911
mtklein6f5df6a2016-08-29 16:01:10 -0700912 if (current_cpu != "mipsel") { # Clang 3.8 crashes while compiling hb-icu.cc for mipsel.
halcanary3eee9d92016-09-10 07:01:53 -0700913 executable("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -0700914 sources = [
915 "tools/SkShaper_harfbuzz.cpp",
916 "tools/using_skia_and_harfbuzz.cpp",
917 ]
918 deps = [
919 ":skia",
920 "//third_party/harfbuzz",
921 ]
922 testonly = true
923 }
halcanary19a97202016-08-03 15:08:04 -0700924 }
halcanary3eee9d92016-09-10 07:01:53 -0700925 executable("sktexttopdf") {
926 sources = [
927 "tools/SkShaper_primitive.cpp",
928 "tools/using_skia_and_harfbuzz.cpp",
929 ]
930 deps = [
931 ":skia",
932 ]
933 testonly = true
934 }
mtklein046cb562016-09-16 10:23:12 -0700935
936 executable("get_images_from_skps") {
937 sources = [
938 "tools/get_images_from_skps.cpp",
939 ]
940 deps = [
941 ":flags",
942 ":skia",
943 "//third_party/jsoncpp",
944 ]
945 testonly = true
946 }
mtkleinecbc5262016-09-22 11:51:24 -0700947
948 executable("skiaserve") {
949 sources = [
950 "tools/skiaserve/Request.cpp",
951 "tools/skiaserve/Response.cpp",
952 "tools/skiaserve/skiaserve.cpp",
953 "tools/skiaserve/urlhandlers/BatchBoundsHandler.cpp",
954 "tools/skiaserve/urlhandlers/BatchesHandler.cpp",
955 "tools/skiaserve/urlhandlers/BreakHandler.cpp",
956 "tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp",
957 "tools/skiaserve/urlhandlers/CmdHandler.cpp",
958 "tools/skiaserve/urlhandlers/ColorModeHandler.cpp",
959 "tools/skiaserve/urlhandlers/DataHandler.cpp",
960 "tools/skiaserve/urlhandlers/DownloadHandler.cpp",
961 "tools/skiaserve/urlhandlers/EnableGPUHandler.cpp",
962 "tools/skiaserve/urlhandlers/ImgHandler.cpp",
963 "tools/skiaserve/urlhandlers/InfoHandler.cpp",
964 "tools/skiaserve/urlhandlers/PostHandler.cpp",
965 "tools/skiaserve/urlhandlers/QuitHandler.cpp",
966 "tools/skiaserve/urlhandlers/RootHandler.cpp",
967 ]
968 deps = [
969 ":flags",
970 ":gpu_tool_utils",
971 ":skia",
972 ":tool_utils",
973 "//third_party/jsoncpp",
974 "//third_party/libmicrohttpd",
975 "//third_party/libpng",
976 ]
977 testonly = true
978 }
mtklein25c81d42016-07-27 13:55:26 -0700979}