blob: 8d53e51f2a8aa342bf4f8add4896dcf64b37cd75 [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
mtklein6ef69992016-09-14 06:12:09 -070019 skia_use_vulkan = false
mtklein63213812016-08-24 09:55:56 -070020 skia_use_zlib = true
mtkleinc04ff472016-06-23 10:29:30 -070021}
22
mtkleina45be612016-08-29 15:22:10 -070023fontmgr_android_enabled = skia_use_expat && skia_use_freetype
24
mtklein1211e0c2016-07-26 13:55:45 -070025skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070026 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070027 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070028 "include/codec",
29 "include/config",
30 "include/core",
31 "include/effects",
32 "include/gpu",
33 "include/gpu/gl",
34 "include/images",
35 "include/pathops",
36 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070037 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070038 "include/utils",
39 "include/utils/mac",
mtklein25c81d42016-07-27 13:55:26 -070040 "include/xml",
mtklein1211e0c2016-07-26 13:55:45 -070041]
42
mtkleinc04ff472016-06-23 10:29:30 -070043# Skia public API, generally provided by :skia.
44config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -070045 include_dirs = skia_public_includes
mtkleinc04ff472016-06-23 10:29:30 -070046 defines = [ "SKIA_DLL" ]
jcgregorio5561e3d2016-08-25 09:25:11 -070047 if (is_linux) {
48 defines += [ "SK_SAMPLES_FOR_X" ]
49 }
mtkleinc04ff472016-06-23 10:29:30 -070050}
51
52# Skia internal APIs, used by Skia itself and a few test tools.
53config("skia_private") {
54 visibility = [ ":*" ]
55
56 include_dirs = [
57 "include/private",
58 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -070059 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -070060 "src/config",
61 "src/core",
62 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -070063 "src/effects/gradients",
64 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -070065 "src/gpu",
66 "src/image",
67 "src/images",
68 "src/lazy",
69 "src/opts",
70 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -070071 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -070072 "src/ports",
73 "src/sfnt",
mtklein9e0d9dd2016-08-30 10:37:19 -070074 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -070075 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -070076 "src/utils/win",
mtkleinc04ff472016-06-23 10:29:30 -070077 "third_party/etc1",
78 "third_party/ktx",
79 ]
mtklein150d1132016-08-01 06:56:40 -070080
mtklein63213812016-08-24 09:55:56 -070081 defines = [ "SK_GAMMA_APPLY_TO_A8" ]
mtkleinb37c0342016-09-09 11:07:45 -070082 if (is_android) {
83 defines += [
84 "SK_GAMMA_EXPONENT=1.4",
85 "SK_GAMMA_CONTRAST=0.0",
86 ]
87 }
mtkleinc04ff472016-06-23 10:29:30 -070088}
89
90# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
91config("skia_library") {
92 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -070093 defines = [ "SKIA_IMPLEMENTATION=1" ]
94}
95
96skia_library_configs = [
97 ":skia_public",
98 ":skia_private",
99 ":skia_library",
100]
101
mtklein9b8583d2016-08-24 17:32:30 -0700102# Use for CPU-specific Skia code that needs particular compiler flags.
103template("opts") {
104 if (invoker.enabled) {
105 source_set(target_name) {
106 forward_variables_from(invoker, "*")
107 configs += skia_library_configs
108 }
109 } else {
110 # If not enabled, a phony empty target that swallows all otherwise unused variables.
111 source_set(target_name) {
112 forward_variables_from(invoker,
113 "*",
114 [
115 "sources",
116 "cflags",
117 ])
118 }
119 }
anmittala7eaf2e2016-08-17 13:57:26 -0700120}
121
mtklein422310d2016-08-16 18:28:43 -0700122is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700123
mtklein7d6fb2c2016-08-25 14:50:44 -0700124opts("none") {
125 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700126 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700127 cflags = []
128}
129
mtklein7d6fb2c2016-08-25 14:50:44 -0700130opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700131 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700132 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700133 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700134}
135
136opts("arm64") {
137 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700138 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700139 cflags = []
140}
141
142opts("crc32") {
143 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700144 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700145 cflags = [ "-march=armv8-a+crc" ]
146}
147
mtklein9b8583d2016-08-24 17:32:30 -0700148opts("sse2") {
149 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700150 sources = skia_opts.sse2_sources
mtklein9b8583d2016-08-24 17:32:30 -0700151 cflags = [ "-msse2" ]
152}
mtkleinc04ff472016-06-23 10:29:30 -0700153
mtklein9b8583d2016-08-24 17:32:30 -0700154opts("ssse3") {
155 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700156 sources = skia_opts.ssse3_sources
mtklein9b8583d2016-08-24 17:32:30 -0700157 cflags = [ "-mssse3" ]
158}
mtkleinc04ff472016-06-23 10:29:30 -0700159
mtklein9b8583d2016-08-24 17:32:30 -0700160opts("sse41") {
161 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700162 sources = skia_opts.sse41_sources
mtklein9b8583d2016-08-24 17:32:30 -0700163 cflags = [ "-msse4.1" ]
164}
mtklein4e976072016-08-08 09:06:27 -0700165
mtklein9b8583d2016-08-24 17:32:30 -0700166opts("sse42") {
167 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700168 sources = skia_opts.sse42_sources
mtklein9b8583d2016-08-24 17:32:30 -0700169 cflags = [ "-msse4.2" ]
170}
171
172opts("avx") {
173 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700174 sources = skia_opts.avx_sources
mtklein9b8583d2016-08-24 17:32:30 -0700175 cflags = [ "-mavx" ]
mtkleinc04ff472016-06-23 10:29:30 -0700176}
177
mtklein349cece2016-08-26 08:13:04 -0700178opts("dsp") {
179 enabled = current_cpu == "mipsel"
brettwb9447282016-09-01 14:24:39 -0700180 sources = skia_opts.mips_dsp_sources
mtkleinb6064ef2016-08-30 11:49:24 -0700181 cflags = []
mtklein349cece2016-08-26 08:13:04 -0700182}
183
mtkleinc095df52016-08-24 12:23:52 -0700184# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700185template("optional") {
186 if (invoker.enabled) {
187 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700188 if (defined(invoker.public_defines)) {
189 defines = invoker.public_defines
190 }
mtklein457b42a2016-08-23 13:56:37 -0700191 }
192 source_set(target_name) {
mtkleincd01b032016-08-31 04:58:19 -0700193 forward_variables_from(invoker,
194 "*",
195 [
196 "public_defines",
197 "sources_when_disabled",
198 ])
mtklein457b42a2016-08-23 13:56:37 -0700199 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700200 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700201 }
202 } else {
mtklein457b42a2016-08-23 13:56:37 -0700203 source_set(target_name) {
204 forward_variables_from(invoker,
205 "*",
206 [
207 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700208 "deps",
mtklein6ef69992016-09-14 06:12:09 -0700209 "libs",
mtklein457b42a2016-08-23 13:56:37 -0700210 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700211 "sources_when_disabled",
mtklein457b42a2016-08-23 13:56:37 -0700212 ])
mtkleincd01b032016-08-31 04:58:19 -0700213 if (defined(invoker.sources_when_disabled)) {
214 sources = invoker.sources_when_disabled
215 }
216 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700217 }
mtkleineb3c4252016-08-23 07:38:09 -0700218 }
mtklein457b42a2016-08-23 13:56:37 -0700219}
mtklein457b42a2016-08-23 13:56:37 -0700220
mtkleina45be612016-08-29 15:22:10 -0700221optional("fontmgr_android") {
222 enabled = fontmgr_android_enabled
mtkleina45be612016-08-29 15:22:10 -0700223
224 deps = [
225 "//third_party/expat",
226 "//third_party/freetype2",
227 ]
228 sources = [
229 "src/ports/SkFontMgr_android.cpp",
230 "src/ports/SkFontMgr_android_factory.cpp",
231 "src/ports/SkFontMgr_android_parser.cpp",
232 ]
233}
234
mtkleind2e39db2016-09-07 07:52:55 -0700235optional("fontmgr_custom") {
236 enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
237
238 deps = [
239 "//third_party/freetype2",
240 ]
241 sources = [
242 "src/ports/SkFontMgr_custom.cpp",
243 "src/ports/SkFontMgr_custom_directory_factory.cpp",
244 ]
245}
246
mtklein3cc22182016-08-29 13:26:14 -0700247optional("fontmgr_fontconfig") {
248 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700249
250 deps = [
251 "//third_party:fontconfig",
252 "//third_party/freetype2",
253 ]
254 sources = [
255 "src/ports/SkFontConfigInterface_direct.cpp",
256 "src/ports/SkFontConfigInterface_direct_factory.cpp",
257 "src/ports/SkFontMgr_FontConfigInterface.cpp",
258 "src/ports/SkFontMgr_fontconfig.cpp",
259 "src/ports/SkFontMgr_fontconfig_factory.cpp",
260 ]
261}
262
mtkleincdedd0e2016-09-12 15:15:44 -0700263optional("fontmgr_fuchsia") {
264 enabled = is_fuchsia && skia_use_freetype
265
266 deps = [
267 "//third_party/freetype2",
268 ]
269 sources = [
270 "src/ports/SkFontMgr_custom.cpp",
271 "src/ports/SkFontMgr_custom_empty_factory.cpp",
272 ]
273}
274
mtklein457b42a2016-08-23 13:56:37 -0700275optional("gif") {
276 enabled = skia_use_giflib
277 public_defines = [ "SK_HAS_GIF_LIBRARY" ]
278
mtklein457b42a2016-08-23 13:56:37 -0700279 deps = [
280 "//third_party/giflib",
281 ]
282 sources = [
283 "src/codec/SkGifCodec.cpp",
284 ]
285}
286
mtklein63213812016-08-24 09:55:56 -0700287optional("jpeg") {
288 enabled = skia_use_libjpeg_turbo
289 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
290
mtklein63213812016-08-24 09:55:56 -0700291 deps = [
292 "//third_party/libjpeg-turbo:libjpeg",
293 ]
294 sources = [
295 "src/codec/SkJpegCodec.cpp",
296 "src/codec/SkJpegDecoderMgr.cpp",
297 "src/codec/SkJpegUtility.cpp",
298 "src/images/SkJPEGImageEncoder.cpp",
299 "src/images/SkJPEGWriteUtility.cpp",
300 ]
301}
302
303optional("pdf") {
304 enabled = skia_use_zlib
mtklein63213812016-08-24 09:55:56 -0700305
mtklein63213812016-08-24 09:55:56 -0700306 deps = [
307 "//third_party/zlib",
308 ]
brettwb9447282016-09-01 14:24:39 -0700309 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700310 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700311
312 if (skia_use_sfntly) {
313 deps += [ "//third_party/sfntly" ]
mtkleincd01b032016-08-31 04:58:19 -0700314 public_defines = [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700315 }
316}
317
318optional("png") {
319 enabled = skia_use_libpng
320 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
321
mtklein63213812016-08-24 09:55:56 -0700322 deps = [
323 "//third_party/libpng",
324 ]
325 sources = [
326 "src/codec/SkIcoCodec.cpp",
327 "src/codec/SkPngCodec.cpp",
328 "src/images/SkPNGImageEncoder.cpp",
329 ]
330}
331
mtklein3cc22182016-08-29 13:26:14 -0700332optional("typeface_freetype") {
333 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700334
335 deps = [
336 "//third_party/freetype2",
337 ]
338 sources = [
339 "src/ports/SkFontHost_FreeType.cpp",
340 "src/ports/SkFontHost_FreeType_common.cpp",
341 ]
342}
343
mtklein6ef69992016-09-14 06:12:09 -0700344optional("vulkan") {
345 enabled = skia_use_vulkan
346 public_defines = [ "SK_VULKAN" ]
347 libs = [ "vulkan" ]
348 sources = skia_vk_sources
349}
350
mtklein457b42a2016-08-23 13:56:37 -0700351optional("webp") {
352 enabled = skia_use_libwebp
353 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
354
mtklein457b42a2016-08-23 13:56:37 -0700355 deps = [
356 "//third_party/libwebp",
357 ]
358 sources = [
359 "src/codec/SkWebpAdapterCodec.cpp",
360 "src/codec/SkWebpCodec.cpp",
361 "src/images/SkWEBPImageEncoder.cpp",
362 ]
mtkleineb3c4252016-08-23 07:38:09 -0700363}
364
mtklein63213812016-08-24 09:55:56 -0700365optional("xml") {
366 enabled = skia_use_expat
mtklein63213812016-08-24 09:55:56 -0700367
mtklein63213812016-08-24 09:55:56 -0700368 deps = [
369 "//third_party/expat",
370 ]
371 sources = [
372 "src/xml/SkDOM.cpp",
373 "src/xml/SkXMLParser.cpp",
374 "src/xml/SkXMLWriter.cpp",
375 ]
376}
377
mtkleinc04ff472016-06-23 10:29:30 -0700378component("skia") {
379 public_configs = [ ":skia_public" ]
380 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700381
382 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700383 ":arm64",
384 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700385 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700386 ":crc32",
mtklein349cece2016-08-26 08:13:04 -0700387 ":dsp",
mtkleina45be612016-08-29 15:22:10 -0700388 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700389 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700390 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700391 ":fontmgr_fuchsia",
mtklein457b42a2016-08-23 13:56:37 -0700392 ":gif",
mtklein63213812016-08-24 09:55:56 -0700393 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700394 ":none",
mtklein63213812016-08-24 09:55:56 -0700395 ":pdf",
396 ":png",
mtklein9b8583d2016-08-24 17:32:30 -0700397 ":sse2",
398 ":sse41",
399 ":sse42",
400 ":ssse3",
mtklein3cc22182016-08-29 13:26:14 -0700401 ":typeface_freetype",
mtklein6ef69992016-09-14 06:12:09 -0700402 ":vulkan",
mtkleineb3c4252016-08-23 07:38:09 -0700403 ":webp",
mtklein63213812016-08-24 09:55:56 -0700404 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700405 ]
406
mtkleinc04ff472016-06-23 10:29:30 -0700407 sources = []
brettwb9447282016-09-01 14:24:39 -0700408 sources += skia_core_sources
409 sources += skia_effects_sources
410 sources += skia_gpu_sources
411 sources += skia_sksl_sources
412 sources += skia_utils_sources
mtkleinc04ff472016-06-23 10:29:30 -0700413 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700414 "src/android/SkBitmapRegionCodec.cpp",
415 "src/android/SkBitmapRegionDecoder.cpp",
416 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700417 "src/codec/SkBmpCodec.cpp",
418 "src/codec/SkBmpMaskCodec.cpp",
419 "src/codec/SkBmpRLECodec.cpp",
420 "src/codec/SkBmpStandardCodec.cpp",
421 "src/codec/SkCodec.cpp",
422 "src/codec/SkCodecImageGenerator.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700423 "src/codec/SkMaskSwizzler.cpp",
424 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700425 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700426 "src/codec/SkSampler.cpp",
427 "src/codec/SkSwizzler.cpp",
428 "src/codec/SkWbmpCodec.cpp",
mtklein09e61f72016-08-23 13:35:28 -0700429 "src/gpu/gl/GrGLDefaultInterface_native.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700430 "src/images/SkImageEncoder.cpp",
431 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700432 "src/images/SkKTXImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700433 "src/ports/SkDiscardableMemory_none.cpp",
434 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700435 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700436 "src/ports/SkMemory_malloc.cpp",
437 "src/ports/SkOSFile_stdio.cpp",
438 "src/sfnt/SkOTTable_name.cpp",
439 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700440 "src/svg/SkSVGCanvas.cpp",
441 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700442 "src/utils/mac/SkStream_mac.cpp",
443 "third_party/etc1/etc1.cpp",
444 "third_party/ktx/ktx.cpp",
445 ]
brettwb9447282016-09-01 14:24:39 -0700446
447 # These paths need to be absolute to match the ones produced by
448 # shared_sources.gni, but this file may be used from different directory
449 # locations.
450 sources -= get_path_info([
451 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
452 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
453 ],
454 "abspath")
mtkleinc04ff472016-06-23 10:29:30 -0700455
mtklein7d6fb2c2016-08-25 14:50:44 -0700456 libs = []
457
mtkleinc04ff472016-06-23 10:29:30 -0700458 if (is_win) {
459 sources += [
460 "src/ports/SkDebug_win.cpp",
461 "src/ports/SkFontHost_win.cpp",
462 "src/ports/SkFontMgr_win_dw.cpp",
463 "src/ports/SkFontMgr_win_dw_factory.cpp",
464 "src/ports/SkImageEncoder_WIC.cpp",
465 "src/ports/SkImageGeneratorWIC.cpp",
466 "src/ports/SkOSFile_win.cpp",
467 "src/ports/SkScalerContext_win_dw.cpp",
468 "src/ports/SkTLS_win.cpp",
469 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700470 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700471 ]
mtklein7a1f45f2016-08-04 06:19:33 -0700472 sources -= [ "src/utils/SkThreadUtils_pthread.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700473 } else {
474 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700475 "src/ports/SkOSFile_posix.cpp",
476 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700477 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700478 ]
479 }
480
mtklein7d6fb2c2016-08-25 14:50:44 -0700481 if (is_android) {
482 deps += [
483 "//third_party/cpu-features",
484 "//third_party/expat",
mtklein7d6fb2c2016-08-25 14:50:44 -0700485 ]
486 sources += [
487 "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp",
488 "src/ports/SkDebug_android.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700489 ]
490 libs += [
491 "EGL",
492 "GLESv2",
493 "log",
494 ]
495 }
496
mtkleinc04ff472016-06-23 10:29:30 -0700497 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700498 libs += [
499 "GL",
500 "GLU",
501 "X11",
502 ]
mtkleinc04ff472016-06-23 10:29:30 -0700503 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700504 "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700505 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700506 ]
507 }
508
509 if (is_mac) {
510 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700511 "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700512 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700513 "src/ports/SkFontHost_mac.cpp",
514 "src/ports/SkImageEncoder_CG.cpp",
515 "src/ports/SkImageGeneratorCG.cpp",
516 ]
mtklein09e61f72016-08-23 13:35:28 -0700517 libs += [
518 "ApplicationServices.framework",
519 "OpenGL.framework",
520 ]
mtkleinc04ff472016-06-23 10:29:30 -0700521 }
abarth6fc8ff02016-07-15 15:15:15 -0700522
523 if (is_fuchsia) {
mikejurka21cc9952016-09-13 16:15:03 -0700524 sources += [
525 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
526 "src/ports/SkDebug_stdio.cpp",
527 ]
abarth6fc8ff02016-07-15 15:15:15 -0700528 }
mtkleinc04ff472016-06-23 10:29:30 -0700529}
530
mtkleinada5a442016-08-02 14:28:26 -0700531skia_h_headers = exec_script("gyp/find.py",
532 [ "*.h" ] + rebase_path(skia_public_includes),
533 "list lines",
534 []) -
535 [
536 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
537 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
538 rebase_path("include/gpu/vk/GrVkDefines.h"),
539 rebase_path("include/gpu/vk/GrVkInterface.h"),
540 rebase_path("include/gpu/vk/GrVkTypes.h"),
541 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
542 ]
543
mtklein1211e0c2016-07-26 13:55:45 -0700544action("skia.h") {
545 script = "gn/echo_headers.py"
546 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinc095df52016-08-24 12:23:52 -0700547 rebase_path(skia_h_headers, target_gen_dir)
mtklein1211e0c2016-07-26 13:55:45 -0700548 outputs = [
549 "$target_gen_dir/skia.h",
550 ]
551}
552
553executable("fiddle") {
554 include_dirs = [ "$target_gen_dir" ]
mtklein7d10b9f2016-07-27 11:17:18 -0700555 libs = []
556 if (is_linux) {
557 libs += [ "OSMesa" ]
558 }
mtklein1211e0c2016-07-26 13:55:45 -0700559
mtkleinc04ff472016-06-23 10:29:30 -0700560 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700561 "src/images/SkForceLinking.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700562 "tools/fiddle/draw.cpp",
563 "tools/fiddle/fiddle_main.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700564 ]
565 deps = [
566 ":skia",
mtklein1211e0c2016-07-26 13:55:45 -0700567 ":skia.h",
mtkleinc04ff472016-06-23 10:29:30 -0700568 ]
mtkleinc04ff472016-06-23 10:29:30 -0700569}
mtklein25c81d42016-07-27 13:55:26 -0700570
mtkleinc095df52016-08-24 12:23:52 -0700571# Targets guarded by skia_enable_tools may use //third_party freely.
572if (skia_enable_tools) {
573 template("test_lib") {
574 config(target_name + "_config") {
575 include_dirs = invoker.public_include_dirs
mtklein25c81d42016-07-27 13:55:26 -0700576 }
mtkleinc095df52016-08-24 12:23:52 -0700577 source_set(target_name) {
578 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
579 public_configs = [
580 ":" + target_name + "_config",
581 ":skia_private",
582 ]
583
584 if (!defined(deps)) {
585 deps = []
586 }
587 deps += [ ":skia" ]
588 testonly = true
589 }
mtklein25c81d42016-07-27 13:55:26 -0700590 }
mtklein25c81d42016-07-27 13:55:26 -0700591
mtkleinc095df52016-08-24 12:23:52 -0700592 test_lib("gpu_tool_utils") {
593 public_include_dirs = [ "tools/gpu" ]
594 sources = [
595 "tools/gpu/GrContextFactory.cpp",
596 "tools/gpu/GrTest.cpp",
597 "tools/gpu/TestContext.cpp",
598 "tools/gpu/gl/GLTestContext.cpp",
599 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
600 "tools/gpu/gl/debug/GrBufferObj.cpp",
601 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
602 "tools/gpu/gl/debug/GrProgramObj.cpp",
603 "tools/gpu/gl/debug/GrShaderObj.cpp",
604 "tools/gpu/gl/debug/GrTextureObj.cpp",
605 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
606 "tools/gpu/gl/null/NullGLTestContext.cpp",
607 ]
608 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700609
mtklein7d6fb2c2016-08-25 14:50:44 -0700610 if (is_android) {
611 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
612 } else if (is_linux) {
mtkleinc095df52016-08-24 12:23:52 -0700613 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
614 } else if (is_mac) {
615 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
616 }
mtklein6ef69992016-09-14 06:12:09 -0700617
618 if (skia_use_vulkan) {
619 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
620 }
mtklein25c81d42016-07-27 13:55:26 -0700621 }
mtklein25c81d42016-07-27 13:55:26 -0700622
mtkleinc095df52016-08-24 12:23:52 -0700623 test_lib("flags") {
624 public_include_dirs = [ "tools/flags" ]
625 sources = [
626 "tools/flags/SkCommandLineFlags.cpp",
627 "tools/flags/SkCommonFlags.cpp",
628 "tools/flags/SkCommonFlagsConfig.cpp",
629 ]
630 deps = [
631 ":gpu_tool_utils",
632 ]
633 }
mtklein25c81d42016-07-27 13:55:26 -0700634
mtkleinc095df52016-08-24 12:23:52 -0700635 test_lib("tool_utils") {
636 public_include_dirs = [
637 "tools",
638 "tools/debugger",
639 "tools/timer",
640 ]
641 sources = [
642 "src/images/SkForceLinking.cpp",
643 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700644 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700645 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700646 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700647 "tools/ProcStats.cpp",
648 "tools/Resources.cpp",
649 "tools/ThermalManager.cpp",
650 "tools/UrlDataManager.cpp",
651 "tools/debugger/SkDebugCanvas.cpp",
652 "tools/debugger/SkDrawCommand.cpp",
653 "tools/debugger/SkJsonWriteBuffer.cpp",
654 "tools/debugger/SkObjectParser.cpp",
655 "tools/debugger/SkOverdrawMode.cpp",
656 "tools/picture_utils.cpp",
657 "tools/random_parse_path.cpp",
658 "tools/sk_tool_utils.cpp",
659 "tools/sk_tool_utils_font.cpp",
660 "tools/timer/Timer.cpp",
661 ]
662 deps = [
663 ":flags",
664 "//third_party/libpng",
665 ]
666 public_deps = [
667 "//third_party/jsoncpp",
668 ]
669 }
mtklein25c81d42016-07-27 13:55:26 -0700670
mtkleinc095df52016-08-24 12:23:52 -0700671 gm_sources = exec_script("gyp/find.py",
672 [
673 "*.c*",
674 rebase_path("gm"),
675 ],
676 "list lines",
677 [])
678 test_lib("gm") {
679 public_include_dirs = [ "gm" ]
680 sources = gm_sources
681 deps = [
682 ":gpu_tool_utils",
683 ":skia",
684 ":tool_utils",
685 ]
686 }
mtklein25c81d42016-07-27 13:55:26 -0700687
mtkleinc095df52016-08-24 12:23:52 -0700688 tests_sources = exec_script("gyp/find.py",
689 [
690 "*.c*",
691 rebase_path("tests"),
692 ],
693 "list lines",
694 [])
mtklein2f3416d2016-08-02 16:02:05 -0700695
mtkleinc095df52016-08-24 12:23:52 -0700696 test_lib("tests") {
697 public_include_dirs = [ "tests" ]
mtkleina45be612016-08-29 15:22:10 -0700698 sources = tests_sources - [
699 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
mtkleina45be612016-08-29 15:22:10 -0700700 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
701 rebase_path("tests/skia_test.cpp"), # alternate main
702 ]
703 if (!fontmgr_android_enabled) {
704 sources -= [ rebase_path("tests/FontMgrAndroidParserTest.cpp") ]
705 }
mtkleinc095df52016-08-24 12:23:52 -0700706 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700707 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700708 ":flags",
709 ":gpu_tool_utils",
710 ":skia",
711 ":tool_utils",
712 "//third_party/libpng",
713 "//third_party/zlib",
714 ]
715 }
mtklein2f3416d2016-08-02 16:02:05 -0700716
mtkleinc095df52016-08-24 12:23:52 -0700717 bench_sources = exec_script("gyp/find.py",
718 [
719 "*.c*",
720 rebase_path("bench"),
721 ],
722 "list lines",
723 [])
mtklein25c81d42016-07-27 13:55:26 -0700724
mtkleinc095df52016-08-24 12:23:52 -0700725 test_lib("bench") {
726 public_include_dirs = [ "bench" ]
727 sources = bench_sources
728 sources -= [
729 rebase_path("bench/nanobench.cpp"),
730 rebase_path("bench/nanobenchAndroid.cpp"),
731 ]
732 deps = [
733 ":flags",
734 ":gm",
735 ":gpu_tool_utils",
736 ":skia",
737 ":tool_utils",
738 ]
739 }
mtklein2b6870c2016-07-28 14:17:33 -0700740
mtkleinc095df52016-08-24 12:23:52 -0700741 test_lib("experimental_svg_model") {
742 public_include_dirs = [ "experimental/svg/model" ]
743 sources = [
744 "experimental/svg/model/SkSVGAttribute.cpp",
745 "experimental/svg/model/SkSVGAttributeParser.cpp",
746 "experimental/svg/model/SkSVGCircle.cpp",
747 "experimental/svg/model/SkSVGContainer.cpp",
748 "experimental/svg/model/SkSVGDOM.cpp",
749 "experimental/svg/model/SkSVGEllipse.cpp",
750 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700751 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700752 "experimental/svg/model/SkSVGNode.cpp",
753 "experimental/svg/model/SkSVGPath.cpp",
754 "experimental/svg/model/SkSVGPoly.cpp",
755 "experimental/svg/model/SkSVGRect.cpp",
756 "experimental/svg/model/SkSVGRenderContext.cpp",
757 "experimental/svg/model/SkSVGSVG.cpp",
758 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700759 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700760 "experimental/svg/model/SkSVGTransformableNode.cpp",
761 "experimental/svg/model/SkSVGValue.cpp",
762 ]
763 deps = [
764 ":skia",
765 ]
766 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700767
mtklein2b6870c2016-07-28 14:17:33 -0700768 executable("dm") {
769 sources = [
770 "dm/DM.cpp",
771 "dm/DMJsonWriter.cpp",
772 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700773 ]
774 include_dirs = [ "tests" ]
775 deps = [
fmalitaa2b9fdf2016-08-03 19:53:36 -0700776 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700777 ":flags",
778 ":gm",
779 ":gpu_tool_utils",
780 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700781 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700782 ":tool_utils",
783 "//third_party/jsoncpp",
784 "//third_party/libpng",
785 ]
786 testonly = true
787 }
788
789 executable("monobench") {
790 sources = [
791 "tools/monobench.cpp",
792 ]
793 deps = [
794 ":bench",
795 ":skia",
796 ]
797 testonly = true
798 }
799
800 executable("nanobench") {
801 sources = [
802 "bench/nanobench.cpp",
803 ]
804 deps = [
805 ":bench",
806 ":flags",
807 ":gm",
808 ":gpu_tool_utils",
809 ":skia",
810 ":tool_utils",
811 "//third_party/jsoncpp",
812 ]
813 testonly = true
814 }
halcanary19a97202016-08-03 15:08:04 -0700815
mtklein6f5df6a2016-08-29 16:01:10 -0700816 if (current_cpu != "mipsel") { # Clang 3.8 crashes while compiling hb-icu.cc for mipsel.
halcanary3eee9d92016-09-10 07:01:53 -0700817 executable("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -0700818 sources = [
819 "tools/SkShaper_harfbuzz.cpp",
820 "tools/using_skia_and_harfbuzz.cpp",
821 ]
822 deps = [
823 ":skia",
824 "//third_party/harfbuzz",
825 ]
826 testonly = true
827 }
halcanary19a97202016-08-03 15:08:04 -0700828 }
halcanary3eee9d92016-09-10 07:01:53 -0700829 executable("sktexttopdf") {
830 sources = [
831 "tools/SkShaper_primitive.cpp",
832 "tools/using_skia_and_harfbuzz.cpp",
833 ]
834 deps = [
835 ":skia",
836 ]
837 testonly = true
838 }
mtklein25c81d42016-07-27 13:55:26 -0700839}