blob: 90f531fdf10acc3e4ac518a658f0ff15fbf1ce15 [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
anmittalb8b3f712016-08-25 04:55:19 -0700164opts("armv7") {
165 enabled = current_cpu == "arm"
166 sources = opts_gypi.armv7_sources
167 cflags = []
168}
169
170opts("neon") {
171 enabled = current_cpu == "arm"
172 sources = opts_gypi.neon_sources
173 cflags = [ "-mfpu=neon" ]
174}
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("none") {
anmittalb8b3f712016-08-25 04:55:19 -0700189 enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
mtklein9b8583d2016-08-24 17:32:30 -0700190 sources = opts_gypi.none_sources
191 cflags = []
192}
mtkleinc04ff472016-06-23 10:29:30 -0700193
mtklein9b8583d2016-08-24 17:32:30 -0700194opts("sse2") {
195 enabled = is_x86
196 sources = opts_gypi.sse2_sources
197 cflags = [ "-msse2" ]
198}
mtkleinc04ff472016-06-23 10:29:30 -0700199
mtklein9b8583d2016-08-24 17:32:30 -0700200opts("ssse3") {
201 enabled = is_x86
202 sources = opts_gypi.ssse3_sources
203 cflags = [ "-mssse3" ]
204}
mtkleinc04ff472016-06-23 10:29:30 -0700205
mtklein9b8583d2016-08-24 17:32:30 -0700206opts("sse41") {
207 enabled = is_x86
208 sources = opts_gypi.sse41_sources
209 cflags = [ "-msse4.1" ]
210}
mtklein4e976072016-08-08 09:06:27 -0700211
mtklein9b8583d2016-08-24 17:32:30 -0700212opts("sse42") {
213 enabled = is_x86
214 sources = opts_gypi.sse42_sources
215 cflags = [ "-msse4.2" ]
216}
217
218opts("avx") {
219 enabled = is_x86
220 sources = opts_gypi.avx_sources
221 cflags = [ "-mavx" ]
mtkleinc04ff472016-06-23 10:29:30 -0700222}
223
mtkleinc095df52016-08-24 12:23:52 -0700224# Any feature of Skia that requires third-party code should be optional and use this template.
mtklein457b42a2016-08-23 13:56:37 -0700225template("optional") {
226 if (invoker.enabled) {
227 config(target_name + "_public") {
228 defines = invoker.public_defines
229 }
230 source_set(target_name) {
231 forward_variables_from(invoker, "*", [ "public_defines" ])
232 all_dependent_configs = [ ":" + target_name + "_public" ]
mtklein9b8583d2016-08-24 17:32:30 -0700233 configs += skia_library_configs
mtklein457b42a2016-08-23 13:56:37 -0700234 }
235 } else {
236 # If not enabled, a phony empty target that swallows all otherwise unused variables.
237 source_set(target_name) {
238 forward_variables_from(invoker,
239 "*",
240 [
241 "public_defines",
mtklein457b42a2016-08-23 13:56:37 -0700242 "deps",
243 "sources",
244 ])
245 }
mtkleineb3c4252016-08-23 07:38:09 -0700246 }
mtklein457b42a2016-08-23 13:56:37 -0700247}
mtklein457b42a2016-08-23 13:56:37 -0700248
249optional("gif") {
250 enabled = skia_use_giflib
251 public_defines = [ "SK_HAS_GIF_LIBRARY" ]
252
mtklein457b42a2016-08-23 13:56:37 -0700253 deps = [
254 "//third_party/giflib",
255 ]
256 sources = [
257 "src/codec/SkGifCodec.cpp",
258 ]
259}
260
mtklein63213812016-08-24 09:55:56 -0700261optional("jpeg") {
262 enabled = skia_use_libjpeg_turbo
263 public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
264
mtklein63213812016-08-24 09:55:56 -0700265 deps = [
266 "//third_party/libjpeg-turbo:libjpeg",
267 ]
268 sources = [
269 "src/codec/SkJpegCodec.cpp",
270 "src/codec/SkJpegDecoderMgr.cpp",
271 "src/codec/SkJpegUtility.cpp",
272 "src/images/SkJPEGImageEncoder.cpp",
273 "src/images/SkJPEGWriteUtility.cpp",
274 ]
275}
276
277optional("pdf") {
278 enabled = skia_use_zlib
279 public_defines = []
280
mtklein63213812016-08-24 09:55:56 -0700281 deps = [
282 "//third_party/zlib",
283 ]
284 sources = pdf_gypi.sources
285
286 if (skia_use_sfntly) {
287 deps += [ "//third_party/sfntly" ]
halcanary650e20d2016-08-25 09:07:02 -0700288 public_defines += [ "SK_PDF_USE_SFNTLY" ]
mtklein63213812016-08-24 09:55:56 -0700289 }
290}
291
292optional("png") {
293 enabled = skia_use_libpng
294 public_defines = [ "SK_HAS_PNG_LIBRARY" ]
295
mtklein63213812016-08-24 09:55:56 -0700296 deps = [
297 "//third_party/libpng",
298 ]
299 sources = [
300 "src/codec/SkIcoCodec.cpp",
301 "src/codec/SkPngCodec.cpp",
302 "src/images/SkPNGImageEncoder.cpp",
303 ]
304}
305
mtklein457b42a2016-08-23 13:56:37 -0700306optional("webp") {
307 enabled = skia_use_libwebp
308 public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
309
mtklein457b42a2016-08-23 13:56:37 -0700310 deps = [
311 "//third_party/libwebp",
312 ]
313 sources = [
314 "src/codec/SkWebpAdapterCodec.cpp",
315 "src/codec/SkWebpCodec.cpp",
316 "src/images/SkWEBPImageEncoder.cpp",
317 ]
mtkleineb3c4252016-08-23 07:38:09 -0700318}
319
mtklein63213812016-08-24 09:55:56 -0700320optional("xml") {
321 enabled = skia_use_expat
322 public_defines = []
323
mtklein63213812016-08-24 09:55:56 -0700324 deps = [
325 "//third_party/expat",
326 ]
327 sources = [
328 "src/xml/SkDOM.cpp",
329 "src/xml/SkXMLParser.cpp",
330 "src/xml/SkXMLWriter.cpp",
331 ]
332}
333
mtkleinc04ff472016-06-23 10:29:30 -0700334component("skia") {
335 public_configs = [ ":skia_public" ]
336 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700337
338 deps = [
anmittalb8b3f712016-08-25 04:55:19 -0700339 ":arm64",
340 ":armv7",
mtklein9b8583d2016-08-24 17:32:30 -0700341 ":avx",
anmittalb8b3f712016-08-25 04:55:19 -0700342 ":crc32",
mtklein457b42a2016-08-23 13:56:37 -0700343 ":gif",
mtklein63213812016-08-24 09:55:56 -0700344 ":jpeg",
anmittalb8b3f712016-08-25 04:55:19 -0700345 ":neon",
mtklein9b8583d2016-08-24 17:32:30 -0700346 ":none",
mtklein63213812016-08-24 09:55:56 -0700347 ":pdf",
348 ":png",
mtklein9b8583d2016-08-24 17:32:30 -0700349 ":sse2",
350 ":sse41",
351 ":sse42",
352 ":ssse3",
mtkleineb3c4252016-08-23 07:38:09 -0700353 ":webp",
mtklein63213812016-08-24 09:55:56 -0700354 ":xml",
mtkleinc04ff472016-06-23 10:29:30 -0700355 ]
356
mtklein7a1f45f2016-08-04 06:19:33 -0700357 if (!is_win) {
358 libs = [ "pthread" ]
359 }
mtkleinc04ff472016-06-23 10:29:30 -0700360
361 sources = []
362 sources += core_gypi.sources
363 sources += effects_gypi.sources
364 sources += gpu_gypi.skgpu_sources
mtkleinc04ff472016-06-23 10:29:30 -0700365 sources += utils_gypi.sources
366 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700367 "src/android/SkBitmapRegionCodec.cpp",
368 "src/android/SkBitmapRegionDecoder.cpp",
369 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700370 "src/codec/SkBmpCodec.cpp",
371 "src/codec/SkBmpMaskCodec.cpp",
372 "src/codec/SkBmpRLECodec.cpp",
373 "src/codec/SkBmpStandardCodec.cpp",
374 "src/codec/SkCodec.cpp",
375 "src/codec/SkCodecImageGenerator.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700376 "src/codec/SkMaskSwizzler.cpp",
377 "src/codec/SkMasks.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700378 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700379 "src/codec/SkSampler.cpp",
380 "src/codec/SkSwizzler.cpp",
381 "src/codec/SkWbmpCodec.cpp",
mtklein09e61f72016-08-23 13:35:28 -0700382 "src/gpu/gl/GrGLDefaultInterface_native.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700383 "src/images/SkImageEncoder.cpp",
384 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700385 "src/images/SkKTXImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700386 "src/ports/SkDiscardableMemory_none.cpp",
387 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700388 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700389 "src/ports/SkMemory_malloc.cpp",
390 "src/ports/SkOSFile_stdio.cpp",
391 "src/sfnt/SkOTTable_name.cpp",
392 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700393 "src/svg/SkSVGCanvas.cpp",
394 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700395 "src/utils/mac/SkStream_mac.cpp",
396 "third_party/etc1/etc1.cpp",
397 "third_party/ktx/ktx.cpp",
398 ]
mtklein09e61f72016-08-23 13:35:28 -0700399 sources -= [
400 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
401 "src/gpu/gl/GrGLDefaultInterface_none.cpp",
402 ]
mtkleinc04ff472016-06-23 10:29:30 -0700403
404 if (is_win) {
405 sources += [
406 "src/ports/SkDebug_win.cpp",
407 "src/ports/SkFontHost_win.cpp",
408 "src/ports/SkFontMgr_win_dw.cpp",
409 "src/ports/SkFontMgr_win_dw_factory.cpp",
410 "src/ports/SkImageEncoder_WIC.cpp",
411 "src/ports/SkImageGeneratorWIC.cpp",
412 "src/ports/SkOSFile_win.cpp",
413 "src/ports/SkScalerContext_win_dw.cpp",
414 "src/ports/SkTLS_win.cpp",
415 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700416 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700417 ]
mtklein7a1f45f2016-08-04 06:19:33 -0700418 sources -= [ "src/utils/SkThreadUtils_pthread.cpp" ]
mtkleinc04ff472016-06-23 10:29:30 -0700419 } else {
420 sources += [
421 "src/ports/SkDebug_stdio.cpp",
422 "src/ports/SkOSFile_posix.cpp",
423 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700424 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700425 ]
426 }
427
428 if (is_linux) {
429 deps += [
430 "third_party:fontconfig",
431 "third_party:freetype2",
mtkleinc04ff472016-06-23 10:29:30 -0700432 ]
mtklein09e61f72016-08-23 13:35:28 -0700433 libs += [
434 "GL",
435 "GLU",
436 "X11",
437 ]
mtkleinc04ff472016-06-23 10:29:30 -0700438 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700439 "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700440 "src/ports/SkFontConfigInterface_direct.cpp",
441 "src/ports/SkFontConfigInterface_direct_factory.cpp",
442 "src/ports/SkFontHost_FreeType.cpp",
443 "src/ports/SkFontHost_FreeType_common.cpp",
bungeman7d0e3bc2016-08-02 07:07:33 -0700444 "src/ports/SkFontMgr_FontConfigInterface.cpp",
mtklein7a34b1c2016-08-01 13:08:46 -0700445 "src/ports/SkFontMgr_fontconfig.cpp",
446 "src/ports/SkFontMgr_fontconfig_factory.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700447 ]
448 }
449
450 if (is_mac) {
451 sources += [
mtklein09e61f72016-08-23 13:35:28 -0700452 "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700453 "src/ports/SkFontHost_mac.cpp",
454 "src/ports/SkImageEncoder_CG.cpp",
455 "src/ports/SkImageGeneratorCG.cpp",
456 ]
mtklein09e61f72016-08-23 13:35:28 -0700457 libs += [
458 "ApplicationServices.framework",
459 "OpenGL.framework",
460 ]
mtkleinc04ff472016-06-23 10:29:30 -0700461 }
abarth6fc8ff02016-07-15 15:15:15 -0700462
463 if (is_fuchsia) {
mtklein2ff47c22016-08-24 10:27:13 -0700464 sources += [
465 "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
466 "src/ports/SkFontMgr_empty_factory.cpp",
467 ]
abarth6fc8ff02016-07-15 15:15:15 -0700468 }
mtkleinc04ff472016-06-23 10:29:30 -0700469}
470
mtkleinada5a442016-08-02 14:28:26 -0700471skia_h_headers = exec_script("gyp/find.py",
472 [ "*.h" ] + rebase_path(skia_public_includes),
473 "list lines",
474 []) -
475 [
476 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
477 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
478 rebase_path("include/gpu/vk/GrVkDefines.h"),
479 rebase_path("include/gpu/vk/GrVkInterface.h"),
480 rebase_path("include/gpu/vk/GrVkTypes.h"),
481 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
482 ]
483
mtklein1211e0c2016-07-26 13:55:45 -0700484action("skia.h") {
485 script = "gn/echo_headers.py"
486 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinc095df52016-08-24 12:23:52 -0700487 rebase_path(skia_h_headers, target_gen_dir)
mtklein1211e0c2016-07-26 13:55:45 -0700488 outputs = [
489 "$target_gen_dir/skia.h",
490 ]
491}
492
493executable("fiddle") {
494 include_dirs = [ "$target_gen_dir" ]
mtklein7d10b9f2016-07-27 11:17:18 -0700495 libs = []
496 if (is_linux) {
497 libs += [ "OSMesa" ]
498 }
mtklein1211e0c2016-07-26 13:55:45 -0700499
mtkleinc04ff472016-06-23 10:29:30 -0700500 sources = [
mtkleinc095df52016-08-24 12:23:52 -0700501 "src/images/SkForceLinking.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700502 "tools/fiddle/draw.cpp",
503 "tools/fiddle/fiddle_main.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700504 ]
505 deps = [
506 ":skia",
mtklein1211e0c2016-07-26 13:55:45 -0700507 ":skia.h",
mtkleinc04ff472016-06-23 10:29:30 -0700508 ]
mtkleinc04ff472016-06-23 10:29:30 -0700509}
mtklein25c81d42016-07-27 13:55:26 -0700510
mtkleinc095df52016-08-24 12:23:52 -0700511# Targets guarded by skia_enable_tools may use //third_party freely.
512if (skia_enable_tools) {
513 template("test_lib") {
514 config(target_name + "_config") {
515 include_dirs = invoker.public_include_dirs
mtklein25c81d42016-07-27 13:55:26 -0700516 }
mtkleinc095df52016-08-24 12:23:52 -0700517 source_set(target_name) {
518 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
519 public_configs = [
520 ":" + target_name + "_config",
521 ":skia_private",
522 ]
523
524 if (!defined(deps)) {
525 deps = []
526 }
527 deps += [ ":skia" ]
528 testonly = true
529 }
mtklein25c81d42016-07-27 13:55:26 -0700530 }
mtklein25c81d42016-07-27 13:55:26 -0700531
mtkleinc095df52016-08-24 12:23:52 -0700532 test_lib("gpu_tool_utils") {
533 public_include_dirs = [ "tools/gpu" ]
534 sources = [
535 "tools/gpu/GrContextFactory.cpp",
536 "tools/gpu/GrTest.cpp",
537 "tools/gpu/TestContext.cpp",
538 "tools/gpu/gl/GLTestContext.cpp",
539 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
540 "tools/gpu/gl/debug/GrBufferObj.cpp",
541 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
542 "tools/gpu/gl/debug/GrProgramObj.cpp",
543 "tools/gpu/gl/debug/GrShaderObj.cpp",
544 "tools/gpu/gl/debug/GrTextureObj.cpp",
545 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
546 "tools/gpu/gl/null/NullGLTestContext.cpp",
547 ]
548 libs = []
mtklein25c81d42016-07-27 13:55:26 -0700549
mtkleinc095df52016-08-24 12:23:52 -0700550 if (is_linux) {
551 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
552 } else if (is_mac) {
553 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
554 }
mtklein25c81d42016-07-27 13:55:26 -0700555 }
mtklein25c81d42016-07-27 13:55:26 -0700556
mtkleinc095df52016-08-24 12:23:52 -0700557 test_lib("flags") {
558 public_include_dirs = [ "tools/flags" ]
559 sources = [
560 "tools/flags/SkCommandLineFlags.cpp",
561 "tools/flags/SkCommonFlags.cpp",
562 "tools/flags/SkCommonFlagsConfig.cpp",
563 ]
564 deps = [
565 ":gpu_tool_utils",
566 ]
567 }
mtklein25c81d42016-07-27 13:55:26 -0700568
mtkleinc095df52016-08-24 12:23:52 -0700569 test_lib("tool_utils") {
570 public_include_dirs = [
571 "tools",
572 "tools/debugger",
573 "tools/timer",
574 ]
575 sources = [
576 "src/images/SkForceLinking.cpp",
577 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
578 "tools/CrashHandler.cpp",
579 "tools/ProcStats.cpp",
580 "tools/Resources.cpp",
581 "tools/ThermalManager.cpp",
582 "tools/UrlDataManager.cpp",
583 "tools/debugger/SkDebugCanvas.cpp",
584 "tools/debugger/SkDrawCommand.cpp",
585 "tools/debugger/SkJsonWriteBuffer.cpp",
586 "tools/debugger/SkObjectParser.cpp",
587 "tools/debugger/SkOverdrawMode.cpp",
588 "tools/picture_utils.cpp",
589 "tools/random_parse_path.cpp",
590 "tools/sk_tool_utils.cpp",
591 "tools/sk_tool_utils_font.cpp",
592 "tools/timer/Timer.cpp",
593 ]
594 deps = [
595 ":flags",
596 "//third_party/libpng",
597 ]
598 public_deps = [
599 "//third_party/jsoncpp",
600 ]
601 }
mtklein25c81d42016-07-27 13:55:26 -0700602
mtkleinc095df52016-08-24 12:23:52 -0700603 gm_sources = exec_script("gyp/find.py",
604 [
605 "*.c*",
606 rebase_path("gm"),
607 ],
608 "list lines",
609 [])
610 test_lib("gm") {
611 public_include_dirs = [ "gm" ]
612 sources = gm_sources
613 deps = [
614 ":gpu_tool_utils",
615 ":skia",
616 ":tool_utils",
617 ]
618 }
mtklein25c81d42016-07-27 13:55:26 -0700619
mtkleinc095df52016-08-24 12:23:52 -0700620 tests_sources = exec_script("gyp/find.py",
621 [
622 "*.c*",
623 rebase_path("tests"),
624 ],
625 "list lines",
626 [])
mtklein2f3416d2016-08-02 16:02:05 -0700627
mtkleinc095df52016-08-24 12:23:52 -0700628 test_lib("tests") {
629 public_include_dirs = [ "tests" ]
630 sources =
631 tests_sources - [
632 rebase_path("tests/FontMgrAndroidParserTest.cpp"), # Android only
633 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
634 rebase_path("tests/SkSLErrorTest.cpp"), # TODO: make work
635 rebase_path("tests/SkSLGLSLTest.cpp"), # TODO: make work
636 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
637 rebase_path("tests/skia_test.cpp"), # alternate main
638 ]
639 deps = [
fmalita6cf896d2016-08-25 08:44:35 -0700640 ":experimental_svg_model",
mtkleinc095df52016-08-24 12:23:52 -0700641 ":flags",
642 ":gpu_tool_utils",
643 ":skia",
644 ":tool_utils",
645 "//third_party/libpng",
646 "//third_party/zlib",
647 ]
648 }
mtklein2f3416d2016-08-02 16:02:05 -0700649
mtkleinc095df52016-08-24 12:23:52 -0700650 bench_sources = exec_script("gyp/find.py",
651 [
652 "*.c*",
653 rebase_path("bench"),
654 ],
655 "list lines",
656 [])
mtklein25c81d42016-07-27 13:55:26 -0700657
mtkleinc095df52016-08-24 12:23:52 -0700658 test_lib("bench") {
659 public_include_dirs = [ "bench" ]
660 sources = bench_sources
661 sources -= [
662 rebase_path("bench/nanobench.cpp"),
663 rebase_path("bench/nanobenchAndroid.cpp"),
664 ]
665 deps = [
666 ":flags",
667 ":gm",
668 ":gpu_tool_utils",
669 ":skia",
670 ":tool_utils",
671 ]
672 }
mtklein2b6870c2016-07-28 14:17:33 -0700673
mtkleinc095df52016-08-24 12:23:52 -0700674 test_lib("experimental_svg_model") {
675 public_include_dirs = [ "experimental/svg/model" ]
676 sources = [
677 "experimental/svg/model/SkSVGAttribute.cpp",
678 "experimental/svg/model/SkSVGAttributeParser.cpp",
679 "experimental/svg/model/SkSVGCircle.cpp",
680 "experimental/svg/model/SkSVGContainer.cpp",
681 "experimental/svg/model/SkSVGDOM.cpp",
682 "experimental/svg/model/SkSVGEllipse.cpp",
683 "experimental/svg/model/SkSVGLine.cpp",
684 "experimental/svg/model/SkSVGNode.cpp",
685 "experimental/svg/model/SkSVGPath.cpp",
686 "experimental/svg/model/SkSVGPoly.cpp",
687 "experimental/svg/model/SkSVGRect.cpp",
688 "experimental/svg/model/SkSVGRenderContext.cpp",
689 "experimental/svg/model/SkSVGSVG.cpp",
690 "experimental/svg/model/SkSVGShape.cpp",
691 "experimental/svg/model/SkSVGTransformableNode.cpp",
692 "experimental/svg/model/SkSVGValue.cpp",
693 ]
694 deps = [
695 ":skia",
696 ]
697 }
fmalitaa2b9fdf2016-08-03 19:53:36 -0700698
mtklein2b6870c2016-07-28 14:17:33 -0700699 executable("dm") {
700 sources = [
701 "dm/DM.cpp",
702 "dm/DMJsonWriter.cpp",
703 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700704 ]
705 include_dirs = [ "tests" ]
706 deps = [
fmalitaa2b9fdf2016-08-03 19:53:36 -0700707 ":experimental_svg_model",
mtklein2b6870c2016-07-28 14:17:33 -0700708 ":flags",
709 ":gm",
710 ":gpu_tool_utils",
711 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700712 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700713 ":tool_utils",
714 "//third_party/jsoncpp",
715 "//third_party/libpng",
716 ]
717 testonly = true
718 }
719
720 executable("monobench") {
721 sources = [
722 "tools/monobench.cpp",
723 ]
724 deps = [
725 ":bench",
726 ":skia",
727 ]
728 testonly = true
729 }
730
731 executable("nanobench") {
732 sources = [
733 "bench/nanobench.cpp",
734 ]
735 deps = [
736 ":bench",
737 ":flags",
738 ":gm",
739 ":gpu_tool_utils",
740 ":skia",
741 ":tool_utils",
742 "//third_party/jsoncpp",
743 ]
744 testonly = true
745 }
halcanary19a97202016-08-03 15:08:04 -0700746
747 executable("sktexttopdf") {
748 sources = [
749 "tools/SkShaper_harfbuzz.cpp",
750 "tools/using_skia_and_harfbuzz.cpp",
751 ]
752 deps = [
753 ":skia",
754 "//third_party/harfbuzz",
755 ]
756 testonly = true
757 }
mtklein25c81d42016-07-27 13:55:26 -0700758}