blob: c6841bbd95912e95b65722966a5de766abfeb09d [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
brettwb9447282016-09-01 14:24:39 -07006import("//gn/shared_sources.gni")
7
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
19 skia_use_zlib = true
mtkleinc04ff472016-06-23 10:29:30 -070020}
21
mtkleina45be612016-08-29 15:22:10 -070022fontmgr_android_enabled = skia_use_expat && skia_use_freetype
23
mtklein1211e0c2016-07-26 13:55:45 -070024skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070025 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070026 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070027 "include/codec",
28 "include/config",
29 "include/core",
30 "include/effects",
31 "include/gpu",
32 "include/gpu/gl",
33 "include/images",
34 "include/pathops",
35 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070036 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070037 "include/utils",
38 "include/utils/mac",
mtklein25c81d42016-07-27 13:55:26 -070039 "include/xml",
mtklein1211e0c2016-07-26 13:55:45 -070040]
41
mtkleinc04ff472016-06-23 10:29:30 -070042# Skia public API, generally provided by :skia.
43config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -070044 include_dirs = skia_public_includes
mtkleinc04ff472016-06-23 10:29:30 -070045 defines = [ "SKIA_DLL" ]
jcgregorio5561e3d2016-08-25 09:25:11 -070046 if (is_linux) {
47 defines += [ "SK_SAMPLES_FOR_X" ]
48 }
mtkleinc04ff472016-06-23 10:29:30 -070049}
50
51# Skia internal APIs, used by Skia itself and a few test tools.
52config("skia_private") {
53 visibility = [ ":*" ]
54
55 include_dirs = [
56 "include/private",
57 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -070058 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -070059 "src/config",
60 "src/core",
61 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -070062 "src/effects/gradients",
63 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -070064 "src/gpu",
65 "src/image",
66 "src/images",
67 "src/lazy",
68 "src/opts",
69 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -070070 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -070071 "src/ports",
72 "src/sfnt",
mtklein9e0d9dd2016-08-30 10:37:19 -070073 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -070074 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -070075 "src/utils/win",
mtkleinc04ff472016-06-23 10:29:30 -070076 "third_party/etc1",
77 "third_party/ktx",
78 ]
mtklein150d1132016-08-01 06:56:40 -070079
mtklein63213812016-08-24 09:55:56 -070080 defines = [ "SK_GAMMA_APPLY_TO_A8" ]
mtkleinb37c0342016-09-09 11:07:45 -070081 if (is_android) {
82 defines += [
83 "SK_GAMMA_EXPONENT=1.4",
84 "SK_GAMMA_CONTRAST=0.0",
85 ]
86 }
mtkleinc04ff472016-06-23 10:29:30 -070087}
88
89# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
90config("skia_library") {
91 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -070092 defines = [ "SKIA_IMPLEMENTATION=1" ]
93}
94
95skia_library_configs = [
96 ":skia_public",
97 ":skia_private",
98 ":skia_library",
99]
100
mtklein9b8583d2016-08-24 17:32:30 -0700101# Use for CPU-specific Skia code that needs particular compiler flags.
102template("opts") {
103 if (invoker.enabled) {
104 source_set(target_name) {
105 forward_variables_from(invoker, "*")
106 configs += skia_library_configs
107 }
108 } else {
109 # If not enabled, a phony empty target that swallows all otherwise unused variables.
110 source_set(target_name) {
111 forward_variables_from(invoker,
112 "*",
113 [
114 "sources",
115 "cflags",
116 ])
117 }
118 }
anmittala7eaf2e2016-08-17 13:57:26 -0700119}
120
mtklein422310d2016-08-16 18:28:43 -0700121is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700122
mtklein7d6fb2c2016-08-25 14:50:44 -0700123opts("none") {
124 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700125 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700126 cflags = []
127}
128
mtklein7d6fb2c2016-08-25 14:50:44 -0700129opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700130 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700131 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700132 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700133}
134
135opts("arm64") {
136 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700137 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700138 cflags = []
139}
140
141opts("crc32") {
142 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700143 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700144 cflags = [ "-march=armv8-a+crc" ]
145}
146
mtklein9b8583d2016-08-24 17:32:30 -0700147opts("sse2") {
148 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700149 sources = skia_opts.sse2_sources
mtklein9b8583d2016-08-24 17:32:30 -0700150 cflags = [ "-msse2" ]
151}
mtkleinc04ff472016-06-23 10:29:30 -0700152
mtklein9b8583d2016-08-24 17:32:30 -0700153opts("ssse3") {
154 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700155 sources = skia_opts.ssse3_sources
mtklein9b8583d2016-08-24 17:32:30 -0700156 cflags = [ "-mssse3" ]
157}
mtkleinc04ff472016-06-23 10:29:30 -0700158
mtklein9b8583d2016-08-24 17:32:30 -0700159opts("sse41") {
160 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700161 sources = skia_opts.sse41_sources
mtklein9b8583d2016-08-24 17:32:30 -0700162 cflags = [ "-msse4.1" ]
163}
mtklein4e976072016-08-08 09:06:27 -0700164
mtklein9b8583d2016-08-24 17:32:30 -0700165opts("sse42") {
166 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700167 sources = skia_opts.sse42_sources
mtklein9b8583d2016-08-24 17:32:30 -0700168 cflags = [ "-msse4.2" ]
169}
170
171opts("avx") {
172 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700173 sources = skia_opts.avx_sources
mtklein9b8583d2016-08-24 17:32:30 -0700174 cflags = [ "-mavx" ]
mtkleinc04ff472016-06-23 10:29:30 -0700175}
176
mtklein349cece2016-08-26 08:13:04 -0700177opts("dsp") {
178 enabled = current_cpu == "mipsel"
brettwb9447282016-09-01 14:24:39 -0700179 sources = skia_opts.mips_dsp_sources
mtkleinb6064ef2016-08-30 11:49:24 -0700180 cflags = []
mtklein349cece2016-08-26 08:13:04 -0700181}
182
mtkleinc095df52016-08-24 12:23:52 -0700183# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700184template("optional") {
185 if (invoker.enabled) {
186 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700187 if (defined(invoker.public_defines)) {
188 defines = invoker.public_defines
189 }
mtklein457b42a2016-08-23 13:56:37 -0700190 }
191 source_set(target_name) {
mtkleincd01b032016-08-31 04:58:19 -0700192 forward_variables_from(invoker,
193 "*",
194 [
195 "public_defines",
196 "sources_when_disabled",
197 ])
mtklein457b42a2016-08-23 13:56:37 -0700198 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700199 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700200 }
201 } else {
mtklein457b42a2016-08-23 13:56:37 -0700202 source_set(target_name) {
203 forward_variables_from(invoker,
204 "*",
205 [
206 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700207 "deps",
208 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700209 "sources_when_disabled",
mtklein457b42a2016-08-23 13:56:37 -0700210 ])
mtkleincd01b032016-08-31 04:58:19 -0700211 if (defined(invoker.sources_when_disabled)) {
212 sources = invoker.sources_when_disabled
213 }
214 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700215 }
mtkleineb3c4252016-08-23 07:38:09 -0700216 }
mtklein457b42a2016-08-23 13:56:37 -0700217}
mtklein457b42a2016-08-23 13:56:37 -0700218
mtkleina45be612016-08-29 15:22:10 -0700219optional("fontmgr_android") {
220 enabled = fontmgr_android_enabled
mtkleina45be612016-08-29 15:22:10 -0700221
222 deps = [
223 "//third_party/expat",
224 "//third_party/freetype2",
225 ]
226 sources = [
227 "src/ports/SkFontMgr_android.cpp",
228 "src/ports/SkFontMgr_android_factory.cpp",
229 "src/ports/SkFontMgr_android_parser.cpp",
230 ]
231}
232
mtkleind2e39db2016-09-07 07:52:55 -0700233optional("fontmgr_custom") {
234 enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
235
236 deps = [
237 "//third_party/freetype2",
238 ]
239 sources = [
240 "src/ports/SkFontMgr_custom.cpp",
241 "src/ports/SkFontMgr_custom_directory_factory.cpp",
242 ]
243}
244
mtklein3cc22182016-08-29 13:26:14 -0700245optional("fontmgr_fontconfig") {
246 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700247
248 deps = [
249 "//third_party:fontconfig",
250 "//third_party/freetype2",
251 ]
252 sources = [
253 "src/ports/SkFontConfigInterface_direct.cpp",
254 "src/ports/SkFontConfigInterface_direct_factory.cpp",
255 "src/ports/SkFontMgr_FontConfigInterface.cpp",
256 "src/ports/SkFontMgr_fontconfig.cpp",
257 "src/ports/SkFontMgr_fontconfig_factory.cpp",
258 ]
259}
260
mtkleincdedd0e2016-09-12 15:15:44 -0700261optional("fontmgr_fuchsia") {
262 enabled = is_fuchsia && skia_use_freetype
263
264 deps = [
265 "//third_party/freetype2",
266 ]
267 sources = [
268 "src/ports/SkFontMgr_custom.cpp",
269 "src/ports/SkFontMgr_custom_empty_factory.cpp",
270 ]
271}
272
mtklein457b42a2016-08-23 13:56:37 -0700273optional("gif") {
274 enabled = skia_use_giflib
275 public_defines = [ "SK_HAS_GIF_LIBRARY" ]
276
mtklein457b42a2016-08-23 13:56:37 -0700277 deps = [
278 "//third_party/giflib",
279 ]
280 sources = [
281 "src/codec/SkGifCodec.cpp",
282 ]
283}
284
mtklein63213812016-08-24 09:55:56 -0700285optional("jpeg") {
286 enabled = skia_use_libjpeg_turbo
287 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
288
mtklein63213812016-08-24 09:55:56 -0700289 deps = [
290 "//third_party/libjpeg-turbo:libjpeg",
291 ]
292 sources = [
293 "src/codec/SkJpegCodec.cpp",
294 "src/codec/SkJpegDecoderMgr.cpp",
295 "src/codec/SkJpegUtility.cpp",
296 "src/images/SkJPEGImageEncoder.cpp",
297 "src/images/SkJPEGWriteUtility.cpp",
298 ]
299}
300
301optional("pdf") {
302 enabled = skia_use_zlib
mtklein63213812016-08-24 09:55:56 -0700303
mtklein63213812016-08-24 09:55:56 -0700304 deps = [
305 "//third_party/zlib",
306 ]
brettwb9447282016-09-01 14:24:39 -0700307 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700308 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700309
310 if (skia_use_sfntly) {
311 deps += [ "//third_party/sfntly" ]
mtkleincd01b032016-08-31 04:58:19 -0700312 public_defines = [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700313 }
314}
315
316optional("png") {
317 enabled = skia_use_libpng
318 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
319
mtklein63213812016-08-24 09:55:56 -0700320 deps = [
321 "//third_party/libpng",
322 ]
323 sources = [
324 "src/codec/SkIcoCodec.cpp",
325 "src/codec/SkPngCodec.cpp",
326 "src/images/SkPNGImageEncoder.cpp",
327 ]
328}
329
mtklein3cc22182016-08-29 13:26:14 -0700330optional("typeface_freetype") {
331 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700332
333 deps = [
334 "//third_party/freetype2",
335 ]
336 sources = [
337 "src/ports/SkFontHost_FreeType.cpp",
338 "src/ports/SkFontHost_FreeType_common.cpp",
339 ]
340}
341
mtklein457b42a2016-08-23 13:56:37 -0700342optional("webp") {
343 enabled = skia_use_libwebp
344 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
345
mtklein457b42a2016-08-23 13:56:37 -0700346 deps = [
347 "//third_party/libwebp",
348 ]
349 sources = [
350 "src/codec/SkWebpAdapterCodec.cpp",
351 "src/codec/SkWebpCodec.cpp",
352 "src/images/SkWEBPImageEncoder.cpp",
353 ]
mtkleineb3c4252016-08-23 07:38:09 -0700354}
355
mtklein63213812016-08-24 09:55:56 -0700356optional("xml") {
357 enabled = skia_use_expat
mtklein63213812016-08-24 09:55:56 -0700358
mtklein63213812016-08-24 09:55:56 -0700359 deps = [
360 "//third_party/expat",
361 ]
362 sources = [
363 "src/xml/SkDOM.cpp",
364 "src/xml/SkXMLParser.cpp",
365 "src/xml/SkXMLWriter.cpp",
366 ]
367}
368
mtkleinc04ff472016-06-23 10:29:30 -0700369component("skia") {
370 public_configs = [ ":skia_public" ]
371 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700372
373 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700374 ":arm64",
375 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700376 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700377 ":crc32",
mtklein349cece2016-08-26 08:13:04 -0700378 ":dsp",
mtkleina45be612016-08-29 15:22:10 -0700379 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700380 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700381 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700382 ":fontmgr_fuchsia",
mtklein457b42a2016-08-23 13:56:37 -0700383 ":gif",
mtklein63213812016-08-24 09:55:56 -0700384 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700385 ":none",
mtklein63213812016-08-24 09:55:56 -0700386 ":pdf",
387 ":png",
mtklein9b8583d2016-08-24 17:32:30 -0700388 ":sse2",
389 ":sse41",
390 ":sse42",
391 ":ssse3",
mtklein3cc22182016-08-29 13:26:14 -0700392 ":typeface_freetype",
mtkleineb3c4252016-08-23 07:38:09 -0700393 ":webp",
mtklein63213812016-08-24 09:55:56 -0700394 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700395 ]
396
mtkleinc04ff472016-06-23 10:29:30 -0700397 sources = []
brettwb9447282016-09-01 14:24:39 -0700398 sources += skia_core_sources
399 sources += skia_effects_sources
400 sources += skia_gpu_sources
401 sources += skia_sksl_sources
402 sources += skia_utils_sources
mtkleinc04ff472016-06-23 10:29:30 -0700403 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700404 "src/android/SkBitmapRegionCodec.cpp",
405 "src/android/SkBitmapRegionDecoder.cpp",
406 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700407 "src/codec/SkBmpCodec.cpp",
408 "src/codec/SkBmpMaskCodec.cpp",
409 "src/codec/SkBmpRLECodec.cpp",
410 "src/codec/SkBmpStandardCodec.cpp",
411 "src/codec/SkCodec.cpp",
412 "src/codec/SkCodecImageGenerator.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700413 "src/codec/SkMaskSwizzler.cpp",
414 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700415 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700416 "src/codec/SkSampler.cpp",
417 "src/codec/SkSwizzler.cpp",
418 "src/codec/SkWbmpCodec.cpp",
mtklein09e61f72016-08-23 13:35:28 -0700419 "src/gpu/gl/GrGLDefaultInterface_native.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700420 "src/images/SkImageEncoder.cpp",
421 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700422 "src/images/SkKTXImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700423 "src/ports/SkDiscardableMemory_none.cpp",
424 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700425 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700426 "src/ports/SkMemory_malloc.cpp",
427 "src/ports/SkOSFile_stdio.cpp",
428 "src/sfnt/SkOTTable_name.cpp",
429 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700430 "src/svg/SkSVGCanvas.cpp",
431 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700432 "src/utils/mac/SkStream_mac.cpp",
433 "third_party/etc1/etc1.cpp",
434 "third_party/ktx/ktx.cpp",
435 ]
brettwb9447282016-09-01 14:24:39 -0700436
437 # These paths need to be absolute to match the ones produced by
438 # shared_sources.gni, but this file may be used from different directory
439 # locations.
440 sources -= get_path_info([
441 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
442 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
443 ],
444 "abspath")
mtkleinc04ff472016-06-23 10:29:30 -0700445
mtklein7d6fb2c2016-08-25 14:50:44 -0700446 libs = []
447
mtkleinc04ff472016-06-23 10:29:30 -0700448 if (is_win) {
449 sources += [
450 "src/ports/SkDebug_win.cpp",
451 "src/ports/SkFontHost_win.cpp",
452 "src/ports/SkFontMgr_win_dw.cpp",
453 "src/ports/SkFontMgr_win_dw_factory.cpp",
454 "src/ports/SkImageEncoder_WIC.cpp",
455 "src/ports/SkImageGeneratorWIC.cpp",
456 "src/ports/SkOSFile_win.cpp",
457 "src/ports/SkScalerContext_win_dw.cpp",
458 "src/ports/SkTLS_win.cpp",
459 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700460 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700461 ]
mtklein7a1f45f2016-08-04 06:19:33 -0700462 sources -= [ "src/utils/SkThreadUtils_pthread.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700463 } else {
464 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700465 "src/ports/SkOSFile_posix.cpp",
466 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700467 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700468 ]
469 }
470
mtklein7d6fb2c2016-08-25 14:50:44 -0700471 if (is_android) {
472 deps += [
473 "//third_party/cpu-features",
474 "//third_party/expat",
mtklein7d6fb2c2016-08-25 14:50:44 -0700475 ]
476 sources += [
477 "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp",
478 "src/ports/SkDebug_android.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700479 ]
480 libs += [
481 "EGL",
482 "GLESv2",
483 "log",
484 ]
485 }
486
mtkleinc04ff472016-06-23 10:29:30 -0700487 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700488 libs += [
489 "GL",
490 "GLU",
491 "X11",
492 ]
mtkleinc04ff472016-06-23 10:29:30 -0700493 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700494 "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700495 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700496 ]
497 }
498
499 if (is_mac) {
500 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700501 "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700502 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700503 "src/ports/SkFontHost_mac.cpp",
504 "src/ports/SkImageEncoder_CG.cpp",
505 "src/ports/SkImageGeneratorCG.cpp",
506 ]
mtklein09e61f72016-08-23 13:35:28 -0700507 libs += [
508 "ApplicationServices.framework",
509 "OpenGL.framework",
510 ]
mtkleinc04ff472016-06-23 10:29:30 -0700511 }
abarth6fc8ff02016-07-15 15:15:15 -0700512
513 if (is_fuchsia) {
mtkleincdedd0e2016-09-12 15:15:44 -0700514 sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700515 }
mtkleinc04ff472016-06-23 10:29:30 -0700516}
517
mtkleinada5a442016-08-02 14:28:26 -0700518skia_h_headers = exec_script("gyp/find.py",
519 [ "*.h" ] + rebase_path(skia_public_includes),
520 "list lines",
521 []) -
522 [
523 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
524 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
525 rebase_path("include/gpu/vk/GrVkDefines.h"),
526 rebase_path("include/gpu/vk/GrVkInterface.h"),
527 rebase_path("include/gpu/vk/GrVkTypes.h"),
528 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
529 ]
530
mtklein1211e0c2016-07-26 13:55:45 -0700531action("skia.h") {
532 script = "gn/echo_headers.py"
533 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinc095df52016-08-24 12:23:52 -0700534 rebase_path(skia_h_headers, target_gen_dir)
mtklein1211e0c2016-07-26 13:55:45 -0700535 outputs = [
536 "$target_gen_dir/skia.h",
537 ]
538}
539
540executable("fiddle") {
541 include_dirs = [ "$target_gen_dir" ]
mtklein7d10b9f2016-07-27 11:17:18 -0700542 libs = []
543 if (is_linux) {
544 libs += [ "OSMesa" ]
545 }
mtklein1211e0c2016-07-26 13:55:45 -0700546
mtkleinc04ff472016-06-23 10:29:30 -0700547 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700548 "src/images/SkForceLinking.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700549 "tools/fiddle/draw.cpp",
550 "tools/fiddle/fiddle_main.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700551 ]
552 deps = [
553 ":skia",
mtklein1211e0c2016-07-26 13:55:45 -0700554 ":skia.h",
mtkleinc04ff472016-06-23 10:29:30 -0700555 ]
mtkleinc04ff472016-06-23 10:29:30 -0700556}
mtklein25c81d42016-07-27 13:55:26 -0700557
mtkleinc095df52016-08-24 12:23:52 -0700558# Targets guarded by skia_enable_tools may use //third_party freely.
559if (skia_enable_tools) {
560 template("test_lib") {
561 config(target_name + "_config") {
562 include_dirs = invoker.public_include_dirs
mtklein25c81d42016-07-27 13:55:26 -0700563 }
mtkleinc095df52016-08-24 12:23:52 -0700564 source_set(target_name) {
565 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
566 public_configs = [
567 ":" + target_name + "_config",
568 ":skia_private",
569 ]
570
571 if (!defined(deps)) {
572 deps = []
573 }
574 deps += [ ":skia" ]
575 testonly = true
576 }
mtklein25c81d42016-07-27 13:55:26 -0700577 }
mtklein25c81d42016-07-27 13:55:26 -0700578
mtkleinc095df52016-08-24 12:23:52 -0700579 test_lib("gpu_tool_utils") {
580 public_include_dirs = [ "tools/gpu" ]
581 sources = [
582 "tools/gpu/GrContextFactory.cpp",
583 "tools/gpu/GrTest.cpp",
584 "tools/gpu/TestContext.cpp",
585 "tools/gpu/gl/GLTestContext.cpp",
586 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
587 "tools/gpu/gl/debug/GrBufferObj.cpp",
588 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
589 "tools/gpu/gl/debug/GrProgramObj.cpp",
590 "tools/gpu/gl/debug/GrShaderObj.cpp",
591 "tools/gpu/gl/debug/GrTextureObj.cpp",
592 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
593 "tools/gpu/gl/null/NullGLTestContext.cpp",
594 ]
595 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700596
mtklein7d6fb2c2016-08-25 14:50:44 -0700597 if (is_android) {
598 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
599 } else if (is_linux) {
mtkleinc095df52016-08-24 12:23:52 -0700600 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
601 } else if (is_mac) {
602 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
603 }
mtklein25c81d42016-07-27 13:55:26 -0700604 }
mtklein25c81d42016-07-27 13:55:26 -0700605
mtkleinc095df52016-08-24 12:23:52 -0700606 test_lib("flags") {
607 public_include_dirs = [ "tools/flags" ]
608 sources = [
609 "tools/flags/SkCommandLineFlags.cpp",
610 "tools/flags/SkCommonFlags.cpp",
611 "tools/flags/SkCommonFlagsConfig.cpp",
612 ]
613 deps = [
614 ":gpu_tool_utils",
615 ]
616 }
mtklein25c81d42016-07-27 13:55:26 -0700617
mtkleinc095df52016-08-24 12:23:52 -0700618 test_lib("tool_utils") {
619 public_include_dirs = [
620 "tools",
621 "tools/debugger",
622 "tools/timer",
623 ]
624 sources = [
625 "src/images/SkForceLinking.cpp",
626 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700627 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700628 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700629 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700630 "tools/ProcStats.cpp",
631 "tools/Resources.cpp",
632 "tools/ThermalManager.cpp",
633 "tools/UrlDataManager.cpp",
634 "tools/debugger/SkDebugCanvas.cpp",
635 "tools/debugger/SkDrawCommand.cpp",
636 "tools/debugger/SkJsonWriteBuffer.cpp",
637 "tools/debugger/SkObjectParser.cpp",
638 "tools/debugger/SkOverdrawMode.cpp",
639 "tools/picture_utils.cpp",
640 "tools/random_parse_path.cpp",
641 "tools/sk_tool_utils.cpp",
642 "tools/sk_tool_utils_font.cpp",
643 "tools/timer/Timer.cpp",
644 ]
645 deps = [
646 ":flags",
647 "//third_party/libpng",
648 ]
649 public_deps = [
650 "//third_party/jsoncpp",
651 ]
652 }
mtklein25c81d42016-07-27 13:55:26 -0700653
mtkleinc095df52016-08-24 12:23:52 -0700654 gm_sources = exec_script("gyp/find.py",
655 [
656 "*.c*",
657 rebase_path("gm"),
658 ],
659 "list lines",
660 [])
661 test_lib("gm") {
662 public_include_dirs = [ "gm" ]
663 sources = gm_sources
664 deps = [
665 ":gpu_tool_utils",
666 ":skia",
667 ":tool_utils",
668 ]
669 }
mtklein25c81d42016-07-27 13:55:26 -0700670
mtkleinc095df52016-08-24 12:23:52 -0700671 tests_sources = exec_script("gyp/find.py",
672 [
673 "*.c*",
674 rebase_path("tests"),
675 ],
676 "list lines",
677 [])
mtklein2f3416d2016-08-02 16:02:05 -0700678
mtkleinc095df52016-08-24 12:23:52 -0700679 test_lib("tests") {
680 public_include_dirs = [ "tests" ]
mtkleina45be612016-08-29 15:22:10 -0700681 sources = tests_sources - [
682 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
mtkleina45be612016-08-29 15:22:10 -0700683 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
684 rebase_path("tests/skia_test.cpp"), # alternate main
685 ]
686 if (!fontmgr_android_enabled) {
687 sources -= [ rebase_path("tests/FontMgrAndroidParserTest.cpp") ]
688 }
mtkleinc095df52016-08-24 12:23:52 -0700689 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700690 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700691 ":flags",
692 ":gpu_tool_utils",
693 ":skia",
694 ":tool_utils",
695 "//third_party/libpng",
696 "//third_party/zlib",
697 ]
698 }
mtklein2f3416d2016-08-02 16:02:05 -0700699
mtkleinc095df52016-08-24 12:23:52 -0700700 bench_sources = exec_script("gyp/find.py",
701 [
702 "*.c*",
703 rebase_path("bench"),
704 ],
705 "list lines",
706 [])
mtklein25c81d42016-07-27 13:55:26 -0700707
mtkleinc095df52016-08-24 12:23:52 -0700708 test_lib("bench") {
709 public_include_dirs = [ "bench" ]
710 sources = bench_sources
711 sources -= [
712 rebase_path("bench/nanobench.cpp"),
713 rebase_path("bench/nanobenchAndroid.cpp"),
714 ]
715 deps = [
716 ":flags",
717 ":gm",
718 ":gpu_tool_utils",
719 ":skia",
720 ":tool_utils",
721 ]
722 }
mtklein2b6870c2016-07-28 14:17:33 -0700723
mtkleinc095df52016-08-24 12:23:52 -0700724 test_lib("experimental_svg_model") {
725 public_include_dirs = [ "experimental/svg/model" ]
726 sources = [
727 "experimental/svg/model/SkSVGAttribute.cpp",
728 "experimental/svg/model/SkSVGAttributeParser.cpp",
729 "experimental/svg/model/SkSVGCircle.cpp",
730 "experimental/svg/model/SkSVGContainer.cpp",
731 "experimental/svg/model/SkSVGDOM.cpp",
732 "experimental/svg/model/SkSVGEllipse.cpp",
733 "experimental/svg/model/SkSVGLine.cpp",
734 "experimental/svg/model/SkSVGNode.cpp",
735 "experimental/svg/model/SkSVGPath.cpp",
736 "experimental/svg/model/SkSVGPoly.cpp",
737 "experimental/svg/model/SkSVGRect.cpp",
738 "experimental/svg/model/SkSVGRenderContext.cpp",
739 "experimental/svg/model/SkSVGSVG.cpp",
740 "experimental/svg/model/SkSVGShape.cpp",
741 "experimental/svg/model/SkSVGTransformableNode.cpp",
742 "experimental/svg/model/SkSVGValue.cpp",
743 ]
744 deps = [
745 ":skia",
746 ]
747 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700748
mtklein2b6870c2016-07-28 14:17:33 -0700749 executable("dm") {
750 sources = [
751 "dm/DM.cpp",
752 "dm/DMJsonWriter.cpp",
753 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700754 ]
755 include_dirs = [ "tests" ]
756 deps = [
fmalitaa2b9fdf2016-08-03 19:53:36 -0700757 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700758 ":flags",
759 ":gm",
760 ":gpu_tool_utils",
761 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700762 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700763 ":tool_utils",
764 "//third_party/jsoncpp",
765 "//third_party/libpng",
766 ]
767 testonly = true
768 }
769
770 executable("monobench") {
771 sources = [
772 "tools/monobench.cpp",
773 ]
774 deps = [
775 ":bench",
776 ":skia",
777 ]
778 testonly = true
779 }
780
781 executable("nanobench") {
782 sources = [
783 "bench/nanobench.cpp",
784 ]
785 deps = [
786 ":bench",
787 ":flags",
788 ":gm",
789 ":gpu_tool_utils",
790 ":skia",
791 ":tool_utils",
792 "//third_party/jsoncpp",
793 ]
794 testonly = true
795 }
halcanary19a97202016-08-03 15:08:04 -0700796
mtklein6f5df6a2016-08-29 16:01:10 -0700797 if (current_cpu != "mipsel") { # Clang 3.8 crashes while compiling hb-icu.cc for mipsel.
halcanary3eee9d92016-09-10 07:01:53 -0700798 executable("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -0700799 sources = [
800 "tools/SkShaper_harfbuzz.cpp",
801 "tools/using_skia_and_harfbuzz.cpp",
802 ]
803 deps = [
804 ":skia",
805 "//third_party/harfbuzz",
806 ]
807 testonly = true
808 }
halcanary19a97202016-08-03 15:08:04 -0700809 }
halcanary3eee9d92016-09-10 07:01:53 -0700810 executable("sktexttopdf") {
811 sources = [
812 "tools/SkShaper_primitive.cpp",
813 "tools/using_skia_and_harfbuzz.cpp",
814 ]
815 deps = [
816 ":skia",
817 ]
818 testonly = true
819 }
mtklein25c81d42016-07-27 13:55:26 -0700820}