blob: 3c6ac0f462447cd4fbb40ce200843ca91c95bffc [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() {
mtklein63213812016-08-24 09:55:56 -07009 skia_use_expat = true
mtklein3cc22182016-08-29 13:26:14 -070010 skia_use_fontconfig = is_linux
mtkleincdedd0e2016-09-12 15:15:44 -070011 skia_use_freetype = is_android || is_fuchsia || is_linux
mtklein457b42a2016-08-23 13:56:37 -070012 skia_use_giflib = !is_fuchsia
mtklein63213812016-08-24 09:55:56 -070013 skia_use_libjpeg_turbo = true
14 skia_use_libpng = true
mtkleineb3c4252016-08-23 07:38:09 -070015 skia_use_libwebp = !is_fuchsia
mtklein63213812016-08-24 09:55:56 -070016 skia_use_sfntly = !is_fuchsia
mtkleinf29180e2016-09-16 07:01:17 -070017 skia_use_vulkan = is_android && defined(ndk_api) && ndk_api >= 24
mtklein63213812016-08-24 09:55:56 -070018 skia_use_zlib = true
mtklein1bd72ba2016-09-16 07:45:52 -070019
20 skia_enable_android_framework_defines = false
mtklein06c35c02016-09-20 12:28:12 -070021 skia_enable_gpu = true
22 skia_enable_tools = !is_fuchsia
mtkleinc04ff472016-06-23 10:29:30 -070023}
24
mtklein06c35c02016-09-20 12:28:12 -070025# Our tools require static linking (they use non-exported symbols) and GPU support (just lazy).
26skia_enable_tools = skia_enable_tools && skia_enable_gpu && !is_component_build
27
mtkleina45be612016-08-29 15:22:10 -070028fontmgr_android_enabled = skia_use_expat && skia_use_freetype
29
mtklein1211e0c2016-07-26 13:55:45 -070030skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070031 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070032 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070033 "include/codec",
34 "include/config",
35 "include/core",
36 "include/effects",
37 "include/gpu",
38 "include/gpu/gl",
39 "include/images",
40 "include/pathops",
41 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070042 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070043 "include/utils",
44 "include/utils/mac",
mtklein25c81d42016-07-27 13:55:26 -070045 "include/xml",
mtklein1211e0c2016-07-26 13:55:45 -070046]
47
mtkleinc04ff472016-06-23 10:29:30 -070048# Skia public API, generally provided by :skia.
49config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -070050 include_dirs = skia_public_includes
mtkleinc04ff472016-06-23 10:29:30 -070051 defines = [ "SKIA_DLL" ]
jcgregorio5561e3d2016-08-25 09:25:11 -070052 if (is_linux) {
53 defines += [ "SK_SAMPLES_FOR_X" ]
54 }
mtkleincae1be52016-09-20 08:24:34 -070055 if (skia_enable_android_framework_defines) {
56 defines += skia_android_framework_defines
57 }
mtklein06c35c02016-09-20 12:28:12 -070058 if (!skia_enable_gpu) {
59 defines += [ "SK_SUPPORT_GPU=0" ]
60 }
mtkleinc04ff472016-06-23 10:29:30 -070061}
62
63# Skia internal APIs, used by Skia itself and a few test tools.
64config("skia_private") {
65 visibility = [ ":*" ]
66
67 include_dirs = [
68 "include/private",
69 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -070070 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -070071 "src/config",
72 "src/core",
73 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -070074 "src/effects/gradients",
75 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -070076 "src/gpu",
77 "src/image",
78 "src/images",
79 "src/lazy",
80 "src/opts",
81 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -070082 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -070083 "src/ports",
84 "src/sfnt",
mtklein9e0d9dd2016-08-30 10:37:19 -070085 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -070086 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -070087 "src/utils/win",
mtkleinc04ff472016-06-23 10:29:30 -070088 "third_party/etc1",
89 "third_party/ktx",
90 ]
mtklein150d1132016-08-01 06:56:40 -070091
mtklein63213812016-08-24 09:55:56 -070092 defines = [ "SK_GAMMA_APPLY_TO_A8" ]
mtkleinb37c0342016-09-09 11:07:45 -070093 if (is_android) {
94 defines += [
95 "SK_GAMMA_EXPONENT=1.4",
96 "SK_GAMMA_CONTRAST=0.0",
97 ]
98 }
mtklein88a7ac02016-09-14 11:16:49 -070099 if (is_official_build || is_android) {
100 # TODO(bsalomon): it'd be nice to make Android normal.
101 defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
102 }
mtkleinc04ff472016-06-23 10:29:30 -0700103}
104
105# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
106config("skia_library") {
107 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -0700108 defines = [ "SKIA_IMPLEMENTATION=1" ]
109}
110
111skia_library_configs = [
112 ":skia_public",
113 ":skia_private",
114 ":skia_library",
115]
116
mtklein9b8583d2016-08-24 17:32:30 -0700117# Use for CPU-specific Skia code that needs particular compiler flags.
118template("opts") {
119 if (invoker.enabled) {
120 source_set(target_name) {
121 forward_variables_from(invoker, "*")
122 configs += skia_library_configs
123 }
124 } else {
125 # If not enabled, a phony empty target that swallows all otherwise unused variables.
126 source_set(target_name) {
127 forward_variables_from(invoker,
128 "*",
129 [
130 "sources",
131 "cflags",
132 ])
133 }
134 }
anmittala7eaf2e2016-08-17 13:57:26 -0700135}
136
mtklein422310d2016-08-16 18:28:43 -0700137is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700138
mtklein7d6fb2c2016-08-25 14:50:44 -0700139opts("none") {
140 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700141 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700142 cflags = []
143}
144
mtklein7d6fb2c2016-08-25 14:50:44 -0700145opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700146 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700147 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700148 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700149}
150
151opts("arm64") {
152 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700153 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700154 cflags = []
155}
156
157opts("crc32") {
158 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700159 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700160 cflags = [ "-march=armv8-a+crc" ]
161}
162
mtklein9b8583d2016-08-24 17:32:30 -0700163opts("sse2") {
164 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700165 sources = skia_opts.sse2_sources
mtklein9b8583d2016-08-24 17:32:30 -0700166 cflags = [ "-msse2" ]
167}
mtkleinc04ff472016-06-23 10:29:30 -0700168
mtklein9b8583d2016-08-24 17:32:30 -0700169opts("ssse3") {
170 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700171 sources = skia_opts.ssse3_sources
mtklein9b8583d2016-08-24 17:32:30 -0700172 cflags = [ "-mssse3" ]
173}
mtkleinc04ff472016-06-23 10:29:30 -0700174
mtklein9b8583d2016-08-24 17:32:30 -0700175opts("sse41") {
176 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700177 sources = skia_opts.sse41_sources
mtklein9b8583d2016-08-24 17:32:30 -0700178 cflags = [ "-msse4.1" ]
179}
mtklein4e976072016-08-08 09:06:27 -0700180
mtklein9b8583d2016-08-24 17:32:30 -0700181opts("sse42") {
182 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700183 sources = skia_opts.sse42_sources
mtklein9b8583d2016-08-24 17:32:30 -0700184 cflags = [ "-msse4.2" ]
185}
186
187opts("avx") {
188 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700189 sources = skia_opts.avx_sources
mtklein9b8583d2016-08-24 17:32:30 -0700190 cflags = [ "-mavx" ]
mtkleinc04ff472016-06-23 10:29:30 -0700191}
192
mtklein349cece2016-08-26 08:13:04 -0700193opts("dsp") {
194 enabled = current_cpu == "mipsel"
brettwb9447282016-09-01 14:24:39 -0700195 sources = skia_opts.mips_dsp_sources
mtkleinb6064ef2016-08-30 11:49:24 -0700196 cflags = []
mtklein349cece2016-08-26 08:13:04 -0700197}
198
mtkleinc095df52016-08-24 12:23:52 -0700199# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700200template("optional") {
201 if (invoker.enabled) {
202 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700203 if (defined(invoker.public_defines)) {
204 defines = invoker.public_defines
205 }
mtklein457b42a2016-08-23 13:56:37 -0700206 }
207 source_set(target_name) {
mtkleincd01b032016-08-31 04:58:19 -0700208 forward_variables_from(invoker,
209 "*",
210 [
211 "public_defines",
212 "sources_when_disabled",
213 ])
mtklein457b42a2016-08-23 13:56:37 -0700214 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700215 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700216 }
217 } else {
mtklein457b42a2016-08-23 13:56:37 -0700218 source_set(target_name) {
219 forward_variables_from(invoker,
220 "*",
221 [
222 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700223 "deps",
mtklein6ef69992016-09-14 06:12:09 -0700224 "libs",
mtklein457b42a2016-08-23 13:56:37 -0700225 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700226 "sources_when_disabled",
mtklein457b42a2016-08-23 13:56:37 -0700227 ])
mtkleincd01b032016-08-31 04:58:19 -0700228 if (defined(invoker.sources_when_disabled)) {
229 sources = invoker.sources_when_disabled
230 }
231 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700232 }
mtkleineb3c4252016-08-23 07:38:09 -0700233 }
mtklein457b42a2016-08-23 13:56:37 -0700234}
mtklein457b42a2016-08-23 13:56:37 -0700235
mtkleina45be612016-08-29 15:22:10 -0700236optional("fontmgr_android") {
237 enabled = fontmgr_android_enabled
mtkleina45be612016-08-29 15:22:10 -0700238
239 deps = [
240 "//third_party/expat",
241 "//third_party/freetype2",
242 ]
243 sources = [
244 "src/ports/SkFontMgr_android.cpp",
245 "src/ports/SkFontMgr_android_factory.cpp",
246 "src/ports/SkFontMgr_android_parser.cpp",
247 ]
248}
249
mtkleind2e39db2016-09-07 07:52:55 -0700250optional("fontmgr_custom") {
251 enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
252
253 deps = [
254 "//third_party/freetype2",
255 ]
256 sources = [
257 "src/ports/SkFontMgr_custom.cpp",
258 "src/ports/SkFontMgr_custom_directory_factory.cpp",
259 ]
260}
261
mtklein3cc22182016-08-29 13:26:14 -0700262optional("fontmgr_fontconfig") {
263 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700264
265 deps = [
266 "//third_party:fontconfig",
267 "//third_party/freetype2",
268 ]
269 sources = [
bungeman1ae0e012016-09-19 12:13:16 -0700270 "src/ports/SkFontConfigInterface.cpp",
mtklein3cc22182016-08-29 13:26:14 -0700271 "src/ports/SkFontConfigInterface_direct.cpp",
272 "src/ports/SkFontConfigInterface_direct_factory.cpp",
273 "src/ports/SkFontMgr_FontConfigInterface.cpp",
274 "src/ports/SkFontMgr_fontconfig.cpp",
275 "src/ports/SkFontMgr_fontconfig_factory.cpp",
276 ]
277}
278
mtkleincdedd0e2016-09-12 15:15:44 -0700279optional("fontmgr_fuchsia") {
280 enabled = is_fuchsia && skia_use_freetype
281
282 deps = [
283 "//third_party/freetype2",
284 ]
285 sources = [
286 "src/ports/SkFontMgr_custom.cpp",
287 "src/ports/SkFontMgr_custom_empty_factory.cpp",
288 ]
289}
290
mtklein457b42a2016-08-23 13:56:37 -0700291optional("gif") {
292 enabled = skia_use_giflib
293 public_defines = [ "SK_HAS_GIF_LIBRARY" ]
294
mtklein457b42a2016-08-23 13:56:37 -0700295 deps = [
296 "//third_party/giflib",
297 ]
298 sources = [
299 "src/codec/SkGifCodec.cpp",
300 ]
301}
302
mtklein06c35c02016-09-20 12:28:12 -0700303optional("gpu") {
304 enabled = skia_enable_gpu
305 sources = skia_gpu_sources + [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ]
306
307 # These paths need to be absolute to match the ones produced by shared_sources.gni.
308 sources -= get_path_info([
309 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
310 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
311 ],
312 "abspath")
313 if (is_android) {
314 sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
315 } else if (is_linux) {
316 sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
317 } else if (is_mac) {
318 sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
319 } else {
320 sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
321 }
322}
323
mtklein63213812016-08-24 09:55:56 -0700324optional("jpeg") {
325 enabled = skia_use_libjpeg_turbo
326 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
327
mtklein63213812016-08-24 09:55:56 -0700328 deps = [
329 "//third_party/libjpeg-turbo:libjpeg",
330 ]
331 sources = [
332 "src/codec/SkJpegCodec.cpp",
333 "src/codec/SkJpegDecoderMgr.cpp",
334 "src/codec/SkJpegUtility.cpp",
335 "src/images/SkJPEGImageEncoder.cpp",
336 "src/images/SkJPEGWriteUtility.cpp",
337 ]
338}
339
340optional("pdf") {
341 enabled = skia_use_zlib
mtklein63213812016-08-24 09:55:56 -0700342
mtklein63213812016-08-24 09:55:56 -0700343 deps = [
344 "//third_party/zlib",
345 ]
brettwb9447282016-09-01 14:24:39 -0700346 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700347 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700348
349 if (skia_use_sfntly) {
350 deps += [ "//third_party/sfntly" ]
mtkleincd01b032016-08-31 04:58:19 -0700351 public_defines = [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700352 }
353}
354
355optional("png") {
356 enabled = skia_use_libpng
357 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
358
mtklein63213812016-08-24 09:55:56 -0700359 deps = [
360 "//third_party/libpng",
361 ]
362 sources = [
363 "src/codec/SkIcoCodec.cpp",
364 "src/codec/SkPngCodec.cpp",
365 "src/images/SkPNGImageEncoder.cpp",
366 ]
367}
368
mtklein3cc22182016-08-29 13:26:14 -0700369optional("typeface_freetype") {
370 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700371
372 deps = [
373 "//third_party/freetype2",
374 ]
375 sources = [
376 "src/ports/SkFontHost_FreeType.cpp",
377 "src/ports/SkFontHost_FreeType_common.cpp",
378 ]
379}
380
mtklein6ef69992016-09-14 06:12:09 -0700381optional("vulkan") {
382 enabled = skia_use_vulkan
383 public_defines = [ "SK_VULKAN" ]
384 libs = [ "vulkan" ]
385 sources = skia_vk_sources
386}
387
mtklein457b42a2016-08-23 13:56:37 -0700388optional("webp") {
389 enabled = skia_use_libwebp
390 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
391
mtklein457b42a2016-08-23 13:56:37 -0700392 deps = [
393 "//third_party/libwebp",
394 ]
395 sources = [
396 "src/codec/SkWebpAdapterCodec.cpp",
397 "src/codec/SkWebpCodec.cpp",
398 "src/images/SkWEBPImageEncoder.cpp",
399 ]
mtkleineb3c4252016-08-23 07:38:09 -0700400}
401
mtklein63213812016-08-24 09:55:56 -0700402optional("xml") {
403 enabled = skia_use_expat
mtklein63213812016-08-24 09:55:56 -0700404
mtklein63213812016-08-24 09:55:56 -0700405 deps = [
406 "//third_party/expat",
407 ]
408 sources = [
409 "src/xml/SkDOM.cpp",
410 "src/xml/SkXMLParser.cpp",
411 "src/xml/SkXMLWriter.cpp",
412 ]
413}
414
mtkleinc04ff472016-06-23 10:29:30 -0700415component("skia") {
416 public_configs = [ ":skia_public" ]
417 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700418
419 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700420 ":arm64",
421 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700422 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700423 ":crc32",
mtklein349cece2016-08-26 08:13:04 -0700424 ":dsp",
mtkleina45be612016-08-29 15:22:10 -0700425 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700426 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700427 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700428 ":fontmgr_fuchsia",
mtklein457b42a2016-08-23 13:56:37 -0700429 ":gif",
mtklein06c35c02016-09-20 12:28:12 -0700430 ":gpu",
mtklein63213812016-08-24 09:55:56 -0700431 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700432 ":none",
mtklein63213812016-08-24 09:55:56 -0700433 ":pdf",
434 ":png",
mtklein9b8583d2016-08-24 17:32:30 -0700435 ":sse2",
436 ":sse41",
437 ":sse42",
438 ":ssse3",
mtklein3cc22182016-08-29 13:26:14 -0700439 ":typeface_freetype",
mtklein6ef69992016-09-14 06:12:09 -0700440 ":vulkan",
mtkleineb3c4252016-08-23 07:38:09 -0700441 ":webp",
mtklein63213812016-08-24 09:55:56 -0700442 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700443 ]
444
mtkleinc04ff472016-06-23 10:29:30 -0700445 sources = []
brettwb9447282016-09-01 14:24:39 -0700446 sources += skia_core_sources
447 sources += skia_effects_sources
brettwb9447282016-09-01 14:24:39 -0700448 sources += skia_sksl_sources
449 sources += skia_utils_sources
mtkleinc04ff472016-06-23 10:29:30 -0700450 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700451 "src/android/SkBitmapRegionCodec.cpp",
452 "src/android/SkBitmapRegionDecoder.cpp",
453 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700454 "src/codec/SkBmpCodec.cpp",
455 "src/codec/SkBmpMaskCodec.cpp",
456 "src/codec/SkBmpRLECodec.cpp",
457 "src/codec/SkBmpStandardCodec.cpp",
458 "src/codec/SkCodec.cpp",
459 "src/codec/SkCodecImageGenerator.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700460 "src/codec/SkMaskSwizzler.cpp",
461 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700462 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700463 "src/codec/SkSampler.cpp",
464 "src/codec/SkSwizzler.cpp",
465 "src/codec/SkWbmpCodec.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700466 "src/images/SkImageEncoder.cpp",
467 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700468 "src/images/SkKTXImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700469 "src/ports/SkDiscardableMemory_none.cpp",
470 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700471 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700472 "src/ports/SkMemory_malloc.cpp",
473 "src/ports/SkOSFile_stdio.cpp",
474 "src/sfnt/SkOTTable_name.cpp",
475 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700476 "src/svg/SkSVGCanvas.cpp",
477 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700478 "src/utils/mac/SkStream_mac.cpp",
479 "third_party/etc1/etc1.cpp",
480 "third_party/ktx/ktx.cpp",
481 ]
brettwb9447282016-09-01 14:24:39 -0700482
mtklein7d6fb2c2016-08-25 14:50:44 -0700483 libs = []
484
mtkleinc04ff472016-06-23 10:29:30 -0700485 if (is_win) {
486 sources += [
487 "src/ports/SkDebug_win.cpp",
488 "src/ports/SkFontHost_win.cpp",
489 "src/ports/SkFontMgr_win_dw.cpp",
490 "src/ports/SkFontMgr_win_dw_factory.cpp",
491 "src/ports/SkImageEncoder_WIC.cpp",
492 "src/ports/SkImageGeneratorWIC.cpp",
493 "src/ports/SkOSFile_win.cpp",
494 "src/ports/SkScalerContext_win_dw.cpp",
495 "src/ports/SkTLS_win.cpp",
496 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700497 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700498 ]
mtkleinb9be9792016-09-16 14:44:18 -0700499 sources -=
500 [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
mtkleinc04ff472016-06-23 10:29:30 -0700501 } else {
502 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700503 "src/ports/SkOSFile_posix.cpp",
504 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700505 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700506 ]
507 }
508
mtklein7d6fb2c2016-08-25 14:50:44 -0700509 if (is_android) {
510 deps += [
511 "//third_party/cpu-features",
512 "//third_party/expat",
mtklein7d6fb2c2016-08-25 14:50:44 -0700513 ]
mtklein06c35c02016-09-20 12:28:12 -0700514 sources += [ "src/ports/SkDebug_android.cpp" ]
mtklein7d6fb2c2016-08-25 14:50:44 -0700515 libs += [
516 "EGL",
517 "GLESv2",
518 "log",
519 ]
520 }
521
mtkleinc04ff472016-06-23 10:29:30 -0700522 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700523 libs += [
524 "GL",
525 "GLU",
526 "X11",
527 ]
mtklein06c35c02016-09-20 12:28:12 -0700528 sources += [ "src/ports/SkDebug_stdio.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700529 }
530
531 if (is_mac) {
532 sources += [
mtklein7d6fb2c2016-08-25 14:50:44 -0700533 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700534 "src/ports/SkFontHost_mac.cpp",
535 "src/ports/SkImageEncoder_CG.cpp",
536 "src/ports/SkImageGeneratorCG.cpp",
537 ]
mtklein09e61f72016-08-23 13:35:28 -0700538 libs += [
539 "ApplicationServices.framework",
540 "OpenGL.framework",
541 ]
mtkleinc04ff472016-06-23 10:29:30 -0700542 }
abarth6fc8ff02016-07-15 15:15:15 -0700543
544 if (is_fuchsia) {
mtklein06c35c02016-09-20 12:28:12 -0700545 sources += [ "src/ports/SkDebug_stdio.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700546 }
mtkleinc04ff472016-06-23 10:29:30 -0700547}
548
mtkleinada5a442016-08-02 14:28:26 -0700549skia_h_headers = exec_script("gyp/find.py",
550 [ "*.h" ] + rebase_path(skia_public_includes),
551 "list lines",
552 []) -
553 [
554 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
555 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
556 rebase_path("include/gpu/vk/GrVkDefines.h"),
557 rebase_path("include/gpu/vk/GrVkInterface.h"),
558 rebase_path("include/gpu/vk/GrVkTypes.h"),
559 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
560 ]
561
mtklein1211e0c2016-07-26 13:55:45 -0700562action("skia.h") {
563 script = "gn/echo_headers.py"
564 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinc095df52016-08-24 12:23:52 -0700565 rebase_path(skia_h_headers, target_gen_dir)
mtklein1211e0c2016-07-26 13:55:45 -0700566 outputs = [
567 "$target_gen_dir/skia.h",
568 ]
569}
570
mtklein06c35c02016-09-20 12:28:12 -0700571if (skia_enable_gpu && target_cpu == "x64") {
mtklein1fbdf982016-09-15 12:07:48 -0700572 # Our bots only have 64-bit libOSMesa installed.
573 # TODO: worth fixing?
574 executable("fiddle") {
575 include_dirs = [ "$target_gen_dir" ]
576 libs = []
577 if (is_linux) {
578 libs += [ "OSMesa" ]
579 }
mtklein56d56692016-09-15 11:18:55 -0700580
mtklein1fbdf982016-09-15 12:07:48 -0700581 sources = [
582 "src/images/SkForceLinking.cpp",
583 "tools/fiddle/draw.cpp",
584 "tools/fiddle/fiddle_main.cpp",
585 ]
586 deps = [
587 ":skia",
588 ":skia.h",
589 ]
590 }
mtkleinc04ff472016-06-23 10:29:30 -0700591}
mtklein25c81d42016-07-27 13:55:26 -0700592
mtkleinc095df52016-08-24 12:23:52 -0700593# Targets guarded by skia_enable_tools may use //third_party freely.
594if (skia_enable_tools) {
595 template("test_lib") {
596 config(target_name + "_config") {
597 include_dirs = invoker.public_include_dirs
mtklein25c81d42016-07-27 13:55:26 -0700598 }
mtkleinc095df52016-08-24 12:23:52 -0700599 source_set(target_name) {
600 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
601 public_configs = [
602 ":" + target_name + "_config",
603 ":skia_private",
604 ]
605
606 if (!defined(deps)) {
607 deps = []
608 }
609 deps += [ ":skia" ]
610 testonly = true
611 }
mtklein25c81d42016-07-27 13:55:26 -0700612 }
mtklein25c81d42016-07-27 13:55:26 -0700613
mtkleinc095df52016-08-24 12:23:52 -0700614 test_lib("gpu_tool_utils") {
615 public_include_dirs = [ "tools/gpu" ]
616 sources = [
617 "tools/gpu/GrContextFactory.cpp",
618 "tools/gpu/GrTest.cpp",
619 "tools/gpu/TestContext.cpp",
620 "tools/gpu/gl/GLTestContext.cpp",
621 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
622 "tools/gpu/gl/debug/GrBufferObj.cpp",
623 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
624 "tools/gpu/gl/debug/GrProgramObj.cpp",
625 "tools/gpu/gl/debug/GrShaderObj.cpp",
626 "tools/gpu/gl/debug/GrTextureObj.cpp",
627 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
628 "tools/gpu/gl/null/NullGLTestContext.cpp",
629 ]
630 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700631
mtklein7d6fb2c2016-08-25 14:50:44 -0700632 if (is_android) {
633 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
634 } else if (is_linux) {
mtkleinc095df52016-08-24 12:23:52 -0700635 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
636 } else if (is_mac) {
637 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
638 }
mtklein6ef69992016-09-14 06:12:09 -0700639
640 if (skia_use_vulkan) {
641 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
642 }
mtklein25c81d42016-07-27 13:55:26 -0700643 }
mtklein25c81d42016-07-27 13:55:26 -0700644
mtkleinc095df52016-08-24 12:23:52 -0700645 test_lib("flags") {
646 public_include_dirs = [ "tools/flags" ]
647 sources = [
648 "tools/flags/SkCommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -0700649 ]
650 }
651 test_lib("common_flags") {
652 public_include_dirs = [ "tools/flags" ]
653 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700654 "tools/flags/SkCommonFlags.cpp",
655 "tools/flags/SkCommonFlagsConfig.cpp",
656 ]
657 deps = [
mtklein046cb562016-09-16 10:23:12 -0700658 ":flags",
mtkleinc095df52016-08-24 12:23:52 -0700659 ":gpu_tool_utils",
660 ]
661 }
mtklein25c81d42016-07-27 13:55:26 -0700662
mtkleinc095df52016-08-24 12:23:52 -0700663 test_lib("tool_utils") {
664 public_include_dirs = [
665 "tools",
666 "tools/debugger",
667 "tools/timer",
668 ]
669 sources = [
670 "src/images/SkForceLinking.cpp",
671 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700672 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700673 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700674 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700675 "tools/ProcStats.cpp",
676 "tools/Resources.cpp",
677 "tools/ThermalManager.cpp",
678 "tools/UrlDataManager.cpp",
679 "tools/debugger/SkDebugCanvas.cpp",
680 "tools/debugger/SkDrawCommand.cpp",
681 "tools/debugger/SkJsonWriteBuffer.cpp",
682 "tools/debugger/SkObjectParser.cpp",
683 "tools/debugger/SkOverdrawMode.cpp",
684 "tools/picture_utils.cpp",
685 "tools/random_parse_path.cpp",
686 "tools/sk_tool_utils.cpp",
687 "tools/sk_tool_utils_font.cpp",
688 "tools/timer/Timer.cpp",
689 ]
690 deps = [
mtklein046cb562016-09-16 10:23:12 -0700691 ":common_flags",
mtkleinc095df52016-08-24 12:23:52 -0700692 ":flags",
693 "//third_party/libpng",
694 ]
695 public_deps = [
696 "//third_party/jsoncpp",
697 ]
698 }
mtklein25c81d42016-07-27 13:55:26 -0700699
mtkleinc095df52016-08-24 12:23:52 -0700700 gm_sources = exec_script("gyp/find.py",
701 [
702 "*.c*",
703 rebase_path("gm"),
704 ],
705 "list lines",
706 [])
707 test_lib("gm") {
708 public_include_dirs = [ "gm" ]
709 sources = gm_sources
710 deps = [
711 ":gpu_tool_utils",
712 ":skia",
713 ":tool_utils",
714 ]
715 }
mtklein25c81d42016-07-27 13:55:26 -0700716
mtkleinc095df52016-08-24 12:23:52 -0700717 tests_sources = exec_script("gyp/find.py",
718 [
719 "*.c*",
720 rebase_path("tests"),
721 ],
722 "list lines",
723 [])
mtklein2f3416d2016-08-02 16:02:05 -0700724
mtkleinc095df52016-08-24 12:23:52 -0700725 test_lib("tests") {
726 public_include_dirs = [ "tests" ]
mtkleina45be612016-08-29 15:22:10 -0700727 sources = tests_sources - [
728 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
mtkleina45be612016-08-29 15:22:10 -0700729 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
730 rebase_path("tests/skia_test.cpp"), # alternate main
731 ]
732 if (!fontmgr_android_enabled) {
733 sources -= [ rebase_path("tests/FontMgrAndroidParserTest.cpp") ]
734 }
mtkleinc095df52016-08-24 12:23:52 -0700735 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700736 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700737 ":flags",
738 ":gpu_tool_utils",
739 ":skia",
740 ":tool_utils",
741 "//third_party/libpng",
742 "//third_party/zlib",
743 ]
744 }
mtklein2f3416d2016-08-02 16:02:05 -0700745
mtkleinc095df52016-08-24 12:23:52 -0700746 bench_sources = exec_script("gyp/find.py",
747 [
748 "*.c*",
749 rebase_path("bench"),
750 ],
751 "list lines",
752 [])
mtklein25c81d42016-07-27 13:55:26 -0700753
mtkleinc095df52016-08-24 12:23:52 -0700754 test_lib("bench") {
755 public_include_dirs = [ "bench" ]
756 sources = bench_sources
757 sources -= [
758 rebase_path("bench/nanobench.cpp"),
759 rebase_path("bench/nanobenchAndroid.cpp"),
760 ]
761 deps = [
762 ":flags",
763 ":gm",
764 ":gpu_tool_utils",
765 ":skia",
766 ":tool_utils",
767 ]
768 }
mtklein2b6870c2016-07-28 14:17:33 -0700769
mtkleinc095df52016-08-24 12:23:52 -0700770 test_lib("experimental_svg_model") {
771 public_include_dirs = [ "experimental/svg/model" ]
772 sources = [
773 "experimental/svg/model/SkSVGAttribute.cpp",
774 "experimental/svg/model/SkSVGAttributeParser.cpp",
775 "experimental/svg/model/SkSVGCircle.cpp",
776 "experimental/svg/model/SkSVGContainer.cpp",
777 "experimental/svg/model/SkSVGDOM.cpp",
778 "experimental/svg/model/SkSVGEllipse.cpp",
779 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700780 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700781 "experimental/svg/model/SkSVGNode.cpp",
782 "experimental/svg/model/SkSVGPath.cpp",
783 "experimental/svg/model/SkSVGPoly.cpp",
784 "experimental/svg/model/SkSVGRect.cpp",
785 "experimental/svg/model/SkSVGRenderContext.cpp",
786 "experimental/svg/model/SkSVGSVG.cpp",
787 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700788 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700789 "experimental/svg/model/SkSVGTransformableNode.cpp",
790 "experimental/svg/model/SkSVGValue.cpp",
791 ]
792 deps = [
793 ":skia",
794 ]
795 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700796
mtklein2b6870c2016-07-28 14:17:33 -0700797 executable("dm") {
798 sources = [
799 "dm/DM.cpp",
800 "dm/DMJsonWriter.cpp",
801 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700802 ]
803 include_dirs = [ "tests" ]
804 deps = [
mtklein046cb562016-09-16 10:23:12 -0700805 ":common_flags",
fmalitaa2b9fdf2016-08-03 19:53:36 -0700806 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700807 ":flags",
808 ":gm",
809 ":gpu_tool_utils",
810 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700811 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700812 ":tool_utils",
813 "//third_party/jsoncpp",
814 "//third_party/libpng",
815 ]
816 testonly = true
817 }
818
819 executable("monobench") {
820 sources = [
821 "tools/monobench.cpp",
822 ]
823 deps = [
824 ":bench",
825 ":skia",
826 ]
827 testonly = true
828 }
829
830 executable("nanobench") {
831 sources = [
832 "bench/nanobench.cpp",
833 ]
834 deps = [
835 ":bench",
mtklein046cb562016-09-16 10:23:12 -0700836 ":common_flags",
fmalita6519c212016-09-14 08:05:17 -0700837 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700838 ":flags",
839 ":gm",
840 ":gpu_tool_utils",
841 ":skia",
842 ":tool_utils",
843 "//third_party/jsoncpp",
844 ]
845 testonly = true
846 }
halcanary19a97202016-08-03 15:08:04 -0700847
csmartdalton4b5179b2016-09-19 11:03:58 -0700848 executable("skpbench") {
849 sources = [
850 "tools/skpbench/skpbench.cpp",
851 ]
852 deps = [
853 ":flags",
854 ":gpu_tool_utils",
855 ":skia",
856 ":tool_utils",
857 ]
858 testonly = true
859 }
860
mtklein6f5df6a2016-08-29 16:01:10 -0700861 if (current_cpu != "mipsel") { # Clang 3.8 crashes while compiling hb-icu.cc for mipsel.
halcanary3eee9d92016-09-10 07:01:53 -0700862 executable("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -0700863 sources = [
864 "tools/SkShaper_harfbuzz.cpp",
865 "tools/using_skia_and_harfbuzz.cpp",
866 ]
867 deps = [
868 ":skia",
869 "//third_party/harfbuzz",
870 ]
871 testonly = true
872 }
halcanary19a97202016-08-03 15:08:04 -0700873 }
halcanary3eee9d92016-09-10 07:01:53 -0700874 executable("sktexttopdf") {
875 sources = [
876 "tools/SkShaper_primitive.cpp",
877 "tools/using_skia_and_harfbuzz.cpp",
878 ]
879 deps = [
880 ":skia",
881 ]
882 testonly = true
883 }
mtklein046cb562016-09-16 10:23:12 -0700884
885 executable("get_images_from_skps") {
886 sources = [
887 "tools/get_images_from_skps.cpp",
888 ]
889 deps = [
890 ":flags",
891 ":skia",
892 "//third_party/jsoncpp",
893 ]
894 testonly = true
895 }
mtklein25c81d42016-07-27 13:55:26 -0700896}