blob: 8c053cfbb96697865b4c91ba81ec9788e01105f3 [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
6declare_args() {
mtkleinc095df52016-08-24 12:23:52 -07007 skia_enable_tools = !is_fuchsia && !is_component_build
8
mtklein63213812016-08-24 09:55:56 -07009 skia_use_expat = true
mtklein457b42a2016-08-23 13:56:37 -070010 skia_use_giflib = !is_fuchsia
mtklein63213812016-08-24 09:55:56 -070011 skia_use_libjpeg_turbo = true
12 skia_use_libpng = true
mtkleineb3c4252016-08-23 07:38:09 -070013 skia_use_libwebp = !is_fuchsia
mtklein63213812016-08-24 09:55:56 -070014 skia_use_sfntly = !is_fuchsia
15 skia_use_zlib = true
mtkleinc04ff472016-06-23 10:29:30 -070016}
17
mtklein1211e0c2016-07-26 13:55:45 -070018skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070019 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070020 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070021 "include/codec",
22 "include/config",
23 "include/core",
24 "include/effects",
25 "include/gpu",
26 "include/gpu/gl",
27 "include/images",
28 "include/pathops",
29 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070030 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070031 "include/utils",
32 "include/utils/mac",
mtklein25c81d42016-07-27 13:55:26 -070033 "include/xml",
mtklein1211e0c2016-07-26 13:55:45 -070034]
35
mtkleinc04ff472016-06-23 10:29:30 -070036# Skia public API, generally provided by :skia.
37config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -070038 include_dirs = skia_public_includes
mtkleinc04ff472016-06-23 10:29:30 -070039 defines = [ "SKIA_DLL" ]
jcgregorio5561e3d2016-08-25 09:25:11 -070040 if (is_linux) {
41 defines += [ "SK_SAMPLES_FOR_X" ]
42 }
mtkleinc04ff472016-06-23 10:29:30 -070043}
44
45# Skia internal APIs, used by Skia itself and a few test tools.
46config("skia_private") {
47 visibility = [ ":*" ]
48
49 include_dirs = [
50 "include/private",
51 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -070052 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -070053 "src/config",
54 "src/core",
55 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -070056 "src/effects/gradients",
57 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -070058 "src/gpu",
59 "src/image",
60 "src/images",
61 "src/lazy",
62 "src/opts",
63 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -070064 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -070065 "src/ports",
66 "src/sfnt",
67 "src/utils",
mtklein7a1f45f2016-08-04 06:19:33 -070068 "src/utils/win",
mtkleinc04ff472016-06-23 10:29:30 -070069 "third_party/etc1",
70 "third_party/ktx",
71 ]
mtklein150d1132016-08-01 06:56:40 -070072
mtklein63213812016-08-24 09:55:56 -070073 defines = [ "SK_GAMMA_APPLY_TO_A8" ]
mtkleinc04ff472016-06-23 10:29:30 -070074}
75
76# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
77config("skia_library") {
78 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -070079 defines = [ "SKIA_IMPLEMENTATION=1" ]
80}
81
82skia_library_configs = [
83 ":skia_public",
84 ":skia_private",
85 ":skia_library",
86]
87
mtklein7fbfbbe2016-07-21 12:25:45 -070088core_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -070089 [
90 rebase_path("gyp/core.gypi"),
91 "--replace=<(skia_include_path)=include",
92 "--replace=<(skia_src_path)=src",
93 ],
94 "scope",
95 [ "gyp/core.gypi" ])
96
mtklein7fbfbbe2016-07-21 12:25:45 -070097effects_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -070098 [
99 rebase_path("gyp/effects.gypi"),
100 "--replace=<(skia_include_path)=include",
101 "--replace=<(skia_src_path)=src",
102 ],
103 "scope",
104 [ "gyp/effects.gypi" ])
105
mtklein7fbfbbe2016-07-21 12:25:45 -0700106gpu_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700107 [
108 rebase_path("gyp/gpu.gypi"),
109 "--replace=<(skia_include_path)=include",
110 "--replace=<(skia_src_path)=src",
111 ],
112 "scope",
113 [ "gyp/gpu.gypi" ])
114
mtklein7fbfbbe2016-07-21 12:25:45 -0700115opts_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700116 [
117 rebase_path("gyp/opts.gypi"),
118 "--replace=<(skia_include_path)=include",
119 "--replace=<(skia_src_path)=src",
120 ],
121 "scope",
122 [ "gyp/opts.gypi" ])
123
mtklein7fbfbbe2016-07-21 12:25:45 -0700124pdf_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700125 [
126 rebase_path("gyp/pdf.gypi"),
127 "--replace=<(skia_include_path)=include",
128 "--replace=<(skia_src_path)=src",
129 ],
130 "scope",
131 [ "gyp/pdf.gypi" ])
132
mtklein7fbfbbe2016-07-21 12:25:45 -0700133utils_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700134 [
135 rebase_path("gyp/utils.gypi"),
136 "--replace=<(skia_include_path)=include",
137 "--replace=<(skia_src_path)=src",
138 ],
139 "scope",
140 [ "gyp/utils.gypi" ])
141
mtklein9b8583d2016-08-24 17:32:30 -0700142# Use for CPU-specific Skia code that needs particular compiler flags.
143template("opts") {
144 if (invoker.enabled) {
145 source_set(target_name) {
146 forward_variables_from(invoker, "*")
147 configs += skia_library_configs
148 }
149 } else {
150 # If not enabled, a phony empty target that swallows all otherwise unused variables.
151 source_set(target_name) {
152 forward_variables_from(invoker,
153 "*",
154 [
155 "sources",
156 "cflags",
157 ])
158 }
159 }
anmittala7eaf2e2016-08-17 13:57:26 -0700160}
161
mtklein422310d2016-08-16 18:28:43 -0700162is_x86 = current_cpu == "x64" || current_cpu == "x86"
mtkleinc04ff472016-06-23 10:29:30 -0700163
mtklein7d6fb2c2016-08-25 14:50:44 -0700164opts("none") {
165 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
166 sources = opts_gypi.none_sources
anmittalb8b3f712016-08-25 04:55:19 -0700167 cflags = []
168}
169
mtklein7d6fb2c2016-08-25 14:50:44 -0700170opts("armv7") {
anmittalb8b3f712016-08-25 04:55:19 -0700171 enabled = current_cpu == "arm"
mtklein7d6fb2c2016-08-25 14:50:44 -0700172 sources = opts_gypi.armv7_sources + opts_gypi.neon_sources
173 cflags = []
anmittalb8b3f712016-08-25 04:55:19 -0700174}
175
176opts("arm64") {
177 enabled = current_cpu == "arm64"
178 sources = opts_gypi.arm64_sources
179 cflags = []
180}
181
182opts("crc32") {
183 enabled = current_cpu == "arm64"
184 sources = opts_gypi.crc32_sources
185 cflags = [ "-march=armv8-a+crc" ]
186}
187
mtklein9b8583d2016-08-24 17:32:30 -0700188opts("sse2") {
189 enabled = is_x86
190 sources = opts_gypi.sse2_sources
191 cflags = [ "-msse2" ]
192}
mtkleinc04ff472016-06-23 10:29:30 -0700193
mtklein9b8583d2016-08-24 17:32:30 -0700194opts("ssse3") {
195 enabled = is_x86
196 sources = opts_gypi.ssse3_sources
197 cflags = [ "-mssse3" ]
198}
mtkleinc04ff472016-06-23 10:29:30 -0700199
mtklein9b8583d2016-08-24 17:32:30 -0700200opts("sse41") {
201 enabled = is_x86
202 sources = opts_gypi.sse41_sources
203 cflags = [ "-msse4.1" ]
204}
mtklein4e976072016-08-08 09:06:27 -0700205
mtklein9b8583d2016-08-24 17:32:30 -0700206opts("sse42") {
207 enabled = is_x86
208 sources = opts_gypi.sse42_sources
209 cflags = [ "-msse4.2" ]
210}
211
212opts("avx") {
213 enabled = is_x86
214 sources = opts_gypi.avx_sources
215 cflags = [ "-mavx" ]
mtkleinc04ff472016-06-23 10:29:30 -0700216}
217
mtkleinc095df52016-08-24 12:23:52 -0700218# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700219template("optional") {
220 if (invoker.enabled) {
221 config(target_name + "_public") {
222 defines = invoker.public_defines
223 }
224 source_set(target_name) {
225 forward_variables_from(invoker, "*", [ "public_defines" ])
226 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700227 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700228 }
229 } else {
230 # If not enabled, a phony empty target that swallows all otherwise unused variables.
231 source_set(target_name) {
232 forward_variables_from(invoker,
233 "*",
234 [
235 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700236 "deps",
237 "sources",
238 ])
239 }
mtkleineb3c4252016-08-23 07:38:09 -0700240 }
mtklein457b42a2016-08-23 13:56:37 -0700241}
mtklein457b42a2016-08-23 13:56:37 -0700242
243optional("gif") {
244 enabled = skia_use_giflib
245 public_defines = [ "SK_HAS_GIF_LIBRARY" ]
246
mtklein457b42a2016-08-23 13:56:37 -0700247 deps = [
248 "//third_party/giflib",
249 ]
250 sources = [
251 "src/codec/SkGifCodec.cpp",
252 ]
253}
254
mtklein63213812016-08-24 09:55:56 -0700255optional("jpeg") {
256 enabled = skia_use_libjpeg_turbo
257 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
258
mtklein63213812016-08-24 09:55:56 -0700259 deps = [
260 "//third_party/libjpeg-turbo:libjpeg",
261 ]
262 sources = [
263 "src/codec/SkJpegCodec.cpp",
264 "src/codec/SkJpegDecoderMgr.cpp",
265 "src/codec/SkJpegUtility.cpp",
266 "src/images/SkJPEGImageEncoder.cpp",
267 "src/images/SkJPEGWriteUtility.cpp",
268 ]
269}
270
271optional("pdf") {
272 enabled = skia_use_zlib
273 public_defines = []
274
mtklein63213812016-08-24 09:55:56 -0700275 deps = [
276 "//third_party/zlib",
277 ]
278 sources = pdf_gypi.sources
279
280 if (skia_use_sfntly) {
281 deps += [ "//third_party/sfntly" ]
halcanary650e20d2016-08-25 09:07:02 -0700282 public_defines += [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700283 }
284}
285
286optional("png") {
287 enabled = skia_use_libpng
288 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
289
mtklein63213812016-08-24 09:55:56 -0700290 deps = [
291 "//third_party/libpng",
292 ]
293 sources = [
294 "src/codec/SkIcoCodec.cpp",
295 "src/codec/SkPngCodec.cpp",
296 "src/images/SkPNGImageEncoder.cpp",
297 ]
298}
299
mtklein457b42a2016-08-23 13:56:37 -0700300optional("webp") {
301 enabled = skia_use_libwebp
302 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
303
mtklein457b42a2016-08-23 13:56:37 -0700304 deps = [
305 "//third_party/libwebp",
306 ]
307 sources = [
308 "src/codec/SkWebpAdapterCodec.cpp",
309 "src/codec/SkWebpCodec.cpp",
310 "src/images/SkWEBPImageEncoder.cpp",
311 ]
mtkleineb3c4252016-08-23 07:38:09 -0700312}
313
mtklein63213812016-08-24 09:55:56 -0700314optional("xml") {
315 enabled = skia_use_expat
316 public_defines = []
317
mtklein63213812016-08-24 09:55:56 -0700318 deps = [
319 "//third_party/expat",
320 ]
321 sources = [
322 "src/xml/SkDOM.cpp",
323 "src/xml/SkXMLParser.cpp",
324 "src/xml/SkXMLWriter.cpp",
325 ]
326}
327
mtkleinc04ff472016-06-23 10:29:30 -0700328component("skia") {
329 public_configs = [ ":skia_public" ]
330 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700331
332 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700333 ":arm64",
334 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700335 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700336 ":crc32",
mtklein457b42a2016-08-23 13:56:37 -0700337 ":gif",
mtklein63213812016-08-24 09:55:56 -0700338 ":jpeg",
mtklein9b8583d2016-08-24 17:32:30 -0700339 ":none",
mtklein63213812016-08-24 09:55:56 -0700340 ":pdf",
341 ":png",
mtklein9b8583d2016-08-24 17:32:30 -0700342 ":sse2",
343 ":sse41",
344 ":sse42",
345 ":ssse3",
mtkleineb3c4252016-08-23 07:38:09 -0700346 ":webp",
mtklein63213812016-08-24 09:55:56 -0700347 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700348 ]
349
mtkleinc04ff472016-06-23 10:29:30 -0700350 sources = []
351 sources += core_gypi.sources
352 sources += effects_gypi.sources
353 sources += gpu_gypi.skgpu_sources
mtkleinc04ff472016-06-23 10:29:30 -0700354 sources += utils_gypi.sources
355 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700356 "src/android/SkBitmapRegionCodec.cpp",
357 "src/android/SkBitmapRegionDecoder.cpp",
358 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700359 "src/codec/SkBmpCodec.cpp",
360 "src/codec/SkBmpMaskCodec.cpp",
361 "src/codec/SkBmpRLECodec.cpp",
362 "src/codec/SkBmpStandardCodec.cpp",
363 "src/codec/SkCodec.cpp",
364 "src/codec/SkCodecImageGenerator.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700365 "src/codec/SkMaskSwizzler.cpp",
366 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700367 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700368 "src/codec/SkSampler.cpp",
369 "src/codec/SkSwizzler.cpp",
370 "src/codec/SkWbmpCodec.cpp",
mtklein09e61f72016-08-23 13:35:28 -0700371 "src/gpu/gl/GrGLDefaultInterface_native.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700372 "src/images/SkImageEncoder.cpp",
373 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700374 "src/images/SkKTXImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700375 "src/ports/SkDiscardableMemory_none.cpp",
376 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700377 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700378 "src/ports/SkMemory_malloc.cpp",
379 "src/ports/SkOSFile_stdio.cpp",
380 "src/sfnt/SkOTTable_name.cpp",
381 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700382 "src/svg/SkSVGCanvas.cpp",
383 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700384 "src/utils/mac/SkStream_mac.cpp",
385 "third_party/etc1/etc1.cpp",
386 "third_party/ktx/ktx.cpp",
387 ]
mtklein09e61f72016-08-23 13:35:28 -0700388 sources -= [
389 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
390 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
391 ]
mtkleinc04ff472016-06-23 10:29:30 -0700392
mtklein7d6fb2c2016-08-25 14:50:44 -0700393 libs = []
394
mtkleinc04ff472016-06-23 10:29:30 -0700395 if (is_win) {
396 sources += [
397 "src/ports/SkDebug_win.cpp",
398 "src/ports/SkFontHost_win.cpp",
399 "src/ports/SkFontMgr_win_dw.cpp",
400 "src/ports/SkFontMgr_win_dw_factory.cpp",
401 "src/ports/SkImageEncoder_WIC.cpp",
402 "src/ports/SkImageGeneratorWIC.cpp",
403 "src/ports/SkOSFile_win.cpp",
404 "src/ports/SkScalerContext_win_dw.cpp",
405 "src/ports/SkTLS_win.cpp",
406 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700407 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700408 ]
mtklein7a1f45f2016-08-04 06:19:33 -0700409 sources -= [ "src/utils/SkThreadUtils_pthread.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700410 } else {
411 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700412 "src/ports/SkOSFile_posix.cpp",
413 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700414 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700415 ]
416 }
417
mtklein7d6fb2c2016-08-25 14:50:44 -0700418 if (is_android) {
419 deps += [
420 "//third_party/cpu-features",
421 "//third_party/expat",
422 "//third_party/freetype2",
423 ]
424 sources += [
425 "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp",
426 "src/ports/SkDebug_android.cpp",
427 "src/ports/SkFontHost_FreeType.cpp",
428 "src/ports/SkFontHost_FreeType_common.cpp",
429 "src/ports/SkFontMgr_android.cpp",
430 "src/ports/SkFontMgr_android_factory.cpp",
431 "src/ports/SkFontMgr_android_parser.cpp",
432 ]
433 libs += [
434 "EGL",
435 "GLESv2",
436 "log",
437 ]
438 }
439
mtkleinc04ff472016-06-23 10:29:30 -0700440 if (is_linux) {
441 deps += [
442 "third_party:fontconfig",
mtklein7d6fb2c2016-08-25 14:50:44 -0700443 "//third_party/freetype2",
mtkleinc04ff472016-06-23 10:29:30 -0700444 ]
mtklein09e61f72016-08-23 13:35:28 -0700445 libs += [
446 "GL",
447 "GLU",
448 "X11",
449 ]
mtkleinc04ff472016-06-23 10:29:30 -0700450 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700451 "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700452 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700453 "src/ports/SkFontConfigInterface_direct.cpp",
454 "src/ports/SkFontConfigInterface_direct_factory.cpp",
455 "src/ports/SkFontHost_FreeType.cpp",
456 "src/ports/SkFontHost_FreeType_common.cpp",
bungeman7d0e3bc2016-08-02 07:07:33 -0700457 "src/ports/SkFontMgr_FontConfigInterface.cpp",
mtklein7a34b1c2016-08-01 13:08:46 -0700458 "src/ports/SkFontMgr_fontconfig.cpp",
459 "src/ports/SkFontMgr_fontconfig_factory.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700460 ]
461 }
462
463 if (is_mac) {
464 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700465 "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700466 "src/ports/SkDebug_stdio.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700467 "src/ports/SkFontHost_mac.cpp",
468 "src/ports/SkImageEncoder_CG.cpp",
469 "src/ports/SkImageGeneratorCG.cpp",
470 ]
mtklein09e61f72016-08-23 13:35:28 -0700471 libs += [
472 "ApplicationServices.framework",
473 "OpenGL.framework",
474 ]
mtkleinc04ff472016-06-23 10:29:30 -0700475 }
abarth6fc8ff02016-07-15 15:15:15 -0700476
477 if (is_fuchsia) {
mtklein2ff47c22016-08-24 10:27:13 -0700478 sources += [
479 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
mtklein7d6fb2c2016-08-25 14:50:44 -0700480 "src/ports/SkDebug_stdio.cpp",
mtklein2ff47c22016-08-24 10:27:13 -0700481 "src/ports/SkFontMgr_empty_factory.cpp",
482 ]
abarth6fc8ff02016-07-15 15:15:15 -0700483 }
mtkleinc04ff472016-06-23 10:29:30 -0700484}
485
mtkleinada5a442016-08-02 14:28:26 -0700486skia_h_headers = exec_script("gyp/find.py",
487 [ "*.h" ] + rebase_path(skia_public_includes),
488 "list lines",
489 []) -
490 [
491 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
492 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
493 rebase_path("include/gpu/vk/GrVkDefines.h"),
494 rebase_path("include/gpu/vk/GrVkInterface.h"),
495 rebase_path("include/gpu/vk/GrVkTypes.h"),
496 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
497 ]
498
mtklein1211e0c2016-07-26 13:55:45 -0700499action("skia.h") {
500 script = "gn/echo_headers.py"
501 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinc095df52016-08-24 12:23:52 -0700502 rebase_path(skia_h_headers, target_gen_dir)
mtklein1211e0c2016-07-26 13:55:45 -0700503 outputs = [
504 "$target_gen_dir/skia.h",
505 ]
506}
507
508executable("fiddle") {
509 include_dirs = [ "$target_gen_dir" ]
mtklein7d10b9f2016-07-27 11:17:18 -0700510 libs = []
511 if (is_linux) {
512 libs += [ "OSMesa" ]
513 }
mtklein1211e0c2016-07-26 13:55:45 -0700514
mtkleinc04ff472016-06-23 10:29:30 -0700515 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700516 "src/images/SkForceLinking.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700517 "tools/fiddle/draw.cpp",
518 "tools/fiddle/fiddle_main.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700519 ]
520 deps = [
521 ":skia",
mtklein1211e0c2016-07-26 13:55:45 -0700522 ":skia.h",
mtkleinc04ff472016-06-23 10:29:30 -0700523 ]
mtkleinc04ff472016-06-23 10:29:30 -0700524}
mtklein25c81d42016-07-27 13:55:26 -0700525
mtkleinc095df52016-08-24 12:23:52 -0700526# Targets guarded by skia_enable_tools may use //third_party freely.
527if (skia_enable_tools) {
528 template("test_lib") {
529 config(target_name + "_config") {
530 include_dirs = invoker.public_include_dirs
mtklein25c81d42016-07-27 13:55:26 -0700531 }
mtkleinc095df52016-08-24 12:23:52 -0700532 source_set(target_name) {
533 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
534 public_configs = [
535 ":" + target_name + "_config",
536 ":skia_private",
537 ]
538
539 if (!defined(deps)) {
540 deps = []
541 }
542 deps += [ ":skia" ]
543 testonly = true
544 }
mtklein25c81d42016-07-27 13:55:26 -0700545 }
mtklein25c81d42016-07-27 13:55:26 -0700546
mtkleinc095df52016-08-24 12:23:52 -0700547 test_lib("gpu_tool_utils") {
548 public_include_dirs = [ "tools/gpu" ]
549 sources = [
550 "tools/gpu/GrContextFactory.cpp",
551 "tools/gpu/GrTest.cpp",
552 "tools/gpu/TestContext.cpp",
553 "tools/gpu/gl/GLTestContext.cpp",
554 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
555 "tools/gpu/gl/debug/GrBufferObj.cpp",
556 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
557 "tools/gpu/gl/debug/GrProgramObj.cpp",
558 "tools/gpu/gl/debug/GrShaderObj.cpp",
559 "tools/gpu/gl/debug/GrTextureObj.cpp",
560 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
561 "tools/gpu/gl/null/NullGLTestContext.cpp",
562 ]
563 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700564
mtklein7d6fb2c2016-08-25 14:50:44 -0700565 if (is_android) {
566 sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
567 } else if (is_linux) {
mtkleinc095df52016-08-24 12:23:52 -0700568 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
569 } else if (is_mac) {
570 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
571 }
mtklein25c81d42016-07-27 13:55:26 -0700572 }
mtklein25c81d42016-07-27 13:55:26 -0700573
mtkleinc095df52016-08-24 12:23:52 -0700574 test_lib("flags") {
575 public_include_dirs = [ "tools/flags" ]
576 sources = [
577 "tools/flags/SkCommandLineFlags.cpp",
578 "tools/flags/SkCommonFlags.cpp",
579 "tools/flags/SkCommonFlagsConfig.cpp",
580 ]
581 deps = [
582 ":gpu_tool_utils",
583 ]
584 }
mtklein25c81d42016-07-27 13:55:26 -0700585
mtkleinc095df52016-08-24 12:23:52 -0700586 test_lib("tool_utils") {
587 public_include_dirs = [
588 "tools",
589 "tools/debugger",
590 "tools/timer",
591 ]
592 sources = [
593 "src/images/SkForceLinking.cpp",
594 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
595 "tools/CrashHandler.cpp",
596 "tools/ProcStats.cpp",
597 "tools/Resources.cpp",
598 "tools/ThermalManager.cpp",
599 "tools/UrlDataManager.cpp",
600 "tools/debugger/SkDebugCanvas.cpp",
601 "tools/debugger/SkDrawCommand.cpp",
602 "tools/debugger/SkJsonWriteBuffer.cpp",
603 "tools/debugger/SkObjectParser.cpp",
604 "tools/debugger/SkOverdrawMode.cpp",
605 "tools/picture_utils.cpp",
606 "tools/random_parse_path.cpp",
607 "tools/sk_tool_utils.cpp",
608 "tools/sk_tool_utils_font.cpp",
609 "tools/timer/Timer.cpp",
610 ]
611 deps = [
612 ":flags",
613 "//third_party/libpng",
614 ]
615 public_deps = [
616 "//third_party/jsoncpp",
617 ]
618 }
mtklein25c81d42016-07-27 13:55:26 -0700619
mtkleinc095df52016-08-24 12:23:52 -0700620 gm_sources = exec_script("gyp/find.py",
621 [
622 "*.c*",
623 rebase_path("gm"),
624 ],
625 "list lines",
626 [])
627 test_lib("gm") {
628 public_include_dirs = [ "gm" ]
629 sources = gm_sources
630 deps = [
631 ":gpu_tool_utils",
632 ":skia",
633 ":tool_utils",
634 ]
635 }
mtklein25c81d42016-07-27 13:55:26 -0700636
mtkleinc095df52016-08-24 12:23:52 -0700637 tests_sources = exec_script("gyp/find.py",
638 [
639 "*.c*",
640 rebase_path("tests"),
641 ],
642 "list lines",
643 [])
mtklein2f3416d2016-08-02 16:02:05 -0700644
mtkleinc095df52016-08-24 12:23:52 -0700645 test_lib("tests") {
646 public_include_dirs = [ "tests" ]
647 sources =
648 tests_sources - [
649 rebase_path("tests/FontMgrAndroidParserTest.cpp"), # Android only
650 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
651 rebase_path("tests/SkSLErrorTest.cpp"), # TODO: make work
652 rebase_path("tests/SkSLGLSLTest.cpp"), # TODO: make work
653 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
654 rebase_path("tests/skia_test.cpp"), # alternate main
655 ]
656 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700657 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700658 ":flags",
659 ":gpu_tool_utils",
660 ":skia",
661 ":tool_utils",
662 "//third_party/libpng",
663 "//third_party/zlib",
664 ]
665 }
mtklein2f3416d2016-08-02 16:02:05 -0700666
mtkleinc095df52016-08-24 12:23:52 -0700667 bench_sources = exec_script("gyp/find.py",
668 [
669 "*.c*",
670 rebase_path("bench"),
671 ],
672 "list lines",
673 [])
mtklein25c81d42016-07-27 13:55:26 -0700674
mtkleinc095df52016-08-24 12:23:52 -0700675 test_lib("bench") {
676 public_include_dirs = [ "bench" ]
677 sources = bench_sources
678 sources -= [
679 rebase_path("bench/nanobench.cpp"),
680 rebase_path("bench/nanobenchAndroid.cpp"),
681 ]
682 deps = [
683 ":flags",
684 ":gm",
685 ":gpu_tool_utils",
686 ":skia",
687 ":tool_utils",
688 ]
689 }
mtklein2b6870c2016-07-28 14:17:33 -0700690
mtkleinc095df52016-08-24 12:23:52 -0700691 test_lib("experimental_svg_model") {
692 public_include_dirs = [ "experimental/svg/model" ]
693 sources = [
694 "experimental/svg/model/SkSVGAttribute.cpp",
695 "experimental/svg/model/SkSVGAttributeParser.cpp",
696 "experimental/svg/model/SkSVGCircle.cpp",
697 "experimental/svg/model/SkSVGContainer.cpp",
698 "experimental/svg/model/SkSVGDOM.cpp",
699 "experimental/svg/model/SkSVGEllipse.cpp",
700 "experimental/svg/model/SkSVGLine.cpp",
701 "experimental/svg/model/SkSVGNode.cpp",
702 "experimental/svg/model/SkSVGPath.cpp",
703 "experimental/svg/model/SkSVGPoly.cpp",
704 "experimental/svg/model/SkSVGRect.cpp",
705 "experimental/svg/model/SkSVGRenderContext.cpp",
706 "experimental/svg/model/SkSVGSVG.cpp",
707 "experimental/svg/model/SkSVGShape.cpp",
708 "experimental/svg/model/SkSVGTransformableNode.cpp",
709 "experimental/svg/model/SkSVGValue.cpp",
710 ]
711 deps = [
712 ":skia",
713 ]
714 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700715
mtklein2b6870c2016-07-28 14:17:33 -0700716 executable("dm") {
717 sources = [
718 "dm/DM.cpp",
719 "dm/DMJsonWriter.cpp",
720 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700721 ]
722 include_dirs = [ "tests" ]
723 deps = [
fmalitaa2b9fdf2016-08-03 19:53:36 -0700724 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700725 ":flags",
726 ":gm",
727 ":gpu_tool_utils",
728 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700729 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700730 ":tool_utils",
731 "//third_party/jsoncpp",
732 "//third_party/libpng",
733 ]
734 testonly = true
735 }
736
737 executable("monobench") {
738 sources = [
739 "tools/monobench.cpp",
740 ]
741 deps = [
742 ":bench",
743 ":skia",
744 ]
745 testonly = true
746 }
747
748 executable("nanobench") {
749 sources = [
750 "bench/nanobench.cpp",
751 ]
752 deps = [
753 ":bench",
754 ":flags",
755 ":gm",
756 ":gpu_tool_utils",
757 ":skia",
758 ":tool_utils",
759 "//third_party/jsoncpp",
760 ]
761 testonly = true
762 }
halcanary19a97202016-08-03 15:08:04 -0700763
764 executable("sktexttopdf") {
765 sources = [
766 "tools/SkShaper_harfbuzz.cpp",
767 "tools/using_skia_and_harfbuzz.cpp",
768 ]
769 deps = [
770 ":skia",
771 "//third_party/harfbuzz",
772 ]
773 testonly = true
774 }
mtklein25c81d42016-07-27 13:55:26 -0700775}