blob: 05fe3500ffdaa5335346ef07fc57f55144008bfe [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
mtkleinc04ff472016-06-23 10:29:30 -07008declare_args() {
mtkleinc095df52016-08-24 12:23:52 -07009 skia_enable_tools = !is_fuchsia && !is_component_build
10
mtklein63213812016-08-24 09:55:56 -070011 skia_use_expat = true
mtklein3cc22182016-08-29 13:26:14 -070012 skia_use_fontconfig = is_linux
mtkleincdedd0e2016-09-12 15:15:44 -070013 skia_use_freetype = is_android || is_fuchsia || is_linux
mtklein457b42a2016-08-23 13:56:37 -070014 skia_use_giflib = !is_fuchsia
mtklein63213812016-08-24 09:55:56 -070015 skia_use_libjpeg_turbo = true
16 skia_use_libpng = true
mtkleineb3c4252016-08-23 07:38:09 -070017 skia_use_libwebp = !is_fuchsia
mtklein63213812016-08-24 09:55:56 -070018 skia_use_sfntly = !is_fuchsia
mtklein6ef69992016-09-14 06:12:09 -070019 skia_use_vulkan = false
mtklein63213812016-08-24 09:55:56 -070020 skia_use_zlib = true
mtkleinc04ff472016-06-23 10:29:30 -070021}
22
mtkleina45be612016-08-29 15:22:10 -070023fontmgr_android_enabled = skia_use_expat && skia_use_freetype
24
mtklein1211e0c2016-07-26 13:55:45 -070025skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070026 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070027 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070028 "include/codec",
29 "include/config",
30 "include/core",
31 "include/effects",
32 "include/gpu",
33 "include/gpu/gl",
34 "include/images",
35 "include/pathops",
36 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070037 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070038 "include/utils",
39 "include/utils/mac",
mtklein25c81d42016-07-27 13:55:26 -070040 "include/xml",
mtklein1211e0c2016-07-26 13:55:45 -070041]
42
mtkleinc04ff472016-06-23 10:29:30 -070043# Skia public API, generally provided by :skia.
44config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -070045 include_dirs = skia_public_includes
mtkleinc04ff472016-06-23 10:29:30 -070046 defines = [ "SKIA_DLL" ]
jcgregorio5561e3d2016-08-25 09:25:11 -070047 if (is_linux) {
48 defines += [ "SK_SAMPLES_FOR_X" ]
49 }
mtkleinc04ff472016-06-23 10:29:30 -070050}
51
52# Skia internal APIs, used by Skia itself and a few test tools.
53config("skia_private") {
54 visibility = [ ":*" ]
55
56 include_dirs = [
57 "include/private",
58 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -070059 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -070060 "src/config",
61 "src/core",
62 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -070063 "src/effects/gradients",
64 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -070065 "src/gpu",
66 "src/image",
67 "src/images",
68 "src/lazy",
69 "src/opts",
70 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -070071 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -070072 "src/ports",
73 "src/sfnt",
mtklein9e0d9dd2016-08-30 10:37:19 -070074 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -070075 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -070076 "src/utils/win",
mtkleinc04ff472016-06-23 10:29:30 -070077 "third_party/etc1",
78 "third_party/ktx",
79 ]
mtklein150d1132016-08-01 06:56:40 -070080
mtklein63213812016-08-24 09:55:56 -070081 defines = [ "SK_GAMMA_APPLY_TO_A8" ]
mtkleinb37c0342016-09-09 11:07:45 -070082 if (is_android) {
83 defines += [
84 "SK_GAMMA_EXPONENT=1.4",
85 "SK_GAMMA_CONTRAST=0.0",
86 ]
87 }
mtklein88a7ac02016-09-14 11:16:49 -070088 if (is_official_build || is_android) {
89 # TODO(bsalomon): it'd be nice to make Android normal.
90 defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
91 }
mtkleinc04ff472016-06-23 10:29:30 -070092}
93
94# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
95config("skia_library") {
96 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -070097 defines = [ "SKIA_IMPLEMENTATION=1" ]
98}
99
100skia_library_configs = [
101 ":skia_public",
102 ":skia_private",
103 ":skia_library",
104]
105
mtklein9b8583d2016-08-24 17:32:30 -0700106# Use for CPU-specific Skia code that needs particular compiler flags.
107template("opts") {
108 if (invoker.enabled) {
109 source_set(target_name) {
110 forward_variables_from(invoker, "*")
111 configs += skia_library_configs
112 }
113 } else {
114 # If not enabled, a phony empty target that swallows all otherwise unused variables.
115 source_set(target_name) {
116 forward_variables_from(invoker,
117 "*",
118 [
119 "sources",
120 "cflags",
121 ])
122 }
123 }
anmittala7eaf2e2016-08-17 13:57:26 -0700124}
125
mtklein422310d2016-08-16 18:28:43 -0700126is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700127
mtklein7d6fb2c2016-08-25 14:50:44 -0700128opts("none") {
129 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700130 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700131 cflags = []
132}
133
mtklein7d6fb2c2016-08-25 14:50:44 -0700134opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700135 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700136 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700137 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700138}
139
140opts("arm64") {
141 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700142 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700143 cflags = []
144}
145
146opts("crc32") {
147 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700148 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700149 cflags = [ "-march=armv8-a+crc" ]
150}
151
mtklein9b8583d2016-08-24 17:32:30 -0700152opts("sse2") {
153 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700154 sources = skia_opts.sse2_sources
mtklein9b8583d2016-08-24 17:32:30 -0700155 cflags = [ "-msse2" ]
156}
mtkleinc04ff472016-06-23 10:29:30 -0700157
mtklein9b8583d2016-08-24 17:32:30 -0700158opts("ssse3") {
159 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700160 sources = skia_opts.ssse3_sources
mtklein9b8583d2016-08-24 17:32:30 -0700161 cflags = [ "-mssse3" ]
162}
mtkleinc04ff472016-06-23 10:29:30 -0700163
mtklein9b8583d2016-08-24 17:32:30 -0700164opts("sse41") {
165 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700166 sources = skia_opts.sse41_sources
mtklein9b8583d2016-08-24 17:32:30 -0700167 cflags = [ "-msse4.1" ]
168}
mtklein4e976072016-08-08 09:06:27 -0700169
mtklein9b8583d2016-08-24 17:32:30 -0700170opts("sse42") {
171 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700172 sources = skia_opts.sse42_sources
mtklein9b8583d2016-08-24 17:32:30 -0700173 cflags = [ "-msse4.2" ]
174}
175
176opts("avx") {
177 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700178 sources = skia_opts.avx_sources
mtklein9b8583d2016-08-24 17:32:30 -0700179 cflags = [ "-mavx" ]
mtkleinc04ff472016-06-23 10:29:30 -0700180}
181
mtklein349cece2016-08-26 08:13:04 -0700182opts("dsp") {
183 enabled = current_cpu == "mipsel"
brettwb9447282016-09-01 14:24:39 -0700184 sources = skia_opts.mips_dsp_sources
mtkleinb6064ef2016-08-30 11:49:24 -0700185 cflags = []
mtklein349cece2016-08-26 08:13:04 -0700186}
187
mtkleinc095df52016-08-24 12:23:52 -0700188# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700189template("optional") {
190 if (invoker.enabled) {
191 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700192 if (defined(invoker.public_defines)) {
193 defines = invoker.public_defines
194 }
mtklein457b42a2016-08-23 13:56:37 -0700195 }
196 source_set(target_name) {
mtkleincd01b032016-08-31 04:58:19 -0700197 forward_variables_from(invoker,
198 "*",
199 [
200 "public_defines",
201 "sources_when_disabled",
202 ])
mtklein457b42a2016-08-23 13:56:37 -0700203 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700204 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700205 }
206 } else {
mtklein457b42a2016-08-23 13:56:37 -0700207 source_set(target_name) {
208 forward_variables_from(invoker,
209 "*",
210 [
211 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700212 "deps",
mtklein6ef69992016-09-14 06:12:09 -0700213 "libs",
mtklein457b42a2016-08-23 13:56:37 -0700214 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700215 "sources_when_disabled",
mtklein457b42a2016-08-23 13:56:37 -0700216 ])
mtkleincd01b032016-08-31 04:58:19 -0700217 if (defined(invoker.sources_when_disabled)) {
218 sources = invoker.sources_when_disabled
219 }
220 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700221 }
mtkleineb3c4252016-08-23 07:38:09 -0700222 }
mtklein457b42a2016-08-23 13:56:37 -0700223}
mtklein457b42a2016-08-23 13:56:37 -0700224
mtkleina45be612016-08-29 15:22:10 -0700225optional("fontmgr_android") {
226 enabled = fontmgr_android_enabled
mtkleina45be612016-08-29 15:22:10 -0700227
228 deps = [
229 "//third_party/expat",
230 "//third_party/freetype2",
231 ]
232 sources = [
233 "src/ports/SkFontMgr_android.cpp",
234 "src/ports/SkFontMgr_android_factory.cpp",
235 "src/ports/SkFontMgr_android_parser.cpp",
236 ]
237}
238
mtkleind2e39db2016-09-07 07:52:55 -0700239optional("fontmgr_custom") {
240 enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
241
242 deps = [
243 "//third_party/freetype2",
244 ]
245 sources = [
246 "src/ports/SkFontMgr_custom.cpp",
247 "src/ports/SkFontMgr_custom_directory_factory.cpp",
248 ]
249}
250
mtklein3cc22182016-08-29 13:26:14 -0700251optional("fontmgr_fontconfig") {
252 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700253
254 deps = [
255 "//third_party:fontconfig",
256 "//third_party/freetype2",
257 ]
258 sources = [
259 "src/ports/SkFontConfigInterface_direct.cpp",
260 "src/ports/SkFontConfigInterface_direct_factory.cpp",
261 "src/ports/SkFontMgr_FontConfigInterface.cpp",
262 "src/ports/SkFontMgr_fontconfig.cpp",
263 "src/ports/SkFontMgr_fontconfig_factory.cpp",
264 ]
265}
266
mtkleincdedd0e2016-09-12 15:15:44 -0700267optional("fontmgr_fuchsia") {
268 enabled = is_fuchsia && skia_use_freetype
269
270 deps = [
271 "//third_party/freetype2",
272 ]
273 sources = [
274 "src/ports/SkFontMgr_custom.cpp",
275 "src/ports/SkFontMgr_custom_empty_factory.cpp",
276 ]
277}
278
mtklein457b42a2016-08-23 13:56:37 -0700279optional("gif") {
280 enabled = skia_use_giflib
281 public_defines = [ "SK_HAS_GIF_LIBRARY" ]
282
mtklein457b42a2016-08-23 13:56:37 -0700283 deps = [
284 "//third_party/giflib",
285 ]
286 sources = [
287 "src/codec/SkGifCodec.cpp",
288 ]
289}
290
mtklein63213812016-08-24 09:55:56 -0700291optional("jpeg") {
292 enabled = skia_use_libjpeg_turbo
293 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
294
mtklein63213812016-08-24 09:55:56 -0700295 deps = [
296 "//third_party/libjpeg-turbo:libjpeg",
297 ]
298 sources = [
299 "src/codec/SkJpegCodec.cpp",
300 "src/codec/SkJpegDecoderMgr.cpp",
301 "src/codec/SkJpegUtility.cpp",
302 "src/images/SkJPEGImageEncoder.cpp",
303 "src/images/SkJPEGWriteUtility.cpp",
304 ]
305}
306
307optional("pdf") {
308 enabled = skia_use_zlib
mtklein63213812016-08-24 09:55:56 -0700309
mtklein63213812016-08-24 09:55:56 -0700310 deps = [
311 "//third_party/zlib",
312 ]
brettwb9447282016-09-01 14:24:39 -0700313 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700314 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700315
316 if (skia_use_sfntly) {
317 deps += [ "//third_party/sfntly" ]
mtkleincd01b032016-08-31 04:58:19 -0700318 public_defines = [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700319 }
320}
321
322optional("png") {
323 enabled = skia_use_libpng
324 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
325
mtklein63213812016-08-24 09:55:56 -0700326 deps = [
327 "//third_party/libpng",
328 ]
329 sources = [
330 "src/codec/SkIcoCodec.cpp",
331 "src/codec/SkPngCodec.cpp",
332 "src/images/SkPNGImageEncoder.cpp",
333 ]
334}
335
mtklein3cc22182016-08-29 13:26:14 -0700336optional("typeface_freetype") {
337 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700338
339 deps = [
340 "//third_party/freetype2",
341 ]
342 sources = [
343 "src/ports/SkFontHost_FreeType.cpp",
344 "src/ports/SkFontHost_FreeType_common.cpp",
345 ]
346}
347
mtklein6ef69992016-09-14 06:12:09 -0700348optional("vulkan") {
349 enabled = skia_use_vulkan
350 public_defines = [ "SK_VULKAN" ]
351 libs = [ "vulkan" ]
352 sources = skia_vk_sources
353}
354
mtklein457b42a2016-08-23 13:56:37 -0700355optional("webp") {
356 enabled = skia_use_libwebp
357 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
358
mtklein457b42a2016-08-23 13:56:37 -0700359 deps = [
360 "//third_party/libwebp",
361 ]
362 sources = [
363 "src/codec/SkWebpAdapterCodec.cpp",
364 "src/codec/SkWebpCodec.cpp",
365 "src/images/SkWEBPImageEncoder.cpp",
366 ]
mtkleineb3c4252016-08-23 07:38:09 -0700367}
368
mtklein63213812016-08-24 09:55:56 -0700369optional("xml") {
370 enabled = skia_use_expat
mtklein63213812016-08-24 09:55:56 -0700371
mtklein63213812016-08-24 09:55:56 -0700372 deps = [
373 "//third_party/expat",
374 ]
375 sources = [
376 "src/xml/SkDOM.cpp",
377 "src/xml/SkXMLParser.cpp",
378 "src/xml/SkXMLWriter.cpp",
379 ]
380}
381
mtkleinc04ff472016-06-23 10:29:30 -0700382component("skia") {
383 public_configs = [ ":skia_public" ]
384 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700385
386 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700387 ":arm64",
388 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700389 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700390 ":crc32",
mtklein349cece2016-08-26 08:13:04 -0700391 ":dsp",
mtkleina45be612016-08-29 15:22:10 -0700392 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700393 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700394 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700395 ":fontmgr_fuchsia",
mtklein457b42a2016-08-23 13:56:37 -0700396 ":gif",
mtklein63213812016-08-24 09:55:56 -0700397 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700398 ":none",
mtklein63213812016-08-24 09:55:56 -0700399 ":pdf",
400 ":png",
mtklein9b8583d2016-08-24 17:32:30 -0700401 ":sse2",
402 ":sse41",
403 ":sse42",
404 ":ssse3",
mtklein3cc22182016-08-29 13:26:14 -0700405 ":typeface_freetype",
mtklein6ef69992016-09-14 06:12:09 -0700406 ":vulkan",
mtkleineb3c4252016-08-23 07:38:09 -0700407 ":webp",
mtklein63213812016-08-24 09:55:56 -0700408 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700409 ]
410
mtkleinc04ff472016-06-23 10:29:30 -0700411 sources = []
brettwb9447282016-09-01 14:24:39 -0700412 sources += skia_core_sources
413 sources += skia_effects_sources
414 sources += skia_gpu_sources
415 sources += skia_sksl_sources
416 sources += skia_utils_sources
mtkleinc04ff472016-06-23 10:29:30 -0700417 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700418 "src/android/SkBitmapRegionCodec.cpp",
419 "src/android/SkBitmapRegionDecoder.cpp",
420 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700421 "src/codec/SkBmpCodec.cpp",
422 "src/codec/SkBmpMaskCodec.cpp",
423 "src/codec/SkBmpRLECodec.cpp",
424 "src/codec/SkBmpStandardCodec.cpp",
425 "src/codec/SkCodec.cpp",
426 "src/codec/SkCodecImageGenerator.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700427 "src/codec/SkMaskSwizzler.cpp",
428 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700429 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700430 "src/codec/SkSampler.cpp",
431 "src/codec/SkSwizzler.cpp",
432 "src/codec/SkWbmpCodec.cpp",
mtklein09e61f72016-08-23 13:35:28 -0700433 "src/gpu/gl/GrGLDefaultInterface_native.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700434 "src/images/SkImageEncoder.cpp",
435 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700436 "src/images/SkKTXImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700437 "src/ports/SkDiscardableMemory_none.cpp",
438 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700439 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700440 "src/ports/SkMemory_malloc.cpp",
441 "src/ports/SkOSFile_stdio.cpp",
442 "src/sfnt/SkOTTable_name.cpp",
443 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700444 "src/svg/SkSVGCanvas.cpp",
445 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700446 "src/utils/mac/SkStream_mac.cpp",
447 "third_party/etc1/etc1.cpp",
448 "third_party/ktx/ktx.cpp",
449 ]
brettwb9447282016-09-01 14:24:39 -0700450
451 # These paths need to be absolute to match the ones produced by
452 # shared_sources.gni, but this file may be used from different directory
453 # locations.
454 sources -= get_path_info([
455 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
456 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
457 ],
458 "abspath")
mtkleinc04ff472016-06-23 10:29:30 -0700459
mtklein7d6fb2c2016-08-25 14:50:44 -0700460 libs = []
461
mtkleinc04ff472016-06-23 10:29:30 -0700462 if (is_win) {
463 sources += [
464 "src/ports/SkDebug_win.cpp",
465 "src/ports/SkFontHost_win.cpp",
466 "src/ports/SkFontMgr_win_dw.cpp",
467 "src/ports/SkFontMgr_win_dw_factory.cpp",
468 "src/ports/SkImageEncoder_WIC.cpp",
469 "src/ports/SkImageGeneratorWIC.cpp",
470 "src/ports/SkOSFile_win.cpp",
471 "src/ports/SkScalerContext_win_dw.cpp",
472 "src/ports/SkTLS_win.cpp",
473 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700474 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700475 ]
mtklein7a1f45f2016-08-04 06:19:33 -0700476 sources -= [ "src/utils/SkThreadUtils_pthread.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700477 } else {
478 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700479 "src/ports/SkOSFile_posix.cpp",
480 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700481 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700482 ]
483 }
484
mtklein7d6fb2c2016-08-25 14:50:44 -0700485 if (is_android) {
486 deps += [
487 "//third_party/cpu-features",
488 "//third_party/expat",
mtklein7d6fb2c2016-08-25 14:50:44 -0700489 ]
490 sources += [
491 "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp",
492 "src/ports/SkDebug_android.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700493 ]
494 libs += [
495 "EGL",
496 "GLESv2",
497 "log",
498 ]
499 }
500
mtkleinc04ff472016-06-23 10:29:30 -0700501 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700502 libs += [
503 "GL",
504 "GLU",
505 "X11",
506 ]
mtkleinc04ff472016-06-23 10:29:30 -0700507 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700508 "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700509 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700510 ]
511 }
512
513 if (is_mac) {
514 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700515 "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700516 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700517 "src/ports/SkFontHost_mac.cpp",
518 "src/ports/SkImageEncoder_CG.cpp",
519 "src/ports/SkImageGeneratorCG.cpp",
520 ]
mtklein09e61f72016-08-23 13:35:28 -0700521 libs += [
522 "ApplicationServices.framework",
523 "OpenGL.framework",
524 ]
mtkleinc04ff472016-06-23 10:29:30 -0700525 }
abarth6fc8ff02016-07-15 15:15:15 -0700526
527 if (is_fuchsia) {
mikejurka21cc9952016-09-13 16:15:03 -0700528 sources += [
529 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
530 "src/ports/SkDebug_stdio.cpp",
531 ]
abarth6fc8ff02016-07-15 15:15:15 -0700532 }
mtkleinc04ff472016-06-23 10:29:30 -0700533}
534
mtkleinada5a442016-08-02 14:28:26 -0700535skia_h_headers = exec_script("gyp/find.py",
536 [ "*.h" ] + rebase_path(skia_public_includes),
537 "list lines",
538 []) -
539 [
540 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
541 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
542 rebase_path("include/gpu/vk/GrVkDefines.h"),
543 rebase_path("include/gpu/vk/GrVkInterface.h"),
544 rebase_path("include/gpu/vk/GrVkTypes.h"),
545 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
546 ]
547
mtklein1211e0c2016-07-26 13:55:45 -0700548action("skia.h") {
549 script = "gn/echo_headers.py"
550 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinc095df52016-08-24 12:23:52 -0700551 rebase_path(skia_h_headers, target_gen_dir)
mtklein1211e0c2016-07-26 13:55:45 -0700552 outputs = [
553 "$target_gen_dir/skia.h",
554 ]
555}
556
557executable("fiddle") {
558 include_dirs = [ "$target_gen_dir" ]
mtklein7d10b9f2016-07-27 11:17:18 -0700559 libs = []
560 if (is_linux) {
561 libs += [ "OSMesa" ]
562 }
mtklein1211e0c2016-07-26 13:55:45 -0700563
mtkleinc04ff472016-06-23 10:29:30 -0700564 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700565 "src/images/SkForceLinking.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700566 "tools/fiddle/draw.cpp",
567 "tools/fiddle/fiddle_main.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700568 ]
569 deps = [
570 ":skia",
mtklein1211e0c2016-07-26 13:55:45 -0700571 ":skia.h",
mtkleinc04ff472016-06-23 10:29:30 -0700572 ]
mtkleinc04ff472016-06-23 10:29:30 -0700573}
mtklein25c81d42016-07-27 13:55:26 -0700574
mtkleinc095df52016-08-24 12:23:52 -0700575# Targets guarded by skia_enable_tools may use //third_party freely.
576if (skia_enable_tools) {
577 template("test_lib") {
578 config(target_name + "_config") {
579 include_dirs = invoker.public_include_dirs
mtklein25c81d42016-07-27 13:55:26 -0700580 }
mtkleinc095df52016-08-24 12:23:52 -0700581 source_set(target_name) {
582 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
583 public_configs = [
584 ":" + target_name + "_config",
585 ":skia_private",
586 ]
587
588 if (!defined(deps)) {
589 deps = []
590 }
591 deps += [ ":skia" ]
592 testonly = true
593 }
mtklein25c81d42016-07-27 13:55:26 -0700594 }
mtklein25c81d42016-07-27 13:55:26 -0700595
mtkleinc095df52016-08-24 12:23:52 -0700596 test_lib("gpu_tool_utils") {
597 public_include_dirs = [ "tools/gpu" ]
598 sources = [
599 "tools/gpu/GrContextFactory.cpp",
600 "tools/gpu/GrTest.cpp",
601 "tools/gpu/TestContext.cpp",
602 "tools/gpu/gl/GLTestContext.cpp",
603 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
604 "tools/gpu/gl/debug/GrBufferObj.cpp",
605 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
606 "tools/gpu/gl/debug/GrProgramObj.cpp",
607 "tools/gpu/gl/debug/GrShaderObj.cpp",
608 "tools/gpu/gl/debug/GrTextureObj.cpp",
609 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
610 "tools/gpu/gl/null/NullGLTestContext.cpp",
611 ]
612 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700613
mtklein7d6fb2c2016-08-25 14:50:44 -0700614 if (is_android) {
615 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
616 } else if (is_linux) {
mtkleinc095df52016-08-24 12:23:52 -0700617 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
618 } else if (is_mac) {
619 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
620 }
mtklein6ef69992016-09-14 06:12:09 -0700621
622 if (skia_use_vulkan) {
623 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
624 }
mtklein25c81d42016-07-27 13:55:26 -0700625 }
mtklein25c81d42016-07-27 13:55:26 -0700626
mtkleinc095df52016-08-24 12:23:52 -0700627 test_lib("flags") {
628 public_include_dirs = [ "tools/flags" ]
629 sources = [
630 "tools/flags/SkCommandLineFlags.cpp",
631 "tools/flags/SkCommonFlags.cpp",
632 "tools/flags/SkCommonFlagsConfig.cpp",
633 ]
634 deps = [
635 ":gpu_tool_utils",
636 ]
637 }
mtklein25c81d42016-07-27 13:55:26 -0700638
mtkleinc095df52016-08-24 12:23:52 -0700639 test_lib("tool_utils") {
640 public_include_dirs = [
641 "tools",
642 "tools/debugger",
643 "tools/timer",
644 ]
645 sources = [
646 "src/images/SkForceLinking.cpp",
647 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700648 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700649 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700650 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700651 "tools/ProcStats.cpp",
652 "tools/Resources.cpp",
653 "tools/ThermalManager.cpp",
654 "tools/UrlDataManager.cpp",
655 "tools/debugger/SkDebugCanvas.cpp",
656 "tools/debugger/SkDrawCommand.cpp",
657 "tools/debugger/SkJsonWriteBuffer.cpp",
658 "tools/debugger/SkObjectParser.cpp",
659 "tools/debugger/SkOverdrawMode.cpp",
660 "tools/picture_utils.cpp",
661 "tools/random_parse_path.cpp",
662 "tools/sk_tool_utils.cpp",
663 "tools/sk_tool_utils_font.cpp",
664 "tools/timer/Timer.cpp",
665 ]
666 deps = [
667 ":flags",
668 "//third_party/libpng",
669 ]
670 public_deps = [
671 "//third_party/jsoncpp",
672 ]
673 }
mtklein25c81d42016-07-27 13:55:26 -0700674
mtkleinc095df52016-08-24 12:23:52 -0700675 gm_sources = exec_script("gyp/find.py",
676 [
677 "*.c*",
678 rebase_path("gm"),
679 ],
680 "list lines",
681 [])
682 test_lib("gm") {
683 public_include_dirs = [ "gm" ]
684 sources = gm_sources
685 deps = [
686 ":gpu_tool_utils",
687 ":skia",
688 ":tool_utils",
689 ]
690 }
mtklein25c81d42016-07-27 13:55:26 -0700691
mtkleinc095df52016-08-24 12:23:52 -0700692 tests_sources = exec_script("gyp/find.py",
693 [
694 "*.c*",
695 rebase_path("tests"),
696 ],
697 "list lines",
698 [])
mtklein2f3416d2016-08-02 16:02:05 -0700699
mtkleinc095df52016-08-24 12:23:52 -0700700 test_lib("tests") {
701 public_include_dirs = [ "tests" ]
mtkleina45be612016-08-29 15:22:10 -0700702 sources = tests_sources - [
703 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
mtkleina45be612016-08-29 15:22:10 -0700704 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
705 rebase_path("tests/skia_test.cpp"), # alternate main
706 ]
707 if (!fontmgr_android_enabled) {
708 sources -= [ rebase_path("tests/FontMgrAndroidParserTest.cpp") ]
709 }
mtkleinc095df52016-08-24 12:23:52 -0700710 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700711 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700712 ":flags",
713 ":gpu_tool_utils",
714 ":skia",
715 ":tool_utils",
716 "//third_party/libpng",
717 "//third_party/zlib",
718 ]
719 }
mtklein2f3416d2016-08-02 16:02:05 -0700720
mtkleinc095df52016-08-24 12:23:52 -0700721 bench_sources = exec_script("gyp/find.py",
722 [
723 "*.c*",
724 rebase_path("bench"),
725 ],
726 "list lines",
727 [])
mtklein25c81d42016-07-27 13:55:26 -0700728
mtkleinc095df52016-08-24 12:23:52 -0700729 test_lib("bench") {
730 public_include_dirs = [ "bench" ]
731 sources = bench_sources
732 sources -= [
733 rebase_path("bench/nanobench.cpp"),
734 rebase_path("bench/nanobenchAndroid.cpp"),
735 ]
736 deps = [
737 ":flags",
738 ":gm",
739 ":gpu_tool_utils",
740 ":skia",
741 ":tool_utils",
742 ]
743 }
mtklein2b6870c2016-07-28 14:17:33 -0700744
mtkleinc095df52016-08-24 12:23:52 -0700745 test_lib("experimental_svg_model") {
746 public_include_dirs = [ "experimental/svg/model" ]
747 sources = [
748 "experimental/svg/model/SkSVGAttribute.cpp",
749 "experimental/svg/model/SkSVGAttributeParser.cpp",
750 "experimental/svg/model/SkSVGCircle.cpp",
751 "experimental/svg/model/SkSVGContainer.cpp",
752 "experimental/svg/model/SkSVGDOM.cpp",
753 "experimental/svg/model/SkSVGEllipse.cpp",
754 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700755 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700756 "experimental/svg/model/SkSVGNode.cpp",
757 "experimental/svg/model/SkSVGPath.cpp",
758 "experimental/svg/model/SkSVGPoly.cpp",
759 "experimental/svg/model/SkSVGRect.cpp",
760 "experimental/svg/model/SkSVGRenderContext.cpp",
761 "experimental/svg/model/SkSVGSVG.cpp",
762 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700763 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700764 "experimental/svg/model/SkSVGTransformableNode.cpp",
765 "experimental/svg/model/SkSVGValue.cpp",
766 ]
767 deps = [
768 ":skia",
769 ]
770 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700771
mtklein2b6870c2016-07-28 14:17:33 -0700772 executable("dm") {
773 sources = [
774 "dm/DM.cpp",
775 "dm/DMJsonWriter.cpp",
776 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700777 ]
778 include_dirs = [ "tests" ]
779 deps = [
fmalitaa2b9fdf2016-08-03 19:53:36 -0700780 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700781 ":flags",
782 ":gm",
783 ":gpu_tool_utils",
784 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700785 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700786 ":tool_utils",
787 "//third_party/jsoncpp",
788 "//third_party/libpng",
789 ]
790 testonly = true
791 }
792
793 executable("monobench") {
794 sources = [
795 "tools/monobench.cpp",
796 ]
797 deps = [
798 ":bench",
799 ":skia",
800 ]
801 testonly = true
802 }
803
804 executable("nanobench") {
805 sources = [
806 "bench/nanobench.cpp",
807 ]
808 deps = [
809 ":bench",
fmalita6519c212016-09-14 08:05:17 -0700810 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700811 ":flags",
812 ":gm",
813 ":gpu_tool_utils",
814 ":skia",
815 ":tool_utils",
816 "//third_party/jsoncpp",
817 ]
818 testonly = true
819 }
halcanary19a97202016-08-03 15:08:04 -0700820
mtklein6f5df6a2016-08-29 16:01:10 -0700821 if (current_cpu != "mipsel") { # Clang 3.8 crashes while compiling hb-icu.cc for mipsel.
halcanary3eee9d92016-09-10 07:01:53 -0700822 executable("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -0700823 sources = [
824 "tools/SkShaper_harfbuzz.cpp",
825 "tools/using_skia_and_harfbuzz.cpp",
826 ]
827 deps = [
828 ":skia",
829 "//third_party/harfbuzz",
830 ]
831 testonly = true
832 }
halcanary19a97202016-08-03 15:08:04 -0700833 }
halcanary3eee9d92016-09-10 07:01:53 -0700834 executable("sktexttopdf") {
835 sources = [
836 "tools/SkShaper_primitive.cpp",
837 "tools/using_skia_and_harfbuzz.cpp",
838 ]
839 deps = [
840 ":skia",
841 ]
842 testonly = true
843 }
mtklein25c81d42016-07-27 13:55:26 -0700844}