blob: dddf118393825738741edd15a5c01cef7ed30e99 [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
egdaniele4a9bd72016-09-21 07:36:14 -070024
25 # TODO: Vulkan debug layers should be disabled for all client uses of skia as well.
26 skia_enable_vulkan_debug_layers = !is_fuchsia && is_debug
mtkleinc04ff472016-06-23 10:29:30 -070027}
28
mtklein06c35c02016-09-20 12:28:12 -070029# Our tools require static linking (they use non-exported symbols) and GPU support (just lazy).
30skia_enable_tools = skia_enable_tools && skia_enable_gpu && !is_component_build
31
mtkleina45be612016-08-29 15:22:10 -070032fontmgr_android_enabled = skia_use_expat && skia_use_freetype
33
mtklein1211e0c2016-07-26 13:55:45 -070034skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070035 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070036 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070037 "include/codec",
38 "include/config",
39 "include/core",
40 "include/effects",
41 "include/gpu",
42 "include/gpu/gl",
43 "include/images",
44 "include/pathops",
45 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070046 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070047 "include/utils",
48 "include/utils/mac",
mtklein25c81d42016-07-27 13:55:26 -070049 "include/xml",
mtklein1211e0c2016-07-26 13:55:45 -070050]
51
mtkleinc04ff472016-06-23 10:29:30 -070052# Skia public API, generally provided by :skia.
53config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -070054 include_dirs = skia_public_includes
mtkleinc04ff472016-06-23 10:29:30 -070055 defines = [ "SKIA_DLL" ]
jcgregorio5561e3d2016-08-25 09:25:11 -070056 if (is_linux) {
57 defines += [ "SK_SAMPLES_FOR_X" ]
58 }
mtkleincae1be52016-09-20 08:24:34 -070059 if (skia_enable_android_framework_defines) {
60 defines += skia_android_framework_defines
61 }
mtklein06c35c02016-09-20 12:28:12 -070062 if (!skia_enable_gpu) {
63 defines += [ "SK_SUPPORT_GPU=0" ]
64 }
mtkleinc04ff472016-06-23 10:29:30 -070065}
66
67# Skia internal APIs, used by Skia itself and a few test tools.
68config("skia_private") {
69 visibility = [ ":*" ]
70
71 include_dirs = [
72 "include/private",
73 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -070074 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -070075 "src/config",
76 "src/core",
77 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -070078 "src/effects/gradients",
79 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -070080 "src/gpu",
81 "src/image",
82 "src/images",
83 "src/lazy",
84 "src/opts",
85 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -070086 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -070087 "src/ports",
88 "src/sfnt",
mtklein9e0d9dd2016-08-30 10:37:19 -070089 "src/sksl",
mtkleinc04ff472016-06-23 10:29:30 -070090 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -070091 "src/utils/win",
mtkleinc04ff472016-06-23 10:29:30 -070092 "third_party/etc1",
93 "third_party/ktx",
94 ]
mtklein150d1132016-08-01 06:56:40 -070095
mtklein63213812016-08-24 09:55:56 -070096 defines = [ "SK_GAMMA_APPLY_TO_A8" ]
mtkleinb37c0342016-09-09 11:07:45 -070097 if (is_android) {
98 defines += [
99 "SK_GAMMA_EXPONENT=1.4",
100 "SK_GAMMA_CONTRAST=0.0",
101 ]
102 }
mtklein88a7ac02016-09-14 11:16:49 -0700103 if (is_official_build || is_android) {
104 # TODO(bsalomon): it'd be nice to make Android normal.
105 defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
106 }
mtkleinc04ff472016-06-23 10:29:30 -0700107}
108
109# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
110config("skia_library") {
111 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -0700112 defines = [ "SKIA_IMPLEMENTATION=1" ]
113}
114
115skia_library_configs = [
116 ":skia_public",
117 ":skia_private",
118 ":skia_library",
119]
120
mtklein9b8583d2016-08-24 17:32:30 -0700121# Use for CPU-specific Skia code that needs particular compiler flags.
122template("opts") {
123 if (invoker.enabled) {
124 source_set(target_name) {
125 forward_variables_from(invoker, "*")
126 configs += skia_library_configs
127 }
128 } else {
129 # If not enabled, a phony empty target that swallows all otherwise unused variables.
130 source_set(target_name) {
131 forward_variables_from(invoker,
132 "*",
133 [
134 "sources",
135 "cflags",
136 ])
137 }
138 }
anmittala7eaf2e2016-08-17 13:57:26 -0700139}
140
mtklein422310d2016-08-16 18:28:43 -0700141is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700142
mtklein7d6fb2c2016-08-25 14:50:44 -0700143opts("none") {
144 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
brettwb9447282016-09-01 14:24:39 -0700145 sources = skia_opts.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700146 cflags = []
147}
148
mtklein7d6fb2c2016-08-25 14:50:44 -0700149opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700150 enabled = current_cpu == "arm"
brettwb9447282016-09-01 14:24:39 -0700151 sources = skia_opts.armv7_sources + skia_opts.neon_sources
mtklein7d6fb2c2016-08-25 14:50:44 -0700152 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700153}
154
155opts("arm64") {
156 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700157 sources = skia_opts.arm64_sources
anmittalb8b3f712016-08-25 04:55:19 -0700158 cflags = []
159}
160
161opts("crc32") {
162 enabled = current_cpu == "arm64"
brettwb9447282016-09-01 14:24:39 -0700163 sources = skia_opts.crc32_sources
anmittalb8b3f712016-08-25 04:55:19 -0700164 cflags = [ "-march=armv8-a+crc" ]
165}
166
mtklein9b8583d2016-08-24 17:32:30 -0700167opts("sse2") {
168 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700169 sources = skia_opts.sse2_sources
mtklein9b8583d2016-08-24 17:32:30 -0700170 cflags = [ "-msse2" ]
171}
mtkleinc04ff472016-06-23 10:29:30 -0700172
mtklein9b8583d2016-08-24 17:32:30 -0700173opts("ssse3") {
174 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700175 sources = skia_opts.ssse3_sources
mtklein9b8583d2016-08-24 17:32:30 -0700176 cflags = [ "-mssse3" ]
177}
mtkleinc04ff472016-06-23 10:29:30 -0700178
mtklein9b8583d2016-08-24 17:32:30 -0700179opts("sse41") {
180 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700181 sources = skia_opts.sse41_sources
mtklein9b8583d2016-08-24 17:32:30 -0700182 cflags = [ "-msse4.1" ]
183}
mtklein4e976072016-08-08 09:06:27 -0700184
mtklein9b8583d2016-08-24 17:32:30 -0700185opts("sse42") {
186 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700187 sources = skia_opts.sse42_sources
mtklein9b8583d2016-08-24 17:32:30 -0700188 cflags = [ "-msse4.2" ]
189}
190
191opts("avx") {
192 enabled = is_x86
brettwb9447282016-09-01 14:24:39 -0700193 sources = skia_opts.avx_sources
mtklein9b8583d2016-08-24 17:32:30 -0700194 cflags = [ "-mavx" ]
mtkleinc04ff472016-06-23 10:29:30 -0700195}
196
mtklein349cece2016-08-26 08:13:04 -0700197opts("dsp") {
198 enabled = current_cpu == "mipsel"
brettwb9447282016-09-01 14:24:39 -0700199 sources = skia_opts.mips_dsp_sources
mtkleinb6064ef2016-08-30 11:49:24 -0700200 cflags = []
mtklein349cece2016-08-26 08:13:04 -0700201}
202
mtkleinc095df52016-08-24 12:23:52 -0700203# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700204template("optional") {
205 if (invoker.enabled) {
206 config(target_name + "_public") {
mtkleincd01b032016-08-31 04:58:19 -0700207 if (defined(invoker.public_defines)) {
208 defines = invoker.public_defines
209 }
mtklein457b42a2016-08-23 13:56:37 -0700210 }
211 source_set(target_name) {
mtkleincd01b032016-08-31 04:58:19 -0700212 forward_variables_from(invoker,
213 "*",
214 [
215 "public_defines",
216 "sources_when_disabled",
217 ])
mtklein457b42a2016-08-23 13:56:37 -0700218 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700219 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700220 }
221 } else {
mtklein457b42a2016-08-23 13:56:37 -0700222 source_set(target_name) {
223 forward_variables_from(invoker,
224 "*",
225 [
226 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700227 "deps",
mtklein6ef69992016-09-14 06:12:09 -0700228 "libs",
mtklein457b42a2016-08-23 13:56:37 -0700229 "sources",
mtkleincd01b032016-08-31 04:58:19 -0700230 "sources_when_disabled",
mtklein457b42a2016-08-23 13:56:37 -0700231 ])
mtkleincd01b032016-08-31 04:58:19 -0700232 if (defined(invoker.sources_when_disabled)) {
233 sources = invoker.sources_when_disabled
234 }
235 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700236 }
mtkleineb3c4252016-08-23 07:38:09 -0700237 }
mtklein457b42a2016-08-23 13:56:37 -0700238}
mtklein457b42a2016-08-23 13:56:37 -0700239
mtkleina45be612016-08-29 15:22:10 -0700240optional("fontmgr_android") {
241 enabled = fontmgr_android_enabled
mtkleina45be612016-08-29 15:22:10 -0700242
243 deps = [
244 "//third_party/expat",
245 "//third_party/freetype2",
246 ]
247 sources = [
248 "src/ports/SkFontMgr_android.cpp",
249 "src/ports/SkFontMgr_android_factory.cpp",
250 "src/ports/SkFontMgr_android_parser.cpp",
251 ]
252}
253
mtkleind2e39db2016-09-07 07:52:55 -0700254optional("fontmgr_custom") {
255 enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
256
257 deps = [
258 "//third_party/freetype2",
259 ]
260 sources = [
261 "src/ports/SkFontMgr_custom.cpp",
262 "src/ports/SkFontMgr_custom_directory_factory.cpp",
263 ]
264}
265
mtklein3cc22182016-08-29 13:26:14 -0700266optional("fontmgr_fontconfig") {
267 enabled = skia_use_freetype && skia_use_fontconfig
mtklein3cc22182016-08-29 13:26:14 -0700268
269 deps = [
270 "//third_party:fontconfig",
271 "//third_party/freetype2",
272 ]
273 sources = [
bungeman1ae0e012016-09-19 12:13:16 -0700274 "src/ports/SkFontConfigInterface.cpp",
mtklein3cc22182016-08-29 13:26:14 -0700275 "src/ports/SkFontConfigInterface_direct.cpp",
276 "src/ports/SkFontConfigInterface_direct_factory.cpp",
277 "src/ports/SkFontMgr_FontConfigInterface.cpp",
278 "src/ports/SkFontMgr_fontconfig.cpp",
279 "src/ports/SkFontMgr_fontconfig_factory.cpp",
280 ]
281}
282
mtkleincdedd0e2016-09-12 15:15:44 -0700283optional("fontmgr_fuchsia") {
284 enabled = is_fuchsia && skia_use_freetype
285
286 deps = [
287 "//third_party/freetype2",
288 ]
289 sources = [
290 "src/ports/SkFontMgr_custom.cpp",
291 "src/ports/SkFontMgr_custom_empty_factory.cpp",
292 ]
293}
294
mtklein457b42a2016-08-23 13:56:37 -0700295optional("gif") {
296 enabled = skia_use_giflib
297 public_defines = [ "SK_HAS_GIF_LIBRARY" ]
298
mtklein457b42a2016-08-23 13:56:37 -0700299 deps = [
300 "//third_party/giflib",
301 ]
302 sources = [
303 "src/codec/SkGifCodec.cpp",
304 ]
305}
306
mtklein06c35c02016-09-20 12:28:12 -0700307optional("gpu") {
308 enabled = skia_enable_gpu
mtkleine9fb3d52016-09-20 15:11:46 -0700309 public_defines = []
310
mtklein06c35c02016-09-20 12:28:12 -0700311 sources = skia_gpu_sources + [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ]
312
313 # These paths need to be absolute to match the ones produced by shared_sources.gni.
314 sources -= get_path_info([
315 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
316 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
317 ],
318 "abspath")
319 if (is_android) {
320 sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
321 } else if (is_linux) {
322 sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
323 } else if (is_mac) {
324 sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
325 } else {
326 sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
327 }
mtkleine9fb3d52016-09-20 15:11:46 -0700328 libs = []
329
330 if (skia_use_vulkan) {
331 public_defines += [ "SK_VULKAN" ]
332 sources += skia_vk_sources
333 libs += [ "vulkan" ]
egdaniele4a9bd72016-09-21 07:36:14 -0700334 if (skia_enable_vulkan_debug_layers) {
335 public_defines += [ "SK_ENABLE_VK_LAYERS" ]
336 }
mtkleine9fb3d52016-09-20 15:11:46 -0700337 }
mtklein06c35c02016-09-20 12:28:12 -0700338}
339
mtklein63213812016-08-24 09:55:56 -0700340optional("jpeg") {
341 enabled = skia_use_libjpeg_turbo
342 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
343
mtklein63213812016-08-24 09:55:56 -0700344 deps = [
345 "//third_party/libjpeg-turbo:libjpeg",
346 ]
347 sources = [
348 "src/codec/SkJpegCodec.cpp",
349 "src/codec/SkJpegDecoderMgr.cpp",
350 "src/codec/SkJpegUtility.cpp",
351 "src/images/SkJPEGImageEncoder.cpp",
352 "src/images/SkJPEGWriteUtility.cpp",
353 ]
354}
355
356optional("pdf") {
357 enabled = skia_use_zlib
mtklein63213812016-08-24 09:55:56 -0700358
mtklein63213812016-08-24 09:55:56 -0700359 deps = [
360 "//third_party/zlib",
361 ]
brettwb9447282016-09-01 14:24:39 -0700362 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700363 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700364
365 if (skia_use_sfntly) {
366 deps += [ "//third_party/sfntly" ]
mtkleincd01b032016-08-31 04:58:19 -0700367 public_defines = [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700368 }
369}
370
371optional("png") {
372 enabled = skia_use_libpng
373 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
374
mtklein63213812016-08-24 09:55:56 -0700375 deps = [
376 "//third_party/libpng",
377 ]
378 sources = [
379 "src/codec/SkIcoCodec.cpp",
380 "src/codec/SkPngCodec.cpp",
381 "src/images/SkPNGImageEncoder.cpp",
382 ]
383}
384
mtklein3cc22182016-08-29 13:26:14 -0700385optional("typeface_freetype") {
386 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700387
388 deps = [
389 "//third_party/freetype2",
390 ]
391 sources = [
392 "src/ports/SkFontHost_FreeType.cpp",
393 "src/ports/SkFontHost_FreeType_common.cpp",
394 ]
395}
396
mtklein457b42a2016-08-23 13:56:37 -0700397optional("webp") {
398 enabled = skia_use_libwebp
399 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
400
mtklein457b42a2016-08-23 13:56:37 -0700401 deps = [
402 "//third_party/libwebp",
403 ]
404 sources = [
405 "src/codec/SkWebpAdapterCodec.cpp",
406 "src/codec/SkWebpCodec.cpp",
407 "src/images/SkWEBPImageEncoder.cpp",
408 ]
mtkleineb3c4252016-08-23 07:38:09 -0700409}
410
mtklein63213812016-08-24 09:55:56 -0700411optional("xml") {
412 enabled = skia_use_expat
mtklein63213812016-08-24 09:55:56 -0700413
mtklein63213812016-08-24 09:55:56 -0700414 deps = [
415 "//third_party/expat",
416 ]
417 sources = [
418 "src/xml/SkDOM.cpp",
419 "src/xml/SkXMLParser.cpp",
420 "src/xml/SkXMLWriter.cpp",
421 ]
422}
423
mtkleinc04ff472016-06-23 10:29:30 -0700424component("skia") {
425 public_configs = [ ":skia_public" ]
426 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700427
428 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700429 ":arm64",
430 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700431 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700432 ":crc32",
mtklein349cece2016-08-26 08:13:04 -0700433 ":dsp",
mtkleina45be612016-08-29 15:22:10 -0700434 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700435 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700436 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700437 ":fontmgr_fuchsia",
mtklein457b42a2016-08-23 13:56:37 -0700438 ":gif",
mtklein06c35c02016-09-20 12:28:12 -0700439 ":gpu",
mtklein63213812016-08-24 09:55:56 -0700440 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700441 ":none",
mtklein63213812016-08-24 09:55:56 -0700442 ":pdf",
443 ":png",
mtklein9b8583d2016-08-24 17:32:30 -0700444 ":sse2",
445 ":sse41",
446 ":sse42",
447 ":ssse3",
mtklein3cc22182016-08-29 13:26:14 -0700448 ":typeface_freetype",
mtkleineb3c4252016-08-23 07:38:09 -0700449 ":webp",
mtklein63213812016-08-24 09:55:56 -0700450 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700451 ]
452
mtkleinc04ff472016-06-23 10:29:30 -0700453 sources = []
brettwb9447282016-09-01 14:24:39 -0700454 sources += skia_core_sources
455 sources += skia_effects_sources
brettwb9447282016-09-01 14:24:39 -0700456 sources += skia_sksl_sources
457 sources += skia_utils_sources
mtkleinc04ff472016-06-23 10:29:30 -0700458 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700459 "src/android/SkBitmapRegionCodec.cpp",
460 "src/android/SkBitmapRegionDecoder.cpp",
461 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700462 "src/codec/SkBmpCodec.cpp",
463 "src/codec/SkBmpMaskCodec.cpp",
464 "src/codec/SkBmpRLECodec.cpp",
465 "src/codec/SkBmpStandardCodec.cpp",
466 "src/codec/SkCodec.cpp",
467 "src/codec/SkCodecImageGenerator.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700468 "src/codec/SkMaskSwizzler.cpp",
469 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700470 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700471 "src/codec/SkSampler.cpp",
472 "src/codec/SkSwizzler.cpp",
473 "src/codec/SkWbmpCodec.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700474 "src/images/SkImageEncoder.cpp",
475 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700476 "src/images/SkKTXImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700477 "src/ports/SkDiscardableMemory_none.cpp",
478 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700479 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700480 "src/ports/SkMemory_malloc.cpp",
481 "src/ports/SkOSFile_stdio.cpp",
482 "src/sfnt/SkOTTable_name.cpp",
483 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700484 "src/svg/SkSVGCanvas.cpp",
485 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700486 "src/utils/mac/SkStream_mac.cpp",
487 "third_party/etc1/etc1.cpp",
488 "third_party/ktx/ktx.cpp",
489 ]
brettwb9447282016-09-01 14:24:39 -0700490
mtklein7d6fb2c2016-08-25 14:50:44 -0700491 libs = []
492
mtkleinc04ff472016-06-23 10:29:30 -0700493 if (is_win) {
494 sources += [
495 "src/ports/SkDebug_win.cpp",
496 "src/ports/SkFontHost_win.cpp",
497 "src/ports/SkFontMgr_win_dw.cpp",
498 "src/ports/SkFontMgr_win_dw_factory.cpp",
499 "src/ports/SkImageEncoder_WIC.cpp",
500 "src/ports/SkImageGeneratorWIC.cpp",
501 "src/ports/SkOSFile_win.cpp",
502 "src/ports/SkScalerContext_win_dw.cpp",
503 "src/ports/SkTLS_win.cpp",
504 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700505 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700506 ]
mtkleinb9be9792016-09-16 14:44:18 -0700507 sources -=
508 [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
mtkleinc04ff472016-06-23 10:29:30 -0700509 } else {
510 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700511 "src/ports/SkOSFile_posix.cpp",
512 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700513 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700514 ]
515 }
516
mtklein7d6fb2c2016-08-25 14:50:44 -0700517 if (is_android) {
518 deps += [
519 "//third_party/cpu-features",
520 "//third_party/expat",
mtklein7d6fb2c2016-08-25 14:50:44 -0700521 ]
mtklein06c35c02016-09-20 12:28:12 -0700522 sources += [ "src/ports/SkDebug_android.cpp" ]
mtklein7d6fb2c2016-08-25 14:50:44 -0700523 libs += [
524 "EGL",
525 "GLESv2",
526 "log",
527 ]
528 }
529
mtkleinc04ff472016-06-23 10:29:30 -0700530 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700531 libs += [
532 "GL",
533 "GLU",
534 "X11",
535 ]
mtklein06c35c02016-09-20 12:28:12 -0700536 sources += [ "src/ports/SkDebug_stdio.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700537 }
538
539 if (is_mac) {
540 sources += [
mtklein7d6fb2c2016-08-25 14:50:44 -0700541 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700542 "src/ports/SkFontHost_mac.cpp",
543 "src/ports/SkImageEncoder_CG.cpp",
544 "src/ports/SkImageGeneratorCG.cpp",
545 ]
mtklein09e61f72016-08-23 13:35:28 -0700546 libs += [
547 "ApplicationServices.framework",
548 "OpenGL.framework",
549 ]
mtkleinc04ff472016-06-23 10:29:30 -0700550 }
abarth6fc8ff02016-07-15 15:15:15 -0700551
552 if (is_fuchsia) {
mtklein06c35c02016-09-20 12:28:12 -0700553 sources += [ "src/ports/SkDebug_stdio.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700554 }
mtkleinc04ff472016-06-23 10:29:30 -0700555}
556
mtkleinada5a442016-08-02 14:28:26 -0700557skia_h_headers = exec_script("gyp/find.py",
558 [ "*.h" ] + rebase_path(skia_public_includes),
559 "list lines",
560 []) -
561 [
562 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
563 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
564 rebase_path("include/gpu/vk/GrVkDefines.h"),
565 rebase_path("include/gpu/vk/GrVkInterface.h"),
566 rebase_path("include/gpu/vk/GrVkTypes.h"),
567 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
568 ]
569
mtklein1211e0c2016-07-26 13:55:45 -0700570action("skia.h") {
571 script = "gn/echo_headers.py"
572 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinc095df52016-08-24 12:23:52 -0700573 rebase_path(skia_h_headers, target_gen_dir)
mtklein1211e0c2016-07-26 13:55:45 -0700574 outputs = [
575 "$target_gen_dir/skia.h",
576 ]
577}
578
mtklein06c35c02016-09-20 12:28:12 -0700579if (skia_enable_gpu && target_cpu == "x64") {
mtklein1fbdf982016-09-15 12:07:48 -0700580 # Our bots only have 64-bit libOSMesa installed.
581 # TODO: worth fixing?
582 executable("fiddle") {
583 include_dirs = [ "$target_gen_dir" ]
584 libs = []
585 if (is_linux) {
586 libs += [ "OSMesa" ]
587 }
mtklein56d56692016-09-15 11:18:55 -0700588
mtklein1fbdf982016-09-15 12:07:48 -0700589 sources = [
590 "src/images/SkForceLinking.cpp",
591 "tools/fiddle/draw.cpp",
592 "tools/fiddle/fiddle_main.cpp",
593 ]
594 deps = [
595 ":skia",
596 ":skia.h",
597 ]
598 }
mtkleinc04ff472016-06-23 10:29:30 -0700599}
mtklein25c81d42016-07-27 13:55:26 -0700600
mtkleinc095df52016-08-24 12:23:52 -0700601# Targets guarded by skia_enable_tools may use //third_party freely.
602if (skia_enable_tools) {
603 template("test_lib") {
604 config(target_name + "_config") {
605 include_dirs = invoker.public_include_dirs
mtkleina627b5c2016-09-20 13:36:47 -0700606 if (defined(invoker.public_defines)) {
607 defines = invoker.public_defines
608 }
mtklein25c81d42016-07-27 13:55:26 -0700609 }
mtkleinc095df52016-08-24 12:23:52 -0700610 source_set(target_name) {
611 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
612 public_configs = [
613 ":" + target_name + "_config",
614 ":skia_private",
615 ]
616
617 if (!defined(deps)) {
618 deps = []
619 }
620 deps += [ ":skia" ]
621 testonly = true
622 }
mtklein25c81d42016-07-27 13:55:26 -0700623 }
mtklein25c81d42016-07-27 13:55:26 -0700624
mtkleinc095df52016-08-24 12:23:52 -0700625 test_lib("gpu_tool_utils") {
mtkleina627b5c2016-09-20 13:36:47 -0700626 public_defines = []
mtkleinc095df52016-08-24 12:23:52 -0700627 public_include_dirs = [ "tools/gpu" ]
628 sources = [
629 "tools/gpu/GrContextFactory.cpp",
630 "tools/gpu/GrTest.cpp",
631 "tools/gpu/TestContext.cpp",
632 "tools/gpu/gl/GLTestContext.cpp",
633 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
634 "tools/gpu/gl/debug/GrBufferObj.cpp",
635 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
636 "tools/gpu/gl/debug/GrProgramObj.cpp",
637 "tools/gpu/gl/debug/GrShaderObj.cpp",
638 "tools/gpu/gl/debug/GrTextureObj.cpp",
639 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
640 "tools/gpu/gl/null/NullGLTestContext.cpp",
641 ]
642 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700643
mtklein7d6fb2c2016-08-25 14:50:44 -0700644 if (is_android) {
645 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
646 } else if (is_linux) {
mtkleinc095df52016-08-24 12:23:52 -0700647 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
648 } else if (is_mac) {
649 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
650 }
mtklein6ef69992016-09-14 06:12:09 -0700651
652 if (skia_use_vulkan) {
653 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
654 }
mtkleina627b5c2016-09-20 13:36:47 -0700655 if (skia_use_mesa) {
656 public_defines += [ "SK_MESA" ]
657 sources += [ "tools/gpu/gl/mesa/GLTestContext_mesa.cpp" ]
658 libs += [ "OSMesa" ]
659 }
mtklein25c81d42016-07-27 13:55:26 -0700660 }
mtklein25c81d42016-07-27 13:55:26 -0700661
mtkleinc095df52016-08-24 12:23:52 -0700662 test_lib("flags") {
663 public_include_dirs = [ "tools/flags" ]
664 sources = [
665 "tools/flags/SkCommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -0700666 ]
667 }
668 test_lib("common_flags") {
669 public_include_dirs = [ "tools/flags" ]
670 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700671 "tools/flags/SkCommonFlags.cpp",
672 "tools/flags/SkCommonFlagsConfig.cpp",
673 ]
674 deps = [
mtklein046cb562016-09-16 10:23:12 -0700675 ":flags",
mtkleinc095df52016-08-24 12:23:52 -0700676 ":gpu_tool_utils",
677 ]
678 }
mtklein25c81d42016-07-27 13:55:26 -0700679
mtkleinc095df52016-08-24 12:23:52 -0700680 test_lib("tool_utils") {
681 public_include_dirs = [
682 "tools",
683 "tools/debugger",
684 "tools/timer",
685 ]
686 sources = [
687 "src/images/SkForceLinking.cpp",
688 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700689 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700690 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700691 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700692 "tools/ProcStats.cpp",
693 "tools/Resources.cpp",
694 "tools/ThermalManager.cpp",
695 "tools/UrlDataManager.cpp",
696 "tools/debugger/SkDebugCanvas.cpp",
697 "tools/debugger/SkDrawCommand.cpp",
698 "tools/debugger/SkJsonWriteBuffer.cpp",
699 "tools/debugger/SkObjectParser.cpp",
700 "tools/debugger/SkOverdrawMode.cpp",
701 "tools/picture_utils.cpp",
702 "tools/random_parse_path.cpp",
703 "tools/sk_tool_utils.cpp",
704 "tools/sk_tool_utils_font.cpp",
705 "tools/timer/Timer.cpp",
706 ]
707 deps = [
mtklein046cb562016-09-16 10:23:12 -0700708 ":common_flags",
mtkleinc095df52016-08-24 12:23:52 -0700709 ":flags",
710 "//third_party/libpng",
711 ]
712 public_deps = [
713 "//third_party/jsoncpp",
714 ]
715 }
mtklein25c81d42016-07-27 13:55:26 -0700716
mtkleinc095df52016-08-24 12:23:52 -0700717 gm_sources = exec_script("gyp/find.py",
718 [
719 "*.c*",
720 rebase_path("gm"),
721 ],
722 "list lines",
723 [])
724 test_lib("gm") {
725 public_include_dirs = [ "gm" ]
726 sources = gm_sources
727 deps = [
728 ":gpu_tool_utils",
729 ":skia",
730 ":tool_utils",
731 ]
732 }
mtklein25c81d42016-07-27 13:55:26 -0700733
mtkleinc095df52016-08-24 12:23:52 -0700734 tests_sources = exec_script("gyp/find.py",
735 [
736 "*.c*",
737 rebase_path("tests"),
738 ],
739 "list lines",
740 [])
mtklein2f3416d2016-08-02 16:02:05 -0700741
mtkleinc095df52016-08-24 12:23:52 -0700742 test_lib("tests") {
743 public_include_dirs = [ "tests" ]
mtkleina45be612016-08-29 15:22:10 -0700744 sources = tests_sources - [
745 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
mtkleina45be612016-08-29 15:22:10 -0700746 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
747 rebase_path("tests/skia_test.cpp"), # alternate main
748 ]
749 if (!fontmgr_android_enabled) {
750 sources -= [ rebase_path("tests/FontMgrAndroidParserTest.cpp") ]
751 }
mtkleinc095df52016-08-24 12:23:52 -0700752 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700753 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700754 ":flags",
755 ":gpu_tool_utils",
756 ":skia",
757 ":tool_utils",
758 "//third_party/libpng",
759 "//third_party/zlib",
760 ]
761 }
mtklein2f3416d2016-08-02 16:02:05 -0700762
mtkleinc095df52016-08-24 12:23:52 -0700763 bench_sources = exec_script("gyp/find.py",
764 [
765 "*.c*",
766 rebase_path("bench"),
767 ],
768 "list lines",
769 [])
mtklein25c81d42016-07-27 13:55:26 -0700770
mtkleinc095df52016-08-24 12:23:52 -0700771 test_lib("bench") {
772 public_include_dirs = [ "bench" ]
773 sources = bench_sources
774 sources -= [
775 rebase_path("bench/nanobench.cpp"),
776 rebase_path("bench/nanobenchAndroid.cpp"),
777 ]
778 deps = [
779 ":flags",
780 ":gm",
781 ":gpu_tool_utils",
782 ":skia",
783 ":tool_utils",
784 ]
785 }
mtklein2b6870c2016-07-28 14:17:33 -0700786
mtkleinc095df52016-08-24 12:23:52 -0700787 test_lib("experimental_svg_model") {
788 public_include_dirs = [ "experimental/svg/model" ]
789 sources = [
790 "experimental/svg/model/SkSVGAttribute.cpp",
791 "experimental/svg/model/SkSVGAttributeParser.cpp",
792 "experimental/svg/model/SkSVGCircle.cpp",
793 "experimental/svg/model/SkSVGContainer.cpp",
794 "experimental/svg/model/SkSVGDOM.cpp",
795 "experimental/svg/model/SkSVGEllipse.cpp",
796 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700797 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700798 "experimental/svg/model/SkSVGNode.cpp",
799 "experimental/svg/model/SkSVGPath.cpp",
800 "experimental/svg/model/SkSVGPoly.cpp",
801 "experimental/svg/model/SkSVGRect.cpp",
802 "experimental/svg/model/SkSVGRenderContext.cpp",
803 "experimental/svg/model/SkSVGSVG.cpp",
804 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700805 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700806 "experimental/svg/model/SkSVGTransformableNode.cpp",
807 "experimental/svg/model/SkSVGValue.cpp",
808 ]
809 deps = [
810 ":skia",
811 ]
812 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700813
mtklein2b6870c2016-07-28 14:17:33 -0700814 executable("dm") {
815 sources = [
816 "dm/DM.cpp",
817 "dm/DMJsonWriter.cpp",
818 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700819 ]
820 include_dirs = [ "tests" ]
821 deps = [
mtklein046cb562016-09-16 10:23:12 -0700822 ":common_flags",
fmalitaa2b9fdf2016-08-03 19:53:36 -0700823 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700824 ":flags",
825 ":gm",
826 ":gpu_tool_utils",
827 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700828 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700829 ":tool_utils",
830 "//third_party/jsoncpp",
831 "//third_party/libpng",
832 ]
833 testonly = true
834 }
835
836 executable("monobench") {
837 sources = [
838 "tools/monobench.cpp",
839 ]
840 deps = [
841 ":bench",
842 ":skia",
843 ]
844 testonly = true
845 }
846
847 executable("nanobench") {
848 sources = [
849 "bench/nanobench.cpp",
850 ]
851 deps = [
852 ":bench",
mtklein046cb562016-09-16 10:23:12 -0700853 ":common_flags",
fmalita6519c212016-09-14 08:05:17 -0700854 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700855 ":flags",
856 ":gm",
857 ":gpu_tool_utils",
858 ":skia",
859 ":tool_utils",
860 "//third_party/jsoncpp",
861 ]
862 testonly = true
863 }
halcanary19a97202016-08-03 15:08:04 -0700864
csmartdalton4b5179b2016-09-19 11:03:58 -0700865 executable("skpbench") {
866 sources = [
867 "tools/skpbench/skpbench.cpp",
868 ]
869 deps = [
870 ":flags",
871 ":gpu_tool_utils",
872 ":skia",
873 ":tool_utils",
874 ]
875 testonly = true
876 }
877
mtklein6f5df6a2016-08-29 16:01:10 -0700878 if (current_cpu != "mipsel") { # Clang 3.8 crashes while compiling hb-icu.cc for mipsel.
halcanary3eee9d92016-09-10 07:01:53 -0700879 executable("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -0700880 sources = [
881 "tools/SkShaper_harfbuzz.cpp",
882 "tools/using_skia_and_harfbuzz.cpp",
883 ]
884 deps = [
885 ":skia",
886 "//third_party/harfbuzz",
887 ]
888 testonly = true
889 }
halcanary19a97202016-08-03 15:08:04 -0700890 }
halcanary3eee9d92016-09-10 07:01:53 -0700891 executable("sktexttopdf") {
892 sources = [
893 "tools/SkShaper_primitive.cpp",
894 "tools/using_skia_and_harfbuzz.cpp",
895 ]
896 deps = [
897 ":skia",
898 ]
899 testonly = true
900 }
mtklein046cb562016-09-16 10:23:12 -0700901
902 executable("get_images_from_skps") {
903 sources = [
904 "tools/get_images_from_skps.cpp",
905 ]
906 deps = [
907 ":flags",
908 ":skia",
909 "//third_party/jsoncpp",
910 ]
911 testonly = true
912 }
mtklein25c81d42016-07-27 13:55:26 -0700913}