blob: 5544593e6ef2d704006acb9265c8fdea194c9fc5 [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
mtkleinf29180e2016-09-16 07:01:17 -070019 skia_use_vulkan = is_android && defined(ndk_api) && ndk_api >= 24
mtklein63213812016-08-24 09:55:56 -070020 skia_use_zlib = true
mtklein1bd72ba2016-09-16 07:45:52 -070021
22 skia_enable_android_framework_defines = false
mtkleinc04ff472016-06-23 10:29:30 -070023}
24
mtkleina45be612016-08-29 15:22:10 -070025fontmgr_android_enabled = skia_use_expat && skia_use_freetype
26
mtklein1211e0c2016-07-26 13:55:45 -070027skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070028 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070029 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070030 "include/codec",
31 "include/config",
32 "include/core",
33 "include/effects",
34 "include/gpu",
35 "include/gpu/gl",
36 "include/images",
37 "include/pathops",
38 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070039 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070040 "include/utils",
41 "include/utils/mac",
mtklein25c81d42016-07-27 13:55:26 -070042 "include/xml",
mtklein1211e0c2016-07-26 13:55:45 -070043]
44
mtkleinc04ff472016-06-23 10:29:30 -070045# Skia public API, generally provided by :skia.
46config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -070047 include_dirs = skia_public_includes
mtkleinc04ff472016-06-23 10:29:30 -070048 defines = [ "SKIA_DLL" ]
jcgregorio5561e3d2016-08-25 09:25:11 -070049 if (is_linux) {
50 defines += [ "SK_SAMPLES_FOR_X" ]
51 }
mtkleinc04ff472016-06-23 10:29:30 -070052}
53
54# Skia internal APIs, used by Skia itself and a few test tools.
55config("skia_private") {
56 visibility = [ ":*" ]
57
58 include_dirs = [
59 "include/private",
60 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -070061 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -070062 "src/config",
63 "src/core",
64 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -070065 "src/effects/gradients",
66 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -070067 "src/gpu",
68 "src/image",
69 "src/images",
70 "src/lazy",
71 "src/opts",
72 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -070073 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -070074 "src/ports",
75 "src/sfnt",
mtklein9e0d9dd2016-08-30 10:37:19 -070076 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -070077 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -070078 "src/utils/win",
mtkleinc04ff472016-06-23 10:29:30 -070079 "third_party/etc1",
80 "third_party/ktx",
81 ]
mtklein150d1132016-08-01 06:56:40 -070082
mtklein63213812016-08-24 09:55:56 -070083 defines = [ "SK_GAMMA_APPLY_TO_A8" ]
mtkleinb37c0342016-09-09 11:07:45 -070084 if (is_android) {
85 defines += [
86 "SK_GAMMA_EXPONENT=1.4",
87 "SK_GAMMA_CONTRAST=0.0",
88 ]
89 }
mtklein88a7ac02016-09-14 11:16:49 -070090 if (is_official_build || is_android) {
91 # TODO(bsalomon): it'd be nice to make Android normal.
92 defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
93 }
mtkleinc04ff472016-06-23 10:29:30 -070094}
95
96# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
97config("skia_library") {
98 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -070099 defines = [ "SKIA_IMPLEMENTATION=1" ]
100}
101
102skia_library_configs = [
103 ":skia_public",
104 ":skia_private",
105 ":skia_library",
106]
107
mtklein9b8583d2016-08-24 17:32:30 -0700108# Use for CPU-specific Skia code that needs particular compiler flags.
109template("opts") {
110 if (invoker.enabled) {
111 source_set(target_name) {
112 forward_variables_from(invoker, "*")
113 configs += skia_library_configs
114 }
115 } else {
116 # If not enabled, a phony empty target that swallows all otherwise unused variables.
117 source_set(target_name) {
118 forward_variables_from(invoker,
119 "*",
120 [
121 "sources",
122 "cflags",
123 ])
124 }
125 }
anmittala7eaf2e2016-08-17 13:57:26 -0700126}
127
mtklein422310d2016-08-16 18:28:43 -0700128is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700129
mtklein7d6fb2c2016-08-25 14:50:44 -0700130opts("none") {
131 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700132 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700133 cflags = []
134}
135
mtklein7d6fb2c2016-08-25 14:50:44 -0700136opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700137 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700138 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700139 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700140}
141
142opts("arm64") {
143 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700144 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700145 cflags = []
146}
147
148opts("crc32") {
149 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700150 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700151 cflags = [ "-march=armv8-a+crc" ]
152}
153
mtklein9b8583d2016-08-24 17:32:30 -0700154opts("sse2") {
155 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700156 sources = skia_opts.sse2_sources
mtklein9b8583d2016-08-24 17:32:30 -0700157 cflags = [ "-msse2" ]
158}
mtkleinc04ff472016-06-23 10:29:30 -0700159
mtklein9b8583d2016-08-24 17:32:30 -0700160opts("ssse3") {
161 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700162 sources = skia_opts.ssse3_sources
mtklein9b8583d2016-08-24 17:32:30 -0700163 cflags = [ "-mssse3" ]
164}
mtkleinc04ff472016-06-23 10:29:30 -0700165
mtklein9b8583d2016-08-24 17:32:30 -0700166opts("sse41") {
167 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700168 sources = skia_opts.sse41_sources
mtklein9b8583d2016-08-24 17:32:30 -0700169 cflags = [ "-msse4.1" ]
170}
mtklein4e976072016-08-08 09:06:27 -0700171
mtklein9b8583d2016-08-24 17:32:30 -0700172opts("sse42") {
173 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700174 sources = skia_opts.sse42_sources
mtklein9b8583d2016-08-24 17:32:30 -0700175 cflags = [ "-msse4.2" ]
176}
177
178opts("avx") {
179 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700180 sources = skia_opts.avx_sources
mtklein9b8583d2016-08-24 17:32:30 -0700181 cflags = [ "-mavx" ]
mtkleinc04ff472016-06-23 10:29:30 -0700182}
183
mtklein349cece2016-08-26 08:13:04 -0700184opts("dsp") {
185 enabled = current_cpu == "mipsel"
brettwb9447282016-09-01 14:24:39 -0700186 sources = skia_opts.mips_dsp_sources
mtkleinb6064ef2016-08-30 11:49:24 -0700187 cflags = []
mtklein349cece2016-08-26 08:13:04 -0700188}
189
mtkleinc095df52016-08-24 12:23:52 -0700190# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700191template("optional") {
192 if (invoker.enabled) {
193 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700194 if (defined(invoker.public_defines)) {
195 defines = invoker.public_defines
196 }
mtklein457b42a2016-08-23 13:56:37 -0700197 }
198 source_set(target_name) {
mtkleincd01b032016-08-31 04:58:19 -0700199 forward_variables_from(invoker,
200 "*",
201 [
202 "public_defines",
203 "sources_when_disabled",
204 ])
mtklein457b42a2016-08-23 13:56:37 -0700205 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700206 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700207 }
208 } else {
mtklein457b42a2016-08-23 13:56:37 -0700209 source_set(target_name) {
210 forward_variables_from(invoker,
211 "*",
212 [
213 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700214 "deps",
mtklein6ef69992016-09-14 06:12:09 -0700215 "libs",
mtklein457b42a2016-08-23 13:56:37 -0700216 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700217 "sources_when_disabled",
mtklein457b42a2016-08-23 13:56:37 -0700218 ])
mtkleincd01b032016-08-31 04:58:19 -0700219 if (defined(invoker.sources_when_disabled)) {
220 sources = invoker.sources_when_disabled
221 }
222 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700223 }
mtkleineb3c4252016-08-23 07:38:09 -0700224 }
mtklein457b42a2016-08-23 13:56:37 -0700225}
mtklein457b42a2016-08-23 13:56:37 -0700226
mtklein1bd72ba2016-09-16 07:45:52 -0700227optional("android_framework_defines") {
228 enabled = skia_enable_android_framework_defines
229 public_defines = skia_android_framework_defines
230}
231
mtkleina45be612016-08-29 15:22:10 -0700232optional("fontmgr_android") {
233 enabled = fontmgr_android_enabled
mtkleina45be612016-08-29 15:22:10 -0700234
235 deps = [
236 "//third_party/expat",
237 "//third_party/freetype2",
238 ]
239 sources = [
240 "src/ports/SkFontMgr_android.cpp",
241 "src/ports/SkFontMgr_android_factory.cpp",
242 "src/ports/SkFontMgr_android_parser.cpp",
243 ]
244}
245
mtkleind2e39db2016-09-07 07:52:55 -0700246optional("fontmgr_custom") {
247 enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
248
249 deps = [
250 "//third_party/freetype2",
251 ]
252 sources = [
253 "src/ports/SkFontMgr_custom.cpp",
254 "src/ports/SkFontMgr_custom_directory_factory.cpp",
255 ]
256}
257
mtklein3cc22182016-08-29 13:26:14 -0700258optional("fontmgr_fontconfig") {
259 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700260
261 deps = [
262 "//third_party:fontconfig",
263 "//third_party/freetype2",
264 ]
265 sources = [
bungeman1ae0e012016-09-19 12:13:16 -0700266 "src/ports/SkFontConfigInterface.cpp",
mtklein3cc22182016-08-29 13:26:14 -0700267 "src/ports/SkFontConfigInterface_direct.cpp",
268 "src/ports/SkFontConfigInterface_direct_factory.cpp",
269 "src/ports/SkFontMgr_FontConfigInterface.cpp",
270 "src/ports/SkFontMgr_fontconfig.cpp",
271 "src/ports/SkFontMgr_fontconfig_factory.cpp",
272 ]
273}
274
mtkleincdedd0e2016-09-12 15:15:44 -0700275optional("fontmgr_fuchsia") {
276 enabled = is_fuchsia && skia_use_freetype
277
278 deps = [
279 "//third_party/freetype2",
280 ]
281 sources = [
282 "src/ports/SkFontMgr_custom.cpp",
283 "src/ports/SkFontMgr_custom_empty_factory.cpp",
284 ]
285}
286
mtklein457b42a2016-08-23 13:56:37 -0700287optional("gif") {
288 enabled = skia_use_giflib
289 public_defines = [ "SK_HAS_GIF_LIBRARY" ]
290
mtklein457b42a2016-08-23 13:56:37 -0700291 deps = [
292 "//third_party/giflib",
293 ]
294 sources = [
295 "src/codec/SkGifCodec.cpp",
296 ]
297}
298
mtklein63213812016-08-24 09:55:56 -0700299optional("jpeg") {
300 enabled = skia_use_libjpeg_turbo
301 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
302
mtklein63213812016-08-24 09:55:56 -0700303 deps = [
304 "//third_party/libjpeg-turbo:libjpeg",
305 ]
306 sources = [
307 "src/codec/SkJpegCodec.cpp",
308 "src/codec/SkJpegDecoderMgr.cpp",
309 "src/codec/SkJpegUtility.cpp",
310 "src/images/SkJPEGImageEncoder.cpp",
311 "src/images/SkJPEGWriteUtility.cpp",
312 ]
313}
314
315optional("pdf") {
316 enabled = skia_use_zlib
mtklein63213812016-08-24 09:55:56 -0700317
mtklein63213812016-08-24 09:55:56 -0700318 deps = [
319 "//third_party/zlib",
320 ]
brettwb9447282016-09-01 14:24:39 -0700321 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700322 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700323
324 if (skia_use_sfntly) {
325 deps += [ "//third_party/sfntly" ]
mtkleincd01b032016-08-31 04:58:19 -0700326 public_defines = [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700327 }
328}
329
330optional("png") {
331 enabled = skia_use_libpng
332 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
333
mtklein63213812016-08-24 09:55:56 -0700334 deps = [
335 "//third_party/libpng",
336 ]
337 sources = [
338 "src/codec/SkIcoCodec.cpp",
339 "src/codec/SkPngCodec.cpp",
340 "src/images/SkPNGImageEncoder.cpp",
341 ]
342}
343
mtklein3cc22182016-08-29 13:26:14 -0700344optional("typeface_freetype") {
345 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700346
347 deps = [
348 "//third_party/freetype2",
349 ]
350 sources = [
351 "src/ports/SkFontHost_FreeType.cpp",
352 "src/ports/SkFontHost_FreeType_common.cpp",
353 ]
354}
355
mtklein6ef69992016-09-14 06:12:09 -0700356optional("vulkan") {
357 enabled = skia_use_vulkan
358 public_defines = [ "SK_VULKAN" ]
359 libs = [ "vulkan" ]
360 sources = skia_vk_sources
361}
362
mtklein457b42a2016-08-23 13:56:37 -0700363optional("webp") {
364 enabled = skia_use_libwebp
365 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
366
mtklein457b42a2016-08-23 13:56:37 -0700367 deps = [
368 "//third_party/libwebp",
369 ]
370 sources = [
371 "src/codec/SkWebpAdapterCodec.cpp",
372 "src/codec/SkWebpCodec.cpp",
373 "src/images/SkWEBPImageEncoder.cpp",
374 ]
mtkleineb3c4252016-08-23 07:38:09 -0700375}
376
mtklein63213812016-08-24 09:55:56 -0700377optional("xml") {
378 enabled = skia_use_expat
mtklein63213812016-08-24 09:55:56 -0700379
mtklein63213812016-08-24 09:55:56 -0700380 deps = [
381 "//third_party/expat",
382 ]
383 sources = [
384 "src/xml/SkDOM.cpp",
385 "src/xml/SkXMLParser.cpp",
386 "src/xml/SkXMLWriter.cpp",
387 ]
388}
389
mtkleinc04ff472016-06-23 10:29:30 -0700390component("skia") {
391 public_configs = [ ":skia_public" ]
392 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700393
394 deps = [
mtklein1bd72ba2016-09-16 07:45:52 -0700395 ":android_framework_defines",
anmittalb8b3f712016-08-25 04:55:19 -0700396 ":arm64",
397 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700398 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700399 ":crc32",
mtklein349cece2016-08-26 08:13:04 -0700400 ":dsp",
mtkleina45be612016-08-29 15:22:10 -0700401 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700402 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700403 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700404 ":fontmgr_fuchsia",
mtklein457b42a2016-08-23 13:56:37 -0700405 ":gif",
mtklein63213812016-08-24 09:55:56 -0700406 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700407 ":none",
mtklein63213812016-08-24 09:55:56 -0700408 ":pdf",
409 ":png",
mtklein9b8583d2016-08-24 17:32:30 -0700410 ":sse2",
411 ":sse41",
412 ":sse42",
413 ":ssse3",
mtklein3cc22182016-08-29 13:26:14 -0700414 ":typeface_freetype",
mtklein6ef69992016-09-14 06:12:09 -0700415 ":vulkan",
mtkleineb3c4252016-08-23 07:38:09 -0700416 ":webp",
mtklein63213812016-08-24 09:55:56 -0700417 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700418 ]
419
mtkleinc04ff472016-06-23 10:29:30 -0700420 sources = []
brettwb9447282016-09-01 14:24:39 -0700421 sources += skia_core_sources
422 sources += skia_effects_sources
423 sources += skia_gpu_sources
424 sources += skia_sksl_sources
425 sources += skia_utils_sources
mtkleinc04ff472016-06-23 10:29:30 -0700426 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700427 "src/android/SkBitmapRegionCodec.cpp",
428 "src/android/SkBitmapRegionDecoder.cpp",
429 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700430 "src/codec/SkBmpCodec.cpp",
431 "src/codec/SkBmpMaskCodec.cpp",
432 "src/codec/SkBmpRLECodec.cpp",
433 "src/codec/SkBmpStandardCodec.cpp",
434 "src/codec/SkCodec.cpp",
435 "src/codec/SkCodecImageGenerator.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700436 "src/codec/SkMaskSwizzler.cpp",
437 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700438 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700439 "src/codec/SkSampler.cpp",
440 "src/codec/SkSwizzler.cpp",
441 "src/codec/SkWbmpCodec.cpp",
mtklein09e61f72016-08-23 13:35:28 -0700442 "src/gpu/gl/GrGLDefaultInterface_native.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700443 "src/images/SkImageEncoder.cpp",
444 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700445 "src/images/SkKTXImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700446 "src/ports/SkDiscardableMemory_none.cpp",
447 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700448 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700449 "src/ports/SkMemory_malloc.cpp",
450 "src/ports/SkOSFile_stdio.cpp",
451 "src/sfnt/SkOTTable_name.cpp",
452 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700453 "src/svg/SkSVGCanvas.cpp",
454 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700455 "src/utils/mac/SkStream_mac.cpp",
456 "third_party/etc1/etc1.cpp",
457 "third_party/ktx/ktx.cpp",
458 ]
brettwb9447282016-09-01 14:24:39 -0700459
460 # These paths need to be absolute to match the ones produced by
461 # shared_sources.gni, but this file may be used from different directory
462 # locations.
463 sources -= get_path_info([
464 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
465 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
466 ],
467 "abspath")
mtkleinc04ff472016-06-23 10:29:30 -0700468
mtklein7d6fb2c2016-08-25 14:50:44 -0700469 libs = []
470
mtkleinc04ff472016-06-23 10:29:30 -0700471 if (is_win) {
472 sources += [
473 "src/ports/SkDebug_win.cpp",
474 "src/ports/SkFontHost_win.cpp",
475 "src/ports/SkFontMgr_win_dw.cpp",
476 "src/ports/SkFontMgr_win_dw_factory.cpp",
477 "src/ports/SkImageEncoder_WIC.cpp",
478 "src/ports/SkImageGeneratorWIC.cpp",
479 "src/ports/SkOSFile_win.cpp",
480 "src/ports/SkScalerContext_win_dw.cpp",
481 "src/ports/SkTLS_win.cpp",
482 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700483 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700484 ]
mtkleinb9be9792016-09-16 14:44:18 -0700485 sources -=
486 [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
mtkleinc04ff472016-06-23 10:29:30 -0700487 } else {
488 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700489 "src/ports/SkOSFile_posix.cpp",
490 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700491 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700492 ]
493 }
494
mtklein7d6fb2c2016-08-25 14:50:44 -0700495 if (is_android) {
496 deps += [
497 "//third_party/cpu-features",
498 "//third_party/expat",
mtklein7d6fb2c2016-08-25 14:50:44 -0700499 ]
500 sources += [
501 "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp",
502 "src/ports/SkDebug_android.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700503 ]
504 libs += [
505 "EGL",
506 "GLESv2",
507 "log",
508 ]
509 }
510
mtkleinc04ff472016-06-23 10:29:30 -0700511 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700512 libs += [
513 "GL",
514 "GLU",
515 "X11",
516 ]
mtkleinc04ff472016-06-23 10:29:30 -0700517 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700518 "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700519 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700520 ]
521 }
522
523 if (is_mac) {
524 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700525 "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700526 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700527 "src/ports/SkFontHost_mac.cpp",
528 "src/ports/SkImageEncoder_CG.cpp",
529 "src/ports/SkImageGeneratorCG.cpp",
530 ]
mtklein09e61f72016-08-23 13:35:28 -0700531 libs += [
532 "ApplicationServices.framework",
533 "OpenGL.framework",
534 ]
mtkleinc04ff472016-06-23 10:29:30 -0700535 }
abarth6fc8ff02016-07-15 15:15:15 -0700536
537 if (is_fuchsia) {
mikejurka21cc9952016-09-13 16:15:03 -0700538 sources += [
539 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
540 "src/ports/SkDebug_stdio.cpp",
541 ]
abarth6fc8ff02016-07-15 15:15:15 -0700542 }
mtkleinc04ff472016-06-23 10:29:30 -0700543}
544
mtkleinada5a442016-08-02 14:28:26 -0700545skia_h_headers = exec_script("gyp/find.py",
546 [ "*.h" ] + rebase_path(skia_public_includes),
547 "list lines",
548 []) -
549 [
550 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
551 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
552 rebase_path("include/gpu/vk/GrVkDefines.h"),
553 rebase_path("include/gpu/vk/GrVkInterface.h"),
554 rebase_path("include/gpu/vk/GrVkTypes.h"),
555 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
556 ]
557
mtklein1211e0c2016-07-26 13:55:45 -0700558action("skia.h") {
559 script = "gn/echo_headers.py"
560 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinc095df52016-08-24 12:23:52 -0700561 rebase_path(skia_h_headers, target_gen_dir)
mtklein1211e0c2016-07-26 13:55:45 -0700562 outputs = [
563 "$target_gen_dir/skia.h",
564 ]
565}
566
mtklein1fbdf982016-09-15 12:07:48 -0700567if (target_cpu == "x64") {
568 # Our bots only have 64-bit libOSMesa installed.
569 # TODO: worth fixing?
570 executable("fiddle") {
571 include_dirs = [ "$target_gen_dir" ]
572 libs = []
573 if (is_linux) {
574 libs += [ "OSMesa" ]
575 }
mtklein56d56692016-09-15 11:18:55 -0700576
mtklein1fbdf982016-09-15 12:07:48 -0700577 sources = [
578 "src/images/SkForceLinking.cpp",
579 "tools/fiddle/draw.cpp",
580 "tools/fiddle/fiddle_main.cpp",
581 ]
582 deps = [
583 ":skia",
584 ":skia.h",
585 ]
586 }
mtkleinc04ff472016-06-23 10:29:30 -0700587}
mtklein25c81d42016-07-27 13:55:26 -0700588
mtkleinc095df52016-08-24 12:23:52 -0700589# Targets guarded by skia_enable_tools may use //third_party freely.
590if (skia_enable_tools) {
591 template("test_lib") {
592 config(target_name + "_config") {
593 include_dirs = invoker.public_include_dirs
mtklein25c81d42016-07-27 13:55:26 -0700594 }
mtkleinc095df52016-08-24 12:23:52 -0700595 source_set(target_name) {
596 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
597 public_configs = [
598 ":" + target_name + "_config",
599 ":skia_private",
600 ]
601
602 if (!defined(deps)) {
603 deps = []
604 }
605 deps += [ ":skia" ]
606 testonly = true
607 }
mtklein25c81d42016-07-27 13:55:26 -0700608 }
mtklein25c81d42016-07-27 13:55:26 -0700609
mtkleinc095df52016-08-24 12:23:52 -0700610 test_lib("gpu_tool_utils") {
611 public_include_dirs = [ "tools/gpu" ]
612 sources = [
613 "tools/gpu/GrContextFactory.cpp",
614 "tools/gpu/GrTest.cpp",
615 "tools/gpu/TestContext.cpp",
616 "tools/gpu/gl/GLTestContext.cpp",
617 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
618 "tools/gpu/gl/debug/GrBufferObj.cpp",
619 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
620 "tools/gpu/gl/debug/GrProgramObj.cpp",
621 "tools/gpu/gl/debug/GrShaderObj.cpp",
622 "tools/gpu/gl/debug/GrTextureObj.cpp",
623 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
624 "tools/gpu/gl/null/NullGLTestContext.cpp",
625 ]
626 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700627
mtklein7d6fb2c2016-08-25 14:50:44 -0700628 if (is_android) {
629 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
630 } else if (is_linux) {
mtkleinc095df52016-08-24 12:23:52 -0700631 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
632 } else if (is_mac) {
633 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
634 }
mtklein6ef69992016-09-14 06:12:09 -0700635
636 if (skia_use_vulkan) {
637 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
638 }
mtklein25c81d42016-07-27 13:55:26 -0700639 }
mtklein25c81d42016-07-27 13:55:26 -0700640
mtkleinc095df52016-08-24 12:23:52 -0700641 test_lib("flags") {
642 public_include_dirs = [ "tools/flags" ]
643 sources = [
644 "tools/flags/SkCommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -0700645 ]
646 }
647 test_lib("common_flags") {
648 public_include_dirs = [ "tools/flags" ]
649 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700650 "tools/flags/SkCommonFlags.cpp",
651 "tools/flags/SkCommonFlagsConfig.cpp",
652 ]
653 deps = [
mtklein046cb562016-09-16 10:23:12 -0700654 ":flags",
mtkleinc095df52016-08-24 12:23:52 -0700655 ":gpu_tool_utils",
656 ]
657 }
mtklein25c81d42016-07-27 13:55:26 -0700658
mtkleinc095df52016-08-24 12:23:52 -0700659 test_lib("tool_utils") {
660 public_include_dirs = [
661 "tools",
662 "tools/debugger",
663 "tools/timer",
664 ]
665 sources = [
666 "src/images/SkForceLinking.cpp",
667 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700668 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700669 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700670 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700671 "tools/ProcStats.cpp",
672 "tools/Resources.cpp",
673 "tools/ThermalManager.cpp",
674 "tools/UrlDataManager.cpp",
675 "tools/debugger/SkDebugCanvas.cpp",
676 "tools/debugger/SkDrawCommand.cpp",
677 "tools/debugger/SkJsonWriteBuffer.cpp",
678 "tools/debugger/SkObjectParser.cpp",
679 "tools/debugger/SkOverdrawMode.cpp",
680 "tools/picture_utils.cpp",
681 "tools/random_parse_path.cpp",
682 "tools/sk_tool_utils.cpp",
683 "tools/sk_tool_utils_font.cpp",
684 "tools/timer/Timer.cpp",
685 ]
686 deps = [
mtklein046cb562016-09-16 10:23:12 -0700687 ":common_flags",
mtkleinc095df52016-08-24 12:23:52 -0700688 ":flags",
689 "//third_party/libpng",
690 ]
691 public_deps = [
692 "//third_party/jsoncpp",
693 ]
694 }
mtklein25c81d42016-07-27 13:55:26 -0700695
mtkleinc095df52016-08-24 12:23:52 -0700696 gm_sources = exec_script("gyp/find.py",
697 [
698 "*.c*",
699 rebase_path("gm"),
700 ],
701 "list lines",
702 [])
703 test_lib("gm") {
704 public_include_dirs = [ "gm" ]
705 sources = gm_sources
706 deps = [
707 ":gpu_tool_utils",
708 ":skia",
709 ":tool_utils",
710 ]
711 }
mtklein25c81d42016-07-27 13:55:26 -0700712
mtkleinc095df52016-08-24 12:23:52 -0700713 tests_sources = exec_script("gyp/find.py",
714 [
715 "*.c*",
716 rebase_path("tests"),
717 ],
718 "list lines",
719 [])
mtklein2f3416d2016-08-02 16:02:05 -0700720
mtkleinc095df52016-08-24 12:23:52 -0700721 test_lib("tests") {
722 public_include_dirs = [ "tests" ]
mtkleina45be612016-08-29 15:22:10 -0700723 sources = tests_sources - [
724 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
mtkleina45be612016-08-29 15:22:10 -0700725 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
726 rebase_path("tests/skia_test.cpp"), # alternate main
727 ]
728 if (!fontmgr_android_enabled) {
729 sources -= [ rebase_path("tests/FontMgrAndroidParserTest.cpp") ]
730 }
mtkleinc095df52016-08-24 12:23:52 -0700731 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700732 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700733 ":flags",
734 ":gpu_tool_utils",
735 ":skia",
736 ":tool_utils",
737 "//third_party/libpng",
738 "//third_party/zlib",
739 ]
740 }
mtklein2f3416d2016-08-02 16:02:05 -0700741
mtkleinc095df52016-08-24 12:23:52 -0700742 bench_sources = exec_script("gyp/find.py",
743 [
744 "*.c*",
745 rebase_path("bench"),
746 ],
747 "list lines",
748 [])
mtklein25c81d42016-07-27 13:55:26 -0700749
mtkleinc095df52016-08-24 12:23:52 -0700750 test_lib("bench") {
751 public_include_dirs = [ "bench" ]
752 sources = bench_sources
753 sources -= [
754 rebase_path("bench/nanobench.cpp"),
755 rebase_path("bench/nanobenchAndroid.cpp"),
756 ]
757 deps = [
758 ":flags",
759 ":gm",
760 ":gpu_tool_utils",
761 ":skia",
762 ":tool_utils",
763 ]
764 }
mtklein2b6870c2016-07-28 14:17:33 -0700765
mtkleinc095df52016-08-24 12:23:52 -0700766 test_lib("experimental_svg_model") {
767 public_include_dirs = [ "experimental/svg/model" ]
768 sources = [
769 "experimental/svg/model/SkSVGAttribute.cpp",
770 "experimental/svg/model/SkSVGAttributeParser.cpp",
771 "experimental/svg/model/SkSVGCircle.cpp",
772 "experimental/svg/model/SkSVGContainer.cpp",
773 "experimental/svg/model/SkSVGDOM.cpp",
774 "experimental/svg/model/SkSVGEllipse.cpp",
775 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700776 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700777 "experimental/svg/model/SkSVGNode.cpp",
778 "experimental/svg/model/SkSVGPath.cpp",
779 "experimental/svg/model/SkSVGPoly.cpp",
780 "experimental/svg/model/SkSVGRect.cpp",
781 "experimental/svg/model/SkSVGRenderContext.cpp",
782 "experimental/svg/model/SkSVGSVG.cpp",
783 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700784 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700785 "experimental/svg/model/SkSVGTransformableNode.cpp",
786 "experimental/svg/model/SkSVGValue.cpp",
787 ]
788 deps = [
789 ":skia",
790 ]
791 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700792
mtklein2b6870c2016-07-28 14:17:33 -0700793 executable("dm") {
794 sources = [
795 "dm/DM.cpp",
796 "dm/DMJsonWriter.cpp",
797 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700798 ]
799 include_dirs = [ "tests" ]
800 deps = [
mtklein046cb562016-09-16 10:23:12 -0700801 ":common_flags",
fmalitaa2b9fdf2016-08-03 19:53:36 -0700802 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700803 ":flags",
804 ":gm",
805 ":gpu_tool_utils",
806 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700807 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700808 ":tool_utils",
809 "//third_party/jsoncpp",
810 "//third_party/libpng",
811 ]
812 testonly = true
813 }
814
815 executable("monobench") {
816 sources = [
817 "tools/monobench.cpp",
818 ]
819 deps = [
820 ":bench",
821 ":skia",
822 ]
823 testonly = true
824 }
825
826 executable("nanobench") {
827 sources = [
828 "bench/nanobench.cpp",
829 ]
830 deps = [
831 ":bench",
mtklein046cb562016-09-16 10:23:12 -0700832 ":common_flags",
fmalita6519c212016-09-14 08:05:17 -0700833 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700834 ":flags",
835 ":gm",
836 ":gpu_tool_utils",
837 ":skia",
838 ":tool_utils",
839 "//third_party/jsoncpp",
840 ]
841 testonly = true
842 }
halcanary19a97202016-08-03 15:08:04 -0700843
csmartdalton4b5179b2016-09-19 11:03:58 -0700844 executable("skpbench") {
845 sources = [
846 "tools/skpbench/skpbench.cpp",
847 ]
848 deps = [
849 ":flags",
850 ":gpu_tool_utils",
851 ":skia",
852 ":tool_utils",
853 ]
854 testonly = true
855 }
856
mtklein6f5df6a2016-08-29 16:01:10 -0700857 if (current_cpu != "mipsel") { # Clang 3.8 crashes while compiling hb-icu.cc for mipsel.
halcanary3eee9d92016-09-10 07:01:53 -0700858 executable("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -0700859 sources = [
860 "tools/SkShaper_harfbuzz.cpp",
861 "tools/using_skia_and_harfbuzz.cpp",
862 ]
863 deps = [
864 ":skia",
865 "//third_party/harfbuzz",
866 ]
867 testonly = true
868 }
halcanary19a97202016-08-03 15:08:04 -0700869 }
halcanary3eee9d92016-09-10 07:01:53 -0700870 executable("sktexttopdf") {
871 sources = [
872 "tools/SkShaper_primitive.cpp",
873 "tools/using_skia_and_harfbuzz.cpp",
874 ]
875 deps = [
876 ":skia",
877 ]
878 testonly = true
879 }
mtklein046cb562016-09-16 10:23:12 -0700880
881 executable("get_images_from_skps") {
882 sources = [
883 "tools/get_images_from_skps.cpp",
884 ]
885 deps = [
886 ":flags",
887 ":skia",
888 "//third_party/jsoncpp",
889 ]
890 testonly = true
891 }
mtklein25c81d42016-07-27 13:55:26 -0700892}