blob: f1439c7857253515868d76665385449977c9f35f [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
13 skia_use_freetype = is_android || 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
mtklein457b42a2016-08-23 13:56:37 -0700261optional("gif") {
262 enabled = skia_use_giflib
263 public_defines = [ "SK_HAS_GIF_LIBRARY" ]
264
mtklein457b42a2016-08-23 13:56:37 -0700265 deps = [
266 "//third_party/giflib",
267 ]
268 sources = [
269 "src/codec/SkGifCodec.cpp",
270 ]
271}
272
mtklein63213812016-08-24 09:55:56 -0700273optional("jpeg") {
274 enabled = skia_use_libjpeg_turbo
275 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
276
mtklein63213812016-08-24 09:55:56 -0700277 deps = [
278 "//third_party/libjpeg-turbo:libjpeg",
279 ]
280 sources = [
281 "src/codec/SkJpegCodec.cpp",
282 "src/codec/SkJpegDecoderMgr.cpp",
283 "src/codec/SkJpegUtility.cpp",
284 "src/images/SkJPEGImageEncoder.cpp",
285 "src/images/SkJPEGWriteUtility.cpp",
286 ]
287}
288
289optional("pdf") {
290 enabled = skia_use_zlib
mtklein63213812016-08-24 09:55:56 -0700291
mtklein63213812016-08-24 09:55:56 -0700292 deps = [
293 "//third_party/zlib",
294 ]
brettwb9447282016-09-01 14:24:39 -0700295 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700296 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700297
298 if (skia_use_sfntly) {
299 deps += [ "//third_party/sfntly" ]
mtkleincd01b032016-08-31 04:58:19 -0700300 public_defines = [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700301 }
302}
303
304optional("png") {
305 enabled = skia_use_libpng
306 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
307
mtklein63213812016-08-24 09:55:56 -0700308 deps = [
309 "//third_party/libpng",
310 ]
311 sources = [
312 "src/codec/SkIcoCodec.cpp",
313 "src/codec/SkPngCodec.cpp",
314 "src/images/SkPNGImageEncoder.cpp",
315 ]
316}
317
mtklein3cc22182016-08-29 13:26:14 -0700318optional("typeface_freetype") {
319 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700320
321 deps = [
322 "//third_party/freetype2",
323 ]
324 sources = [
325 "src/ports/SkFontHost_FreeType.cpp",
326 "src/ports/SkFontHost_FreeType_common.cpp",
327 ]
328}
329
mtklein457b42a2016-08-23 13:56:37 -0700330optional("webp") {
331 enabled = skia_use_libwebp
332 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
333
mtklein457b42a2016-08-23 13:56:37 -0700334 deps = [
335 "//third_party/libwebp",
336 ]
337 sources = [
338 "src/codec/SkWebpAdapterCodec.cpp",
339 "src/codec/SkWebpCodec.cpp",
340 "src/images/SkWEBPImageEncoder.cpp",
341 ]
mtkleineb3c4252016-08-23 07:38:09 -0700342}
343
mtklein63213812016-08-24 09:55:56 -0700344optional("xml") {
345 enabled = skia_use_expat
mtklein63213812016-08-24 09:55:56 -0700346
mtklein63213812016-08-24 09:55:56 -0700347 deps = [
348 "//third_party/expat",
349 ]
350 sources = [
351 "src/xml/SkDOM.cpp",
352 "src/xml/SkXMLParser.cpp",
353 "src/xml/SkXMLWriter.cpp",
354 ]
355}
356
mtkleinc04ff472016-06-23 10:29:30 -0700357component("skia") {
358 public_configs = [ ":skia_public" ]
359 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700360
361 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700362 ":arm64",
363 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700364 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700365 ":crc32",
mtklein349cece2016-08-26 08:13:04 -0700366 ":dsp",
mtkleina45be612016-08-29 15:22:10 -0700367 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700368 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700369 ":fontmgr_fontconfig",
mtklein457b42a2016-08-23 13:56:37 -0700370 ":gif",
mtklein63213812016-08-24 09:55:56 -0700371 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700372 ":none",
mtklein63213812016-08-24 09:55:56 -0700373 ":pdf",
374 ":png",
mtklein9b8583d2016-08-24 17:32:30 -0700375 ":sse2",
376 ":sse41",
377 ":sse42",
378 ":ssse3",
mtklein3cc22182016-08-29 13:26:14 -0700379 ":typeface_freetype",
mtkleineb3c4252016-08-23 07:38:09 -0700380 ":webp",
mtklein63213812016-08-24 09:55:56 -0700381 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700382 ]
383
mtkleinc04ff472016-06-23 10:29:30 -0700384 sources = []
brettwb9447282016-09-01 14:24:39 -0700385 sources += skia_core_sources
386 sources += skia_effects_sources
387 sources += skia_gpu_sources
388 sources += skia_sksl_sources
389 sources += skia_utils_sources
mtkleinc04ff472016-06-23 10:29:30 -0700390 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700391 "src/android/SkBitmapRegionCodec.cpp",
392 "src/android/SkBitmapRegionDecoder.cpp",
393 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700394 "src/codec/SkBmpCodec.cpp",
395 "src/codec/SkBmpMaskCodec.cpp",
396 "src/codec/SkBmpRLECodec.cpp",
397 "src/codec/SkBmpStandardCodec.cpp",
398 "src/codec/SkCodec.cpp",
399 "src/codec/SkCodecImageGenerator.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700400 "src/codec/SkMaskSwizzler.cpp",
401 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700402 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700403 "src/codec/SkSampler.cpp",
404 "src/codec/SkSwizzler.cpp",
405 "src/codec/SkWbmpCodec.cpp",
mtklein09e61f72016-08-23 13:35:28 -0700406 "src/gpu/gl/GrGLDefaultInterface_native.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700407 "src/images/SkImageEncoder.cpp",
408 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700409 "src/images/SkKTXImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700410 "src/ports/SkDiscardableMemory_none.cpp",
411 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700412 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700413 "src/ports/SkMemory_malloc.cpp",
414 "src/ports/SkOSFile_stdio.cpp",
415 "src/sfnt/SkOTTable_name.cpp",
416 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700417 "src/svg/SkSVGCanvas.cpp",
418 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700419 "src/utils/mac/SkStream_mac.cpp",
420 "third_party/etc1/etc1.cpp",
421 "third_party/ktx/ktx.cpp",
422 ]
brettwb9447282016-09-01 14:24:39 -0700423
424 # These paths need to be absolute to match the ones produced by
425 # shared_sources.gni, but this file may be used from different directory
426 # locations.
427 sources -= get_path_info([
428 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
429 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
430 ],
431 "abspath")
mtkleinc04ff472016-06-23 10:29:30 -0700432
mtklein7d6fb2c2016-08-25 14:50:44 -0700433 libs = []
434
mtkleinc04ff472016-06-23 10:29:30 -0700435 if (is_win) {
436 sources += [
437 "src/ports/SkDebug_win.cpp",
438 "src/ports/SkFontHost_win.cpp",
439 "src/ports/SkFontMgr_win_dw.cpp",
440 "src/ports/SkFontMgr_win_dw_factory.cpp",
441 "src/ports/SkImageEncoder_WIC.cpp",
442 "src/ports/SkImageGeneratorWIC.cpp",
443 "src/ports/SkOSFile_win.cpp",
444 "src/ports/SkScalerContext_win_dw.cpp",
445 "src/ports/SkTLS_win.cpp",
446 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700447 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700448 ]
mtklein7a1f45f2016-08-04 06:19:33 -0700449 sources -= [ "src/utils/SkThreadUtils_pthread.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700450 } else {
451 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700452 "src/ports/SkOSFile_posix.cpp",
453 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700454 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700455 ]
456 }
457
mtklein7d6fb2c2016-08-25 14:50:44 -0700458 if (is_android) {
459 deps += [
460 "//third_party/cpu-features",
461 "//third_party/expat",
mtklein7d6fb2c2016-08-25 14:50:44 -0700462 ]
463 sources += [
464 "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp",
465 "src/ports/SkDebug_android.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700466 ]
467 libs += [
468 "EGL",
469 "GLESv2",
470 "log",
471 ]
472 }
473
mtkleinc04ff472016-06-23 10:29:30 -0700474 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700475 libs += [
476 "GL",
477 "GLU",
478 "X11",
479 ]
mtkleinc04ff472016-06-23 10:29:30 -0700480 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700481 "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700482 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700483 ]
484 }
485
486 if (is_mac) {
487 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700488 "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700489 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700490 "src/ports/SkFontHost_mac.cpp",
491 "src/ports/SkImageEncoder_CG.cpp",
492 "src/ports/SkImageGeneratorCG.cpp",
493 ]
mtklein09e61f72016-08-23 13:35:28 -0700494 libs += [
495 "ApplicationServices.framework",
496 "OpenGL.framework",
497 ]
mtkleinc04ff472016-06-23 10:29:30 -0700498 }
abarth6fc8ff02016-07-15 15:15:15 -0700499
500 if (is_fuchsia) {
mtklein2ff47c22016-08-24 10:27:13 -0700501 sources += [
502 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700503 "src/ports/SkDebug_stdio.cpp",
mtklein2ff47c22016-08-24 10:27:13 -0700504 "src/ports/SkFontMgr_empty_factory.cpp",
505 ]
abarth6fc8ff02016-07-15 15:15:15 -0700506 }
mtkleinc04ff472016-06-23 10:29:30 -0700507}
508
mtkleinada5a442016-08-02 14:28:26 -0700509skia_h_headers = exec_script("gyp/find.py",
510 [ "*.h" ] + rebase_path(skia_public_includes),
511 "list lines",
512 []) -
513 [
514 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
515 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
516 rebase_path("include/gpu/vk/GrVkDefines.h"),
517 rebase_path("include/gpu/vk/GrVkInterface.h"),
518 rebase_path("include/gpu/vk/GrVkTypes.h"),
519 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
520 ]
521
mtklein1211e0c2016-07-26 13:55:45 -0700522action("skia.h") {
523 script = "gn/echo_headers.py"
524 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinc095df52016-08-24 12:23:52 -0700525 rebase_path(skia_h_headers, target_gen_dir)
mtklein1211e0c2016-07-26 13:55:45 -0700526 outputs = [
527 "$target_gen_dir/skia.h",
528 ]
529}
530
531executable("fiddle") {
532 include_dirs = [ "$target_gen_dir" ]
mtklein7d10b9f2016-07-27 11:17:18 -0700533 libs = []
534 if (is_linux) {
535 libs += [ "OSMesa" ]
536 }
mtklein1211e0c2016-07-26 13:55:45 -0700537
mtkleinc04ff472016-06-23 10:29:30 -0700538 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700539 "src/images/SkForceLinking.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700540 "tools/fiddle/draw.cpp",
541 "tools/fiddle/fiddle_main.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700542 ]
543 deps = [
544 ":skia",
mtklein1211e0c2016-07-26 13:55:45 -0700545 ":skia.h",
mtkleinc04ff472016-06-23 10:29:30 -0700546 ]
mtkleinc04ff472016-06-23 10:29:30 -0700547}
mtklein25c81d42016-07-27 13:55:26 -0700548
mtkleinc095df52016-08-24 12:23:52 -0700549# Targets guarded by skia_enable_tools may use //third_party freely.
550if (skia_enable_tools) {
551 template("test_lib") {
552 config(target_name + "_config") {
553 include_dirs = invoker.public_include_dirs
mtklein25c81d42016-07-27 13:55:26 -0700554 }
mtkleinc095df52016-08-24 12:23:52 -0700555 source_set(target_name) {
556 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
557 public_configs = [
558 ":" + target_name + "_config",
559 ":skia_private",
560 ]
561
562 if (!defined(deps)) {
563 deps = []
564 }
565 deps += [ ":skia" ]
566 testonly = true
567 }
mtklein25c81d42016-07-27 13:55:26 -0700568 }
mtklein25c81d42016-07-27 13:55:26 -0700569
mtkleinc095df52016-08-24 12:23:52 -0700570 test_lib("gpu_tool_utils") {
571 public_include_dirs = [ "tools/gpu" ]
572 sources = [
573 "tools/gpu/GrContextFactory.cpp",
574 "tools/gpu/GrTest.cpp",
575 "tools/gpu/TestContext.cpp",
576 "tools/gpu/gl/GLTestContext.cpp",
577 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
578 "tools/gpu/gl/debug/GrBufferObj.cpp",
579 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
580 "tools/gpu/gl/debug/GrProgramObj.cpp",
581 "tools/gpu/gl/debug/GrShaderObj.cpp",
582 "tools/gpu/gl/debug/GrTextureObj.cpp",
583 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
584 "tools/gpu/gl/null/NullGLTestContext.cpp",
585 ]
586 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700587
mtklein7d6fb2c2016-08-25 14:50:44 -0700588 if (is_android) {
589 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
590 } else if (is_linux) {
mtkleinc095df52016-08-24 12:23:52 -0700591 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
592 } else if (is_mac) {
593 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
594 }
mtklein25c81d42016-07-27 13:55:26 -0700595 }
mtklein25c81d42016-07-27 13:55:26 -0700596
mtkleinc095df52016-08-24 12:23:52 -0700597 test_lib("flags") {
598 public_include_dirs = [ "tools/flags" ]
599 sources = [
600 "tools/flags/SkCommandLineFlags.cpp",
601 "tools/flags/SkCommonFlags.cpp",
602 "tools/flags/SkCommonFlagsConfig.cpp",
603 ]
604 deps = [
605 ":gpu_tool_utils",
606 ]
607 }
mtklein25c81d42016-07-27 13:55:26 -0700608
mtkleinc095df52016-08-24 12:23:52 -0700609 test_lib("tool_utils") {
610 public_include_dirs = [
611 "tools",
612 "tools/debugger",
613 "tools/timer",
614 ]
615 sources = [
616 "src/images/SkForceLinking.cpp",
617 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700618 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700619 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700620 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700621 "tools/ProcStats.cpp",
622 "tools/Resources.cpp",
623 "tools/ThermalManager.cpp",
624 "tools/UrlDataManager.cpp",
625 "tools/debugger/SkDebugCanvas.cpp",
626 "tools/debugger/SkDrawCommand.cpp",
627 "tools/debugger/SkJsonWriteBuffer.cpp",
628 "tools/debugger/SkObjectParser.cpp",
629 "tools/debugger/SkOverdrawMode.cpp",
630 "tools/picture_utils.cpp",
631 "tools/random_parse_path.cpp",
632 "tools/sk_tool_utils.cpp",
633 "tools/sk_tool_utils_font.cpp",
634 "tools/timer/Timer.cpp",
635 ]
636 deps = [
637 ":flags",
638 "//third_party/libpng",
639 ]
640 public_deps = [
641 "//third_party/jsoncpp",
642 ]
643 }
mtklein25c81d42016-07-27 13:55:26 -0700644
mtkleinc095df52016-08-24 12:23:52 -0700645 gm_sources = exec_script("gyp/find.py",
646 [
647 "*.c*",
648 rebase_path("gm"),
649 ],
650 "list lines",
651 [])
652 test_lib("gm") {
653 public_include_dirs = [ "gm" ]
654 sources = gm_sources
655 deps = [
656 ":gpu_tool_utils",
657 ":skia",
658 ":tool_utils",
659 ]
660 }
mtklein25c81d42016-07-27 13:55:26 -0700661
mtkleinc095df52016-08-24 12:23:52 -0700662 tests_sources = exec_script("gyp/find.py",
663 [
664 "*.c*",
665 rebase_path("tests"),
666 ],
667 "list lines",
668 [])
mtklein2f3416d2016-08-02 16:02:05 -0700669
mtkleinc095df52016-08-24 12:23:52 -0700670 test_lib("tests") {
671 public_include_dirs = [ "tests" ]
mtkleina45be612016-08-29 15:22:10 -0700672 sources = tests_sources - [
673 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
mtkleina45be612016-08-29 15:22:10 -0700674 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
675 rebase_path("tests/skia_test.cpp"), # alternate main
676 ]
677 if (!fontmgr_android_enabled) {
678 sources -= [ rebase_path("tests/FontMgrAndroidParserTest.cpp") ]
679 }
mtkleinc095df52016-08-24 12:23:52 -0700680 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700681 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700682 ":flags",
683 ":gpu_tool_utils",
684 ":skia",
685 ":tool_utils",
686 "//third_party/libpng",
687 "//third_party/zlib",
688 ]
689 }
mtklein2f3416d2016-08-02 16:02:05 -0700690
mtkleinc095df52016-08-24 12:23:52 -0700691 bench_sources = exec_script("gyp/find.py",
692 [
693 "*.c*",
694 rebase_path("bench"),
695 ],
696 "list lines",
697 [])
mtklein25c81d42016-07-27 13:55:26 -0700698
mtkleinc095df52016-08-24 12:23:52 -0700699 test_lib("bench") {
700 public_include_dirs = [ "bench" ]
701 sources = bench_sources
702 sources -= [
703 rebase_path("bench/nanobench.cpp"),
704 rebase_path("bench/nanobenchAndroid.cpp"),
705 ]
706 deps = [
707 ":flags",
708 ":gm",
709 ":gpu_tool_utils",
710 ":skia",
711 ":tool_utils",
712 ]
713 }
mtklein2b6870c2016-07-28 14:17:33 -0700714
mtkleinc095df52016-08-24 12:23:52 -0700715 test_lib("experimental_svg_model") {
716 public_include_dirs = [ "experimental/svg/model" ]
717 sources = [
718 "experimental/svg/model/SkSVGAttribute.cpp",
719 "experimental/svg/model/SkSVGAttributeParser.cpp",
720 "experimental/svg/model/SkSVGCircle.cpp",
721 "experimental/svg/model/SkSVGContainer.cpp",
722 "experimental/svg/model/SkSVGDOM.cpp",
723 "experimental/svg/model/SkSVGEllipse.cpp",
724 "experimental/svg/model/SkSVGLine.cpp",
725 "experimental/svg/model/SkSVGNode.cpp",
726 "experimental/svg/model/SkSVGPath.cpp",
727 "experimental/svg/model/SkSVGPoly.cpp",
728 "experimental/svg/model/SkSVGRect.cpp",
729 "experimental/svg/model/SkSVGRenderContext.cpp",
730 "experimental/svg/model/SkSVGSVG.cpp",
731 "experimental/svg/model/SkSVGShape.cpp",
732 "experimental/svg/model/SkSVGTransformableNode.cpp",
733 "experimental/svg/model/SkSVGValue.cpp",
734 ]
735 deps = [
736 ":skia",
737 ]
738 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700739
mtklein2b6870c2016-07-28 14:17:33 -0700740 executable("dm") {
741 sources = [
742 "dm/DM.cpp",
743 "dm/DMJsonWriter.cpp",
744 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700745 ]
746 include_dirs = [ "tests" ]
747 deps = [
fmalitaa2b9fdf2016-08-03 19:53:36 -0700748 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700749 ":flags",
750 ":gm",
751 ":gpu_tool_utils",
752 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700753 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700754 ":tool_utils",
755 "//third_party/jsoncpp",
756 "//third_party/libpng",
757 ]
758 testonly = true
759 }
760
761 executable("monobench") {
762 sources = [
763 "tools/monobench.cpp",
764 ]
765 deps = [
766 ":bench",
767 ":skia",
768 ]
769 testonly = true
770 }
771
772 executable("nanobench") {
773 sources = [
774 "bench/nanobench.cpp",
775 ]
776 deps = [
777 ":bench",
778 ":flags",
779 ":gm",
780 ":gpu_tool_utils",
781 ":skia",
782 ":tool_utils",
783 "//third_party/jsoncpp",
784 ]
785 testonly = true
786 }
halcanary19a97202016-08-03 15:08:04 -0700787
mtklein6f5df6a2016-08-29 16:01:10 -0700788 if (current_cpu != "mipsel") { # Clang 3.8 crashes while compiling hb-icu.cc for mipsel.
789 executable("sktexttopdf") {
790 sources = [
791 "tools/SkShaper_harfbuzz.cpp",
792 "tools/using_skia_and_harfbuzz.cpp",
793 ]
794 deps = [
795 ":skia",
796 "//third_party/harfbuzz",
797 ]
798 testonly = true
799 }
halcanary19a97202016-08-03 15:08:04 -0700800 }
mtklein25c81d42016-07-27 13:55:26 -0700801}