blob: 6a655c896a8afa2ddf2d61b08c8b8327e4ba1104 [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() {
7}
8
mtklein1211e0c2016-07-26 13:55:45 -07009skia_public_includes = [
mtklein25c81d42016-07-27 13:55:26 -070010 "include/android",
mtkleinfa84d942016-07-28 09:45:14 -070011 "include/c",
mtklein1211e0c2016-07-26 13:55:45 -070012 "include/codec",
13 "include/config",
14 "include/core",
15 "include/effects",
16 "include/gpu",
17 "include/gpu/gl",
18 "include/images",
19 "include/pathops",
20 "include/ports",
mtklein25c81d42016-07-27 13:55:26 -070021 "include/svg",
mtklein1211e0c2016-07-26 13:55:45 -070022 "include/utils",
23 "include/utils/mac",
mtklein25c81d42016-07-27 13:55:26 -070024 "include/xml",
mtklein1211e0c2016-07-26 13:55:45 -070025]
26
mtkleinc04ff472016-06-23 10:29:30 -070027# Skia public API, generally provided by :skia.
28config("skia_public") {
mtklein1211e0c2016-07-26 13:55:45 -070029 include_dirs = skia_public_includes
mtkleinc04ff472016-06-23 10:29:30 -070030 defines = [ "SKIA_DLL" ]
31}
32
33# Skia internal APIs, used by Skia itself and a few test tools.
34config("skia_private") {
35 visibility = [ ":*" ]
36
37 include_dirs = [
38 "include/private",
39 "src/c",
mtklein1211e0c2016-07-26 13:55:45 -070040 "src/codec",
mtkleinc04ff472016-06-23 10:29:30 -070041 "src/config",
42 "src/core",
43 "src/effects",
mtklein25c81d42016-07-27 13:55:26 -070044 "src/effects/gradients",
45 "src/fonts",
mtkleinc04ff472016-06-23 10:29:30 -070046 "src/gpu",
47 "src/image",
48 "src/images",
49 "src/lazy",
50 "src/opts",
51 "src/pathops",
mtklein2b6870c2016-07-28 14:17:33 -070052 "src/pdf",
mtkleinc04ff472016-06-23 10:29:30 -070053 "src/ports",
54 "src/sfnt",
55 "src/utils",
56 "third_party/etc1",
57 "third_party/ktx",
58 ]
mtklein150d1132016-08-01 06:56:40 -070059
60 defines = [
mtklein9be68662016-08-01 08:37:48 -070061 "SK_GAMMA_SRGB",
62 "SK_GAMMA_APPLY_TO_A8",
63
mtklein150d1132016-08-01 06:56:40 -070064 "SK_HAS_GIF_LIBRARY",
65 "SK_HAS_JPEG_LIBRARY",
66 "SK_HAS_PNG_LIBRARY",
67 "SK_HAS_WEBP_LIBRARY",
mtklein7c1ae7a2016-08-01 15:50:27 -070068
69 "TURBO_HAS_565",
70 "TURBO_HAS_CROP",
71 "TURBO_HAS_SKIP",
mtklein150d1132016-08-01 06:56:40 -070072 ]
mtkleinc04ff472016-06-23 10:29:30 -070073}
74
75# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
76config("skia_library") {
77 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -070078 defines = [ "SKIA_IMPLEMENTATION=1" ]
79}
80
81skia_library_configs = [
82 ":skia_public",
83 ":skia_private",
84 ":skia_library",
85]
86
mtklein7fbfbbe2016-07-21 12:25:45 -070087core_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -070088 [
89 rebase_path("gyp/core.gypi"),
90 "--replace=<(skia_include_path)=include",
91 "--replace=<(skia_src_path)=src",
92 ],
93 "scope",
94 [ "gyp/core.gypi" ])
95
mtklein7fbfbbe2016-07-21 12:25:45 -070096effects_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -070097 [
98 rebase_path("gyp/effects.gypi"),
99 "--replace=<(skia_include_path)=include",
100 "--replace=<(skia_src_path)=src",
101 ],
102 "scope",
103 [ "gyp/effects.gypi" ])
104
mtklein7fbfbbe2016-07-21 12:25:45 -0700105gpu_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700106 [
107 rebase_path("gyp/gpu.gypi"),
108 "--replace=<(skia_include_path)=include",
109 "--replace=<(skia_src_path)=src",
110 ],
111 "scope",
112 [ "gyp/gpu.gypi" ])
113
mtklein7fbfbbe2016-07-21 12:25:45 -0700114opts_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700115 [
116 rebase_path("gyp/opts.gypi"),
117 "--replace=<(skia_include_path)=include",
118 "--replace=<(skia_src_path)=src",
119 ],
120 "scope",
121 [ "gyp/opts.gypi" ])
122
mtklein7fbfbbe2016-07-21 12:25:45 -0700123pdf_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700124 [
125 rebase_path("gyp/pdf.gypi"),
126 "--replace=<(skia_include_path)=include",
127 "--replace=<(skia_src_path)=src",
128 ],
129 "scope",
130 [ "gyp/pdf.gypi" ])
131
mtklein7fbfbbe2016-07-21 12:25:45 -0700132utils_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700133 [
134 rebase_path("gyp/utils.gypi"),
135 "--replace=<(skia_include_path)=include",
136 "--replace=<(skia_src_path)=src",
137 ],
138 "scope",
139 [ "gyp/utils.gypi" ])
140
141source_set("opts_ssse3") {
142 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700143
144 sources = opts_gypi.ssse3_sources
145 cflags = [ "-mssse3" ]
146}
147
148source_set("opts_sse41") {
149 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700150
151 sources = opts_gypi.sse41_sources
152 cflags = [ "-msse4.1" ]
153}
154
155source_set("opts_avx") {
156 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700157
158 sources = opts_gypi.avx_sources
159 cflags = [ "-mavx" ]
160}
161
162component("skia") {
163 public_configs = [ ":skia_public" ]
164 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700165
166 deps = [
167 ":opts_avx",
168 ":opts_sse41",
169 ":opts_ssse3",
mtklein25c81d42016-07-27 13:55:26 -0700170 "//third_party/expat",
171 "//third_party/giflib",
mtklein7d10b9f2016-07-27 11:17:18 -0700172 "//third_party/libjpeg_turbo",
173 "//third_party/libpng",
mtklein25c81d42016-07-27 13:55:26 -0700174 "//third_party/libwebp",
abarth6fc8ff02016-07-15 15:15:15 -0700175 "//third_party/zlib",
mtkleinc04ff472016-06-23 10:29:30 -0700176 ]
177
mtklein7fbfbbe2016-07-21 12:25:45 -0700178 libs = [ "pthread" ]
mtkleinc04ff472016-06-23 10:29:30 -0700179
180 sources = []
181 sources += core_gypi.sources
182 sources += effects_gypi.sources
183 sources += gpu_gypi.skgpu_sources
184 sources += opts_gypi.sse2_sources
185 sources += pdf_gypi.sources
186 sources += utils_gypi.sources
187 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700188 "src/android/SkBitmapRegionCodec.cpp",
189 "src/android/SkBitmapRegionDecoder.cpp",
190 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700191 "src/codec/SkBmpCodec.cpp",
192 "src/codec/SkBmpMaskCodec.cpp",
193 "src/codec/SkBmpRLECodec.cpp",
194 "src/codec/SkBmpStandardCodec.cpp",
195 "src/codec/SkCodec.cpp",
196 "src/codec/SkCodecImageGenerator.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700197 "src/codec/SkGifCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700198 "src/codec/SkIcoCodec.cpp",
199 "src/codec/SkJpegCodec.cpp",
200 "src/codec/SkJpegDecoderMgr.cpp",
201 "src/codec/SkJpegUtility.cpp",
202 "src/codec/SkMaskSwizzler.cpp",
203 "src/codec/SkMasks.cpp",
204 "src/codec/SkPngCodec.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700205 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700206 "src/codec/SkSampler.cpp",
207 "src/codec/SkSwizzler.cpp",
208 "src/codec/SkWbmpCodec.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700209 "src/codec/SkWebpAdapterCodec.cpp",
210 "src/codec/SkWebpCodec.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700211 "src/images/SkImageEncoder.cpp",
212 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700213 "src/images/SkJPEGImageEncoder.cpp",
214 "src/images/SkJPEGWriteUtility.cpp",
215 "src/images/SkKTXImageEncoder.cpp",
216 "src/images/SkPNGImageEncoder.cpp",
217 "src/images/SkWEBPImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700218 "src/ports/SkDiscardableMemory_none.cpp",
219 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700220 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700221 "src/ports/SkMemory_malloc.cpp",
222 "src/ports/SkOSFile_stdio.cpp",
223 "src/sfnt/SkOTTable_name.cpp",
224 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700225 "src/svg/SkSVGCanvas.cpp",
226 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700227 "src/utils/mac/SkStream_mac.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700228 "src/xml/SkDOM.cpp",
229 "src/xml/SkXMLParser.cpp",
230 "src/xml/SkXMLWriter.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700231 "third_party/etc1/etc1.cpp",
232 "third_party/ktx/ktx.cpp",
233 ]
234
235 if (is_win) {
236 sources += [
237 "src/ports/SkDebug_win.cpp",
238 "src/ports/SkFontHost_win.cpp",
239 "src/ports/SkFontMgr_win_dw.cpp",
240 "src/ports/SkFontMgr_win_dw_factory.cpp",
241 "src/ports/SkImageEncoder_WIC.cpp",
242 "src/ports/SkImageGeneratorWIC.cpp",
243 "src/ports/SkOSFile_win.cpp",
244 "src/ports/SkScalerContext_win_dw.cpp",
245 "src/ports/SkTLS_win.cpp",
246 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700247 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700248 ]
249 } else {
250 sources += [
251 "src/ports/SkDebug_stdio.cpp",
252 "src/ports/SkOSFile_posix.cpp",
253 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700254 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700255 ]
256 }
257
258 if (is_linux) {
259 deps += [
260 "third_party:fontconfig",
261 "third_party:freetype2",
mtkleinc04ff472016-06-23 10:29:30 -0700262 ]
263 sources += [
mtkleinc04ff472016-06-23 10:29:30 -0700264 "src/ports/SkFontConfigInterface_direct.cpp",
265 "src/ports/SkFontConfigInterface_direct_factory.cpp",
266 "src/ports/SkFontHost_FreeType.cpp",
267 "src/ports/SkFontHost_FreeType_common.cpp",
mtklein7a34b1c2016-08-01 13:08:46 -0700268 "src/ports/SkFontMgr_fontconfig.cpp",
269 "src/ports/SkFontMgr_fontconfig_factory.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700270 ]
271 }
272
273 if (is_mac) {
274 sources += [
275 "src/ports/SkFontHost_mac.cpp",
276 "src/ports/SkImageEncoder_CG.cpp",
277 "src/ports/SkImageGeneratorCG.cpp",
278 ]
279 libs += [ "ApplicationServices.framework" ]
280 }
abarth6fc8ff02016-07-15 15:15:15 -0700281
282 if (is_fuchsia) {
mtkleine817ddf2016-07-19 06:03:22 -0700283 sources += [ "src/ports/SkFontMgr_empty_factory.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700284 }
mtkleinc04ff472016-06-23 10:29:30 -0700285}
286
mtklein1211e0c2016-07-26 13:55:45 -0700287action("skia.h") {
288 script = "gn/echo_headers.py"
289 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
290 rebase_path(skia_public_includes, root_build_dir)
291 outputs = [
292 "$target_gen_dir/skia.h",
293 ]
294}
295
296executable("fiddle") {
297 include_dirs = [ "$target_gen_dir" ]
mtklein7d10b9f2016-07-27 11:17:18 -0700298 libs = []
299 if (is_linux) {
300 libs += [ "OSMesa" ]
301 }
mtklein1211e0c2016-07-26 13:55:45 -0700302
mtkleinc04ff472016-06-23 10:29:30 -0700303 sources = [
mtklein1211e0c2016-07-26 13:55:45 -0700304 "tools/fiddle/draw.cpp",
305 "tools/fiddle/fiddle_main.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700306 ]
307 deps = [
308 ":skia",
mtklein1211e0c2016-07-26 13:55:45 -0700309 ":skia.h",
mtkleinc04ff472016-06-23 10:29:30 -0700310 ]
mtkleinc04ff472016-06-23 10:29:30 -0700311}
mtklein25c81d42016-07-27 13:55:26 -0700312
313template("test_lib") {
314 config(target_name + "_config") {
315 include_dirs = invoker.public_include_dirs
316 }
317 source_set(target_name) {
318 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
319 public_configs = [
320 ":" + target_name + "_config",
321 ":skia_private",
322 ]
323
324 if (!defined(deps)) {
325 deps = []
326 }
327 deps += [ ":skia" ]
328 testonly = true
329 }
330}
331
332test_lib("gpu_tool_utils") {
333 public_include_dirs = [ "tools/gpu" ]
334 sources = [
335 "tools/gpu/GrContextFactory.cpp",
336 "tools/gpu/GrTest.cpp",
337 "tools/gpu/TestContext.cpp",
338 "tools/gpu/gl/GLTestContext.cpp",
339 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
340 "tools/gpu/gl/debug/GrBufferObj.cpp",
341 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
342 "tools/gpu/gl/debug/GrProgramObj.cpp",
343 "tools/gpu/gl/debug/GrShaderObj.cpp",
344 "tools/gpu/gl/debug/GrTextureObj.cpp",
345 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
346 "tools/gpu/gl/null/NullGLTestContext.cpp",
347 ]
348 libs = []
349
350 if (is_linux) {
351 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
352 libs += [
353 "GL",
354 "GLU",
355 "X11",
356 ]
357 } else if (is_mac) {
358 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
359 libs += [ "OpenGL.framework" ]
360 }
361}
362
363test_lib("flags") {
364 public_include_dirs = [ "tools/flags" ]
365 sources = [
366 "tools/flags/SkCommandLineFlags.cpp",
367 "tools/flags/SkCommonFlags.cpp",
368 "tools/flags/SkCommonFlagsConfig.cpp",
369 ]
370 deps = [
371 ":gpu_tool_utils",
372 ]
373}
374
375test_lib("tool_utils") {
376 public_include_dirs = [
377 "tools",
378 "tools/timer",
379 ]
380 sources = [
mtklein2b6870c2016-07-28 14:17:33 -0700381 "src/images/SkForceLinking.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700382 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtklein2b6870c2016-07-28 14:17:33 -0700383 "tools/CrashHandler.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700384 "tools/ProcStats.cpp",
385 "tools/Resources.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700386 "tools/ThermalManager.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700387 "tools/picture_utils.cpp",
388 "tools/random_parse_path.cpp",
389 "tools/sk_tool_utils.cpp",
390 "tools/sk_tool_utils_font.cpp",
391 "tools/timer/Timer.cpp",
392 ]
393 deps = [
394 ":flags",
395 ]
396}
397
398gm_sources = exec_script("gyp/find.py",
399 [
400 rebase_path("gm"),
401 "*.c*",
402 ],
403 "list lines",
404 [])
405test_lib("gm") {
406 public_include_dirs = [ "gm" ]
407 sources = gm_sources
408 deps = [
409 ":gpu_tool_utils",
410 ":skia",
411 ":tool_utils",
412 ]
413}
414
mtklein2b6870c2016-07-28 14:17:33 -0700415bench_sources = exec_script("gyp/find.py",
416 [
417 rebase_path("bench"),
418 "*.c*",
419 ],
420 "list lines",
421 [])
mtklein25c81d42016-07-27 13:55:26 -0700422
mtklein2b6870c2016-07-28 14:17:33 -0700423test_lib("bench") {
424 public_include_dirs = [ "bench" ]
425 sources = bench_sources
426 sources -= [
427 rebase_path("bench/nanobench.cpp"),
428 rebase_path("bench/nanobenchAndroid.cpp"),
429 ]
430 deps = [
431 ":flags",
432 ":gm",
433 ":gpu_tool_utils",
434 ":skia",
435 ":tool_utils",
436 ]
437}
438
439if (!is_component_build) { # Our test tools use many non-SK_API APIs...
440 executable("dm") {
441 sources = [
442 "dm/DM.cpp",
443 "dm/DMJsonWriter.cpp",
444 "dm/DMSrcSink.cpp",
445
446 # TODO: tests for real
447 "tests/Test.cpp",
448 ]
449 include_dirs = [ "tests" ]
450 deps = [
451 ":flags",
452 ":gm",
453 ":gpu_tool_utils",
454 ":skia",
455 ":tool_utils",
456 "//third_party/jsoncpp",
457 "//third_party/libpng",
458 ]
459 testonly = true
460 }
461
462 executable("monobench") {
463 sources = [
464 "tools/monobench.cpp",
465 ]
466 deps = [
467 ":bench",
468 ":skia",
469 ]
470 testonly = true
471 }
472
473 executable("nanobench") {
474 sources = [
475 "bench/nanobench.cpp",
476 ]
477 deps = [
478 ":bench",
479 ":flags",
480 ":gm",
481 ":gpu_tool_utils",
482 ":skia",
483 ":tool_utils",
484 "//third_party/jsoncpp",
485 ]
486 testonly = true
487 }
mtklein25c81d42016-07-27 13:55:26 -0700488}