blob: 4e78a1c61991a73b07ba01abaf712f62be8925db [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
mtkleina627b5c2016-09-20 13:36:47 -070016 skia_use_mesa = false
mtklein63213812016-08-24 09:55:56 -070017 skia_use_sfntly = !is_fuchsia
mtkleinf29180e2016-09-16 07:01:17 -070018 skia_use_vulkan = is_android && defined(ndk_api) && ndk_api >= 24
mtklein63213812016-08-24 09:55:56 -070019 skia_use_zlib = true
mtklein1bd72ba2016-09-16 07:45:52 -070020
21 skia_enable_android_framework_defines = false
mtklein06c35c02016-09-20 12:28:12 -070022 skia_enable_gpu = true
23 skia_enable_tools = !is_fuchsia
mtkleinc04ff472016-06-23 10:29:30 -070024}
25
mtklein06c35c02016-09-20 12:28:12 -070026# Our tools require static linking (they use non-exported symbols) and GPU support (just lazy).
27skia_enable_tools = skia_enable_tools && skia_enable_gpu && !is_component_build
28
mtkleina45be612016-08-29 15:22:10 -070029fontmgr_android_enabled = skia_use_expat && skia_use_freetype
30
mtklein1211e0c2016-07-26 13:55:45 -070031skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070032 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070033 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070034 "include/codec",
35 "include/config",
36 "include/core",
37 "include/effects",
38 "include/gpu",
39 "include/gpu/gl",
40 "include/images",
41 "include/pathops",
42 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070043 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070044 "include/utils",
45 "include/utils/mac",
mtklein25c81d42016-07-27 13:55:26 -070046 "include/xml",
mtklein1211e0c2016-07-26 13:55:45 -070047]
48
mtkleinc04ff472016-06-23 10:29:30 -070049# Skia public API, generally provided by :skia.
50config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -070051 include_dirs = skia_public_includes
mtkleinc04ff472016-06-23 10:29:30 -070052 defines = [ "SKIA_DLL" ]
jcgregorio5561e3d2016-08-25 09:25:11 -070053 if (is_linux) {
54 defines += [ "SK_SAMPLES_FOR_X" ]
55 }
mtkleincae1be52016-09-20 08:24:34 -070056 if (skia_enable_android_framework_defines) {
57 defines += skia_android_framework_defines
58 }
mtklein06c35c02016-09-20 12:28:12 -070059 if (!skia_enable_gpu) {
60 defines += [ "SK_SUPPORT_GPU=0" ]
61 }
mtkleinc04ff472016-06-23 10:29:30 -070062}
63
64# Skia internal APIs, used by Skia itself and a few test tools.
65config("skia_private") {
66 visibility = [ ":*" ]
67
68 include_dirs = [
69 "include/private",
70 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -070071 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -070072 "src/config",
73 "src/core",
74 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -070075 "src/effects/gradients",
76 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -070077 "src/gpu",
78 "src/image",
79 "src/images",
80 "src/lazy",
81 "src/opts",
82 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -070083 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -070084 "src/ports",
85 "src/sfnt",
mtklein9e0d9dd2016-08-30 10:37:19 -070086 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -070087 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -070088 "src/utils/win",
mtkleinc04ff472016-06-23 10:29:30 -070089 "third_party/etc1",
90 "third_party/ktx",
91 ]
mtklein150d1132016-08-01 06:56:40 -070092
mtklein63213812016-08-24 09:55:56 -070093 defines = [ "SK_GAMMA_APPLY_TO_A8" ]
mtkleinb37c0342016-09-09 11:07:45 -070094 if (is_android) {
95 defines += [
96 "SK_GAMMA_EXPONENT=1.4",
97 "SK_GAMMA_CONTRAST=0.0",
98 ]
99 }
mtklein88a7ac02016-09-14 11:16:49 -0700100 if (is_official_build || is_android) {
101 # TODO(bsalomon): it'd be nice to make Android normal.
102 defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
103 }
mtkleinc04ff472016-06-23 10:29:30 -0700104}
105
106# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
107config("skia_library") {
108 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -0700109 defines = [ "SKIA_IMPLEMENTATION=1" ]
110}
111
112skia_library_configs = [
113 ":skia_public",
114 ":skia_private",
115 ":skia_library",
116]
117
mtklein9b8583d2016-08-24 17:32:30 -0700118# Use for CPU-specific Skia code that needs particular compiler flags.
119template("opts") {
120 if (invoker.enabled) {
121 source_set(target_name) {
122 forward_variables_from(invoker, "*")
123 configs += skia_library_configs
124 }
125 } else {
126 # If not enabled, a phony empty target that swallows all otherwise unused variables.
127 source_set(target_name) {
128 forward_variables_from(invoker,
129 "*",
130 [
131 "sources",
132 "cflags",
133 ])
134 }
135 }
anmittala7eaf2e2016-08-17 13:57:26 -0700136}
137
mtklein422310d2016-08-16 18:28:43 -0700138is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700139
mtklein7d6fb2c2016-08-25 14:50:44 -0700140opts("none") {
141 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700142 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700143 cflags = []
144}
145
mtklein7d6fb2c2016-08-25 14:50:44 -0700146opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700147 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700148 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700149 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700150}
151
152opts("arm64") {
153 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700154 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700155 cflags = []
156}
157
158opts("crc32") {
159 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700160 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700161 cflags = [ "-march=armv8-a+crc" ]
162}
163
mtklein9b8583d2016-08-24 17:32:30 -0700164opts("sse2") {
165 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700166 sources = skia_opts.sse2_sources
mtklein9b8583d2016-08-24 17:32:30 -0700167 cflags = [ "-msse2" ]
168}
mtkleinc04ff472016-06-23 10:29:30 -0700169
mtklein9b8583d2016-08-24 17:32:30 -0700170opts("ssse3") {
171 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700172 sources = skia_opts.ssse3_sources
mtklein9b8583d2016-08-24 17:32:30 -0700173 cflags = [ "-mssse3" ]
174}
mtkleinc04ff472016-06-23 10:29:30 -0700175
mtklein9b8583d2016-08-24 17:32:30 -0700176opts("sse41") {
177 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700178 sources = skia_opts.sse41_sources
mtklein9b8583d2016-08-24 17:32:30 -0700179 cflags = [ "-msse4.1" ]
180}
mtklein4e976072016-08-08 09:06:27 -0700181
mtklein9b8583d2016-08-24 17:32:30 -0700182opts("sse42") {
183 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700184 sources = skia_opts.sse42_sources
mtklein9b8583d2016-08-24 17:32:30 -0700185 cflags = [ "-msse4.2" ]
186}
187
188opts("avx") {
189 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700190 sources = skia_opts.avx_sources
mtklein9b8583d2016-08-24 17:32:30 -0700191 cflags = [ "-mavx" ]
mtkleinc04ff472016-06-23 10:29:30 -0700192}
193
mtklein349cece2016-08-26 08:13:04 -0700194opts("dsp") {
195 enabled = current_cpu == "mipsel"
brettwb9447282016-09-01 14:24:39 -0700196 sources = skia_opts.mips_dsp_sources
mtkleinb6064ef2016-08-30 11:49:24 -0700197 cflags = []
mtklein349cece2016-08-26 08:13:04 -0700198}
199
mtkleinc095df52016-08-24 12:23:52 -0700200# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700201template("optional") {
202 if (invoker.enabled) {
203 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700204 if (defined(invoker.public_defines)) {
205 defines = invoker.public_defines
206 }
mtklein457b42a2016-08-23 13:56:37 -0700207 }
208 source_set(target_name) {
mtkleincd01b032016-08-31 04:58:19 -0700209 forward_variables_from(invoker,
210 "*",
211 [
212 "public_defines",
213 "sources_when_disabled",
214 ])
mtklein457b42a2016-08-23 13:56:37 -0700215 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700216 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700217 }
218 } else {
mtklein457b42a2016-08-23 13:56:37 -0700219 source_set(target_name) {
220 forward_variables_from(invoker,
221 "*",
222 [
223 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700224 "deps",
mtklein6ef69992016-09-14 06:12:09 -0700225 "libs",
mtklein457b42a2016-08-23 13:56:37 -0700226 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700227 "sources_when_disabled",
mtklein457b42a2016-08-23 13:56:37 -0700228 ])
mtkleincd01b032016-08-31 04:58:19 -0700229 if (defined(invoker.sources_when_disabled)) {
230 sources = invoker.sources_when_disabled
231 }
232 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700233 }
mtkleineb3c4252016-08-23 07:38:09 -0700234 }
mtklein457b42a2016-08-23 13:56:37 -0700235}
mtklein457b42a2016-08-23 13:56:37 -0700236
mtkleina45be612016-08-29 15:22:10 -0700237optional("fontmgr_android") {
238 enabled = fontmgr_android_enabled
mtkleina45be612016-08-29 15:22:10 -0700239
240 deps = [
241 "//third_party/expat",
242 "//third_party/freetype2",
243 ]
244 sources = [
245 "src/ports/SkFontMgr_android.cpp",
246 "src/ports/SkFontMgr_android_factory.cpp",
247 "src/ports/SkFontMgr_android_parser.cpp",
248 ]
249}
250
mtkleind2e39db2016-09-07 07:52:55 -0700251optional("fontmgr_custom") {
252 enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
253
254 deps = [
255 "//third_party/freetype2",
256 ]
257 sources = [
258 "src/ports/SkFontMgr_custom.cpp",
259 "src/ports/SkFontMgr_custom_directory_factory.cpp",
260 ]
261}
262
mtklein3cc22182016-08-29 13:26:14 -0700263optional("fontmgr_fontconfig") {
264 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700265
266 deps = [
267 "//third_party:fontconfig",
268 "//third_party/freetype2",
269 ]
270 sources = [
bungeman1ae0e012016-09-19 12:13:16 -0700271 "src/ports/SkFontConfigInterface.cpp",
mtklein3cc22182016-08-29 13:26:14 -0700272 "src/ports/SkFontConfigInterface_direct.cpp",
273 "src/ports/SkFontConfigInterface_direct_factory.cpp",
274 "src/ports/SkFontMgr_FontConfigInterface.cpp",
275 "src/ports/SkFontMgr_fontconfig.cpp",
276 "src/ports/SkFontMgr_fontconfig_factory.cpp",
277 ]
278}
279
mtkleincdedd0e2016-09-12 15:15:44 -0700280optional("fontmgr_fuchsia") {
281 enabled = is_fuchsia && skia_use_freetype
282
283 deps = [
284 "//third_party/freetype2",
285 ]
286 sources = [
287 "src/ports/SkFontMgr_custom.cpp",
288 "src/ports/SkFontMgr_custom_empty_factory.cpp",
289 ]
290}
291
mtklein457b42a2016-08-23 13:56:37 -0700292optional("gif") {
293 enabled = skia_use_giflib
294 public_defines = [ "SK_HAS_GIF_LIBRARY" ]
295
mtklein457b42a2016-08-23 13:56:37 -0700296 deps = [
297 "//third_party/giflib",
298 ]
299 sources = [
300 "src/codec/SkGifCodec.cpp",
301 ]
302}
303
mtklein06c35c02016-09-20 12:28:12 -0700304optional("gpu") {
305 enabled = skia_enable_gpu
mtkleine9fb3d52016-09-20 15:11:46 -0700306 public_defines = []
307
mtklein06c35c02016-09-20 12:28:12 -0700308 sources = skia_gpu_sources + [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ]
309
310 # These paths need to be absolute to match the ones produced by shared_sources.gni.
311 sources -= get_path_info([
312 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
313 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
314 ],
315 "abspath")
316 if (is_android) {
317 sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
318 } else if (is_linux) {
319 sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
320 } else if (is_mac) {
321 sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
322 } else {
323 sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
324 }
mtkleine9fb3d52016-09-20 15:11:46 -0700325 libs = []
326
327 if (skia_use_vulkan) {
328 public_defines += [ "SK_VULKAN" ]
329 sources += skia_vk_sources
330 libs += [ "vulkan" ]
331 }
mtklein06c35c02016-09-20 12:28:12 -0700332}
333
mtklein63213812016-08-24 09:55:56 -0700334optional("jpeg") {
335 enabled = skia_use_libjpeg_turbo
336 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
337
mtklein63213812016-08-24 09:55:56 -0700338 deps = [
339 "//third_party/libjpeg-turbo:libjpeg",
340 ]
341 sources = [
342 "src/codec/SkJpegCodec.cpp",
343 "src/codec/SkJpegDecoderMgr.cpp",
344 "src/codec/SkJpegUtility.cpp",
345 "src/images/SkJPEGImageEncoder.cpp",
346 "src/images/SkJPEGWriteUtility.cpp",
347 ]
348}
349
350optional("pdf") {
351 enabled = skia_use_zlib
mtklein63213812016-08-24 09:55:56 -0700352
mtklein63213812016-08-24 09:55:56 -0700353 deps = [
354 "//third_party/zlib",
355 ]
brettwb9447282016-09-01 14:24:39 -0700356 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700357 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700358
359 if (skia_use_sfntly) {
360 deps += [ "//third_party/sfntly" ]
mtkleincd01b032016-08-31 04:58:19 -0700361 public_defines = [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700362 }
363}
364
365optional("png") {
366 enabled = skia_use_libpng
367 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
368
mtklein63213812016-08-24 09:55:56 -0700369 deps = [
370 "//third_party/libpng",
371 ]
372 sources = [
373 "src/codec/SkIcoCodec.cpp",
374 "src/codec/SkPngCodec.cpp",
375 "src/images/SkPNGImageEncoder.cpp",
376 ]
377}
378
mtklein3cc22182016-08-29 13:26:14 -0700379optional("typeface_freetype") {
380 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700381
382 deps = [
383 "//third_party/freetype2",
384 ]
385 sources = [
386 "src/ports/SkFontHost_FreeType.cpp",
387 "src/ports/SkFontHost_FreeType_common.cpp",
388 ]
389}
390
mtklein457b42a2016-08-23 13:56:37 -0700391optional("webp") {
392 enabled = skia_use_libwebp
393 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
394
mtklein457b42a2016-08-23 13:56:37 -0700395 deps = [
396 "//third_party/libwebp",
397 ]
398 sources = [
399 "src/codec/SkWebpAdapterCodec.cpp",
400 "src/codec/SkWebpCodec.cpp",
401 "src/images/SkWEBPImageEncoder.cpp",
402 ]
mtkleineb3c4252016-08-23 07:38:09 -0700403}
404
mtklein63213812016-08-24 09:55:56 -0700405optional("xml") {
406 enabled = skia_use_expat
mtklein63213812016-08-24 09:55:56 -0700407
mtklein63213812016-08-24 09:55:56 -0700408 deps = [
409 "//third_party/expat",
410 ]
411 sources = [
412 "src/xml/SkDOM.cpp",
413 "src/xml/SkXMLParser.cpp",
414 "src/xml/SkXMLWriter.cpp",
415 ]
416}
417
mtkleinc04ff472016-06-23 10:29:30 -0700418component("skia") {
419 public_configs = [ ":skia_public" ]
420 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700421
422 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700423 ":arm64",
424 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700425 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700426 ":crc32",
mtklein349cece2016-08-26 08:13:04 -0700427 ":dsp",
mtkleina45be612016-08-29 15:22:10 -0700428 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700429 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700430 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700431 ":fontmgr_fuchsia",
mtklein457b42a2016-08-23 13:56:37 -0700432 ":gif",
mtklein06c35c02016-09-20 12:28:12 -0700433 ":gpu",
mtklein63213812016-08-24 09:55:56 -0700434 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700435 ":none",
mtklein63213812016-08-24 09:55:56 -0700436 ":pdf",
437 ":png",
mtklein9b8583d2016-08-24 17:32:30 -0700438 ":sse2",
439 ":sse41",
440 ":sse42",
441 ":ssse3",
mtklein3cc22182016-08-29 13:26:14 -0700442 ":typeface_freetype",
mtkleineb3c4252016-08-23 07:38:09 -0700443 ":webp",
mtklein63213812016-08-24 09:55:56 -0700444 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700445 ]
446
mtkleinc04ff472016-06-23 10:29:30 -0700447 sources = []
brettwb9447282016-09-01 14:24:39 -0700448 sources += skia_core_sources
449 sources += skia_effects_sources
brettwb9447282016-09-01 14:24:39 -0700450 sources += skia_sksl_sources
451 sources += skia_utils_sources
mtkleinc04ff472016-06-23 10:29:30 -0700452 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700453 "src/android/SkBitmapRegionCodec.cpp",
454 "src/android/SkBitmapRegionDecoder.cpp",
455 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700456 "src/codec/SkBmpCodec.cpp",
457 "src/codec/SkBmpMaskCodec.cpp",
458 "src/codec/SkBmpRLECodec.cpp",
459 "src/codec/SkBmpStandardCodec.cpp",
460 "src/codec/SkCodec.cpp",
461 "src/codec/SkCodecImageGenerator.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700462 "src/codec/SkMaskSwizzler.cpp",
463 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700464 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700465 "src/codec/SkSampler.cpp",
466 "src/codec/SkSwizzler.cpp",
467 "src/codec/SkWbmpCodec.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700468 "src/images/SkImageEncoder.cpp",
469 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700470 "src/images/SkKTXImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700471 "src/ports/SkDiscardableMemory_none.cpp",
472 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700473 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700474 "src/ports/SkMemory_malloc.cpp",
475 "src/ports/SkOSFile_stdio.cpp",
476 "src/sfnt/SkOTTable_name.cpp",
477 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700478 "src/svg/SkSVGCanvas.cpp",
479 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700480 "src/utils/mac/SkStream_mac.cpp",
481 "third_party/etc1/etc1.cpp",
482 "third_party/ktx/ktx.cpp",
483 ]
brettwb9447282016-09-01 14:24:39 -0700484
mtklein7d6fb2c2016-08-25 14:50:44 -0700485 libs = []
486
mtkleinc04ff472016-06-23 10:29:30 -0700487 if (is_win) {
488 sources += [
489 "src/ports/SkDebug_win.cpp",
490 "src/ports/SkFontHost_win.cpp",
491 "src/ports/SkFontMgr_win_dw.cpp",
492 "src/ports/SkFontMgr_win_dw_factory.cpp",
493 "src/ports/SkImageEncoder_WIC.cpp",
494 "src/ports/SkImageGeneratorWIC.cpp",
495 "src/ports/SkOSFile_win.cpp",
496 "src/ports/SkScalerContext_win_dw.cpp",
497 "src/ports/SkTLS_win.cpp",
498 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700499 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700500 ]
mtkleinb9be9792016-09-16 14:44:18 -0700501 sources -=
502 [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
mtkleinc04ff472016-06-23 10:29:30 -0700503 } else {
504 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700505 "src/ports/SkOSFile_posix.cpp",
506 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700507 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700508 ]
509 }
510
mtklein7d6fb2c2016-08-25 14:50:44 -0700511 if (is_android) {
512 deps += [
513 "//third_party/cpu-features",
514 "//third_party/expat",
mtklein7d6fb2c2016-08-25 14:50:44 -0700515 ]
mtklein06c35c02016-09-20 12:28:12 -0700516 sources += [ "src/ports/SkDebug_android.cpp" ]
mtklein7d6fb2c2016-08-25 14:50:44 -0700517 libs += [
518 "EGL",
519 "GLESv2",
520 "log",
521 ]
522 }
523
mtkleinc04ff472016-06-23 10:29:30 -0700524 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700525 libs += [
526 "GL",
527 "GLU",
528 "X11",
529 ]
mtklein06c35c02016-09-20 12:28:12 -0700530 sources += [ "src/ports/SkDebug_stdio.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700531 }
532
533 if (is_mac) {
534 sources += [
mtklein7d6fb2c2016-08-25 14:50:44 -0700535 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700536 "src/ports/SkFontHost_mac.cpp",
537 "src/ports/SkImageEncoder_CG.cpp",
538 "src/ports/SkImageGeneratorCG.cpp",
539 ]
mtklein09e61f72016-08-23 13:35:28 -0700540 libs += [
541 "ApplicationServices.framework",
542 "OpenGL.framework",
543 ]
mtkleinc04ff472016-06-23 10:29:30 -0700544 }
abarth6fc8ff02016-07-15 15:15:15 -0700545
546 if (is_fuchsia) {
mtklein06c35c02016-09-20 12:28:12 -0700547 sources += [ "src/ports/SkDebug_stdio.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700548 }
mtkleinc04ff472016-06-23 10:29:30 -0700549}
550
mtkleinada5a442016-08-02 14:28:26 -0700551skia_h_headers = exec_script("gyp/find.py",
552 [ "*.h" ] + rebase_path(skia_public_includes),
553 "list lines",
554 []) -
555 [
556 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
557 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
558 rebase_path("include/gpu/vk/GrVkDefines.h"),
559 rebase_path("include/gpu/vk/GrVkInterface.h"),
560 rebase_path("include/gpu/vk/GrVkTypes.h"),
561 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
562 ]
563
mtklein1211e0c2016-07-26 13:55:45 -0700564action("skia.h") {
565 script = "gn/echo_headers.py"
566 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinc095df52016-08-24 12:23:52 -0700567 rebase_path(skia_h_headers, target_gen_dir)
mtklein1211e0c2016-07-26 13:55:45 -0700568 outputs = [
569 "$target_gen_dir/skia.h",
570 ]
571}
572
mtklein06c35c02016-09-20 12:28:12 -0700573if (skia_enable_gpu && target_cpu == "x64") {
mtklein1fbdf982016-09-15 12:07:48 -0700574 # Our bots only have 64-bit libOSMesa installed.
575 # TODO: worth fixing?
576 executable("fiddle") {
577 include_dirs = [ "$target_gen_dir" ]
578 libs = []
579 if (is_linux) {
580 libs += [ "OSMesa" ]
581 }
mtklein56d56692016-09-15 11:18:55 -0700582
mtklein1fbdf982016-09-15 12:07:48 -0700583 sources = [
584 "src/images/SkForceLinking.cpp",
585 "tools/fiddle/draw.cpp",
586 "tools/fiddle/fiddle_main.cpp",
587 ]
588 deps = [
589 ":skia",
590 ":skia.h",
591 ]
592 }
mtkleinc04ff472016-06-23 10:29:30 -0700593}
mtklein25c81d42016-07-27 13:55:26 -0700594
mtkleinc095df52016-08-24 12:23:52 -0700595# Targets guarded by skia_enable_tools may use //third_party freely.
596if (skia_enable_tools) {
597 template("test_lib") {
598 config(target_name + "_config") {
599 include_dirs = invoker.public_include_dirs
mtkleina627b5c2016-09-20 13:36:47 -0700600 if (defined(invoker.public_defines)) {
601 defines = invoker.public_defines
602 }
mtklein25c81d42016-07-27 13:55:26 -0700603 }
mtkleinc095df52016-08-24 12:23:52 -0700604 source_set(target_name) {
605 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
606 public_configs = [
607 ":" + target_name + "_config",
608 ":skia_private",
609 ]
610
611 if (!defined(deps)) {
612 deps = []
613 }
614 deps += [ ":skia" ]
615 testonly = true
616 }
mtklein25c81d42016-07-27 13:55:26 -0700617 }
mtklein25c81d42016-07-27 13:55:26 -0700618
mtkleinc095df52016-08-24 12:23:52 -0700619 test_lib("gpu_tool_utils") {
mtkleina627b5c2016-09-20 13:36:47 -0700620 public_defines = []
mtkleinc095df52016-08-24 12:23:52 -0700621 public_include_dirs = [ "tools/gpu" ]
622 sources = [
623 "tools/gpu/GrContextFactory.cpp",
624 "tools/gpu/GrTest.cpp",
625 "tools/gpu/TestContext.cpp",
626 "tools/gpu/gl/GLTestContext.cpp",
627 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
628 "tools/gpu/gl/debug/GrBufferObj.cpp",
629 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
630 "tools/gpu/gl/debug/GrProgramObj.cpp",
631 "tools/gpu/gl/debug/GrShaderObj.cpp",
632 "tools/gpu/gl/debug/GrTextureObj.cpp",
633 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
634 "tools/gpu/gl/null/NullGLTestContext.cpp",
635 ]
636 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700637
mtklein7d6fb2c2016-08-25 14:50:44 -0700638 if (is_android) {
639 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
640 } else if (is_linux) {
mtkleinc095df52016-08-24 12:23:52 -0700641 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
642 } else if (is_mac) {
643 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
644 }
mtklein6ef69992016-09-14 06:12:09 -0700645
646 if (skia_use_vulkan) {
647 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
648 }
mtkleina627b5c2016-09-20 13:36:47 -0700649 if (skia_use_mesa) {
650 public_defines += [ "SK_MESA" ]
651 sources += [ "tools/gpu/gl/mesa/GLTestContext_mesa.cpp" ]
652 libs += [ "OSMesa" ]
653 }
mtklein25c81d42016-07-27 13:55:26 -0700654 }
mtklein25c81d42016-07-27 13:55:26 -0700655
mtkleinc095df52016-08-24 12:23:52 -0700656 test_lib("flags") {
657 public_include_dirs = [ "tools/flags" ]
658 sources = [
659 "tools/flags/SkCommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -0700660 ]
661 }
662 test_lib("common_flags") {
663 public_include_dirs = [ "tools/flags" ]
664 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700665 "tools/flags/SkCommonFlags.cpp",
666 "tools/flags/SkCommonFlagsConfig.cpp",
667 ]
668 deps = [
mtklein046cb562016-09-16 10:23:12 -0700669 ":flags",
mtkleinc095df52016-08-24 12:23:52 -0700670 ":gpu_tool_utils",
671 ]
672 }
mtklein25c81d42016-07-27 13:55:26 -0700673
mtkleinc095df52016-08-24 12:23:52 -0700674 test_lib("tool_utils") {
675 public_include_dirs = [
676 "tools",
677 "tools/debugger",
678 "tools/timer",
679 ]
680 sources = [
681 "src/images/SkForceLinking.cpp",
682 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700683 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700684 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700685 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700686 "tools/ProcStats.cpp",
687 "tools/Resources.cpp",
688 "tools/ThermalManager.cpp",
689 "tools/UrlDataManager.cpp",
690 "tools/debugger/SkDebugCanvas.cpp",
691 "tools/debugger/SkDrawCommand.cpp",
692 "tools/debugger/SkJsonWriteBuffer.cpp",
693 "tools/debugger/SkObjectParser.cpp",
694 "tools/debugger/SkOverdrawMode.cpp",
695 "tools/picture_utils.cpp",
696 "tools/random_parse_path.cpp",
697 "tools/sk_tool_utils.cpp",
698 "tools/sk_tool_utils_font.cpp",
699 "tools/timer/Timer.cpp",
700 ]
701 deps = [
mtklein046cb562016-09-16 10:23:12 -0700702 ":common_flags",
mtkleinc095df52016-08-24 12:23:52 -0700703 ":flags",
704 "//third_party/libpng",
705 ]
706 public_deps = [
707 "//third_party/jsoncpp",
708 ]
709 }
mtklein25c81d42016-07-27 13:55:26 -0700710
mtkleinc095df52016-08-24 12:23:52 -0700711 gm_sources = exec_script("gyp/find.py",
712 [
713 "*.c*",
714 rebase_path("gm"),
715 ],
716 "list lines",
717 [])
718 test_lib("gm") {
719 public_include_dirs = [ "gm" ]
720 sources = gm_sources
721 deps = [
722 ":gpu_tool_utils",
723 ":skia",
724 ":tool_utils",
725 ]
726 }
mtklein25c81d42016-07-27 13:55:26 -0700727
mtkleinc095df52016-08-24 12:23:52 -0700728 tests_sources = exec_script("gyp/find.py",
729 [
730 "*.c*",
731 rebase_path("tests"),
732 ],
733 "list lines",
734 [])
mtklein2f3416d2016-08-02 16:02:05 -0700735
mtkleinc095df52016-08-24 12:23:52 -0700736 test_lib("tests") {
737 public_include_dirs = [ "tests" ]
mtkleina45be612016-08-29 15:22:10 -0700738 sources = tests_sources - [
739 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
mtkleina45be612016-08-29 15:22:10 -0700740 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
741 rebase_path("tests/skia_test.cpp"), # alternate main
742 ]
743 if (!fontmgr_android_enabled) {
744 sources -= [ rebase_path("tests/FontMgrAndroidParserTest.cpp") ]
745 }
mtkleinc095df52016-08-24 12:23:52 -0700746 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700747 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700748 ":flags",
749 ":gpu_tool_utils",
750 ":skia",
751 ":tool_utils",
752 "//third_party/libpng",
753 "//third_party/zlib",
754 ]
755 }
mtklein2f3416d2016-08-02 16:02:05 -0700756
mtkleinc095df52016-08-24 12:23:52 -0700757 bench_sources = exec_script("gyp/find.py",
758 [
759 "*.c*",
760 rebase_path("bench"),
761 ],
762 "list lines",
763 [])
mtklein25c81d42016-07-27 13:55:26 -0700764
mtkleinc095df52016-08-24 12:23:52 -0700765 test_lib("bench") {
766 public_include_dirs = [ "bench" ]
767 sources = bench_sources
768 sources -= [
769 rebase_path("bench/nanobench.cpp"),
770 rebase_path("bench/nanobenchAndroid.cpp"),
771 ]
772 deps = [
773 ":flags",
774 ":gm",
775 ":gpu_tool_utils",
776 ":skia",
777 ":tool_utils",
778 ]
779 }
mtklein2b6870c2016-07-28 14:17:33 -0700780
mtkleinc095df52016-08-24 12:23:52 -0700781 test_lib("experimental_svg_model") {
782 public_include_dirs = [ "experimental/svg/model" ]
783 sources = [
784 "experimental/svg/model/SkSVGAttribute.cpp",
785 "experimental/svg/model/SkSVGAttributeParser.cpp",
786 "experimental/svg/model/SkSVGCircle.cpp",
787 "experimental/svg/model/SkSVGContainer.cpp",
788 "experimental/svg/model/SkSVGDOM.cpp",
789 "experimental/svg/model/SkSVGEllipse.cpp",
790 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700791 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700792 "experimental/svg/model/SkSVGNode.cpp",
793 "experimental/svg/model/SkSVGPath.cpp",
794 "experimental/svg/model/SkSVGPoly.cpp",
795 "experimental/svg/model/SkSVGRect.cpp",
796 "experimental/svg/model/SkSVGRenderContext.cpp",
797 "experimental/svg/model/SkSVGSVG.cpp",
798 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700799 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700800 "experimental/svg/model/SkSVGTransformableNode.cpp",
801 "experimental/svg/model/SkSVGValue.cpp",
802 ]
803 deps = [
804 ":skia",
805 ]
806 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700807
mtklein2b6870c2016-07-28 14:17:33 -0700808 executable("dm") {
809 sources = [
810 "dm/DM.cpp",
811 "dm/DMJsonWriter.cpp",
812 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700813 ]
814 include_dirs = [ "tests" ]
815 deps = [
mtklein046cb562016-09-16 10:23:12 -0700816 ":common_flags",
fmalitaa2b9fdf2016-08-03 19:53:36 -0700817 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700818 ":flags",
819 ":gm",
820 ":gpu_tool_utils",
821 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700822 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700823 ":tool_utils",
824 "//third_party/jsoncpp",
825 "//third_party/libpng",
826 ]
827 testonly = true
828 }
829
830 executable("monobench") {
831 sources = [
832 "tools/monobench.cpp",
833 ]
834 deps = [
835 ":bench",
836 ":skia",
837 ]
838 testonly = true
839 }
840
841 executable("nanobench") {
842 sources = [
843 "bench/nanobench.cpp",
844 ]
845 deps = [
846 ":bench",
mtklein046cb562016-09-16 10:23:12 -0700847 ":common_flags",
fmalita6519c212016-09-14 08:05:17 -0700848 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700849 ":flags",
850 ":gm",
851 ":gpu_tool_utils",
852 ":skia",
853 ":tool_utils",
854 "//third_party/jsoncpp",
855 ]
856 testonly = true
857 }
halcanary19a97202016-08-03 15:08:04 -0700858
csmartdalton4b5179b2016-09-19 11:03:58 -0700859 executable("skpbench") {
860 sources = [
861 "tools/skpbench/skpbench.cpp",
862 ]
863 deps = [
864 ":flags",
865 ":gpu_tool_utils",
866 ":skia",
867 ":tool_utils",
868 ]
869 testonly = true
870 }
871
mtklein6f5df6a2016-08-29 16:01:10 -0700872 if (current_cpu != "mipsel") { # Clang 3.8 crashes while compiling hb-icu.cc for mipsel.
halcanary3eee9d92016-09-10 07:01:53 -0700873 executable("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -0700874 sources = [
875 "tools/SkShaper_harfbuzz.cpp",
876 "tools/using_skia_and_harfbuzz.cpp",
877 ]
878 deps = [
879 ":skia",
880 "//third_party/harfbuzz",
881 ]
882 testonly = true
883 }
halcanary19a97202016-08-03 15:08:04 -0700884 }
halcanary3eee9d92016-09-10 07:01:53 -0700885 executable("sktexttopdf") {
886 sources = [
887 "tools/SkShaper_primitive.cpp",
888 "tools/using_skia_and_harfbuzz.cpp",
889 ]
890 deps = [
891 ":skia",
892 ]
893 testonly = true
894 }
mtklein046cb562016-09-16 10:23:12 -0700895
896 executable("get_images_from_skps") {
897 sources = [
898 "tools/get_images_from_skps.cpp",
899 ]
900 deps = [
901 ":flags",
902 ":skia",
903 "//third_party/jsoncpp",
904 ]
905 testonly = true
906 }
mtklein25c81d42016-07-27 13:55:26 -0700907}