blob: d9f7d79bee4086b9a7f44d644fe634fabdf660b7 [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
306 sources = skia_gpu_sources + [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ]
307
308 # These paths need to be absolute to match the ones produced by shared_sources.gni.
309 sources -= get_path_info([
310 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
311 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
312 ],
313 "abspath")
314 if (is_android) {
315 sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
316 } else if (is_linux) {
317 sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
318 } else if (is_mac) {
319 sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
320 } else {
321 sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
322 }
323}
324
mtklein63213812016-08-24 09:55:56 -0700325optional("jpeg") {
326 enabled = skia_use_libjpeg_turbo
327 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
328
mtklein63213812016-08-24 09:55:56 -0700329 deps = [
330 "//third_party/libjpeg-turbo:libjpeg",
331 ]
332 sources = [
333 "src/codec/SkJpegCodec.cpp",
334 "src/codec/SkJpegDecoderMgr.cpp",
335 "src/codec/SkJpegUtility.cpp",
336 "src/images/SkJPEGImageEncoder.cpp",
337 "src/images/SkJPEGWriteUtility.cpp",
338 ]
339}
340
341optional("pdf") {
342 enabled = skia_use_zlib
mtklein63213812016-08-24 09:55:56 -0700343
mtklein63213812016-08-24 09:55:56 -0700344 deps = [
345 "//third_party/zlib",
346 ]
brettwb9447282016-09-01 14:24:39 -0700347 sources = skia_pdf_sources
mtkleincd01b032016-08-31 04:58:19 -0700348 sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
mtklein63213812016-08-24 09:55:56 -0700349
350 if (skia_use_sfntly) {
351 deps += [ "//third_party/sfntly" ]
mtkleincd01b032016-08-31 04:58:19 -0700352 public_defines = [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700353 }
354}
355
356optional("png") {
357 enabled = skia_use_libpng
358 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
359
mtklein63213812016-08-24 09:55:56 -0700360 deps = [
361 "//third_party/libpng",
362 ]
363 sources = [
364 "src/codec/SkIcoCodec.cpp",
365 "src/codec/SkPngCodec.cpp",
366 "src/images/SkPNGImageEncoder.cpp",
367 ]
368}
369
mtklein3cc22182016-08-29 13:26:14 -0700370optional("typeface_freetype") {
371 enabled = skia_use_freetype
mtklein3cc22182016-08-29 13:26:14 -0700372
373 deps = [
374 "//third_party/freetype2",
375 ]
376 sources = [
377 "src/ports/SkFontHost_FreeType.cpp",
378 "src/ports/SkFontHost_FreeType_common.cpp",
379 ]
380}
381
mtklein6ef69992016-09-14 06:12:09 -0700382optional("vulkan") {
383 enabled = skia_use_vulkan
384 public_defines = [ "SK_VULKAN" ]
385 libs = [ "vulkan" ]
386 sources = skia_vk_sources
387}
388
mtklein457b42a2016-08-23 13:56:37 -0700389optional("webp") {
390 enabled = skia_use_libwebp
391 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
392
mtklein457b42a2016-08-23 13:56:37 -0700393 deps = [
394 "//third_party/libwebp",
395 ]
396 sources = [
397 "src/codec/SkWebpAdapterCodec.cpp",
398 "src/codec/SkWebpCodec.cpp",
399 "src/images/SkWEBPImageEncoder.cpp",
400 ]
mtkleineb3c4252016-08-23 07:38:09 -0700401}
402
mtklein63213812016-08-24 09:55:56 -0700403optional("xml") {
404 enabled = skia_use_expat
mtklein63213812016-08-24 09:55:56 -0700405
mtklein63213812016-08-24 09:55:56 -0700406 deps = [
407 "//third_party/expat",
408 ]
409 sources = [
410 "src/xml/SkDOM.cpp",
411 "src/xml/SkXMLParser.cpp",
412 "src/xml/SkXMLWriter.cpp",
413 ]
414}
415
mtkleinc04ff472016-06-23 10:29:30 -0700416component("skia") {
417 public_configs = [ ":skia_public" ]
418 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700419
420 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700421 ":arm64",
422 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700423 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700424 ":crc32",
mtklein349cece2016-08-26 08:13:04 -0700425 ":dsp",
mtkleina45be612016-08-29 15:22:10 -0700426 ":fontmgr_android",
mtkleind2e39db2016-09-07 07:52:55 -0700427 ":fontmgr_custom",
mtklein3cc22182016-08-29 13:26:14 -0700428 ":fontmgr_fontconfig",
mtkleincdedd0e2016-09-12 15:15:44 -0700429 ":fontmgr_fuchsia",
mtklein457b42a2016-08-23 13:56:37 -0700430 ":gif",
mtklein06c35c02016-09-20 12:28:12 -0700431 ":gpu",
mtklein63213812016-08-24 09:55:56 -0700432 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700433 ":none",
mtklein63213812016-08-24 09:55:56 -0700434 ":pdf",
435 ":png",
mtklein9b8583d2016-08-24 17:32:30 -0700436 ":sse2",
437 ":sse41",
438 ":sse42",
439 ":ssse3",
mtklein3cc22182016-08-29 13:26:14 -0700440 ":typeface_freetype",
mtklein6ef69992016-09-14 06:12:09 -0700441 ":vulkan",
mtkleineb3c4252016-08-23 07:38:09 -0700442 ":webp",
mtklein63213812016-08-24 09:55:56 -0700443 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700444 ]
445
mtkleinc04ff472016-06-23 10:29:30 -0700446 sources = []
brettwb9447282016-09-01 14:24:39 -0700447 sources += skia_core_sources
448 sources += skia_effects_sources
brettwb9447282016-09-01 14:24:39 -0700449 sources += skia_sksl_sources
450 sources += skia_utils_sources
mtkleinc04ff472016-06-23 10:29:30 -0700451 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700452 "src/android/SkBitmapRegionCodec.cpp",
453 "src/android/SkBitmapRegionDecoder.cpp",
454 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700455 "src/codec/SkBmpCodec.cpp",
456 "src/codec/SkBmpMaskCodec.cpp",
457 "src/codec/SkBmpRLECodec.cpp",
458 "src/codec/SkBmpStandardCodec.cpp",
459 "src/codec/SkCodec.cpp",
460 "src/codec/SkCodecImageGenerator.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700461 "src/codec/SkMaskSwizzler.cpp",
462 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700463 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700464 "src/codec/SkSampler.cpp",
465 "src/codec/SkSwizzler.cpp",
466 "src/codec/SkWbmpCodec.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700467 "src/images/SkImageEncoder.cpp",
468 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700469 "src/images/SkKTXImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700470 "src/ports/SkDiscardableMemory_none.cpp",
471 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700472 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700473 "src/ports/SkMemory_malloc.cpp",
474 "src/ports/SkOSFile_stdio.cpp",
475 "src/sfnt/SkOTTable_name.cpp",
476 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700477 "src/svg/SkSVGCanvas.cpp",
478 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700479 "src/utils/mac/SkStream_mac.cpp",
480 "third_party/etc1/etc1.cpp",
481 "third_party/ktx/ktx.cpp",
482 ]
brettwb9447282016-09-01 14:24:39 -0700483
mtklein7d6fb2c2016-08-25 14:50:44 -0700484 libs = []
485
mtkleinc04ff472016-06-23 10:29:30 -0700486 if (is_win) {
487 sources += [
488 "src/ports/SkDebug_win.cpp",
489 "src/ports/SkFontHost_win.cpp",
490 "src/ports/SkFontMgr_win_dw.cpp",
491 "src/ports/SkFontMgr_win_dw_factory.cpp",
492 "src/ports/SkImageEncoder_WIC.cpp",
493 "src/ports/SkImageGeneratorWIC.cpp",
494 "src/ports/SkOSFile_win.cpp",
495 "src/ports/SkScalerContext_win_dw.cpp",
496 "src/ports/SkTLS_win.cpp",
497 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700498 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700499 ]
mtkleinb9be9792016-09-16 14:44:18 -0700500 sources -=
501 [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
mtkleinc04ff472016-06-23 10:29:30 -0700502 } else {
503 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700504 "src/ports/SkOSFile_posix.cpp",
505 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700506 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700507 ]
508 }
509
mtklein7d6fb2c2016-08-25 14:50:44 -0700510 if (is_android) {
511 deps += [
512 "//third_party/cpu-features",
513 "//third_party/expat",
mtklein7d6fb2c2016-08-25 14:50:44 -0700514 ]
mtklein06c35c02016-09-20 12:28:12 -0700515 sources += [ "src/ports/SkDebug_android.cpp" ]
mtklein7d6fb2c2016-08-25 14:50:44 -0700516 libs += [
517 "EGL",
518 "GLESv2",
519 "log",
520 ]
521 }
522
mtkleinc04ff472016-06-23 10:29:30 -0700523 if (is_linux) {
mtklein09e61f72016-08-23 13:35:28 -0700524 libs += [
525 "GL",
526 "GLU",
527 "X11",
528 ]
mtklein06c35c02016-09-20 12:28:12 -0700529 sources += [ "src/ports/SkDebug_stdio.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700530 }
531
532 if (is_mac) {
533 sources += [
mtklein7d6fb2c2016-08-25 14:50:44 -0700534 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700535 "src/ports/SkFontHost_mac.cpp",
536 "src/ports/SkImageEncoder_CG.cpp",
537 "src/ports/SkImageGeneratorCG.cpp",
538 ]
mtklein09e61f72016-08-23 13:35:28 -0700539 libs += [
540 "ApplicationServices.framework",
541 "OpenGL.framework",
542 ]
mtkleinc04ff472016-06-23 10:29:30 -0700543 }
abarth6fc8ff02016-07-15 15:15:15 -0700544
545 if (is_fuchsia) {
mtklein06c35c02016-09-20 12:28:12 -0700546 sources += [ "src/ports/SkDebug_stdio.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700547 }
mtkleinc04ff472016-06-23 10:29:30 -0700548}
549
mtkleinada5a442016-08-02 14:28:26 -0700550skia_h_headers = exec_script("gyp/find.py",
551 [ "*.h" ] + rebase_path(skia_public_includes),
552 "list lines",
553 []) -
554 [
555 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
556 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
557 rebase_path("include/gpu/vk/GrVkDefines.h"),
558 rebase_path("include/gpu/vk/GrVkInterface.h"),
559 rebase_path("include/gpu/vk/GrVkTypes.h"),
560 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
561 ]
562
mtklein1211e0c2016-07-26 13:55:45 -0700563action("skia.h") {
564 script = "gn/echo_headers.py"
565 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinc095df52016-08-24 12:23:52 -0700566 rebase_path(skia_h_headers, target_gen_dir)
mtklein1211e0c2016-07-26 13:55:45 -0700567 outputs = [
568 "$target_gen_dir/skia.h",
569 ]
570}
571
mtklein06c35c02016-09-20 12:28:12 -0700572if (skia_enable_gpu && target_cpu == "x64") {
mtklein1fbdf982016-09-15 12:07:48 -0700573 # Our bots only have 64-bit libOSMesa installed.
574 # TODO: worth fixing?
575 executable("fiddle") {
576 include_dirs = [ "$target_gen_dir" ]
577 libs = []
578 if (is_linux) {
579 libs += [ "OSMesa" ]
580 }
mtklein56d56692016-09-15 11:18:55 -0700581
mtklein1fbdf982016-09-15 12:07:48 -0700582 sources = [
583 "src/images/SkForceLinking.cpp",
584 "tools/fiddle/draw.cpp",
585 "tools/fiddle/fiddle_main.cpp",
586 ]
587 deps = [
588 ":skia",
589 ":skia.h",
590 ]
591 }
mtkleinc04ff472016-06-23 10:29:30 -0700592}
mtklein25c81d42016-07-27 13:55:26 -0700593
mtkleinc095df52016-08-24 12:23:52 -0700594# Targets guarded by skia_enable_tools may use //third_party freely.
595if (skia_enable_tools) {
596 template("test_lib") {
597 config(target_name + "_config") {
598 include_dirs = invoker.public_include_dirs
mtkleina627b5c2016-09-20 13:36:47 -0700599 if (defined(invoker.public_defines)) {
600 defines = invoker.public_defines
601 }
mtklein25c81d42016-07-27 13:55:26 -0700602 }
mtkleinc095df52016-08-24 12:23:52 -0700603 source_set(target_name) {
604 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
605 public_configs = [
606 ":" + target_name + "_config",
607 ":skia_private",
608 ]
609
610 if (!defined(deps)) {
611 deps = []
612 }
613 deps += [ ":skia" ]
614 testonly = true
615 }
mtklein25c81d42016-07-27 13:55:26 -0700616 }
mtklein25c81d42016-07-27 13:55:26 -0700617
mtkleinc095df52016-08-24 12:23:52 -0700618 test_lib("gpu_tool_utils") {
mtkleina627b5c2016-09-20 13:36:47 -0700619 public_defines = []
mtkleinc095df52016-08-24 12:23:52 -0700620 public_include_dirs = [ "tools/gpu" ]
621 sources = [
622 "tools/gpu/GrContextFactory.cpp",
623 "tools/gpu/GrTest.cpp",
624 "tools/gpu/TestContext.cpp",
625 "tools/gpu/gl/GLTestContext.cpp",
626 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
627 "tools/gpu/gl/debug/GrBufferObj.cpp",
628 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
629 "tools/gpu/gl/debug/GrProgramObj.cpp",
630 "tools/gpu/gl/debug/GrShaderObj.cpp",
631 "tools/gpu/gl/debug/GrTextureObj.cpp",
632 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
633 "tools/gpu/gl/null/NullGLTestContext.cpp",
634 ]
635 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700636
mtklein7d6fb2c2016-08-25 14:50:44 -0700637 if (is_android) {
638 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
639 } else if (is_linux) {
mtkleinc095df52016-08-24 12:23:52 -0700640 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
641 } else if (is_mac) {
642 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
643 }
mtklein6ef69992016-09-14 06:12:09 -0700644
645 if (skia_use_vulkan) {
646 sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
647 }
mtkleina627b5c2016-09-20 13:36:47 -0700648 if (skia_use_mesa) {
649 public_defines += [ "SK_MESA" ]
650 sources += [ "tools/gpu/gl/mesa/GLTestContext_mesa.cpp" ]
651 libs += [ "OSMesa" ]
652 }
mtklein25c81d42016-07-27 13:55:26 -0700653 }
mtklein25c81d42016-07-27 13:55:26 -0700654
mtkleinc095df52016-08-24 12:23:52 -0700655 test_lib("flags") {
656 public_include_dirs = [ "tools/flags" ]
657 sources = [
658 "tools/flags/SkCommandLineFlags.cpp",
mtklein046cb562016-09-16 10:23:12 -0700659 ]
660 }
661 test_lib("common_flags") {
662 public_include_dirs = [ "tools/flags" ]
663 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700664 "tools/flags/SkCommonFlags.cpp",
665 "tools/flags/SkCommonFlagsConfig.cpp",
666 ]
667 deps = [
mtklein046cb562016-09-16 10:23:12 -0700668 ":flags",
mtkleinc095df52016-08-24 12:23:52 -0700669 ":gpu_tool_utils",
670 ]
671 }
mtklein25c81d42016-07-27 13:55:26 -0700672
mtkleinc095df52016-08-24 12:23:52 -0700673 test_lib("tool_utils") {
674 public_include_dirs = [
675 "tools",
676 "tools/debugger",
677 "tools/timer",
678 ]
679 sources = [
680 "src/images/SkForceLinking.cpp",
681 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtkleinb37c0342016-09-09 11:07:45 -0700682 "tools/AndroidSkDebugToStdOut.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700683 "tools/CrashHandler.cpp",
mtklein0590fa52016-09-01 07:06:54 -0700684 "tools/LsanSuppressions.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700685 "tools/ProcStats.cpp",
686 "tools/Resources.cpp",
687 "tools/ThermalManager.cpp",
688 "tools/UrlDataManager.cpp",
689 "tools/debugger/SkDebugCanvas.cpp",
690 "tools/debugger/SkDrawCommand.cpp",
691 "tools/debugger/SkJsonWriteBuffer.cpp",
692 "tools/debugger/SkObjectParser.cpp",
693 "tools/debugger/SkOverdrawMode.cpp",
694 "tools/picture_utils.cpp",
695 "tools/random_parse_path.cpp",
696 "tools/sk_tool_utils.cpp",
697 "tools/sk_tool_utils_font.cpp",
698 "tools/timer/Timer.cpp",
699 ]
700 deps = [
mtklein046cb562016-09-16 10:23:12 -0700701 ":common_flags",
mtkleinc095df52016-08-24 12:23:52 -0700702 ":flags",
703 "//third_party/libpng",
704 ]
705 public_deps = [
706 "//third_party/jsoncpp",
707 ]
708 }
mtklein25c81d42016-07-27 13:55:26 -0700709
mtkleinc095df52016-08-24 12:23:52 -0700710 gm_sources = exec_script("gyp/find.py",
711 [
712 "*.c*",
713 rebase_path("gm"),
714 ],
715 "list lines",
716 [])
717 test_lib("gm") {
718 public_include_dirs = [ "gm" ]
719 sources = gm_sources
720 deps = [
721 ":gpu_tool_utils",
722 ":skia",
723 ":tool_utils",
724 ]
725 }
mtklein25c81d42016-07-27 13:55:26 -0700726
mtkleinc095df52016-08-24 12:23:52 -0700727 tests_sources = exec_script("gyp/find.py",
728 [
729 "*.c*",
730 rebase_path("tests"),
731 ],
732 "list lines",
733 [])
mtklein2f3416d2016-08-02 16:02:05 -0700734
mtkleinc095df52016-08-24 12:23:52 -0700735 test_lib("tests") {
736 public_include_dirs = [ "tests" ]
mtkleina45be612016-08-29 15:22:10 -0700737 sources = tests_sources - [
738 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
mtkleina45be612016-08-29 15:22:10 -0700739 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
740 rebase_path("tests/skia_test.cpp"), # alternate main
741 ]
742 if (!fontmgr_android_enabled) {
743 sources -= [ rebase_path("tests/FontMgrAndroidParserTest.cpp") ]
744 }
mtkleinc095df52016-08-24 12:23:52 -0700745 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700746 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700747 ":flags",
748 ":gpu_tool_utils",
749 ":skia",
750 ":tool_utils",
751 "//third_party/libpng",
752 "//third_party/zlib",
753 ]
754 }
mtklein2f3416d2016-08-02 16:02:05 -0700755
mtkleinc095df52016-08-24 12:23:52 -0700756 bench_sources = exec_script("gyp/find.py",
757 [
758 "*.c*",
759 rebase_path("bench"),
760 ],
761 "list lines",
762 [])
mtklein25c81d42016-07-27 13:55:26 -0700763
mtkleinc095df52016-08-24 12:23:52 -0700764 test_lib("bench") {
765 public_include_dirs = [ "bench" ]
766 sources = bench_sources
767 sources -= [
768 rebase_path("bench/nanobench.cpp"),
769 rebase_path("bench/nanobenchAndroid.cpp"),
770 ]
771 deps = [
772 ":flags",
773 ":gm",
774 ":gpu_tool_utils",
775 ":skia",
776 ":tool_utils",
777 ]
778 }
mtklein2b6870c2016-07-28 14:17:33 -0700779
mtkleinc095df52016-08-24 12:23:52 -0700780 test_lib("experimental_svg_model") {
781 public_include_dirs = [ "experimental/svg/model" ]
782 sources = [
783 "experimental/svg/model/SkSVGAttribute.cpp",
784 "experimental/svg/model/SkSVGAttributeParser.cpp",
785 "experimental/svg/model/SkSVGCircle.cpp",
786 "experimental/svg/model/SkSVGContainer.cpp",
787 "experimental/svg/model/SkSVGDOM.cpp",
788 "experimental/svg/model/SkSVGEllipse.cpp",
789 "experimental/svg/model/SkSVGLine.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700790 "experimental/svg/model/SkSVGLinearGradient.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700791 "experimental/svg/model/SkSVGNode.cpp",
792 "experimental/svg/model/SkSVGPath.cpp",
793 "experimental/svg/model/SkSVGPoly.cpp",
794 "experimental/svg/model/SkSVGRect.cpp",
795 "experimental/svg/model/SkSVGRenderContext.cpp",
796 "experimental/svg/model/SkSVGSVG.cpp",
797 "experimental/svg/model/SkSVGShape.cpp",
fmalita28d5b722016-09-12 17:06:47 -0700798 "experimental/svg/model/SkSVGStop.cpp",
mtkleinc095df52016-08-24 12:23:52 -0700799 "experimental/svg/model/SkSVGTransformableNode.cpp",
800 "experimental/svg/model/SkSVGValue.cpp",
801 ]
802 deps = [
803 ":skia",
804 ]
805 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700806
mtklein2b6870c2016-07-28 14:17:33 -0700807 executable("dm") {
808 sources = [
809 "dm/DM.cpp",
810 "dm/DMJsonWriter.cpp",
811 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700812 ]
813 include_dirs = [ "tests" ]
814 deps = [
mtklein046cb562016-09-16 10:23:12 -0700815 ":common_flags",
fmalitaa2b9fdf2016-08-03 19:53:36 -0700816 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700817 ":flags",
818 ":gm",
819 ":gpu_tool_utils",
820 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700821 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700822 ":tool_utils",
823 "//third_party/jsoncpp",
824 "//third_party/libpng",
825 ]
826 testonly = true
827 }
828
829 executable("monobench") {
830 sources = [
831 "tools/monobench.cpp",
832 ]
833 deps = [
834 ":bench",
835 ":skia",
836 ]
837 testonly = true
838 }
839
840 executable("nanobench") {
841 sources = [
842 "bench/nanobench.cpp",
843 ]
844 deps = [
845 ":bench",
mtklein046cb562016-09-16 10:23:12 -0700846 ":common_flags",
fmalita6519c212016-09-14 08:05:17 -0700847 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700848 ":flags",
849 ":gm",
850 ":gpu_tool_utils",
851 ":skia",
852 ":tool_utils",
853 "//third_party/jsoncpp",
854 ]
855 testonly = true
856 }
halcanary19a97202016-08-03 15:08:04 -0700857
csmartdalton4b5179b2016-09-19 11:03:58 -0700858 executable("skpbench") {
859 sources = [
860 "tools/skpbench/skpbench.cpp",
861 ]
862 deps = [
863 ":flags",
864 ":gpu_tool_utils",
865 ":skia",
866 ":tool_utils",
867 ]
868 testonly = true
869 }
870
mtklein6f5df6a2016-08-29 16:01:10 -0700871 if (current_cpu != "mipsel") { # Clang 3.8 crashes while compiling hb-icu.cc for mipsel.
halcanary3eee9d92016-09-10 07:01:53 -0700872 executable("sktexttopdf-hb") {
mtklein6f5df6a2016-08-29 16:01:10 -0700873 sources = [
874 "tools/SkShaper_harfbuzz.cpp",
875 "tools/using_skia_and_harfbuzz.cpp",
876 ]
877 deps = [
878 ":skia",
879 "//third_party/harfbuzz",
880 ]
881 testonly = true
882 }
halcanary19a97202016-08-03 15:08:04 -0700883 }
halcanary3eee9d92016-09-10 07:01:53 -0700884 executable("sktexttopdf") {
885 sources = [
886 "tools/SkShaper_primitive.cpp",
887 "tools/using_skia_and_harfbuzz.cpp",
888 ]
889 deps = [
890 ":skia",
891 ]
892 testonly = true
893 }
mtklein046cb562016-09-16 10:23:12 -0700894
895 executable("get_images_from_skps") {
896 sources = [
897 "tools/get_images_from_skps.cpp",
898 ]
899 deps = [
900 ":flags",
901 ":skia",
902 "//third_party/jsoncpp",
903 ]
904 testonly = true
905 }
mtklein25c81d42016-07-27 13:55:26 -0700906}