blob: cc608f35af7d8c459a9a63b617b9506f47f6cc40 [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 ]
mtklein7a1f45f2016-08-04 06:19:33 -0700484 sources -= [ "src/utils/SkThreadUtils_pthread.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700485 } else {
486 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700487 "src/ports/SkOSFile_posix.cpp",
488 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700489 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700490 ]
491 }
492
mtklein7d6fb2c2016-08-25 14:50:44 -0700493 if (is_android) {
494 deps += [
495 "//third_party/cpu-features",
496 "//third_party/expat",
mtklein7d6fb2c2016-08-25 14:50:44 -0700497 ]
498 sources += [
499 "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp",
500 "src/ports/SkDebug_android.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700501 ]
502 libs += [
503 "EGL",
504 "GLESv2",
505 "log",
506 ]
507 }
508
mtkleinc04ff472016-06-23 10:29:30 -0700509 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700510 libs += [
511 "GL",
512 "GLU",
513 "X11",
514 ]
mtkleinc04ff472016-06-23 10:29:30 -0700515 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700516 "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700517 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700518 ]
519 }
520
521 if (is_mac) {
522 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700523 "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700524 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700525 "src/ports/SkFontHost_mac.cpp",
526 "src/ports/SkImageEncoder_CG.cpp",
527 "src/ports/SkImageGeneratorCG.cpp",
528 ]
mtklein09e61f72016-08-23 13:35:28 -0700529 libs += [
530 "ApplicationServices.framework",
531 "OpenGL.framework",
532 ]
mtkleinc04ff472016-06-23 10:29:30 -0700533 }
abarth6fc8ff02016-07-15 15:15:15 -0700534
535 if (is_fuchsia) {
mikejurka21cc9952016-09-13 16:15:03 -0700536 sources += [
537 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
538 "src/ports/SkDebug_stdio.cpp",
539 ]
abarth6fc8ff02016-07-15 15:15:15 -0700540 }
mtkleinc04ff472016-06-23 10:29:30 -0700541}
542
mtkleinada5a442016-08-02 14:28:26 -0700543skia_h_headers = exec_script("gyp/find.py",
544 [ "*.h" ] + rebase_path(skia_public_includes),
545 "list lines",
546 []) -
547 [
548 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
549 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
550 rebase_path("include/gpu/vk/GrVkDefines.h"),
551 rebase_path("include/gpu/vk/GrVkInterface.h"),
552 rebase_path("include/gpu/vk/GrVkTypes.h"),
553 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
554 ]
555
mtklein1211e0c2016-07-26 13:55:45 -0700556action("skia.h") {
557 script = "gn/echo_headers.py"
558 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinc095df52016-08-24 12:23:52 -0700559 rebase_path(skia_h_headers, target_gen_dir)
mtklein1211e0c2016-07-26 13:55:45 -0700560 outputs = [
561 "$target_gen_dir/skia.h",
562 ]
563}
564
mtklein1fbdf982016-09-15 12:07:48 -0700565if (target_cpu == "x64") {
566 # Our bots only have 64-bit libOSMesa installed.
567 # TODO: worth fixing?
568 executable("fiddle") {
569 include_dirs = [ "$target_gen_dir" ]
570 libs = []
571 if (is_linux) {
572 libs += [ "OSMesa" ]
573 }
mtklein56d56692016-09-15 11:18:55 -0700574
mtklein1fbdf982016-09-15 12:07:48 -0700575 sources = [
576 "src/images/SkForceLinking.cpp",
577 "tools/fiddle/draw.cpp",
578 "tools/fiddle/fiddle_main.cpp",
579 ]
580 deps = [
581 ":skia",
582 ":skia.h",
583 ]
584 }
mtkleinc04ff472016-06-23 10:29:30 -0700585}
mtklein25c81d42016-07-27 13:55:26 -0700586
mtkleinc095df52016-08-24 12:23:52 -0700587# Targets guarded by skia_enable_tools may use //third_party freely.
588if (skia_enable_tools) {
589 template("test_lib") {
590 config(target_name + "_config") {
591 include_dirs = invoker.public_include_dirs
mtklein25c81d42016-07-27 13:55:26 -0700592 }
mtkleinc095df52016-08-24 12:23:52 -0700593 source_set(target_name) {
594 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
595 public_configs = [
596 ":" + target_name + "_config",
597 ":skia_private",
598 ]
599
600 if (!defined(deps)) {
601 deps = []
602 }
603 deps += [ ":skia" ]
604 testonly = true
605 }
mtklein25c81d42016-07-27 13:55:26 -0700606 }
mtklein25c81d42016-07-27 13:55:26 -0700607
mtkleinc095df52016-08-24 12:23:52 -0700608 test_lib("gpu_tool_utils") {
609 public_include_dirs = [ "tools/gpu" ]
610 sources = [
611 "tools/gpu/GrContextFactory.cpp",
612 "tools/gpu/GrTest.cpp",
613 "tools/gpu/TestContext.cpp",
614 "tools/gpu/gl/GLTestContext.cpp",
615 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
616 "tools/gpu/gl/debug/GrBufferObj.cpp",
617 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
618 "tools/gpu/gl/debug/GrProgramObj.cpp",
619 "tools/gpu/gl/debug/GrShaderObj.cpp",
620 "tools/gpu/gl/debug/GrTextureObj.cpp",
621 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
622 "tools/gpu/gl/null/NullGLTestContext.cpp",
623 ]
624 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700625
mtklein7d6fb2c2016-08-25 14:50:44 -0700626 if (is_android) {
627 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
628 } else if (is_linux) {
mtkleinc095df52016-08-24 12:23:52 -0700629 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
630 } else if (is_mac) {
631 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
632 }
mtklein6ef69992016-09-14 06:12:09 -0700633
634 if (skia_use_vulkan) {
635 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
636 }
mtklein25c81d42016-07-27 13:55:26 -0700637 }
mtklein25c81d42016-07-27 13:55:26 -0700638
mtkleinc095df52016-08-24 12:23:52 -0700639 test_lib("flags") {
640 public_include_dirs = [ "tools/flags" ]
641 sources = [
642 "tools/flags/SkCommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -0700643 ]
644 }
645 test_lib("common_flags") {
646 public_include_dirs = [ "tools/flags" ]
647 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700648 "tools/flags/SkCommonFlags.cpp",
649 "tools/flags/SkCommonFlagsConfig.cpp",
650 ]
651 deps = [
mtklein046cb562016-09-16 10:23:12 -0700652 ":flags",
mtkleinc095df52016-08-24 12:23:52 -0700653 ":gpu_tool_utils",
654 ]
655 }
mtklein25c81d42016-07-27 13:55:26 -0700656
mtkleinc095df52016-08-24 12:23:52 -0700657 test_lib("tool_utils") {
658 public_include_dirs = [
659 "tools",
660 "tools/debugger",
661 "tools/timer",
662 ]
663 sources = [
664 "src/images/SkForceLinking.cpp",
665 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700666 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700667 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700668 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700669 "tools/ProcStats.cpp",
670 "tools/Resources.cpp",
671 "tools/ThermalManager.cpp",
672 "tools/UrlDataManager.cpp",
673 "tools/debugger/SkDebugCanvas.cpp",
674 "tools/debugger/SkDrawCommand.cpp",
675 "tools/debugger/SkJsonWriteBuffer.cpp",
676 "tools/debugger/SkObjectParser.cpp",
677 "tools/debugger/SkOverdrawMode.cpp",
678 "tools/picture_utils.cpp",
679 "tools/random_parse_path.cpp",
680 "tools/sk_tool_utils.cpp",
681 "tools/sk_tool_utils_font.cpp",
682 "tools/timer/Timer.cpp",
683 ]
684 deps = [
mtklein046cb562016-09-16 10:23:12 -0700685 ":common_flags",
mtkleinc095df52016-08-24 12:23:52 -0700686 ":flags",
687 "//third_party/libpng",
688 ]
689 public_deps = [
690 "//third_party/jsoncpp",
691 ]
692 }
mtklein25c81d42016-07-27 13:55:26 -0700693
mtkleinc095df52016-08-24 12:23:52 -0700694 gm_sources = exec_script("gyp/find.py",
695 [
696 "*.c*",
697 rebase_path("gm"),
698 ],
699 "list lines",
700 [])
701 test_lib("gm") {
702 public_include_dirs = [ "gm" ]
703 sources = gm_sources
704 deps = [
705 ":gpu_tool_utils",
706 ":skia",
707 ":tool_utils",
708 ]
709 }
mtklein25c81d42016-07-27 13:55:26 -0700710
mtkleinc095df52016-08-24 12:23:52 -0700711 tests_sources = exec_script("gyp/find.py",
712 [
713 "*.c*",
714 rebase_path("tests"),
715 ],
716 "list lines",
717 [])
mtklein2f3416d2016-08-02 16:02:05 -0700718
mtkleinc095df52016-08-24 12:23:52 -0700719 test_lib("tests") {
720 public_include_dirs = [ "tests" ]
mtkleina45be612016-08-29 15:22:10 -0700721 sources = tests_sources - [
722 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
mtkleina45be612016-08-29 15:22:10 -0700723 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
724 rebase_path("tests/skia_test.cpp"), # alternate main
725 ]
726 if (!fontmgr_android_enabled) {
727 sources -= [ rebase_path("tests/FontMgrAndroidParserTest.cpp") ]
728 }
mtkleinc095df52016-08-24 12:23:52 -0700729 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700730 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700731 ":flags",
732 ":gpu_tool_utils",
733 ":skia",
734 ":tool_utils",
735 "//third_party/libpng",
736 "//third_party/zlib",
737 ]
738 }
mtklein2f3416d2016-08-02 16:02:05 -0700739
mtkleinc095df52016-08-24 12:23:52 -0700740 bench_sources = exec_script("gyp/find.py",
741 [
742 "*.c*",
743 rebase_path("bench"),
744 ],
745 "list lines",
746 [])
mtklein25c81d42016-07-27 13:55:26 -0700747
mtkleinc095df52016-08-24 12:23:52 -0700748 test_lib("bench") {
749 public_include_dirs = [ "bench" ]
750 sources = bench_sources
751 sources -= [
752 rebase_path("bench/nanobench.cpp"),
753 rebase_path("bench/nanobenchAndroid.cpp"),
754 ]
755 deps = [
756 ":flags",
757 ":gm",
758 ":gpu_tool_utils",
759 ":skia",
760 ":tool_utils",
761 ]
762 }
mtklein2b6870c2016-07-28 14:17:33 -0700763
mtkleinc095df52016-08-24 12:23:52 -0700764 test_lib("experimental_svg_model") {
765 public_include_dirs = [ "experimental/svg/model" ]
766 sources = [
767 "experimental/svg/model/SkSVGAttribute.cpp",
768 "experimental/svg/model/SkSVGAttributeParser.cpp",
769 "experimental/svg/model/SkSVGCircle.cpp",
770 "experimental/svg/model/SkSVGContainer.cpp",
771 "experimental/svg/model/SkSVGDOM.cpp",
772 "experimental/svg/model/SkSVGEllipse.cpp",
773 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700774 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700775 "experimental/svg/model/SkSVGNode.cpp",
776 "experimental/svg/model/SkSVGPath.cpp",
777 "experimental/svg/model/SkSVGPoly.cpp",
778 "experimental/svg/model/SkSVGRect.cpp",
779 "experimental/svg/model/SkSVGRenderContext.cpp",
780 "experimental/svg/model/SkSVGSVG.cpp",
781 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700782 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700783 "experimental/svg/model/SkSVGTransformableNode.cpp",
784 "experimental/svg/model/SkSVGValue.cpp",
785 ]
786 deps = [
787 ":skia",
788 ]
789 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700790
mtklein2b6870c2016-07-28 14:17:33 -0700791 executable("dm") {
792 sources = [
793 "dm/DM.cpp",
794 "dm/DMJsonWriter.cpp",
795 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700796 ]
797 include_dirs = [ "tests" ]
798 deps = [
mtklein046cb562016-09-16 10:23:12 -0700799 ":common_flags",
fmalitaa2b9fdf2016-08-03 19:53:36 -0700800 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700801 ":flags",
802 ":gm",
803 ":gpu_tool_utils",
804 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700805 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700806 ":tool_utils",
807 "//third_party/jsoncpp",
808 "//third_party/libpng",
809 ]
810 testonly = true
811 }
812
813 executable("monobench") {
814 sources = [
815 "tools/monobench.cpp",
816 ]
817 deps = [
818 ":bench",
819 ":skia",
820 ]
821 testonly = true
822 }
823
824 executable("nanobench") {
825 sources = [
826 "bench/nanobench.cpp",
827 ]
828 deps = [
829 ":bench",
mtklein046cb562016-09-16 10:23:12 -0700830 ":common_flags",
fmalita6519c212016-09-14 08:05:17 -0700831 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700832 ":flags",
833 ":gm",
834 ":gpu_tool_utils",
835 ":skia",
836 ":tool_utils",
837 "//third_party/jsoncpp",
838 ]
839 testonly = true
840 }
halcanary19a97202016-08-03 15:08:04 -0700841
mtklein6f5df6a2016-08-29 16:01:10 -0700842 if (current_cpu != "mipsel") { # Clang 3.8 crashes while compiling hb-icu.cc for mipsel.
halcanary3eee9d92016-09-10 07:01:53 -0700843 executable("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -0700844 sources = [
845 "tools/SkShaper_harfbuzz.cpp",
846 "tools/using_skia_and_harfbuzz.cpp",
847 ]
848 deps = [
849 ":skia",
850 "//third_party/harfbuzz",
851 ]
852 testonly = true
853 }
halcanary19a97202016-08-03 15:08:04 -0700854 }
halcanary3eee9d92016-09-10 07:01:53 -0700855 executable("sktexttopdf") {
856 sources = [
857 "tools/SkShaper_primitive.cpp",
858 "tools/using_skia_and_harfbuzz.cpp",
859 ]
860 deps = [
861 ":skia",
862 ]
863 testonly = true
864 }
mtklein046cb562016-09-16 10:23:12 -0700865
866 executable("get_images_from_skps") {
867 sources = [
868 "tools/get_images_from_skps.cpp",
869 ]
870 deps = [
871 ":flags",
872 ":skia",
873 "//third_party/jsoncpp",
874 ]
875 testonly = true
876 }
mtklein25c81d42016-07-27 13:55:26 -0700877}