blob: 71ae9b818b1b6e3eda3c958b9f2d8f5280e7ab48 [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 = [
266 "src/ports/SkFontConfigInterface_direct.cpp",
267 "src/ports/SkFontConfigInterface_direct_factory.cpp",
268 "src/ports/SkFontMgr_FontConfigInterface.cpp",
269 "src/ports/SkFontMgr_fontconfig.cpp",
270 "src/ports/SkFontMgr_fontconfig_factory.cpp",
271 ]
272}
273
mtkleincdedd0e2016-09-12 15:15:44 -0700274optional("fontmgr_fuchsia") {
275 enabled = is_fuchsia && skia_use_freetype
276
277 deps = [
278 "//third_party/freetype2",
279 ]
280 sources = [
281 "src/ports/SkFontMgr_custom.cpp",
282 "src/ports/SkFontMgr_custom_empty_factory.cpp",
283 ]
284}
285
mtklein457b42a2016-08-23 13:56:37 -0700286optional("gif") {
287 enabled = skia_use_giflib
288 public_defines = [ "SK_HAS_GIF_LIBRARY" ]
289
mtklein457b42a2016-08-23 13:56:37 -0700290 deps = [
291 "//third_party/giflib",
292 ]
293 sources = [
294 "src/codec/SkGifCodec.cpp",
295 ]
296}
297
mtklein63213812016-08-24 09:55:56 -0700298optional("jpeg") {
299 enabled = skia_use_libjpeg_turbo
300 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
301
mtklein63213812016-08-24 09:55:56 -0700302 deps = [
303 "//third_party/libjpeg-turbo:libjpeg",
304 ]
305 sources = [
306 "src/codec/SkJpegCodec.cpp",
307 "src/codec/SkJpegDecoderMgr.cpp",
308 "src/codec/SkJpegUtility.cpp",
309 "src/images/SkJPEGImageEncoder.cpp",
310 "src/images/SkJPEGWriteUtility.cpp",
311 ]
312}
313
314optional("pdf") {
315 enabled = skia_use_zlib
mtklein63213812016-08-24 09:55:56 -0700316
mtklein63213812016-08-24 09:55:56 -0700317 deps = [
318 "//third_party/zlib",
319 ]
brettwb9447282016-09-01 14:24:39 -0700320 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700321 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700322
323 if (skia_use_sfntly) {
324 deps += [ "//third_party/sfntly" ]
mtkleincd01b032016-08-31 04:58:19 -0700325 public_defines = [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700326 }
327}
328
329optional("png") {
330 enabled = skia_use_libpng
331 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
332
mtklein63213812016-08-24 09:55:56 -0700333 deps = [
334 "//third_party/libpng",
335 ]
336 sources = [
337 "src/codec/SkIcoCodec.cpp",
338 "src/codec/SkPngCodec.cpp",
339 "src/images/SkPNGImageEncoder.cpp",
340 ]
341}
342
mtklein3cc22182016-08-29 13:26:14 -0700343optional("typeface_freetype") {
344 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700345
346 deps = [
347 "//third_party/freetype2",
348 ]
349 sources = [
350 "src/ports/SkFontHost_FreeType.cpp",
351 "src/ports/SkFontHost_FreeType_common.cpp",
352 ]
353}
354
mtklein6ef69992016-09-14 06:12:09 -0700355optional("vulkan") {
356 enabled = skia_use_vulkan
357 public_defines = [ "SK_VULKAN" ]
358 libs = [ "vulkan" ]
359 sources = skia_vk_sources
360}
361
mtklein457b42a2016-08-23 13:56:37 -0700362optional("webp") {
363 enabled = skia_use_libwebp
364 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
365
mtklein457b42a2016-08-23 13:56:37 -0700366 deps = [
367 "//third_party/libwebp",
368 ]
369 sources = [
370 "src/codec/SkWebpAdapterCodec.cpp",
371 "src/codec/SkWebpCodec.cpp",
372 "src/images/SkWEBPImageEncoder.cpp",
373 ]
mtkleineb3c4252016-08-23 07:38:09 -0700374}
375
mtklein63213812016-08-24 09:55:56 -0700376optional("xml") {
377 enabled = skia_use_expat
mtklein63213812016-08-24 09:55:56 -0700378
mtklein63213812016-08-24 09:55:56 -0700379 deps = [
380 "//third_party/expat",
381 ]
382 sources = [
383 "src/xml/SkDOM.cpp",
384 "src/xml/SkXMLParser.cpp",
385 "src/xml/SkXMLWriter.cpp",
386 ]
387}
388
mtkleinc04ff472016-06-23 10:29:30 -0700389component("skia") {
390 public_configs = [ ":skia_public" ]
391 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700392
393 deps = [
mtklein1bd72ba2016-09-16 07:45:52 -0700394 ":android_framework_defines",
anmittalb8b3f712016-08-25 04:55:19 -0700395 ":arm64",
396 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700397 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700398 ":crc32",
mtklein349cece2016-08-26 08:13:04 -0700399 ":dsp",
mtkleina45be612016-08-29 15:22:10 -0700400 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700401 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700402 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700403 ":fontmgr_fuchsia",
mtklein457b42a2016-08-23 13:56:37 -0700404 ":gif",
mtklein63213812016-08-24 09:55:56 -0700405 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700406 ":none",
mtklein63213812016-08-24 09:55:56 -0700407 ":pdf",
408 ":png",
mtklein9b8583d2016-08-24 17:32:30 -0700409 ":sse2",
410 ":sse41",
411 ":sse42",
412 ":ssse3",
mtklein3cc22182016-08-29 13:26:14 -0700413 ":typeface_freetype",
mtklein6ef69992016-09-14 06:12:09 -0700414 ":vulkan",
mtkleineb3c4252016-08-23 07:38:09 -0700415 ":webp",
mtklein63213812016-08-24 09:55:56 -0700416 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700417 ]
418
mtkleinc04ff472016-06-23 10:29:30 -0700419 sources = []
brettwb9447282016-09-01 14:24:39 -0700420 sources += skia_core_sources
421 sources += skia_effects_sources
422 sources += skia_gpu_sources
423 sources += skia_sksl_sources
424 sources += skia_utils_sources
mtkleinc04ff472016-06-23 10:29:30 -0700425 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700426 "src/android/SkBitmapRegionCodec.cpp",
427 "src/android/SkBitmapRegionDecoder.cpp",
428 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700429 "src/codec/SkBmpCodec.cpp",
430 "src/codec/SkBmpMaskCodec.cpp",
431 "src/codec/SkBmpRLECodec.cpp",
432 "src/codec/SkBmpStandardCodec.cpp",
433 "src/codec/SkCodec.cpp",
434 "src/codec/SkCodecImageGenerator.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700435 "src/codec/SkMaskSwizzler.cpp",
436 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700437 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700438 "src/codec/SkSampler.cpp",
439 "src/codec/SkSwizzler.cpp",
440 "src/codec/SkWbmpCodec.cpp",
mtklein09e61f72016-08-23 13:35:28 -0700441 "src/gpu/gl/GrGLDefaultInterface_native.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700442 "src/images/SkImageEncoder.cpp",
443 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700444 "src/images/SkKTXImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700445 "src/ports/SkDiscardableMemory_none.cpp",
446 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700447 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700448 "src/ports/SkMemory_malloc.cpp",
449 "src/ports/SkOSFile_stdio.cpp",
450 "src/sfnt/SkOTTable_name.cpp",
451 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700452 "src/svg/SkSVGCanvas.cpp",
453 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700454 "src/utils/mac/SkStream_mac.cpp",
455 "third_party/etc1/etc1.cpp",
456 "third_party/ktx/ktx.cpp",
457 ]
brettwb9447282016-09-01 14:24:39 -0700458
459 # These paths need to be absolute to match the ones produced by
460 # shared_sources.gni, but this file may be used from different directory
461 # locations.
462 sources -= get_path_info([
463 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
464 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
465 ],
466 "abspath")
mtkleinc04ff472016-06-23 10:29:30 -0700467
mtklein7d6fb2c2016-08-25 14:50:44 -0700468 libs = []
469
mtkleinc04ff472016-06-23 10:29:30 -0700470 if (is_win) {
471 sources += [
472 "src/ports/SkDebug_win.cpp",
473 "src/ports/SkFontHost_win.cpp",
474 "src/ports/SkFontMgr_win_dw.cpp",
475 "src/ports/SkFontMgr_win_dw_factory.cpp",
476 "src/ports/SkImageEncoder_WIC.cpp",
477 "src/ports/SkImageGeneratorWIC.cpp",
478 "src/ports/SkOSFile_win.cpp",
479 "src/ports/SkScalerContext_win_dw.cpp",
480 "src/ports/SkTLS_win.cpp",
481 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700482 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700483 ]
mtkleinb9be9792016-09-16 14:44:18 -0700484 sources -=
485 [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
mtkleinc04ff472016-06-23 10:29:30 -0700486 } else {
487 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700488 "src/ports/SkOSFile_posix.cpp",
489 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700490 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700491 ]
492 }
493
mtklein7d6fb2c2016-08-25 14:50:44 -0700494 if (is_android) {
495 deps += [
496 "//third_party/cpu-features",
497 "//third_party/expat",
mtklein7d6fb2c2016-08-25 14:50:44 -0700498 ]
499 sources += [
500 "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp",
501 "src/ports/SkDebug_android.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700502 ]
503 libs += [
504 "EGL",
505 "GLESv2",
506 "log",
507 ]
508 }
509
mtkleinc04ff472016-06-23 10:29:30 -0700510 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700511 libs += [
512 "GL",
513 "GLU",
514 "X11",
515 ]
mtkleinc04ff472016-06-23 10:29:30 -0700516 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700517 "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700518 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700519 ]
520 }
521
522 if (is_mac) {
523 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700524 "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700525 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700526 "src/ports/SkFontHost_mac.cpp",
527 "src/ports/SkImageEncoder_CG.cpp",
528 "src/ports/SkImageGeneratorCG.cpp",
529 ]
mtklein09e61f72016-08-23 13:35:28 -0700530 libs += [
531 "ApplicationServices.framework",
532 "OpenGL.framework",
533 ]
mtkleinc04ff472016-06-23 10:29:30 -0700534 }
abarth6fc8ff02016-07-15 15:15:15 -0700535
536 if (is_fuchsia) {
mikejurka21cc9952016-09-13 16:15:03 -0700537 sources += [
538 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
539 "src/ports/SkDebug_stdio.cpp",
540 ]
abarth6fc8ff02016-07-15 15:15:15 -0700541 }
mtkleinc04ff472016-06-23 10:29:30 -0700542}
543
mtkleinada5a442016-08-02 14:28:26 -0700544skia_h_headers = exec_script("gyp/find.py",
545 [ "*.h" ] + rebase_path(skia_public_includes),
546 "list lines",
547 []) -
548 [
549 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
550 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
551 rebase_path("include/gpu/vk/GrVkDefines.h"),
552 rebase_path("include/gpu/vk/GrVkInterface.h"),
553 rebase_path("include/gpu/vk/GrVkTypes.h"),
554 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
555 ]
556
mtklein1211e0c2016-07-26 13:55:45 -0700557action("skia.h") {
558 script = "gn/echo_headers.py"
559 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinc095df52016-08-24 12:23:52 -0700560 rebase_path(skia_h_headers, target_gen_dir)
mtklein1211e0c2016-07-26 13:55:45 -0700561 outputs = [
562 "$target_gen_dir/skia.h",
563 ]
564}
565
mtklein1fbdf982016-09-15 12:07:48 -0700566if (target_cpu == "x64") {
567 # Our bots only have 64-bit libOSMesa installed.
568 # TODO: worth fixing?
569 executable("fiddle") {
570 include_dirs = [ "$target_gen_dir" ]
571 libs = []
572 if (is_linux) {
573 libs += [ "OSMesa" ]
574 }
mtklein56d56692016-09-15 11:18:55 -0700575
mtklein1fbdf982016-09-15 12:07:48 -0700576 sources = [
577 "src/images/SkForceLinking.cpp",
578 "tools/fiddle/draw.cpp",
579 "tools/fiddle/fiddle_main.cpp",
580 ]
581 deps = [
582 ":skia",
583 ":skia.h",
584 ]
585 }
mtkleinc04ff472016-06-23 10:29:30 -0700586}
mtklein25c81d42016-07-27 13:55:26 -0700587
mtkleinc095df52016-08-24 12:23:52 -0700588# Targets guarded by skia_enable_tools may use //third_party freely.
589if (skia_enable_tools) {
590 template("test_lib") {
591 config(target_name + "_config") {
592 include_dirs = invoker.public_include_dirs
mtklein25c81d42016-07-27 13:55:26 -0700593 }
mtkleinc095df52016-08-24 12:23:52 -0700594 source_set(target_name) {
595 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
596 public_configs = [
597 ":" + target_name + "_config",
598 ":skia_private",
599 ]
600
601 if (!defined(deps)) {
602 deps = []
603 }
604 deps += [ ":skia" ]
605 testonly = true
606 }
mtklein25c81d42016-07-27 13:55:26 -0700607 }
mtklein25c81d42016-07-27 13:55:26 -0700608
mtkleinc095df52016-08-24 12:23:52 -0700609 test_lib("gpu_tool_utils") {
610 public_include_dirs = [ "tools/gpu" ]
611 sources = [
612 "tools/gpu/GrContextFactory.cpp",
613 "tools/gpu/GrTest.cpp",
614 "tools/gpu/TestContext.cpp",
615 "tools/gpu/gl/GLTestContext.cpp",
616 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
617 "tools/gpu/gl/debug/GrBufferObj.cpp",
618 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
619 "tools/gpu/gl/debug/GrProgramObj.cpp",
620 "tools/gpu/gl/debug/GrShaderObj.cpp",
621 "tools/gpu/gl/debug/GrTextureObj.cpp",
622 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
623 "tools/gpu/gl/null/NullGLTestContext.cpp",
624 ]
625 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700626
mtklein7d6fb2c2016-08-25 14:50:44 -0700627 if (is_android) {
628 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
629 } else if (is_linux) {
mtkleinc095df52016-08-24 12:23:52 -0700630 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
631 } else if (is_mac) {
632 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
633 }
mtklein6ef69992016-09-14 06:12:09 -0700634
635 if (skia_use_vulkan) {
636 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
637 }
mtklein25c81d42016-07-27 13:55:26 -0700638 }
mtklein25c81d42016-07-27 13:55:26 -0700639
mtkleinc095df52016-08-24 12:23:52 -0700640 test_lib("flags") {
641 public_include_dirs = [ "tools/flags" ]
642 sources = [
643 "tools/flags/SkCommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -0700644 ]
645 }
646 test_lib("common_flags") {
647 public_include_dirs = [ "tools/flags" ]
648 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700649 "tools/flags/SkCommonFlags.cpp",
650 "tools/flags/SkCommonFlagsConfig.cpp",
651 ]
652 deps = [
mtklein046cb562016-09-16 10:23:12 -0700653 ":flags",
mtkleinc095df52016-08-24 12:23:52 -0700654 ":gpu_tool_utils",
655 ]
656 }
mtklein25c81d42016-07-27 13:55:26 -0700657
mtkleinc095df52016-08-24 12:23:52 -0700658 test_lib("tool_utils") {
659 public_include_dirs = [
660 "tools",
661 "tools/debugger",
662 "tools/timer",
663 ]
664 sources = [
665 "src/images/SkForceLinking.cpp",
666 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700667 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700668 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700669 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700670 "tools/ProcStats.cpp",
671 "tools/Resources.cpp",
672 "tools/ThermalManager.cpp",
673 "tools/UrlDataManager.cpp",
674 "tools/debugger/SkDebugCanvas.cpp",
675 "tools/debugger/SkDrawCommand.cpp",
676 "tools/debugger/SkJsonWriteBuffer.cpp",
677 "tools/debugger/SkObjectParser.cpp",
678 "tools/debugger/SkOverdrawMode.cpp",
679 "tools/picture_utils.cpp",
680 "tools/random_parse_path.cpp",
681 "tools/sk_tool_utils.cpp",
682 "tools/sk_tool_utils_font.cpp",
683 "tools/timer/Timer.cpp",
684 ]
685 deps = [
mtklein046cb562016-09-16 10:23:12 -0700686 ":common_flags",
mtkleinc095df52016-08-24 12:23:52 -0700687 ":flags",
688 "//third_party/libpng",
689 ]
690 public_deps = [
691 "//third_party/jsoncpp",
692 ]
693 }
mtklein25c81d42016-07-27 13:55:26 -0700694
mtkleinc095df52016-08-24 12:23:52 -0700695 gm_sources = exec_script("gyp/find.py",
696 [
697 "*.c*",
698 rebase_path("gm"),
699 ],
700 "list lines",
701 [])
702 test_lib("gm") {
703 public_include_dirs = [ "gm" ]
704 sources = gm_sources
705 deps = [
706 ":gpu_tool_utils",
707 ":skia",
708 ":tool_utils",
709 ]
710 }
mtklein25c81d42016-07-27 13:55:26 -0700711
mtkleinc095df52016-08-24 12:23:52 -0700712 tests_sources = exec_script("gyp/find.py",
713 [
714 "*.c*",
715 rebase_path("tests"),
716 ],
717 "list lines",
718 [])
mtklein2f3416d2016-08-02 16:02:05 -0700719
mtkleinc095df52016-08-24 12:23:52 -0700720 test_lib("tests") {
721 public_include_dirs = [ "tests" ]
mtkleina45be612016-08-29 15:22:10 -0700722 sources = tests_sources - [
723 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
mtkleina45be612016-08-29 15:22:10 -0700724 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
725 rebase_path("tests/skia_test.cpp"), # alternate main
726 ]
727 if (!fontmgr_android_enabled) {
728 sources -= [ rebase_path("tests/FontMgrAndroidParserTest.cpp") ]
729 }
mtkleinc095df52016-08-24 12:23:52 -0700730 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700731 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700732 ":flags",
733 ":gpu_tool_utils",
734 ":skia",
735 ":tool_utils",
736 "//third_party/libpng",
737 "//third_party/zlib",
738 ]
739 }
mtklein2f3416d2016-08-02 16:02:05 -0700740
mtkleinc095df52016-08-24 12:23:52 -0700741 bench_sources = exec_script("gyp/find.py",
742 [
743 "*.c*",
744 rebase_path("bench"),
745 ],
746 "list lines",
747 [])
mtklein25c81d42016-07-27 13:55:26 -0700748
mtkleinc095df52016-08-24 12:23:52 -0700749 test_lib("bench") {
750 public_include_dirs = [ "bench" ]
751 sources = bench_sources
752 sources -= [
753 rebase_path("bench/nanobench.cpp"),
754 rebase_path("bench/nanobenchAndroid.cpp"),
755 ]
756 deps = [
757 ":flags",
758 ":gm",
759 ":gpu_tool_utils",
760 ":skia",
761 ":tool_utils",
762 ]
763 }
mtklein2b6870c2016-07-28 14:17:33 -0700764
mtkleinc095df52016-08-24 12:23:52 -0700765 test_lib("experimental_svg_model") {
766 public_include_dirs = [ "experimental/svg/model" ]
767 sources = [
768 "experimental/svg/model/SkSVGAttribute.cpp",
769 "experimental/svg/model/SkSVGAttributeParser.cpp",
770 "experimental/svg/model/SkSVGCircle.cpp",
771 "experimental/svg/model/SkSVGContainer.cpp",
772 "experimental/svg/model/SkSVGDOM.cpp",
773 "experimental/svg/model/SkSVGEllipse.cpp",
774 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700775 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700776 "experimental/svg/model/SkSVGNode.cpp",
777 "experimental/svg/model/SkSVGPath.cpp",
778 "experimental/svg/model/SkSVGPoly.cpp",
779 "experimental/svg/model/SkSVGRect.cpp",
780 "experimental/svg/model/SkSVGRenderContext.cpp",
781 "experimental/svg/model/SkSVGSVG.cpp",
782 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700783 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700784 "experimental/svg/model/SkSVGTransformableNode.cpp",
785 "experimental/svg/model/SkSVGValue.cpp",
786 ]
787 deps = [
788 ":skia",
789 ]
790 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700791
mtklein2b6870c2016-07-28 14:17:33 -0700792 executable("dm") {
793 sources = [
794 "dm/DM.cpp",
795 "dm/DMJsonWriter.cpp",
796 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700797 ]
798 include_dirs = [ "tests" ]
799 deps = [
mtklein046cb562016-09-16 10:23:12 -0700800 ":common_flags",
fmalitaa2b9fdf2016-08-03 19:53:36 -0700801 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700802 ":flags",
803 ":gm",
804 ":gpu_tool_utils",
805 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700806 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700807 ":tool_utils",
808 "//third_party/jsoncpp",
809 "//third_party/libpng",
810 ]
811 testonly = true
812 }
813
814 executable("monobench") {
815 sources = [
816 "tools/monobench.cpp",
817 ]
818 deps = [
819 ":bench",
820 ":skia",
821 ]
822 testonly = true
823 }
824
825 executable("nanobench") {
826 sources = [
827 "bench/nanobench.cpp",
828 ]
829 deps = [
830 ":bench",
mtklein046cb562016-09-16 10:23:12 -0700831 ":common_flags",
fmalita6519c212016-09-14 08:05:17 -0700832 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700833 ":flags",
834 ":gm",
835 ":gpu_tool_utils",
836 ":skia",
837 ":tool_utils",
838 "//third_party/jsoncpp",
839 ]
840 testonly = true
841 }
halcanary19a97202016-08-03 15:08:04 -0700842
csmartdalton4b5179b2016-09-19 11:03:58 -0700843 executable("skpbench") {
844 sources = [
845 "tools/skpbench/skpbench.cpp",
846 ]
847 deps = [
848 ":flags",
849 ":gpu_tool_utils",
850 ":skia",
851 ":tool_utils",
852 ]
853 testonly = true
854 }
855
mtklein6f5df6a2016-08-29 16:01:10 -0700856 if (current_cpu != "mipsel") { # Clang 3.8 crashes while compiling hb-icu.cc for mipsel.
halcanary3eee9d92016-09-10 07:01:53 -0700857 executable("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -0700858 sources = [
859 "tools/SkShaper_harfbuzz.cpp",
860 "tools/using_skia_and_harfbuzz.cpp",
861 ]
862 deps = [
863 ":skia",
864 "//third_party/harfbuzz",
865 ]
866 testonly = true
867 }
halcanary19a97202016-08-03 15:08:04 -0700868 }
halcanary3eee9d92016-09-10 07:01:53 -0700869 executable("sktexttopdf") {
870 sources = [
871 "tools/SkShaper_primitive.cpp",
872 "tools/using_skia_and_harfbuzz.cpp",
873 ]
874 deps = [
875 ":skia",
876 ]
877 testonly = true
878 }
mtklein046cb562016-09-16 10:23:12 -0700879
880 executable("get_images_from_skps") {
881 sources = [
882 "tools/get_images_from_skps.cpp",
883 ]
884 deps = [
885 ":flags",
886 ":skia",
887 "//third_party/jsoncpp",
888 ]
889 testonly = true
890 }
mtklein25c81d42016-07-27 13:55:26 -0700891}