blob: c94f3cf9dfb64d579ad8fef75afc191e1175484a [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 }
mtkleincae1be52016-09-20 08:24:34 -070052 if (skia_enable_android_framework_defines) {
53 defines += skia_android_framework_defines
54 }
mtkleinc04ff472016-06-23 10:29:30 -070055}
56
57# Skia internal APIs, used by Skia itself and a few test tools.
58config("skia_private") {
59 visibility = [ ":*" ]
60
61 include_dirs = [
62 "include/private",
63 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -070064 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -070065 "src/config",
66 "src/core",
67 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -070068 "src/effects/gradients",
69 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -070070 "src/gpu",
71 "src/image",
72 "src/images",
73 "src/lazy",
74 "src/opts",
75 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -070076 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -070077 "src/ports",
78 "src/sfnt",
mtklein9e0d9dd2016-08-30 10:37:19 -070079 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -070080 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -070081 "src/utils/win",
mtkleinc04ff472016-06-23 10:29:30 -070082 "third_party/etc1",
83 "third_party/ktx",
84 ]
mtklein150d1132016-08-01 06:56:40 -070085
mtklein63213812016-08-24 09:55:56 -070086 defines = [ "SK_GAMMA_APPLY_TO_A8" ]
mtkleinb37c0342016-09-09 11:07:45 -070087 if (is_android) {
88 defines += [
89 "SK_GAMMA_EXPONENT=1.4",
90 "SK_GAMMA_CONTRAST=0.0",
91 ]
92 }
mtklein88a7ac02016-09-14 11:16:49 -070093 if (is_official_build || is_android) {
94 # TODO(bsalomon): it'd be nice to make Android normal.
95 defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
96 }
mtkleinc04ff472016-06-23 10:29:30 -070097}
98
99# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
100config("skia_library") {
101 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -0700102 defines = [ "SKIA_IMPLEMENTATION=1" ]
103}
104
105skia_library_configs = [
106 ":skia_public",
107 ":skia_private",
108 ":skia_library",
109]
110
mtklein9b8583d2016-08-24 17:32:30 -0700111# Use for CPU-specific Skia code that needs particular compiler flags.
112template("opts") {
113 if (invoker.enabled) {
114 source_set(target_name) {
115 forward_variables_from(invoker, "*")
116 configs += skia_library_configs
117 }
118 } else {
119 # If not enabled, a phony empty target that swallows all otherwise unused variables.
120 source_set(target_name) {
121 forward_variables_from(invoker,
122 "*",
123 [
124 "sources",
125 "cflags",
126 ])
127 }
128 }
anmittala7eaf2e2016-08-17 13:57:26 -0700129}
130
mtklein422310d2016-08-16 18:28:43 -0700131is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700132
mtklein7d6fb2c2016-08-25 14:50:44 -0700133opts("none") {
134 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700135 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700136 cflags = []
137}
138
mtklein7d6fb2c2016-08-25 14:50:44 -0700139opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700140 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700141 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700142 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700143}
144
145opts("arm64") {
146 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700147 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700148 cflags = []
149}
150
151opts("crc32") {
152 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700153 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700154 cflags = [ "-march=armv8-a+crc" ]
155}
156
mtklein9b8583d2016-08-24 17:32:30 -0700157opts("sse2") {
158 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700159 sources = skia_opts.sse2_sources
mtklein9b8583d2016-08-24 17:32:30 -0700160 cflags = [ "-msse2" ]
161}
mtkleinc04ff472016-06-23 10:29:30 -0700162
mtklein9b8583d2016-08-24 17:32:30 -0700163opts("ssse3") {
164 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700165 sources = skia_opts.ssse3_sources
mtklein9b8583d2016-08-24 17:32:30 -0700166 cflags = [ "-mssse3" ]
167}
mtkleinc04ff472016-06-23 10:29:30 -0700168
mtklein9b8583d2016-08-24 17:32:30 -0700169opts("sse41") {
170 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700171 sources = skia_opts.sse41_sources
mtklein9b8583d2016-08-24 17:32:30 -0700172 cflags = [ "-msse4.1" ]
173}
mtklein4e976072016-08-08 09:06:27 -0700174
mtklein9b8583d2016-08-24 17:32:30 -0700175opts("sse42") {
176 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700177 sources = skia_opts.sse42_sources
mtklein9b8583d2016-08-24 17:32:30 -0700178 cflags = [ "-msse4.2" ]
179}
180
181opts("avx") {
182 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700183 sources = skia_opts.avx_sources
mtklein9b8583d2016-08-24 17:32:30 -0700184 cflags = [ "-mavx" ]
mtkleinc04ff472016-06-23 10:29:30 -0700185}
186
mtklein349cece2016-08-26 08:13:04 -0700187opts("dsp") {
188 enabled = current_cpu == "mipsel"
brettwb9447282016-09-01 14:24:39 -0700189 sources = skia_opts.mips_dsp_sources
mtkleinb6064ef2016-08-30 11:49:24 -0700190 cflags = []
mtklein349cece2016-08-26 08:13:04 -0700191}
192
mtkleinc095df52016-08-24 12:23:52 -0700193# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700194template("optional") {
195 if (invoker.enabled) {
196 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700197 if (defined(invoker.public_defines)) {
198 defines = invoker.public_defines
199 }
mtklein457b42a2016-08-23 13:56:37 -0700200 }
201 source_set(target_name) {
mtkleincd01b032016-08-31 04:58:19 -0700202 forward_variables_from(invoker,
203 "*",
204 [
205 "public_defines",
206 "sources_when_disabled",
207 ])
mtklein457b42a2016-08-23 13:56:37 -0700208 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700209 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700210 }
211 } else {
mtklein457b42a2016-08-23 13:56:37 -0700212 source_set(target_name) {
213 forward_variables_from(invoker,
214 "*",
215 [
216 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700217 "deps",
mtklein6ef69992016-09-14 06:12:09 -0700218 "libs",
mtklein457b42a2016-08-23 13:56:37 -0700219 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700220 "sources_when_disabled",
mtklein457b42a2016-08-23 13:56:37 -0700221 ])
mtkleincd01b032016-08-31 04:58:19 -0700222 if (defined(invoker.sources_when_disabled)) {
223 sources = invoker.sources_when_disabled
224 }
225 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700226 }
mtkleineb3c4252016-08-23 07:38:09 -0700227 }
mtklein457b42a2016-08-23 13:56:37 -0700228}
mtklein457b42a2016-08-23 13:56:37 -0700229
mtkleina45be612016-08-29 15:22:10 -0700230optional("fontmgr_android") {
231 enabled = fontmgr_android_enabled
mtkleina45be612016-08-29 15:22:10 -0700232
233 deps = [
234 "//third_party/expat",
235 "//third_party/freetype2",
236 ]
237 sources = [
238 "src/ports/SkFontMgr_android.cpp",
239 "src/ports/SkFontMgr_android_factory.cpp",
240 "src/ports/SkFontMgr_android_parser.cpp",
241 ]
242}
243
mtkleind2e39db2016-09-07 07:52:55 -0700244optional("fontmgr_custom") {
245 enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
246
247 deps = [
248 "//third_party/freetype2",
249 ]
250 sources = [
251 "src/ports/SkFontMgr_custom.cpp",
252 "src/ports/SkFontMgr_custom_directory_factory.cpp",
253 ]
254}
255
mtklein3cc22182016-08-29 13:26:14 -0700256optional("fontmgr_fontconfig") {
257 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700258
259 deps = [
260 "//third_party:fontconfig",
261 "//third_party/freetype2",
262 ]
263 sources = [
bungeman1ae0e012016-09-19 12:13:16 -0700264 "src/ports/SkFontConfigInterface.cpp",
mtklein3cc22182016-08-29 13:26:14 -0700265 "src/ports/SkFontConfigInterface_direct.cpp",
266 "src/ports/SkFontConfigInterface_direct_factory.cpp",
267 "src/ports/SkFontMgr_FontConfigInterface.cpp",
268 "src/ports/SkFontMgr_fontconfig.cpp",
269 "src/ports/SkFontMgr_fontconfig_factory.cpp",
270 ]
271}
272
mtkleincdedd0e2016-09-12 15:15:44 -0700273optional("fontmgr_fuchsia") {
274 enabled = is_fuchsia && skia_use_freetype
275
276 deps = [
277 "//third_party/freetype2",
278 ]
279 sources = [
280 "src/ports/SkFontMgr_custom.cpp",
281 "src/ports/SkFontMgr_custom_empty_factory.cpp",
282 ]
283}
284
mtklein457b42a2016-08-23 13:56:37 -0700285optional("gif") {
286 enabled = skia_use_giflib
287 public_defines = [ "SK_HAS_GIF_LIBRARY" ]
288
mtklein457b42a2016-08-23 13:56:37 -0700289 deps = [
290 "//third_party/giflib",
291 ]
292 sources = [
293 "src/codec/SkGifCodec.cpp",
294 ]
295}
296
mtklein63213812016-08-24 09:55:56 -0700297optional("jpeg") {
298 enabled = skia_use_libjpeg_turbo
299 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
300
mtklein63213812016-08-24 09:55:56 -0700301 deps = [
302 "//third_party/libjpeg-turbo:libjpeg",
303 ]
304 sources = [
305 "src/codec/SkJpegCodec.cpp",
306 "src/codec/SkJpegDecoderMgr.cpp",
307 "src/codec/SkJpegUtility.cpp",
308 "src/images/SkJPEGImageEncoder.cpp",
309 "src/images/SkJPEGWriteUtility.cpp",
310 ]
311}
312
313optional("pdf") {
314 enabled = skia_use_zlib
mtklein63213812016-08-24 09:55:56 -0700315
mtklein63213812016-08-24 09:55:56 -0700316 deps = [
317 "//third_party/zlib",
318 ]
brettwb9447282016-09-01 14:24:39 -0700319 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700320 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700321
322 if (skia_use_sfntly) {
323 deps += [ "//third_party/sfntly" ]
mtkleincd01b032016-08-31 04:58:19 -0700324 public_defines = [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700325 }
326}
327
328optional("png") {
329 enabled = skia_use_libpng
330 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
331
mtklein63213812016-08-24 09:55:56 -0700332 deps = [
333 "//third_party/libpng",
334 ]
335 sources = [
336 "src/codec/SkIcoCodec.cpp",
337 "src/codec/SkPngCodec.cpp",
338 "src/images/SkPNGImageEncoder.cpp",
339 ]
340}
341
mtklein3cc22182016-08-29 13:26:14 -0700342optional("typeface_freetype") {
343 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700344
345 deps = [
346 "//third_party/freetype2",
347 ]
348 sources = [
349 "src/ports/SkFontHost_FreeType.cpp",
350 "src/ports/SkFontHost_FreeType_common.cpp",
351 ]
352}
353
mtklein6ef69992016-09-14 06:12:09 -0700354optional("vulkan") {
355 enabled = skia_use_vulkan
356 public_defines = [ "SK_VULKAN" ]
357 libs = [ "vulkan" ]
358 sources = skia_vk_sources
359}
360
mtklein457b42a2016-08-23 13:56:37 -0700361optional("webp") {
362 enabled = skia_use_libwebp
363 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
364
mtklein457b42a2016-08-23 13:56:37 -0700365 deps = [
366 "//third_party/libwebp",
367 ]
368 sources = [
369 "src/codec/SkWebpAdapterCodec.cpp",
370 "src/codec/SkWebpCodec.cpp",
371 "src/images/SkWEBPImageEncoder.cpp",
372 ]
mtkleineb3c4252016-08-23 07:38:09 -0700373}
374
mtklein63213812016-08-24 09:55:56 -0700375optional("xml") {
376 enabled = skia_use_expat
mtklein63213812016-08-24 09:55:56 -0700377
mtklein63213812016-08-24 09:55:56 -0700378 deps = [
379 "//third_party/expat",
380 ]
381 sources = [
382 "src/xml/SkDOM.cpp",
383 "src/xml/SkXMLParser.cpp",
384 "src/xml/SkXMLWriter.cpp",
385 ]
386}
387
mtkleinc04ff472016-06-23 10:29:30 -0700388component("skia") {
389 public_configs = [ ":skia_public" ]
390 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700391
392 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700393 ":arm64",
394 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700395 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700396 ":crc32",
mtklein349cece2016-08-26 08:13:04 -0700397 ":dsp",
mtkleina45be612016-08-29 15:22:10 -0700398 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700399 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700400 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700401 ":fontmgr_fuchsia",
mtklein457b42a2016-08-23 13:56:37 -0700402 ":gif",
mtklein63213812016-08-24 09:55:56 -0700403 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700404 ":none",
mtklein63213812016-08-24 09:55:56 -0700405 ":pdf",
406 ":png",
mtklein9b8583d2016-08-24 17:32:30 -0700407 ":sse2",
408 ":sse41",
409 ":sse42",
410 ":ssse3",
mtklein3cc22182016-08-29 13:26:14 -0700411 ":typeface_freetype",
mtklein6ef69992016-09-14 06:12:09 -0700412 ":vulkan",
mtkleineb3c4252016-08-23 07:38:09 -0700413 ":webp",
mtklein63213812016-08-24 09:55:56 -0700414 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700415 ]
416
mtkleinc04ff472016-06-23 10:29:30 -0700417 sources = []
brettwb9447282016-09-01 14:24:39 -0700418 sources += skia_core_sources
419 sources += skia_effects_sources
420 sources += skia_gpu_sources
421 sources += skia_sksl_sources
422 sources += skia_utils_sources
mtkleinc04ff472016-06-23 10:29:30 -0700423 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700424 "src/android/SkBitmapRegionCodec.cpp",
425 "src/android/SkBitmapRegionDecoder.cpp",
426 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700427 "src/codec/SkBmpCodec.cpp",
428 "src/codec/SkBmpMaskCodec.cpp",
429 "src/codec/SkBmpRLECodec.cpp",
430 "src/codec/SkBmpStandardCodec.cpp",
431 "src/codec/SkCodec.cpp",
432 "src/codec/SkCodecImageGenerator.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700433 "src/codec/SkMaskSwizzler.cpp",
434 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700435 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700436 "src/codec/SkSampler.cpp",
437 "src/codec/SkSwizzler.cpp",
438 "src/codec/SkWbmpCodec.cpp",
mtklein09e61f72016-08-23 13:35:28 -0700439 "src/gpu/gl/GrGLDefaultInterface_native.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700440 "src/images/SkImageEncoder.cpp",
441 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700442 "src/images/SkKTXImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700443 "src/ports/SkDiscardableMemory_none.cpp",
444 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700445 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700446 "src/ports/SkMemory_malloc.cpp",
447 "src/ports/SkOSFile_stdio.cpp",
448 "src/sfnt/SkOTTable_name.cpp",
449 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700450 "src/svg/SkSVGCanvas.cpp",
451 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700452 "src/utils/mac/SkStream_mac.cpp",
453 "third_party/etc1/etc1.cpp",
454 "third_party/ktx/ktx.cpp",
455 ]
brettwb9447282016-09-01 14:24:39 -0700456
457 # These paths need to be absolute to match the ones produced by
458 # shared_sources.gni, but this file may be used from different directory
459 # locations.
460 sources -= get_path_info([
461 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
462 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
463 ],
464 "abspath")
mtkleinc04ff472016-06-23 10:29:30 -0700465
mtklein7d6fb2c2016-08-25 14:50:44 -0700466 libs = []
467
mtkleinc04ff472016-06-23 10:29:30 -0700468 if (is_win) {
469 sources += [
470 "src/ports/SkDebug_win.cpp",
471 "src/ports/SkFontHost_win.cpp",
472 "src/ports/SkFontMgr_win_dw.cpp",
473 "src/ports/SkFontMgr_win_dw_factory.cpp",
474 "src/ports/SkImageEncoder_WIC.cpp",
475 "src/ports/SkImageGeneratorWIC.cpp",
476 "src/ports/SkOSFile_win.cpp",
477 "src/ports/SkScalerContext_win_dw.cpp",
478 "src/ports/SkTLS_win.cpp",
479 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700480 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700481 ]
mtkleinb9be9792016-09-16 14:44:18 -0700482 sources -=
483 [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
mtkleinc04ff472016-06-23 10:29:30 -0700484 } else {
485 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700486 "src/ports/SkOSFile_posix.cpp",
487 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700488 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700489 ]
490 }
491
mtklein7d6fb2c2016-08-25 14:50:44 -0700492 if (is_android) {
493 deps += [
494 "//third_party/cpu-features",
495 "//third_party/expat",
mtklein7d6fb2c2016-08-25 14:50:44 -0700496 ]
497 sources += [
498 "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp",
499 "src/ports/SkDebug_android.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700500 ]
501 libs += [
502 "EGL",
503 "GLESv2",
504 "log",
505 ]
506 }
507
mtkleinc04ff472016-06-23 10:29:30 -0700508 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700509 libs += [
510 "GL",
511 "GLU",
512 "X11",
513 ]
mtkleinc04ff472016-06-23 10:29:30 -0700514 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700515 "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700516 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700517 ]
518 }
519
520 if (is_mac) {
521 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700522 "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700523 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700524 "src/ports/SkFontHost_mac.cpp",
525 "src/ports/SkImageEncoder_CG.cpp",
526 "src/ports/SkImageGeneratorCG.cpp",
527 ]
mtklein09e61f72016-08-23 13:35:28 -0700528 libs += [
529 "ApplicationServices.framework",
530 "OpenGL.framework",
531 ]
mtkleinc04ff472016-06-23 10:29:30 -0700532 }
abarth6fc8ff02016-07-15 15:15:15 -0700533
534 if (is_fuchsia) {
mikejurka21cc9952016-09-13 16:15:03 -0700535 sources += [
536 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
537 "src/ports/SkDebug_stdio.cpp",
538 ]
abarth6fc8ff02016-07-15 15:15:15 -0700539 }
mtkleinc04ff472016-06-23 10:29:30 -0700540}
541
mtkleinada5a442016-08-02 14:28:26 -0700542skia_h_headers = exec_script("gyp/find.py",
543 [ "*.h" ] + rebase_path(skia_public_includes),
544 "list lines",
545 []) -
546 [
547 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
548 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
549 rebase_path("include/gpu/vk/GrVkDefines.h"),
550 rebase_path("include/gpu/vk/GrVkInterface.h"),
551 rebase_path("include/gpu/vk/GrVkTypes.h"),
552 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
553 ]
554
mtklein1211e0c2016-07-26 13:55:45 -0700555action("skia.h") {
556 script = "gn/echo_headers.py"
557 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinc095df52016-08-24 12:23:52 -0700558 rebase_path(skia_h_headers, target_gen_dir)
mtklein1211e0c2016-07-26 13:55:45 -0700559 outputs = [
560 "$target_gen_dir/skia.h",
561 ]
562}
563
mtklein1fbdf982016-09-15 12:07:48 -0700564if (target_cpu == "x64") {
565 # Our bots only have 64-bit libOSMesa installed.
566 # TODO: worth fixing?
567 executable("fiddle") {
568 include_dirs = [ "$target_gen_dir" ]
569 libs = []
570 if (is_linux) {
571 libs += [ "OSMesa" ]
572 }
mtklein56d56692016-09-15 11:18:55 -0700573
mtklein1fbdf982016-09-15 12:07:48 -0700574 sources = [
575 "src/images/SkForceLinking.cpp",
576 "tools/fiddle/draw.cpp",
577 "tools/fiddle/fiddle_main.cpp",
578 ]
579 deps = [
580 ":skia",
581 ":skia.h",
582 ]
583 }
mtkleinc04ff472016-06-23 10:29:30 -0700584}
mtklein25c81d42016-07-27 13:55:26 -0700585
mtkleinc095df52016-08-24 12:23:52 -0700586# Targets guarded by skia_enable_tools may use //third_party freely.
587if (skia_enable_tools) {
588 template("test_lib") {
589 config(target_name + "_config") {
590 include_dirs = invoker.public_include_dirs
mtklein25c81d42016-07-27 13:55:26 -0700591 }
mtkleinc095df52016-08-24 12:23:52 -0700592 source_set(target_name) {
593 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
594 public_configs = [
595 ":" + target_name + "_config",
596 ":skia_private",
597 ]
598
599 if (!defined(deps)) {
600 deps = []
601 }
602 deps += [ ":skia" ]
603 testonly = true
604 }
mtklein25c81d42016-07-27 13:55:26 -0700605 }
mtklein25c81d42016-07-27 13:55:26 -0700606
mtkleinc095df52016-08-24 12:23:52 -0700607 test_lib("gpu_tool_utils") {
608 public_include_dirs = [ "tools/gpu" ]
609 sources = [
610 "tools/gpu/GrContextFactory.cpp",
611 "tools/gpu/GrTest.cpp",
612 "tools/gpu/TestContext.cpp",
613 "tools/gpu/gl/GLTestContext.cpp",
614 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
615 "tools/gpu/gl/debug/GrBufferObj.cpp",
616 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
617 "tools/gpu/gl/debug/GrProgramObj.cpp",
618 "tools/gpu/gl/debug/GrShaderObj.cpp",
619 "tools/gpu/gl/debug/GrTextureObj.cpp",
620 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
621 "tools/gpu/gl/null/NullGLTestContext.cpp",
622 ]
623 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700624
mtklein7d6fb2c2016-08-25 14:50:44 -0700625 if (is_android) {
626 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
627 } else if (is_linux) {
mtkleinc095df52016-08-24 12:23:52 -0700628 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
629 } else if (is_mac) {
630 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
631 }
mtklein6ef69992016-09-14 06:12:09 -0700632
633 if (skia_use_vulkan) {
634 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
635 }
mtklein25c81d42016-07-27 13:55:26 -0700636 }
mtklein25c81d42016-07-27 13:55:26 -0700637
mtkleinc095df52016-08-24 12:23:52 -0700638 test_lib("flags") {
639 public_include_dirs = [ "tools/flags" ]
640 sources = [
641 "tools/flags/SkCommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -0700642 ]
643 }
644 test_lib("common_flags") {
645 public_include_dirs = [ "tools/flags" ]
646 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700647 "tools/flags/SkCommonFlags.cpp",
648 "tools/flags/SkCommonFlagsConfig.cpp",
649 ]
650 deps = [
mtklein046cb562016-09-16 10:23:12 -0700651 ":flags",
mtkleinc095df52016-08-24 12:23:52 -0700652 ":gpu_tool_utils",
653 ]
654 }
mtklein25c81d42016-07-27 13:55:26 -0700655
mtkleinc095df52016-08-24 12:23:52 -0700656 test_lib("tool_utils") {
657 public_include_dirs = [
658 "tools",
659 "tools/debugger",
660 "tools/timer",
661 ]
662 sources = [
663 "src/images/SkForceLinking.cpp",
664 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700665 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700666 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700667 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700668 "tools/ProcStats.cpp",
669 "tools/Resources.cpp",
670 "tools/ThermalManager.cpp",
671 "tools/UrlDataManager.cpp",
672 "tools/debugger/SkDebugCanvas.cpp",
673 "tools/debugger/SkDrawCommand.cpp",
674 "tools/debugger/SkJsonWriteBuffer.cpp",
675 "tools/debugger/SkObjectParser.cpp",
676 "tools/debugger/SkOverdrawMode.cpp",
677 "tools/picture_utils.cpp",
678 "tools/random_parse_path.cpp",
679 "tools/sk_tool_utils.cpp",
680 "tools/sk_tool_utils_font.cpp",
681 "tools/timer/Timer.cpp",
682 ]
683 deps = [
mtklein046cb562016-09-16 10:23:12 -0700684 ":common_flags",
mtkleinc095df52016-08-24 12:23:52 -0700685 ":flags",
686 "//third_party/libpng",
687 ]
688 public_deps = [
689 "//third_party/jsoncpp",
690 ]
691 }
mtklein25c81d42016-07-27 13:55:26 -0700692
mtkleinc095df52016-08-24 12:23:52 -0700693 gm_sources = exec_script("gyp/find.py",
694 [
695 "*.c*",
696 rebase_path("gm"),
697 ],
698 "list lines",
699 [])
700 test_lib("gm") {
701 public_include_dirs = [ "gm" ]
702 sources = gm_sources
703 deps = [
704 ":gpu_tool_utils",
705 ":skia",
706 ":tool_utils",
707 ]
708 }
mtklein25c81d42016-07-27 13:55:26 -0700709
mtkleinc095df52016-08-24 12:23:52 -0700710 tests_sources = exec_script("gyp/find.py",
711 [
712 "*.c*",
713 rebase_path("tests"),
714 ],
715 "list lines",
716 [])
mtklein2f3416d2016-08-02 16:02:05 -0700717
mtkleinc095df52016-08-24 12:23:52 -0700718 test_lib("tests") {
719 public_include_dirs = [ "tests" ]
mtkleina45be612016-08-29 15:22:10 -0700720 sources = tests_sources - [
721 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
mtkleina45be612016-08-29 15:22:10 -0700722 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
723 rebase_path("tests/skia_test.cpp"), # alternate main
724 ]
725 if (!fontmgr_android_enabled) {
726 sources -= [ rebase_path("tests/FontMgrAndroidParserTest.cpp") ]
727 }
mtkleinc095df52016-08-24 12:23:52 -0700728 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700729 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700730 ":flags",
731 ":gpu_tool_utils",
732 ":skia",
733 ":tool_utils",
734 "//third_party/libpng",
735 "//third_party/zlib",
736 ]
737 }
mtklein2f3416d2016-08-02 16:02:05 -0700738
mtkleinc095df52016-08-24 12:23:52 -0700739 bench_sources = exec_script("gyp/find.py",
740 [
741 "*.c*",
742 rebase_path("bench"),
743 ],
744 "list lines",
745 [])
mtklein25c81d42016-07-27 13:55:26 -0700746
mtkleinc095df52016-08-24 12:23:52 -0700747 test_lib("bench") {
748 public_include_dirs = [ "bench" ]
749 sources = bench_sources
750 sources -= [
751 rebase_path("bench/nanobench.cpp"),
752 rebase_path("bench/nanobenchAndroid.cpp"),
753 ]
754 deps = [
755 ":flags",
756 ":gm",
757 ":gpu_tool_utils",
758 ":skia",
759 ":tool_utils",
760 ]
761 }
mtklein2b6870c2016-07-28 14:17:33 -0700762
mtkleinc095df52016-08-24 12:23:52 -0700763 test_lib("experimental_svg_model") {
764 public_include_dirs = [ "experimental/svg/model" ]
765 sources = [
766 "experimental/svg/model/SkSVGAttribute.cpp",
767 "experimental/svg/model/SkSVGAttributeParser.cpp",
768 "experimental/svg/model/SkSVGCircle.cpp",
769 "experimental/svg/model/SkSVGContainer.cpp",
770 "experimental/svg/model/SkSVGDOM.cpp",
771 "experimental/svg/model/SkSVGEllipse.cpp",
772 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700773 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700774 "experimental/svg/model/SkSVGNode.cpp",
775 "experimental/svg/model/SkSVGPath.cpp",
776 "experimental/svg/model/SkSVGPoly.cpp",
777 "experimental/svg/model/SkSVGRect.cpp",
778 "experimental/svg/model/SkSVGRenderContext.cpp",
779 "experimental/svg/model/SkSVGSVG.cpp",
780 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700781 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700782 "experimental/svg/model/SkSVGTransformableNode.cpp",
783 "experimental/svg/model/SkSVGValue.cpp",
784 ]
785 deps = [
786 ":skia",
787 ]
788 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700789
mtklein2b6870c2016-07-28 14:17:33 -0700790 executable("dm") {
791 sources = [
792 "dm/DM.cpp",
793 "dm/DMJsonWriter.cpp",
794 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700795 ]
796 include_dirs = [ "tests" ]
797 deps = [
mtklein046cb562016-09-16 10:23:12 -0700798 ":common_flags",
fmalitaa2b9fdf2016-08-03 19:53:36 -0700799 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700800 ":flags",
801 ":gm",
802 ":gpu_tool_utils",
803 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700804 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700805 ":tool_utils",
806 "//third_party/jsoncpp",
807 "//third_party/libpng",
808 ]
809 testonly = true
810 }
811
812 executable("monobench") {
813 sources = [
814 "tools/monobench.cpp",
815 ]
816 deps = [
817 ":bench",
818 ":skia",
819 ]
820 testonly = true
821 }
822
823 executable("nanobench") {
824 sources = [
825 "bench/nanobench.cpp",
826 ]
827 deps = [
828 ":bench",
mtklein046cb562016-09-16 10:23:12 -0700829 ":common_flags",
fmalita6519c212016-09-14 08:05:17 -0700830 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700831 ":flags",
832 ":gm",
833 ":gpu_tool_utils",
834 ":skia",
835 ":tool_utils",
836 "//third_party/jsoncpp",
837 ]
838 testonly = true
839 }
halcanary19a97202016-08-03 15:08:04 -0700840
csmartdalton4b5179b2016-09-19 11:03:58 -0700841 executable("skpbench") {
842 sources = [
843 "tools/skpbench/skpbench.cpp",
844 ]
845 deps = [
846 ":flags",
847 ":gpu_tool_utils",
848 ":skia",
849 ":tool_utils",
850 ]
851 testonly = true
852 }
853
mtklein6f5df6a2016-08-29 16:01:10 -0700854 if (current_cpu != "mipsel") { # Clang 3.8 crashes while compiling hb-icu.cc for mipsel.
halcanary3eee9d92016-09-10 07:01:53 -0700855 executable("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -0700856 sources = [
857 "tools/SkShaper_harfbuzz.cpp",
858 "tools/using_skia_and_harfbuzz.cpp",
859 ]
860 deps = [
861 ":skia",
862 "//third_party/harfbuzz",
863 ]
864 testonly = true
865 }
halcanary19a97202016-08-03 15:08:04 -0700866 }
halcanary3eee9d92016-09-10 07:01:53 -0700867 executable("sktexttopdf") {
868 sources = [
869 "tools/SkShaper_primitive.cpp",
870 "tools/using_skia_and_harfbuzz.cpp",
871 ]
872 deps = [
873 ":skia",
874 ]
875 testonly = true
876 }
mtklein046cb562016-09-16 10:23:12 -0700877
878 executable("get_images_from_skps") {
879 sources = [
880 "tools/get_images_from_skps.cpp",
881 ]
882 deps = [
883 ":flags",
884 ":skia",
885 "//third_party/jsoncpp",
886 ]
887 testonly = true
888 }
mtklein25c81d42016-07-27 13:55:26 -0700889}