blob: 9dd881db54fc8bfac0e1fd4d7a5b2f3810e6c052 [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() {
mtklein63213812016-08-24 09:55:56 -070013 skia_use_expat = true
mtklein3cc22182016-08-29 13:26:14 -070014 skia_use_fontconfig = is_linux
mtkleincdedd0e2016-09-12 15:15:44 -070015 skia_use_freetype = is_android || is_fuchsia || is_linux
mtklein457b42a2016-08-23 13:56:37 -070016 skia_use_giflib = !is_fuchsia
mtklein63213812016-08-24 09:55:56 -070017 skia_use_libjpeg_turbo = true
18 skia_use_libpng = true
mtkleineb3c4252016-08-23 07:38:09 -070019 skia_use_libwebp = !is_fuchsia
mtkleina627b5c2016-09-20 13:36:47 -070020 skia_use_mesa = false
mtklein63213812016-08-24 09:55:56 -070021 skia_use_sfntly = !is_fuchsia
mtkleinf29180e2016-09-16 07:01:17 -070022 skia_use_vulkan = is_android && defined(ndk_api) && ndk_api >= 24
mtklein63213812016-08-24 09:55:56 -070023 skia_use_zlib = true
mtklein1bd72ba2016-09-16 07:45:52 -070024
25 skia_enable_android_framework_defines = false
mtklein06c35c02016-09-20 12:28:12 -070026 skia_enable_gpu = true
mtklein3e8012e2016-09-21 09:14:19 -070027 skia_enable_tools = is_skia_standalone
28 skia_enable_vulkan_debug_layers = is_skia_standalone && is_debug
mtkleinc04ff472016-06-23 10:29:30 -070029}
30
mtklein38925aa2016-09-21 10:11:25 -070031# Our tools require static linking (they use non-exported symbols).
32skia_enable_tools = skia_enable_tools && !is_component_build
mtklein06c35c02016-09-20 12:28:12 -070033
mtkleina45be612016-08-29 15:22:10 -070034fontmgr_android_enabled = skia_use_expat && skia_use_freetype
35
mtklein1211e0c2016-07-26 13:55:45 -070036skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070037 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070038 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070039 "include/codec",
40 "include/config",
41 "include/core",
42 "include/effects",
43 "include/gpu",
44 "include/gpu/gl",
45 "include/images",
46 "include/pathops",
47 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070048 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070049 "include/utils",
50 "include/utils/mac",
mtklein25c81d42016-07-27 13:55:26 -070051 "include/xml",
mtklein1211e0c2016-07-26 13:55:45 -070052]
53
mtkleinc04ff472016-06-23 10:29:30 -070054# Skia public API, generally provided by :skia.
55config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -070056 include_dirs = skia_public_includes
mtkleinc04ff472016-06-23 10:29:30 -070057 defines = [ "SKIA_DLL" ]
jcgregorio5561e3d2016-08-25 09:25:11 -070058 if (is_linux) {
59 defines += [ "SK_SAMPLES_FOR_X" ]
60 }
mtkleincae1be52016-09-20 08:24:34 -070061 if (skia_enable_android_framework_defines) {
62 defines += skia_android_framework_defines
63 }
mtklein06c35c02016-09-20 12:28:12 -070064 if (!skia_enable_gpu) {
65 defines += [ "SK_SUPPORT_GPU=0" ]
66 }
mtkleinc04ff472016-06-23 10:29:30 -070067}
68
69# Skia internal APIs, used by Skia itself and a few test tools.
70config("skia_private") {
71 visibility = [ ":*" ]
72
73 include_dirs = [
74 "include/private",
75 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -070076 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -070077 "src/config",
78 "src/core",
79 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -070080 "src/effects/gradients",
81 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -070082 "src/gpu",
83 "src/image",
84 "src/images",
85 "src/lazy",
86 "src/opts",
87 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -070088 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -070089 "src/ports",
90 "src/sfnt",
mtklein9e0d9dd2016-08-30 10:37:19 -070091 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -070092 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -070093 "src/utils/win",
mtkleinc04ff472016-06-23 10:29:30 -070094 "third_party/etc1",
95 "third_party/ktx",
96 ]
mtklein150d1132016-08-01 06:56:40 -070097
mtklein63213812016-08-24 09:55:56 -070098 defines = [ "SK_GAMMA_APPLY_TO_A8" ]
mtkleinb37c0342016-09-09 11:07:45 -070099 if (is_android) {
100 defines += [
101 "SK_GAMMA_EXPONENT=1.4",
102 "SK_GAMMA_CONTRAST=0.0",
103 ]
104 }
mtklein88a7ac02016-09-14 11:16:49 -0700105 if (is_official_build || is_android) {
106 # TODO(bsalomon): it'd be nice to make Android normal.
107 defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
108 }
mtkleinc04ff472016-06-23 10:29:30 -0700109}
110
111# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
112config("skia_library") {
113 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -0700114 defines = [ "SKIA_IMPLEMENTATION=1" ]
115}
116
117skia_library_configs = [
118 ":skia_public",
119 ":skia_private",
120 ":skia_library",
121]
122
mtklein9b8583d2016-08-24 17:32:30 -0700123# Use for CPU-specific Skia code that needs particular compiler flags.
124template("opts") {
125 if (invoker.enabled) {
126 source_set(target_name) {
127 forward_variables_from(invoker, "*")
128 configs += skia_library_configs
129 }
130 } else {
131 # If not enabled, a phony empty target that swallows all otherwise unused variables.
132 source_set(target_name) {
133 forward_variables_from(invoker,
134 "*",
135 [
136 "sources",
137 "cflags",
138 ])
139 }
140 }
anmittala7eaf2e2016-08-17 13:57:26 -0700141}
142
mtklein422310d2016-08-16 18:28:43 -0700143is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700144
mtklein7d6fb2c2016-08-25 14:50:44 -0700145opts("none") {
146 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700147 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700148 cflags = []
149}
150
mtklein7d6fb2c2016-08-25 14:50:44 -0700151opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700152 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700153 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700154 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700155}
156
157opts("arm64") {
158 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700159 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700160 cflags = []
161}
162
163opts("crc32") {
164 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700165 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700166 cflags = [ "-march=armv8-a+crc" ]
167}
168
mtklein9b8583d2016-08-24 17:32:30 -0700169opts("sse2") {
170 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700171 sources = skia_opts.sse2_sources
mtklein9b8583d2016-08-24 17:32:30 -0700172 cflags = [ "-msse2" ]
173}
mtkleinc04ff472016-06-23 10:29:30 -0700174
mtklein9b8583d2016-08-24 17:32:30 -0700175opts("ssse3") {
176 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700177 sources = skia_opts.ssse3_sources
mtklein9b8583d2016-08-24 17:32:30 -0700178 cflags = [ "-mssse3" ]
179}
mtkleinc04ff472016-06-23 10:29:30 -0700180
mtklein9b8583d2016-08-24 17:32:30 -0700181opts("sse41") {
182 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700183 sources = skia_opts.sse41_sources
mtklein9b8583d2016-08-24 17:32:30 -0700184 cflags = [ "-msse4.1" ]
185}
mtklein4e976072016-08-08 09:06:27 -0700186
mtklein9b8583d2016-08-24 17:32:30 -0700187opts("sse42") {
188 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700189 sources = skia_opts.sse42_sources
mtklein9b8583d2016-08-24 17:32:30 -0700190 cflags = [ "-msse4.2" ]
191}
192
193opts("avx") {
194 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700195 sources = skia_opts.avx_sources
mtklein9b8583d2016-08-24 17:32:30 -0700196 cflags = [ "-mavx" ]
mtkleinc04ff472016-06-23 10:29:30 -0700197}
198
mtklein349cece2016-08-26 08:13:04 -0700199opts("dsp") {
200 enabled = current_cpu == "mipsel"
brettwb9447282016-09-01 14:24:39 -0700201 sources = skia_opts.mips_dsp_sources
mtkleinb6064ef2016-08-30 11:49:24 -0700202 cflags = []
mtklein349cece2016-08-26 08:13:04 -0700203}
204
mtkleinc095df52016-08-24 12:23:52 -0700205# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700206template("optional") {
207 if (invoker.enabled) {
208 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700209 if (defined(invoker.public_defines)) {
210 defines = invoker.public_defines
211 }
mtklein457b42a2016-08-23 13:56:37 -0700212 }
213 source_set(target_name) {
mtkleincd01b032016-08-31 04:58:19 -0700214 forward_variables_from(invoker,
215 "*",
216 [
217 "public_defines",
218 "sources_when_disabled",
219 ])
mtklein457b42a2016-08-23 13:56:37 -0700220 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700221 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700222 }
223 } else {
mtklein457b42a2016-08-23 13:56:37 -0700224 source_set(target_name) {
225 forward_variables_from(invoker,
226 "*",
227 [
228 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700229 "deps",
mtklein6ef69992016-09-14 06:12:09 -0700230 "libs",
mtklein457b42a2016-08-23 13:56:37 -0700231 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700232 "sources_when_disabled",
mtklein457b42a2016-08-23 13:56:37 -0700233 ])
mtkleincd01b032016-08-31 04:58:19 -0700234 if (defined(invoker.sources_when_disabled)) {
235 sources = invoker.sources_when_disabled
236 }
237 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700238 }
mtkleineb3c4252016-08-23 07:38:09 -0700239 }
mtklein457b42a2016-08-23 13:56:37 -0700240}
mtklein457b42a2016-08-23 13:56:37 -0700241
mtkleina45be612016-08-29 15:22:10 -0700242optional("fontmgr_android") {
243 enabled = fontmgr_android_enabled
mtkleina45be612016-08-29 15:22:10 -0700244
245 deps = [
246 "//third_party/expat",
247 "//third_party/freetype2",
248 ]
249 sources = [
250 "src/ports/SkFontMgr_android.cpp",
251 "src/ports/SkFontMgr_android_factory.cpp",
252 "src/ports/SkFontMgr_android_parser.cpp",
253 ]
254}
255
mtkleind2e39db2016-09-07 07:52:55 -0700256optional("fontmgr_custom") {
257 enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
258
259 deps = [
260 "//third_party/freetype2",
261 ]
262 sources = [
263 "src/ports/SkFontMgr_custom.cpp",
264 "src/ports/SkFontMgr_custom_directory_factory.cpp",
265 ]
266}
267
mtklein3cc22182016-08-29 13:26:14 -0700268optional("fontmgr_fontconfig") {
269 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700270
271 deps = [
272 "//third_party:fontconfig",
273 "//third_party/freetype2",
274 ]
275 sources = [
bungeman1ae0e012016-09-19 12:13:16 -0700276 "src/ports/SkFontConfigInterface.cpp",
mtklein3cc22182016-08-29 13:26:14 -0700277 "src/ports/SkFontConfigInterface_direct.cpp",
278 "src/ports/SkFontConfigInterface_direct_factory.cpp",
279 "src/ports/SkFontMgr_FontConfigInterface.cpp",
280 "src/ports/SkFontMgr_fontconfig.cpp",
281 "src/ports/SkFontMgr_fontconfig_factory.cpp",
282 ]
283}
284
mtkleincdedd0e2016-09-12 15:15:44 -0700285optional("fontmgr_fuchsia") {
286 enabled = is_fuchsia && skia_use_freetype
287
288 deps = [
289 "//third_party/freetype2",
290 ]
291 sources = [
292 "src/ports/SkFontMgr_custom.cpp",
293 "src/ports/SkFontMgr_custom_empty_factory.cpp",
294 ]
295}
296
mtklein457b42a2016-08-23 13:56:37 -0700297optional("gif") {
298 enabled = skia_use_giflib
299 public_defines = [ "SK_HAS_GIF_LIBRARY" ]
300
mtklein457b42a2016-08-23 13:56:37 -0700301 deps = [
302 "//third_party/giflib",
303 ]
304 sources = [
305 "src/codec/SkGifCodec.cpp",
306 ]
307}
308
mtklein06c35c02016-09-20 12:28:12 -0700309optional("gpu") {
310 enabled = skia_enable_gpu
mtkleine9fb3d52016-09-20 15:11:46 -0700311 public_defines = []
312
mtklein06c35c02016-09-20 12:28:12 -0700313 sources = skia_gpu_sources + [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ]
314
315 # These paths need to be absolute to match the ones produced by shared_sources.gni.
316 sources -= get_path_info([
317 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
318 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
319 ],
320 "abspath")
321 if (is_android) {
322 sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
323 } else if (is_linux) {
324 sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
325 } else if (is_mac) {
326 sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
327 } else {
328 sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
329 }
mtkleine9fb3d52016-09-20 15:11:46 -0700330 libs = []
331
332 if (skia_use_vulkan) {
333 public_defines += [ "SK_VULKAN" ]
334 sources += skia_vk_sources
335 libs += [ "vulkan" ]
egdaniele4a9bd72016-09-21 07:36:14 -0700336 if (skia_enable_vulkan_debug_layers) {
337 public_defines += [ "SK_ENABLE_VK_LAYERS" ]
338 }
mtkleine9fb3d52016-09-20 15:11:46 -0700339 }
mtklein06c35c02016-09-20 12:28:12 -0700340}
341
mtklein63213812016-08-24 09:55:56 -0700342optional("jpeg") {
343 enabled = skia_use_libjpeg_turbo
344 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
345
mtklein63213812016-08-24 09:55:56 -0700346 deps = [
347 "//third_party/libjpeg-turbo:libjpeg",
348 ]
349 sources = [
350 "src/codec/SkJpegCodec.cpp",
351 "src/codec/SkJpegDecoderMgr.cpp",
352 "src/codec/SkJpegUtility.cpp",
353 "src/images/SkJPEGImageEncoder.cpp",
354 "src/images/SkJPEGWriteUtility.cpp",
355 ]
356}
357
358optional("pdf") {
359 enabled = skia_use_zlib
mtklein63213812016-08-24 09:55:56 -0700360
mtklein63213812016-08-24 09:55:56 -0700361 deps = [
362 "//third_party/zlib",
363 ]
brettwb9447282016-09-01 14:24:39 -0700364 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700365 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700366
367 if (skia_use_sfntly) {
368 deps += [ "//third_party/sfntly" ]
mtkleincd01b032016-08-31 04:58:19 -0700369 public_defines = [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700370 }
371}
372
373optional("png") {
374 enabled = skia_use_libpng
375 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
376
mtklein63213812016-08-24 09:55:56 -0700377 deps = [
378 "//third_party/libpng",
379 ]
380 sources = [
381 "src/codec/SkIcoCodec.cpp",
382 "src/codec/SkPngCodec.cpp",
383 "src/images/SkPNGImageEncoder.cpp",
384 ]
385}
386
mtklein3cc22182016-08-29 13:26:14 -0700387optional("typeface_freetype") {
388 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700389
390 deps = [
391 "//third_party/freetype2",
392 ]
393 sources = [
394 "src/ports/SkFontHost_FreeType.cpp",
395 "src/ports/SkFontHost_FreeType_common.cpp",
396 ]
397}
398
mtklein457b42a2016-08-23 13:56:37 -0700399optional("webp") {
400 enabled = skia_use_libwebp
401 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
402
mtklein457b42a2016-08-23 13:56:37 -0700403 deps = [
404 "//third_party/libwebp",
405 ]
406 sources = [
407 "src/codec/SkWebpAdapterCodec.cpp",
408 "src/codec/SkWebpCodec.cpp",
409 "src/images/SkWEBPImageEncoder.cpp",
410 ]
mtkleineb3c4252016-08-23 07:38:09 -0700411}
412
mtklein63213812016-08-24 09:55:56 -0700413optional("xml") {
414 enabled = skia_use_expat
mtklein63213812016-08-24 09:55:56 -0700415
mtklein63213812016-08-24 09:55:56 -0700416 deps = [
417 "//third_party/expat",
418 ]
419 sources = [
420 "src/xml/SkDOM.cpp",
421 "src/xml/SkXMLParser.cpp",
422 "src/xml/SkXMLWriter.cpp",
423 ]
424}
425
mtkleinc04ff472016-06-23 10:29:30 -0700426component("skia") {
427 public_configs = [ ":skia_public" ]
428 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700429
430 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700431 ":arm64",
432 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700433 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700434 ":crc32",
mtklein349cece2016-08-26 08:13:04 -0700435 ":dsp",
mtkleina45be612016-08-29 15:22:10 -0700436 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700437 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700438 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700439 ":fontmgr_fuchsia",
mtklein457b42a2016-08-23 13:56:37 -0700440 ":gif",
mtklein06c35c02016-09-20 12:28:12 -0700441 ":gpu",
mtklein63213812016-08-24 09:55:56 -0700442 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700443 ":none",
mtklein63213812016-08-24 09:55:56 -0700444 ":pdf",
445 ":png",
mtklein9b8583d2016-08-24 17:32:30 -0700446 ":sse2",
447 ":sse41",
448 ":sse42",
449 ":ssse3",
mtklein3cc22182016-08-29 13:26:14 -0700450 ":typeface_freetype",
mtkleineb3c4252016-08-23 07:38:09 -0700451 ":webp",
mtklein63213812016-08-24 09:55:56 -0700452 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700453 ]
454
mtkleinc04ff472016-06-23 10:29:30 -0700455 sources = []
brettwb9447282016-09-01 14:24:39 -0700456 sources += skia_core_sources
457 sources += skia_effects_sources
brettwb9447282016-09-01 14:24:39 -0700458 sources += skia_sksl_sources
459 sources += skia_utils_sources
mtkleinc04ff472016-06-23 10:29:30 -0700460 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700461 "src/android/SkBitmapRegionCodec.cpp",
462 "src/android/SkBitmapRegionDecoder.cpp",
463 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700464 "src/codec/SkBmpCodec.cpp",
465 "src/codec/SkBmpMaskCodec.cpp",
466 "src/codec/SkBmpRLECodec.cpp",
467 "src/codec/SkBmpStandardCodec.cpp",
468 "src/codec/SkCodec.cpp",
469 "src/codec/SkCodecImageGenerator.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700470 "src/codec/SkMaskSwizzler.cpp",
471 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700472 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700473 "src/codec/SkSampler.cpp",
474 "src/codec/SkSwizzler.cpp",
475 "src/codec/SkWbmpCodec.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700476 "src/images/SkImageEncoder.cpp",
477 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700478 "src/images/SkKTXImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700479 "src/ports/SkDiscardableMemory_none.cpp",
480 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700481 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700482 "src/ports/SkMemory_malloc.cpp",
483 "src/ports/SkOSFile_stdio.cpp",
484 "src/sfnt/SkOTTable_name.cpp",
485 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700486 "src/svg/SkSVGCanvas.cpp",
487 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700488 "src/utils/mac/SkStream_mac.cpp",
489 "third_party/etc1/etc1.cpp",
490 "third_party/ktx/ktx.cpp",
491 ]
brettwb9447282016-09-01 14:24:39 -0700492
mtklein7d6fb2c2016-08-25 14:50:44 -0700493 libs = []
494
mtkleinc04ff472016-06-23 10:29:30 -0700495 if (is_win) {
496 sources += [
497 "src/ports/SkDebug_win.cpp",
498 "src/ports/SkFontHost_win.cpp",
499 "src/ports/SkFontMgr_win_dw.cpp",
500 "src/ports/SkFontMgr_win_dw_factory.cpp",
501 "src/ports/SkImageEncoder_WIC.cpp",
502 "src/ports/SkImageGeneratorWIC.cpp",
503 "src/ports/SkOSFile_win.cpp",
504 "src/ports/SkScalerContext_win_dw.cpp",
505 "src/ports/SkTLS_win.cpp",
506 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700507 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700508 ]
mtkleinb9be9792016-09-16 14:44:18 -0700509 sources -=
510 [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
mtkleinc04ff472016-06-23 10:29:30 -0700511 } else {
512 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700513 "src/ports/SkOSFile_posix.cpp",
514 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700515 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700516 ]
517 }
518
mtklein7d6fb2c2016-08-25 14:50:44 -0700519 if (is_android) {
520 deps += [
521 "//third_party/cpu-features",
522 "//third_party/expat",
mtklein7d6fb2c2016-08-25 14:50:44 -0700523 ]
mtklein06c35c02016-09-20 12:28:12 -0700524 sources += [ "src/ports/SkDebug_android.cpp" ]
mtklein7d6fb2c2016-08-25 14:50:44 -0700525 libs += [
526 "EGL",
527 "GLESv2",
528 "log",
529 ]
530 }
531
mtkleinc04ff472016-06-23 10:29:30 -0700532 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700533 libs += [
534 "GL",
535 "GLU",
536 "X11",
537 ]
mtklein06c35c02016-09-20 12:28:12 -0700538 sources += [ "src/ports/SkDebug_stdio.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700539 }
540
541 if (is_mac) {
542 sources += [
mtklein7d6fb2c2016-08-25 14:50:44 -0700543 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700544 "src/ports/SkFontHost_mac.cpp",
545 "src/ports/SkImageEncoder_CG.cpp",
546 "src/ports/SkImageGeneratorCG.cpp",
547 ]
mtklein09e61f72016-08-23 13:35:28 -0700548 libs += [
549 "ApplicationServices.framework",
550 "OpenGL.framework",
551 ]
mtkleinc04ff472016-06-23 10:29:30 -0700552 }
abarth6fc8ff02016-07-15 15:15:15 -0700553
554 if (is_fuchsia) {
mtklein06c35c02016-09-20 12:28:12 -0700555 sources += [ "src/ports/SkDebug_stdio.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700556 }
mtkleinc04ff472016-06-23 10:29:30 -0700557}
558
mtkleinada5a442016-08-02 14:28:26 -0700559skia_h_headers = exec_script("gyp/find.py",
560 [ "*.h" ] + rebase_path(skia_public_includes),
561 "list lines",
562 []) -
563 [
564 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
565 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
566 rebase_path("include/gpu/vk/GrVkDefines.h"),
567 rebase_path("include/gpu/vk/GrVkInterface.h"),
568 rebase_path("include/gpu/vk/GrVkTypes.h"),
569 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
570 ]
571
mtklein1211e0c2016-07-26 13:55:45 -0700572action("skia.h") {
573 script = "gn/echo_headers.py"
574 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinc095df52016-08-24 12:23:52 -0700575 rebase_path(skia_h_headers, target_gen_dir)
mtklein1211e0c2016-07-26 13:55:45 -0700576 outputs = [
577 "$target_gen_dir/skia.h",
578 ]
579}
580
mtklein06c35c02016-09-20 12:28:12 -0700581if (skia_enable_gpu && target_cpu == "x64") {
mtklein1fbdf982016-09-15 12:07:48 -0700582 # Our bots only have 64-bit libOSMesa installed.
583 # TODO: worth fixing?
584 executable("fiddle") {
585 include_dirs = [ "$target_gen_dir" ]
586 libs = []
587 if (is_linux) {
588 libs += [ "OSMesa" ]
589 }
mtklein56d56692016-09-15 11:18:55 -0700590
mtklein1fbdf982016-09-15 12:07:48 -0700591 sources = [
592 "src/images/SkForceLinking.cpp",
593 "tools/fiddle/draw.cpp",
594 "tools/fiddle/fiddle_main.cpp",
595 ]
596 deps = [
597 ":skia",
598 ":skia.h",
599 ]
600 }
mtkleinc04ff472016-06-23 10:29:30 -0700601}
mtklein25c81d42016-07-27 13:55:26 -0700602
mtkleinc095df52016-08-24 12:23:52 -0700603# Targets guarded by skia_enable_tools may use //third_party freely.
604if (skia_enable_tools) {
605 template("test_lib") {
606 config(target_name + "_config") {
607 include_dirs = invoker.public_include_dirs
mtkleina627b5c2016-09-20 13:36:47 -0700608 if (defined(invoker.public_defines)) {
609 defines = invoker.public_defines
610 }
mtklein25c81d42016-07-27 13:55:26 -0700611 }
mtkleinc095df52016-08-24 12:23:52 -0700612 source_set(target_name) {
613 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
614 public_configs = [
615 ":" + target_name + "_config",
616 ":skia_private",
617 ]
618
619 if (!defined(deps)) {
620 deps = []
621 }
622 deps += [ ":skia" ]
623 testonly = true
624 }
mtklein25c81d42016-07-27 13:55:26 -0700625 }
mtklein25c81d42016-07-27 13:55:26 -0700626
mtkleinc095df52016-08-24 12:23:52 -0700627 test_lib("gpu_tool_utils") {
mtklein38925aa2016-09-21 10:11:25 -0700628 public_include_dirs = []
629 if (skia_enable_gpu) {
630 public_defines = []
631 public_include_dirs += [ "tools/gpu" ]
632 sources = [
633 "tools/gpu/GrContextFactory.cpp",
634 "tools/gpu/GrTest.cpp",
635 "tools/gpu/TestContext.cpp",
636 "tools/gpu/gl/GLTestContext.cpp",
637 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
638 "tools/gpu/gl/debug/GrBufferObj.cpp",
639 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
640 "tools/gpu/gl/debug/GrProgramObj.cpp",
641 "tools/gpu/gl/debug/GrShaderObj.cpp",
642 "tools/gpu/gl/debug/GrTextureObj.cpp",
643 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
644 "tools/gpu/gl/null/NullGLTestContext.cpp",
645 ]
646 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700647
mtklein38925aa2016-09-21 10:11:25 -0700648 if (is_android) {
649 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
650 } else if (is_linux) {
651 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
652 } else if (is_mac) {
653 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
654 }
mtklein6ef69992016-09-14 06:12:09 -0700655
mtklein38925aa2016-09-21 10:11:25 -0700656 if (skia_use_vulkan) {
657 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
658 }
659 if (skia_use_mesa) {
660 public_defines += [ "SK_MESA" ]
661 sources += [ "tools/gpu/gl/mesa/GLTestContext_mesa.cpp" ]
662 libs += [ "OSMesa" ]
663 }
mtkleina627b5c2016-09-20 13:36:47 -0700664 }
mtklein25c81d42016-07-27 13:55:26 -0700665 }
mtklein25c81d42016-07-27 13:55:26 -0700666
mtkleinc095df52016-08-24 12:23:52 -0700667 test_lib("flags") {
668 public_include_dirs = [ "tools/flags" ]
669 sources = [
670 "tools/flags/SkCommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -0700671 ]
672 }
673 test_lib("common_flags") {
674 public_include_dirs = [ "tools/flags" ]
675 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700676 "tools/flags/SkCommonFlags.cpp",
677 "tools/flags/SkCommonFlagsConfig.cpp",
678 ]
679 deps = [
mtklein046cb562016-09-16 10:23:12 -0700680 ":flags",
mtkleinc095df52016-08-24 12:23:52 -0700681 ":gpu_tool_utils",
682 ]
683 }
mtklein25c81d42016-07-27 13:55:26 -0700684
mtkleinc095df52016-08-24 12:23:52 -0700685 test_lib("tool_utils") {
686 public_include_dirs = [
687 "tools",
688 "tools/debugger",
689 "tools/timer",
690 ]
691 sources = [
692 "src/images/SkForceLinking.cpp",
693 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700694 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700695 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700696 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700697 "tools/ProcStats.cpp",
698 "tools/Resources.cpp",
699 "tools/ThermalManager.cpp",
700 "tools/UrlDataManager.cpp",
701 "tools/debugger/SkDebugCanvas.cpp",
702 "tools/debugger/SkDrawCommand.cpp",
703 "tools/debugger/SkJsonWriteBuffer.cpp",
704 "tools/debugger/SkObjectParser.cpp",
705 "tools/debugger/SkOverdrawMode.cpp",
706 "tools/picture_utils.cpp",
707 "tools/random_parse_path.cpp",
708 "tools/sk_tool_utils.cpp",
709 "tools/sk_tool_utils_font.cpp",
710 "tools/timer/Timer.cpp",
711 ]
712 deps = [
mtklein046cb562016-09-16 10:23:12 -0700713 ":common_flags",
mtkleinc095df52016-08-24 12:23:52 -0700714 ":flags",
715 "//third_party/libpng",
716 ]
717 public_deps = [
718 "//third_party/jsoncpp",
719 ]
720 }
mtklein25c81d42016-07-27 13:55:26 -0700721
mtkleinc095df52016-08-24 12:23:52 -0700722 gm_sources = exec_script("gyp/find.py",
723 [
724 "*.c*",
725 rebase_path("gm"),
726 ],
727 "list lines",
728 [])
729 test_lib("gm") {
730 public_include_dirs = [ "gm" ]
731 sources = gm_sources
732 deps = [
733 ":gpu_tool_utils",
734 ":skia",
735 ":tool_utils",
736 ]
737 }
mtklein25c81d42016-07-27 13:55:26 -0700738
mtkleinc095df52016-08-24 12:23:52 -0700739 tests_sources = exec_script("gyp/find.py",
740 [
741 "*.c*",
742 rebase_path("tests"),
743 ],
744 "list lines",
745 [])
mtklein2f3416d2016-08-02 16:02:05 -0700746
mtkleinc095df52016-08-24 12:23:52 -0700747 test_lib("tests") {
748 public_include_dirs = [ "tests" ]
mtkleina45be612016-08-29 15:22:10 -0700749 sources = tests_sources - [
750 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
mtkleina45be612016-08-29 15:22:10 -0700751 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
752 rebase_path("tests/skia_test.cpp"), # alternate main
753 ]
754 if (!fontmgr_android_enabled) {
755 sources -= [ rebase_path("tests/FontMgrAndroidParserTest.cpp") ]
756 }
mtkleinc095df52016-08-24 12:23:52 -0700757 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700758 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700759 ":flags",
760 ":gpu_tool_utils",
761 ":skia",
762 ":tool_utils",
763 "//third_party/libpng",
764 "//third_party/zlib",
765 ]
766 }
mtklein2f3416d2016-08-02 16:02:05 -0700767
mtkleinc095df52016-08-24 12:23:52 -0700768 bench_sources = exec_script("gyp/find.py",
769 [
770 "*.c*",
771 rebase_path("bench"),
772 ],
773 "list lines",
774 [])
mtklein25c81d42016-07-27 13:55:26 -0700775
mtkleinc095df52016-08-24 12:23:52 -0700776 test_lib("bench") {
777 public_include_dirs = [ "bench" ]
778 sources = bench_sources
779 sources -= [
780 rebase_path("bench/nanobench.cpp"),
781 rebase_path("bench/nanobenchAndroid.cpp"),
782 ]
783 deps = [
784 ":flags",
785 ":gm",
786 ":gpu_tool_utils",
787 ":skia",
788 ":tool_utils",
789 ]
790 }
mtklein2b6870c2016-07-28 14:17:33 -0700791
mtkleinc095df52016-08-24 12:23:52 -0700792 test_lib("experimental_svg_model") {
793 public_include_dirs = [ "experimental/svg/model" ]
794 sources = [
795 "experimental/svg/model/SkSVGAttribute.cpp",
796 "experimental/svg/model/SkSVGAttributeParser.cpp",
797 "experimental/svg/model/SkSVGCircle.cpp",
798 "experimental/svg/model/SkSVGContainer.cpp",
799 "experimental/svg/model/SkSVGDOM.cpp",
800 "experimental/svg/model/SkSVGEllipse.cpp",
801 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700802 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700803 "experimental/svg/model/SkSVGNode.cpp",
804 "experimental/svg/model/SkSVGPath.cpp",
805 "experimental/svg/model/SkSVGPoly.cpp",
806 "experimental/svg/model/SkSVGRect.cpp",
807 "experimental/svg/model/SkSVGRenderContext.cpp",
808 "experimental/svg/model/SkSVGSVG.cpp",
809 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700810 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700811 "experimental/svg/model/SkSVGTransformableNode.cpp",
812 "experimental/svg/model/SkSVGValue.cpp",
813 ]
814 deps = [
815 ":skia",
816 ]
817 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700818
mtklein2b6870c2016-07-28 14:17:33 -0700819 executable("dm") {
820 sources = [
821 "dm/DM.cpp",
822 "dm/DMJsonWriter.cpp",
823 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700824 ]
825 include_dirs = [ "tests" ]
826 deps = [
mtklein046cb562016-09-16 10:23:12 -0700827 ":common_flags",
fmalitaa2b9fdf2016-08-03 19:53:36 -0700828 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700829 ":flags",
830 ":gm",
831 ":gpu_tool_utils",
832 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700833 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700834 ":tool_utils",
835 "//third_party/jsoncpp",
836 "//third_party/libpng",
837 ]
838 testonly = true
839 }
840
841 executable("monobench") {
842 sources = [
843 "tools/monobench.cpp",
844 ]
845 deps = [
846 ":bench",
847 ":skia",
848 ]
849 testonly = true
850 }
851
852 executable("nanobench") {
853 sources = [
854 "bench/nanobench.cpp",
855 ]
856 deps = [
857 ":bench",
mtklein046cb562016-09-16 10:23:12 -0700858 ":common_flags",
fmalita6519c212016-09-14 08:05:17 -0700859 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700860 ":flags",
861 ":gm",
862 ":gpu_tool_utils",
863 ":skia",
864 ":tool_utils",
865 "//third_party/jsoncpp",
866 ]
867 testonly = true
868 }
halcanary19a97202016-08-03 15:08:04 -0700869
mtklein38925aa2016-09-21 10:11:25 -0700870 if (skia_enable_gpu) {
871 executable("skpbench") {
872 sources = [
873 "tools/skpbench/skpbench.cpp",
874 ]
875 deps = [
876 ":flags",
877 ":gpu_tool_utils",
878 ":skia",
879 ":tool_utils",
880 ]
881 testonly = true
882 }
csmartdalton4b5179b2016-09-19 11:03:58 -0700883 }
884
mtklein6f5df6a2016-08-29 16:01:10 -0700885 if (current_cpu != "mipsel") { # Clang 3.8 crashes while compiling hb-icu.cc for mipsel.
halcanary3eee9d92016-09-10 07:01:53 -0700886 executable("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -0700887 sources = [
888 "tools/SkShaper_harfbuzz.cpp",
889 "tools/using_skia_and_harfbuzz.cpp",
890 ]
891 deps = [
892 ":skia",
893 "//third_party/harfbuzz",
894 ]
895 testonly = true
896 }
halcanary19a97202016-08-03 15:08:04 -0700897 }
halcanary3eee9d92016-09-10 07:01:53 -0700898 executable("sktexttopdf") {
899 sources = [
900 "tools/SkShaper_primitive.cpp",
901 "tools/using_skia_and_harfbuzz.cpp",
902 ]
903 deps = [
904 ":skia",
905 ]
906 testonly = true
907 }
mtklein046cb562016-09-16 10:23:12 -0700908
909 executable("get_images_from_skps") {
910 sources = [
911 "tools/get_images_from_skps.cpp",
912 ]
913 deps = [
914 ":flags",
915 ":skia",
916 "//third_party/jsoncpp",
917 ]
918 testonly = true
919 }
mtklein25c81d42016-07-27 13:55:26 -0700920}