blob: 53f49ec58d46ad3e6af598c45991314980ac1102 [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
mtklein3e8012e2016-09-21 09:14:19 -07008if (!defined(is_skia_standalone)) {
9 is_skia_standalone = false
10}
11
mtkleinc04ff472016-06-23 10:29:30 -070012declare_args() {
mtkleind68f9b02016-09-23 13:18:41 -070013 skia_use_angle = false
mtklein63213812016-08-24 09:55:56 -070014 skia_use_expat = true
mtklein3cc22182016-08-29 13:26:14 -070015 skia_use_fontconfig = is_linux
mtkleincdedd0e2016-09-12 15:15:44 -070016 skia_use_freetype = is_android || is_fuchsia || is_linux
mtklein457b42a2016-08-23 13:56:37 -070017 skia_use_giflib = !is_fuchsia
mtklein63213812016-08-24 09:55:56 -070018 skia_use_libjpeg_turbo = true
19 skia_use_libpng = true
mtkleineb3c4252016-08-23 07:38:09 -070020 skia_use_libwebp = !is_fuchsia
mtkleina627b5c2016-09-20 13:36:47 -070021 skia_use_mesa = false
mtklein63213812016-08-24 09:55:56 -070022 skia_use_sfntly = !is_fuchsia
mtkleinf29180e2016-09-16 07:01:17 -070023 skia_use_vulkan = is_android && defined(ndk_api) && ndk_api >= 24
mtklein63213812016-08-24 09:55:56 -070024 skia_use_zlib = true
mtklein1bd72ba2016-09-16 07:45:52 -070025
26 skia_enable_android_framework_defines = false
mtklein06c35c02016-09-20 12:28:12 -070027 skia_enable_gpu = true
mtklein3e8012e2016-09-21 09:14:19 -070028 skia_enable_tools = is_skia_standalone
29 skia_enable_vulkan_debug_layers = is_skia_standalone && is_debug
mtkleinc04ff472016-06-23 10:29:30 -070030}
31
mtklein38925aa2016-09-21 10:11:25 -070032# Our tools require static linking (they use non-exported symbols).
33skia_enable_tools = skia_enable_tools && !is_component_build
mtklein06c35c02016-09-20 12:28:12 -070034
mtkleina45be612016-08-29 15:22:10 -070035fontmgr_android_enabled = skia_use_expat && skia_use_freetype
36
mtklein1211e0c2016-07-26 13:55:45 -070037skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070038 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070039 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070040 "include/codec",
41 "include/config",
42 "include/core",
43 "include/effects",
44 "include/gpu",
45 "include/gpu/gl",
46 "include/images",
47 "include/pathops",
48 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070049 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070050 "include/utils",
51 "include/utils/mac",
mtklein25c81d42016-07-27 13:55:26 -070052 "include/xml",
mtklein1211e0c2016-07-26 13:55:45 -070053]
54
mtkleinc04ff472016-06-23 10:29:30 -070055# Skia public API, generally provided by :skia.
56config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -070057 include_dirs = skia_public_includes
mtkleinc04ff472016-06-23 10:29:30 -070058 defines = [ "SKIA_DLL" ]
Mike Kleinc4cbd742016-09-26 21:37:09 -040059 if (is_fuchsia || is_linux) {
jcgregorio5561e3d2016-08-25 09:25:11 -070060 defines += [ "SK_SAMPLES_FOR_X" ]
61 }
mtkleincae1be52016-09-20 08:24:34 -070062 if (skia_enable_android_framework_defines) {
63 defines += skia_android_framework_defines
64 }
mtklein06c35c02016-09-20 12:28:12 -070065 if (!skia_enable_gpu) {
66 defines += [ "SK_SUPPORT_GPU=0" ]
67 }
mtkleinc04ff472016-06-23 10:29:30 -070068}
69
70# Skia internal APIs, used by Skia itself and a few test tools.
71config("skia_private") {
72 visibility = [ ":*" ]
73
74 include_dirs = [
75 "include/private",
76 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -070077 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -070078 "src/config",
79 "src/core",
80 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -070081 "src/effects/gradients",
82 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -070083 "src/gpu",
84 "src/image",
85 "src/images",
86 "src/lazy",
87 "src/opts",
88 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -070089 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -070090 "src/ports",
91 "src/sfnt",
mtklein9e0d9dd2016-08-30 10:37:19 -070092 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -070093 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -070094 "src/utils/win",
mtkleinc04ff472016-06-23 10:29:30 -070095 "third_party/etc1",
96 "third_party/ktx",
97 ]
mtklein150d1132016-08-01 06:56:40 -070098
mtklein63213812016-08-24 09:55:56 -070099 defines = [ "SK_GAMMA_APPLY_TO_A8" ]
mtkleinb37c0342016-09-09 11:07:45 -0700100 if (is_android) {
101 defines += [
102 "SK_GAMMA_EXPONENT=1.4",
103 "SK_GAMMA_CONTRAST=0.0",
104 ]
105 }
mtklein88a7ac02016-09-14 11:16:49 -0700106 if (is_official_build || is_android) {
107 # TODO(bsalomon): it'd be nice to make Android normal.
108 defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
109 }
mtkleinc04ff472016-06-23 10:29:30 -0700110}
111
112# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
113config("skia_library") {
114 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -0700115 defines = [ "SKIA_IMPLEMENTATION=1" ]
116}
117
118skia_library_configs = [
119 ":skia_public",
120 ":skia_private",
121 ":skia_library",
122]
123
mtklein9b8583d2016-08-24 17:32:30 -0700124# Use for CPU-specific Skia code that needs particular compiler flags.
125template("opts") {
126 if (invoker.enabled) {
127 source_set(target_name) {
128 forward_variables_from(invoker, "*")
129 configs += skia_library_configs
130 }
131 } else {
132 # If not enabled, a phony empty target that swallows all otherwise unused variables.
133 source_set(target_name) {
134 forward_variables_from(invoker,
135 "*",
136 [
137 "sources",
138 "cflags",
139 ])
140 }
141 }
anmittala7eaf2e2016-08-17 13:57:26 -0700142}
143
mtklein422310d2016-08-16 18:28:43 -0700144is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700145
mtklein7d6fb2c2016-08-25 14:50:44 -0700146opts("none") {
147 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700148 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700149 cflags = []
150}
151
mtklein7d6fb2c2016-08-25 14:50:44 -0700152opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700153 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700154 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700155 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700156}
157
158opts("arm64") {
159 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700160 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700161 cflags = []
162}
163
164opts("crc32") {
165 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700166 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700167 cflags = [ "-march=armv8-a+crc" ]
168}
169
mtklein9b8583d2016-08-24 17:32:30 -0700170opts("sse2") {
171 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700172 sources = skia_opts.sse2_sources
mtklein9b8583d2016-08-24 17:32:30 -0700173 cflags = [ "-msse2" ]
174}
mtkleinc04ff472016-06-23 10:29:30 -0700175
mtklein9b8583d2016-08-24 17:32:30 -0700176opts("ssse3") {
177 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700178 sources = skia_opts.ssse3_sources
mtklein9b8583d2016-08-24 17:32:30 -0700179 cflags = [ "-mssse3" ]
180}
mtkleinc04ff472016-06-23 10:29:30 -0700181
mtklein9b8583d2016-08-24 17:32:30 -0700182opts("sse41") {
183 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700184 sources = skia_opts.sse41_sources
mtklein9b8583d2016-08-24 17:32:30 -0700185 cflags = [ "-msse4.1" ]
186}
mtklein4e976072016-08-08 09:06:27 -0700187
mtklein9b8583d2016-08-24 17:32:30 -0700188opts("sse42") {
189 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700190 sources = skia_opts.sse42_sources
mtklein9b8583d2016-08-24 17:32:30 -0700191 cflags = [ "-msse4.2" ]
192}
193
194opts("avx") {
195 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700196 sources = skia_opts.avx_sources
mtklein9b8583d2016-08-24 17:32:30 -0700197 cflags = [ "-mavx" ]
mtkleinc04ff472016-06-23 10:29:30 -0700198}
199
mtklein349cece2016-08-26 08:13:04 -0700200opts("dsp") {
201 enabled = current_cpu == "mipsel"
brettwb9447282016-09-01 14:24:39 -0700202 sources = skia_opts.mips_dsp_sources
mtkleinb6064ef2016-08-30 11:49:24 -0700203 cflags = []
mtklein349cece2016-08-26 08:13:04 -0700204}
205
mtkleinc095df52016-08-24 12:23:52 -0700206# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700207template("optional") {
208 if (invoker.enabled) {
209 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700210 if (defined(invoker.public_defines)) {
211 defines = invoker.public_defines
212 }
mtklein457b42a2016-08-23 13:56:37 -0700213 }
214 source_set(target_name) {
mtkleincd01b032016-08-31 04:58:19 -0700215 forward_variables_from(invoker,
216 "*",
217 [
218 "public_defines",
219 "sources_when_disabled",
220 ])
mtklein457b42a2016-08-23 13:56:37 -0700221 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700222 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700223 }
224 } else {
mtklein457b42a2016-08-23 13:56:37 -0700225 source_set(target_name) {
226 forward_variables_from(invoker,
227 "*",
228 [
229 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700230 "deps",
mtklein6ef69992016-09-14 06:12:09 -0700231 "libs",
mtklein457b42a2016-08-23 13:56:37 -0700232 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700233 "sources_when_disabled",
mtklein457b42a2016-08-23 13:56:37 -0700234 ])
mtkleincd01b032016-08-31 04:58:19 -0700235 if (defined(invoker.sources_when_disabled)) {
236 sources = invoker.sources_when_disabled
237 }
238 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700239 }
mtkleineb3c4252016-08-23 07:38:09 -0700240 }
mtklein457b42a2016-08-23 13:56:37 -0700241}
mtklein457b42a2016-08-23 13:56:37 -0700242
mtkleina45be612016-08-29 15:22:10 -0700243optional("fontmgr_android") {
244 enabled = fontmgr_android_enabled
mtkleina45be612016-08-29 15:22:10 -0700245
246 deps = [
247 "//third_party/expat",
248 "//third_party/freetype2",
249 ]
250 sources = [
251 "src/ports/SkFontMgr_android.cpp",
252 "src/ports/SkFontMgr_android_factory.cpp",
253 "src/ports/SkFontMgr_android_parser.cpp",
254 ]
255}
256
mtkleind2e39db2016-09-07 07:52:55 -0700257optional("fontmgr_custom") {
258 enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
259
260 deps = [
261 "//third_party/freetype2",
262 ]
263 sources = [
264 "src/ports/SkFontMgr_custom.cpp",
265 "src/ports/SkFontMgr_custom_directory_factory.cpp",
266 ]
267}
268
mtklein3cc22182016-08-29 13:26:14 -0700269optional("fontmgr_fontconfig") {
270 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700271
272 deps = [
273 "//third_party:fontconfig",
274 "//third_party/freetype2",
275 ]
276 sources = [
bungeman1ae0e012016-09-19 12:13:16 -0700277 "src/ports/SkFontConfigInterface.cpp",
mtklein3cc22182016-08-29 13:26:14 -0700278 "src/ports/SkFontConfigInterface_direct.cpp",
279 "src/ports/SkFontConfigInterface_direct_factory.cpp",
280 "src/ports/SkFontMgr_FontConfigInterface.cpp",
281 "src/ports/SkFontMgr_fontconfig.cpp",
282 "src/ports/SkFontMgr_fontconfig_factory.cpp",
283 ]
284}
285
mtkleincdedd0e2016-09-12 15:15:44 -0700286optional("fontmgr_fuchsia") {
287 enabled = is_fuchsia && skia_use_freetype
288
289 deps = [
290 "//third_party/freetype2",
291 ]
292 sources = [
293 "src/ports/SkFontMgr_custom.cpp",
294 "src/ports/SkFontMgr_custom_empty_factory.cpp",
295 ]
296}
297
mtklein457b42a2016-08-23 13:56:37 -0700298optional("gif") {
299 enabled = skia_use_giflib
300 public_defines = [ "SK_HAS_GIF_LIBRARY" ]
301
mtklein457b42a2016-08-23 13:56:37 -0700302 deps = [
303 "//third_party/giflib",
304 ]
305 sources = [
306 "src/codec/SkGifCodec.cpp",
307 ]
308}
309
mtklein06c35c02016-09-20 12:28:12 -0700310optional("gpu") {
311 enabled = skia_enable_gpu
mtkleine9fb3d52016-09-20 15:11:46 -0700312 public_defines = []
313
mtklein06c35c02016-09-20 12:28:12 -0700314 sources = skia_gpu_sources + [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ]
315
316 # These paths need to be absolute to match the ones produced by shared_sources.gni.
317 sources -= get_path_info([
318 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
319 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
320 ],
321 "abspath")
322 if (is_android) {
323 sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
324 } else if (is_linux) {
325 sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
326 } else if (is_mac) {
327 sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
328 } else {
329 sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
330 }
mtkleine9fb3d52016-09-20 15:11:46 -0700331 libs = []
332
333 if (skia_use_vulkan) {
334 public_defines += [ "SK_VULKAN" ]
335 sources += skia_vk_sources
336 libs += [ "vulkan" ]
egdaniele4a9bd72016-09-21 07:36:14 -0700337 if (skia_enable_vulkan_debug_layers) {
338 public_defines += [ "SK_ENABLE_VK_LAYERS" ]
339 }
mtkleine9fb3d52016-09-20 15:11:46 -0700340 }
mtklein06c35c02016-09-20 12:28:12 -0700341}
342
mtklein63213812016-08-24 09:55:56 -0700343optional("jpeg") {
344 enabled = skia_use_libjpeg_turbo
345 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
346
mtklein63213812016-08-24 09:55:56 -0700347 deps = [
348 "//third_party/libjpeg-turbo:libjpeg",
349 ]
350 sources = [
351 "src/codec/SkJpegCodec.cpp",
352 "src/codec/SkJpegDecoderMgr.cpp",
353 "src/codec/SkJpegUtility.cpp",
354 "src/images/SkJPEGImageEncoder.cpp",
355 "src/images/SkJPEGWriteUtility.cpp",
356 ]
357}
358
359optional("pdf") {
360 enabled = skia_use_zlib
mtklein63213812016-08-24 09:55:56 -0700361
mtklein63213812016-08-24 09:55:56 -0700362 deps = [
363 "//third_party/zlib",
364 ]
brettwb9447282016-09-01 14:24:39 -0700365 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700366 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700367
368 if (skia_use_sfntly) {
369 deps += [ "//third_party/sfntly" ]
mtkleincd01b032016-08-31 04:58:19 -0700370 public_defines = [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700371 }
372}
373
374optional("png") {
375 enabled = skia_use_libpng
376 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
377
mtklein63213812016-08-24 09:55:56 -0700378 deps = [
379 "//third_party/libpng",
380 ]
381 sources = [
382 "src/codec/SkIcoCodec.cpp",
383 "src/codec/SkPngCodec.cpp",
384 "src/images/SkPNGImageEncoder.cpp",
385 ]
386}
387
mtklein3cc22182016-08-29 13:26:14 -0700388optional("typeface_freetype") {
389 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700390
391 deps = [
392 "//third_party/freetype2",
393 ]
394 sources = [
395 "src/ports/SkFontHost_FreeType.cpp",
396 "src/ports/SkFontHost_FreeType_common.cpp",
397 ]
398}
399
mtklein457b42a2016-08-23 13:56:37 -0700400optional("webp") {
401 enabled = skia_use_libwebp
402 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
403
mtklein457b42a2016-08-23 13:56:37 -0700404 deps = [
405 "//third_party/libwebp",
406 ]
407 sources = [
408 "src/codec/SkWebpAdapterCodec.cpp",
409 "src/codec/SkWebpCodec.cpp",
410 "src/images/SkWEBPImageEncoder.cpp",
411 ]
mtkleineb3c4252016-08-23 07:38:09 -0700412}
413
mtklein63213812016-08-24 09:55:56 -0700414optional("xml") {
415 enabled = skia_use_expat
mtklein63213812016-08-24 09:55:56 -0700416
mtklein63213812016-08-24 09:55:56 -0700417 deps = [
418 "//third_party/expat",
419 ]
420 sources = [
421 "src/xml/SkDOM.cpp",
422 "src/xml/SkXMLParser.cpp",
423 "src/xml/SkXMLWriter.cpp",
424 ]
425}
426
mtkleinc04ff472016-06-23 10:29:30 -0700427component("skia") {
428 public_configs = [ ":skia_public" ]
429 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700430
431 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700432 ":arm64",
433 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700434 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700435 ":crc32",
mtklein349cece2016-08-26 08:13:04 -0700436 ":dsp",
mtkleina45be612016-08-29 15:22:10 -0700437 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700438 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700439 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700440 ":fontmgr_fuchsia",
mtklein457b42a2016-08-23 13:56:37 -0700441 ":gif",
mtklein06c35c02016-09-20 12:28:12 -0700442 ":gpu",
mtklein63213812016-08-24 09:55:56 -0700443 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700444 ":none",
mtklein63213812016-08-24 09:55:56 -0700445 ":pdf",
446 ":png",
mtklein9b8583d2016-08-24 17:32:30 -0700447 ":sse2",
448 ":sse41",
449 ":sse42",
450 ":ssse3",
mtklein3cc22182016-08-29 13:26:14 -0700451 ":typeface_freetype",
mtkleineb3c4252016-08-23 07:38:09 -0700452 ":webp",
mtklein63213812016-08-24 09:55:56 -0700453 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700454 ]
455
mtkleinc04ff472016-06-23 10:29:30 -0700456 sources = []
brettwb9447282016-09-01 14:24:39 -0700457 sources += skia_core_sources
458 sources += skia_effects_sources
brettwb9447282016-09-01 14:24:39 -0700459 sources += skia_sksl_sources
460 sources += skia_utils_sources
mtkleinc04ff472016-06-23 10:29:30 -0700461 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700462 "src/android/SkBitmapRegionCodec.cpp",
463 "src/android/SkBitmapRegionDecoder.cpp",
464 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700465 "src/codec/SkBmpCodec.cpp",
466 "src/codec/SkBmpMaskCodec.cpp",
467 "src/codec/SkBmpRLECodec.cpp",
468 "src/codec/SkBmpStandardCodec.cpp",
469 "src/codec/SkCodec.cpp",
470 "src/codec/SkCodecImageGenerator.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700471 "src/codec/SkMaskSwizzler.cpp",
472 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700473 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700474 "src/codec/SkSampler.cpp",
475 "src/codec/SkSwizzler.cpp",
476 "src/codec/SkWbmpCodec.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700477 "src/images/SkImageEncoder.cpp",
478 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700479 "src/images/SkKTXImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700480 "src/ports/SkDiscardableMemory_none.cpp",
481 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700482 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700483 "src/ports/SkMemory_malloc.cpp",
484 "src/ports/SkOSFile_stdio.cpp",
485 "src/sfnt/SkOTTable_name.cpp",
486 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700487 "src/svg/SkSVGCanvas.cpp",
488 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700489 "src/utils/mac/SkStream_mac.cpp",
490 "third_party/etc1/etc1.cpp",
491 "third_party/ktx/ktx.cpp",
492 ]
brettwb9447282016-09-01 14:24:39 -0700493
mtklein7d6fb2c2016-08-25 14:50:44 -0700494 libs = []
495
mtkleinc04ff472016-06-23 10:29:30 -0700496 if (is_win) {
497 sources += [
498 "src/ports/SkDebug_win.cpp",
499 "src/ports/SkFontHost_win.cpp",
500 "src/ports/SkFontMgr_win_dw.cpp",
501 "src/ports/SkFontMgr_win_dw_factory.cpp",
502 "src/ports/SkImageEncoder_WIC.cpp",
503 "src/ports/SkImageGeneratorWIC.cpp",
504 "src/ports/SkOSFile_win.cpp",
mtklein605d9522016-09-21 14:01:32 -0700505 "src/ports/SkOSLibrary_win.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700506 "src/ports/SkScalerContext_win_dw.cpp",
507 "src/ports/SkTLS_win.cpp",
508 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700509 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700510 ]
mtkleinb9be9792016-09-16 14:44:18 -0700511 sources -=
512 [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
mtkleinc04ff472016-06-23 10:29:30 -0700513 } else {
514 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700515 "src/ports/SkOSFile_posix.cpp",
mtklein605d9522016-09-21 14:01:32 -0700516 "src/ports/SkOSLibrary_posix.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700517 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700518 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700519 ]
520 }
521
mtklein7d6fb2c2016-08-25 14:50:44 -0700522 if (is_android) {
523 deps += [
524 "//third_party/cpu-features",
525 "//third_party/expat",
mtklein7d6fb2c2016-08-25 14:50:44 -0700526 ]
mtklein06c35c02016-09-20 12:28:12 -0700527 sources += [ "src/ports/SkDebug_android.cpp" ]
mtklein7d6fb2c2016-08-25 14:50:44 -0700528 libs += [
529 "EGL",
530 "GLESv2",
531 "log",
532 ]
533 }
534
mtkleinc04ff472016-06-23 10:29:30 -0700535 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700536 libs += [
537 "GL",
538 "GLU",
539 "X11",
540 ]
mtklein06c35c02016-09-20 12:28:12 -0700541 sources += [ "src/ports/SkDebug_stdio.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700542 }
543
544 if (is_mac) {
545 sources += [
mtklein7d6fb2c2016-08-25 14:50:44 -0700546 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700547 "src/ports/SkFontHost_mac.cpp",
548 "src/ports/SkImageEncoder_CG.cpp",
549 "src/ports/SkImageGeneratorCG.cpp",
550 ]
mtklein09e61f72016-08-23 13:35:28 -0700551 libs += [
552 "ApplicationServices.framework",
553 "OpenGL.framework",
554 ]
mtkleinc04ff472016-06-23 10:29:30 -0700555 }
abarth6fc8ff02016-07-15 15:15:15 -0700556
557 if (is_fuchsia) {
mtklein06c35c02016-09-20 12:28:12 -0700558 sources += [ "src/ports/SkDebug_stdio.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700559 }
mtkleinc04ff472016-06-23 10:29:30 -0700560}
561
mtkleinada5a442016-08-02 14:28:26 -0700562skia_h_headers = exec_script("gyp/find.py",
563 [ "*.h" ] + rebase_path(skia_public_includes),
564 "list lines",
565 []) -
566 [
567 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
568 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
569 rebase_path("include/gpu/vk/GrVkDefines.h"),
570 rebase_path("include/gpu/vk/GrVkInterface.h"),
571 rebase_path("include/gpu/vk/GrVkTypes.h"),
572 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
573 ]
574
mtklein1211e0c2016-07-26 13:55:45 -0700575action("skia.h") {
576 script = "gn/echo_headers.py"
577 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinc095df52016-08-24 12:23:52 -0700578 rebase_path(skia_h_headers, target_gen_dir)
Ben Wagnerbc344042016-09-29 15:41:53 -0400579 inputs = skia_h_headers
mtklein1211e0c2016-07-26 13:55:45 -0700580 outputs = [
581 "$target_gen_dir/skia.h",
582 ]
583}
584
mtklein06c35c02016-09-20 12:28:12 -0700585if (skia_enable_gpu && target_cpu == "x64") {
mtklein1fbdf982016-09-15 12:07:48 -0700586 # Our bots only have 64-bit libOSMesa installed.
587 # TODO: worth fixing?
588 executable("fiddle") {
589 include_dirs = [ "$target_gen_dir" ]
590 libs = []
591 if (is_linux) {
592 libs += [ "OSMesa" ]
593 }
mtklein56d56692016-09-15 11:18:55 -0700594
mtklein1fbdf982016-09-15 12:07:48 -0700595 sources = [
596 "src/images/SkForceLinking.cpp",
597 "tools/fiddle/draw.cpp",
598 "tools/fiddle/fiddle_main.cpp",
599 ]
600 deps = [
601 ":skia",
602 ":skia.h",
603 ]
604 }
mtkleinc04ff472016-06-23 10:29:30 -0700605}
mtklein25c81d42016-07-27 13:55:26 -0700606
mtkleinc095df52016-08-24 12:23:52 -0700607# Targets guarded by skia_enable_tools may use //third_party freely.
608if (skia_enable_tools) {
609 template("test_lib") {
610 config(target_name + "_config") {
611 include_dirs = invoker.public_include_dirs
mtkleina627b5c2016-09-20 13:36:47 -0700612 if (defined(invoker.public_defines)) {
613 defines = invoker.public_defines
614 }
mtklein25c81d42016-07-27 13:55:26 -0700615 }
mtkleinc095df52016-08-24 12:23:52 -0700616 source_set(target_name) {
617 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
618 public_configs = [
619 ":" + target_name + "_config",
620 ":skia_private",
621 ]
622
623 if (!defined(deps)) {
624 deps = []
625 }
626 deps += [ ":skia" ]
627 testonly = true
628 }
mtklein25c81d42016-07-27 13:55:26 -0700629 }
mtklein25c81d42016-07-27 13:55:26 -0700630
mtkleinc095df52016-08-24 12:23:52 -0700631 test_lib("gpu_tool_utils") {
mtklein38925aa2016-09-21 10:11:25 -0700632 public_include_dirs = []
633 if (skia_enable_gpu) {
634 public_defines = []
635 public_include_dirs += [ "tools/gpu" ]
mtkleind68f9b02016-09-23 13:18:41 -0700636
637 deps = []
mtklein38925aa2016-09-21 10:11:25 -0700638 sources = [
639 "tools/gpu/GrContextFactory.cpp",
640 "tools/gpu/GrTest.cpp",
641 "tools/gpu/TestContext.cpp",
642 "tools/gpu/gl/GLTestContext.cpp",
mtklein605d9522016-09-21 14:01:32 -0700643 "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
mtklein38925aa2016-09-21 10:11:25 -0700644 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
645 "tools/gpu/gl/debug/GrBufferObj.cpp",
646 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
647 "tools/gpu/gl/debug/GrProgramObj.cpp",
648 "tools/gpu/gl/debug/GrShaderObj.cpp",
649 "tools/gpu/gl/debug/GrTextureObj.cpp",
650 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
651 "tools/gpu/gl/null/NullGLTestContext.cpp",
652 ]
653 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700654
mtklein38925aa2016-09-21 10:11:25 -0700655 if (is_android) {
656 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
657 } else if (is_linux) {
658 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
659 } else if (is_mac) {
660 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
661 }
mtklein6ef69992016-09-14 06:12:09 -0700662
mtkleind68f9b02016-09-23 13:18:41 -0700663 if (skia_use_angle) {
664 public_defines += [ "SK_ANGLE" ]
665 deps += [ "//third_party/angle2" ]
666 sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
mtklein38925aa2016-09-21 10:11:25 -0700667 }
668 if (skia_use_mesa) {
669 public_defines += [ "SK_MESA" ]
670 sources += [ "tools/gpu/gl/mesa/GLTestContext_mesa.cpp" ]
671 libs += [ "OSMesa" ]
672 }
mtkleind68f9b02016-09-23 13:18:41 -0700673 if (skia_use_vulkan) {
674 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
675 }
mtkleina627b5c2016-09-20 13:36:47 -0700676 }
mtklein25c81d42016-07-27 13:55:26 -0700677 }
mtklein25c81d42016-07-27 13:55:26 -0700678
mtkleinc095df52016-08-24 12:23:52 -0700679 test_lib("flags") {
680 public_include_dirs = [ "tools/flags" ]
681 sources = [
682 "tools/flags/SkCommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -0700683 ]
684 }
685 test_lib("common_flags") {
686 public_include_dirs = [ "tools/flags" ]
687 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700688 "tools/flags/SkCommonFlags.cpp",
689 "tools/flags/SkCommonFlagsConfig.cpp",
690 ]
691 deps = [
mtklein046cb562016-09-16 10:23:12 -0700692 ":flags",
mtkleinc095df52016-08-24 12:23:52 -0700693 ":gpu_tool_utils",
694 ]
695 }
mtklein25c81d42016-07-27 13:55:26 -0700696
mtkleinc095df52016-08-24 12:23:52 -0700697 test_lib("tool_utils") {
698 public_include_dirs = [
699 "tools",
700 "tools/debugger",
701 "tools/timer",
702 ]
703 sources = [
704 "src/images/SkForceLinking.cpp",
705 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700706 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700707 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700708 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700709 "tools/ProcStats.cpp",
710 "tools/Resources.cpp",
711 "tools/ThermalManager.cpp",
712 "tools/UrlDataManager.cpp",
713 "tools/debugger/SkDebugCanvas.cpp",
714 "tools/debugger/SkDrawCommand.cpp",
715 "tools/debugger/SkJsonWriteBuffer.cpp",
716 "tools/debugger/SkObjectParser.cpp",
717 "tools/debugger/SkOverdrawMode.cpp",
718 "tools/picture_utils.cpp",
719 "tools/random_parse_path.cpp",
720 "tools/sk_tool_utils.cpp",
721 "tools/sk_tool_utils_font.cpp",
722 "tools/timer/Timer.cpp",
723 ]
724 deps = [
mtklein046cb562016-09-16 10:23:12 -0700725 ":common_flags",
mtkleinc095df52016-08-24 12:23:52 -0700726 ":flags",
727 "//third_party/libpng",
728 ]
729 public_deps = [
730 "//third_party/jsoncpp",
731 ]
732 }
mtklein25c81d42016-07-27 13:55:26 -0700733
mtkleinc095df52016-08-24 12:23:52 -0700734 gm_sources = exec_script("gyp/find.py",
735 [
736 "*.c*",
737 rebase_path("gm"),
738 ],
739 "list lines",
740 [])
741 test_lib("gm") {
742 public_include_dirs = [ "gm" ]
743 sources = gm_sources
744 deps = [
745 ":gpu_tool_utils",
746 ":skia",
747 ":tool_utils",
748 ]
749 }
mtklein25c81d42016-07-27 13:55:26 -0700750
mtkleinc095df52016-08-24 12:23:52 -0700751 tests_sources = exec_script("gyp/find.py",
752 [
753 "*.c*",
754 rebase_path("tests"),
755 ],
756 "list lines",
757 [])
mtklein2f3416d2016-08-02 16:02:05 -0700758
mtkleinc095df52016-08-24 12:23:52 -0700759 test_lib("tests") {
760 public_include_dirs = [ "tests" ]
mtkleina45be612016-08-29 15:22:10 -0700761 sources = tests_sources - [
762 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
mtkleina45be612016-08-29 15:22:10 -0700763 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
764 rebase_path("tests/skia_test.cpp"), # alternate main
765 ]
766 if (!fontmgr_android_enabled) {
767 sources -= [ rebase_path("tests/FontMgrAndroidParserTest.cpp") ]
768 }
mtkleinc095df52016-08-24 12:23:52 -0700769 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700770 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700771 ":flags",
772 ":gpu_tool_utils",
773 ":skia",
774 ":tool_utils",
775 "//third_party/libpng",
776 "//third_party/zlib",
777 ]
778 }
mtklein2f3416d2016-08-02 16:02:05 -0700779
mtkleinc095df52016-08-24 12:23:52 -0700780 bench_sources = exec_script("gyp/find.py",
781 [
782 "*.c*",
783 rebase_path("bench"),
784 ],
785 "list lines",
786 [])
mtklein25c81d42016-07-27 13:55:26 -0700787
mtkleinc095df52016-08-24 12:23:52 -0700788 test_lib("bench") {
789 public_include_dirs = [ "bench" ]
790 sources = bench_sources
791 sources -= [
792 rebase_path("bench/nanobench.cpp"),
793 rebase_path("bench/nanobenchAndroid.cpp"),
794 ]
795 deps = [
796 ":flags",
797 ":gm",
798 ":gpu_tool_utils",
799 ":skia",
800 ":tool_utils",
801 ]
802 }
mtklein2b6870c2016-07-28 14:17:33 -0700803
mtkleinc095df52016-08-24 12:23:52 -0700804 test_lib("experimental_svg_model") {
805 public_include_dirs = [ "experimental/svg/model" ]
806 sources = [
807 "experimental/svg/model/SkSVGAttribute.cpp",
808 "experimental/svg/model/SkSVGAttributeParser.cpp",
809 "experimental/svg/model/SkSVGCircle.cpp",
810 "experimental/svg/model/SkSVGContainer.cpp",
811 "experimental/svg/model/SkSVGDOM.cpp",
812 "experimental/svg/model/SkSVGEllipse.cpp",
813 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700814 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700815 "experimental/svg/model/SkSVGNode.cpp",
816 "experimental/svg/model/SkSVGPath.cpp",
817 "experimental/svg/model/SkSVGPoly.cpp",
818 "experimental/svg/model/SkSVGRect.cpp",
819 "experimental/svg/model/SkSVGRenderContext.cpp",
820 "experimental/svg/model/SkSVGSVG.cpp",
821 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700822 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700823 "experimental/svg/model/SkSVGTransformableNode.cpp",
824 "experimental/svg/model/SkSVGValue.cpp",
825 ]
826 deps = [
827 ":skia",
828 ]
829 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700830
mtklein2b6870c2016-07-28 14:17:33 -0700831 executable("dm") {
832 sources = [
833 "dm/DM.cpp",
834 "dm/DMJsonWriter.cpp",
835 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700836 ]
837 include_dirs = [ "tests" ]
838 deps = [
mtklein046cb562016-09-16 10:23:12 -0700839 ":common_flags",
fmalitaa2b9fdf2016-08-03 19:53:36 -0700840 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700841 ":flags",
842 ":gm",
843 ":gpu_tool_utils",
844 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700845 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700846 ":tool_utils",
847 "//third_party/jsoncpp",
848 "//third_party/libpng",
849 ]
850 testonly = true
851 }
852
Mike Kleina3430172016-09-27 16:46:29 -0400853 if (!is_debug) { # I've benchmarked debug code once too many times...
854 executable("monobench") {
855 sources = [
856 "tools/monobench.cpp",
857 ]
858 deps = [
859 ":bench",
860 ":skia",
861 ]
862 testonly = true
863 }
mtklein2b6870c2016-07-28 14:17:33 -0700864 }
865
866 executable("nanobench") {
867 sources = [
868 "bench/nanobench.cpp",
869 ]
870 deps = [
871 ":bench",
mtklein046cb562016-09-16 10:23:12 -0700872 ":common_flags",
fmalita6519c212016-09-14 08:05:17 -0700873 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700874 ":flags",
875 ":gm",
876 ":gpu_tool_utils",
877 ":skia",
878 ":tool_utils",
879 "//third_party/jsoncpp",
880 ]
881 testonly = true
882 }
halcanary19a97202016-08-03 15:08:04 -0700883
mtklein38925aa2016-09-21 10:11:25 -0700884 if (skia_enable_gpu) {
885 executable("skpbench") {
886 sources = [
887 "tools/skpbench/skpbench.cpp",
888 ]
889 deps = [
890 ":flags",
891 ":gpu_tool_utils",
892 ":skia",
893 ":tool_utils",
894 ]
895 testonly = true
896 }
csmartdalton4b5179b2016-09-19 11:03:58 -0700897 }
898
mtklein6f5df6a2016-08-29 16:01:10 -0700899 if (current_cpu != "mipsel") { # Clang 3.8 crashes while compiling hb-icu.cc for mipsel.
halcanary3eee9d92016-09-10 07:01:53 -0700900 executable("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -0700901 sources = [
902 "tools/SkShaper_harfbuzz.cpp",
903 "tools/using_skia_and_harfbuzz.cpp",
904 ]
905 deps = [
906 ":skia",
907 "//third_party/harfbuzz",
908 ]
909 testonly = true
910 }
halcanary19a97202016-08-03 15:08:04 -0700911 }
halcanary3eee9d92016-09-10 07:01:53 -0700912 executable("sktexttopdf") {
913 sources = [
914 "tools/SkShaper_primitive.cpp",
915 "tools/using_skia_and_harfbuzz.cpp",
916 ]
917 deps = [
918 ":skia",
919 ]
920 testonly = true
921 }
mtklein046cb562016-09-16 10:23:12 -0700922
923 executable("get_images_from_skps") {
924 sources = [
925 "tools/get_images_from_skps.cpp",
926 ]
927 deps = [
928 ":flags",
929 ":skia",
930 "//third_party/jsoncpp",
931 ]
932 testonly = true
933 }
mtkleinecbc5262016-09-22 11:51:24 -0700934
935 executable("skiaserve") {
936 sources = [
937 "tools/skiaserve/Request.cpp",
938 "tools/skiaserve/Response.cpp",
939 "tools/skiaserve/skiaserve.cpp",
940 "tools/skiaserve/urlhandlers/BatchBoundsHandler.cpp",
941 "tools/skiaserve/urlhandlers/BatchesHandler.cpp",
942 "tools/skiaserve/urlhandlers/BreakHandler.cpp",
943 "tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp",
944 "tools/skiaserve/urlhandlers/CmdHandler.cpp",
945 "tools/skiaserve/urlhandlers/ColorModeHandler.cpp",
946 "tools/skiaserve/urlhandlers/DataHandler.cpp",
947 "tools/skiaserve/urlhandlers/DownloadHandler.cpp",
948 "tools/skiaserve/urlhandlers/EnableGPUHandler.cpp",
949 "tools/skiaserve/urlhandlers/ImgHandler.cpp",
950 "tools/skiaserve/urlhandlers/InfoHandler.cpp",
951 "tools/skiaserve/urlhandlers/PostHandler.cpp",
952 "tools/skiaserve/urlhandlers/QuitHandler.cpp",
953 "tools/skiaserve/urlhandlers/RootHandler.cpp",
954 ]
955 deps = [
956 ":flags",
957 ":gpu_tool_utils",
958 ":skia",
959 ":tool_utils",
960 "//third_party/jsoncpp",
961 "//third_party/libmicrohttpd",
962 "//third_party/libpng",
963 ]
964 testonly = true
965 }
mtklein25c81d42016-07-27 13:55:26 -0700966}