blob: d6e25626b3a4dfa131757be16a095ad7b2ccda6e [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 ]
59}
60
61# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
62config("skia_library") {
63 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -070064 defines = [ "SKIA_IMPLEMENTATION=1" ]
65}
66
67skia_library_configs = [
68 ":skia_public",
69 ":skia_private",
70 ":skia_library",
71]
72
mtklein7fbfbbe2016-07-21 12:25:45 -070073core_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -070074 [
75 rebase_path("gyp/core.gypi"),
76 "--replace=<(skia_include_path)=include",
77 "--replace=<(skia_src_path)=src",
78 ],
79 "scope",
80 [ "gyp/core.gypi" ])
81
mtklein7fbfbbe2016-07-21 12:25:45 -070082effects_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -070083 [
84 rebase_path("gyp/effects.gypi"),
85 "--replace=<(skia_include_path)=include",
86 "--replace=<(skia_src_path)=src",
87 ],
88 "scope",
89 [ "gyp/effects.gypi" ])
90
mtklein7fbfbbe2016-07-21 12:25:45 -070091gpu_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -070092 [
93 rebase_path("gyp/gpu.gypi"),
94 "--replace=<(skia_include_path)=include",
95 "--replace=<(skia_src_path)=src",
96 ],
97 "scope",
98 [ "gyp/gpu.gypi" ])
99
mtklein7fbfbbe2016-07-21 12:25:45 -0700100opts_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700101 [
102 rebase_path("gyp/opts.gypi"),
103 "--replace=<(skia_include_path)=include",
104 "--replace=<(skia_src_path)=src",
105 ],
106 "scope",
107 [ "gyp/opts.gypi" ])
108
mtklein7fbfbbe2016-07-21 12:25:45 -0700109pdf_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700110 [
111 rebase_path("gyp/pdf.gypi"),
112 "--replace=<(skia_include_path)=include",
113 "--replace=<(skia_src_path)=src",
114 ],
115 "scope",
116 [ "gyp/pdf.gypi" ])
117
mtklein7fbfbbe2016-07-21 12:25:45 -0700118utils_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700119 [
120 rebase_path("gyp/utils.gypi"),
121 "--replace=<(skia_include_path)=include",
122 "--replace=<(skia_src_path)=src",
123 ],
124 "scope",
125 [ "gyp/utils.gypi" ])
126
127source_set("opts_ssse3") {
128 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700129
130 sources = opts_gypi.ssse3_sources
131 cflags = [ "-mssse3" ]
132}
133
134source_set("opts_sse41") {
135 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700136
137 sources = opts_gypi.sse41_sources
138 cflags = [ "-msse4.1" ]
139}
140
141source_set("opts_avx") {
142 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700143
144 sources = opts_gypi.avx_sources
145 cflags = [ "-mavx" ]
146}
147
148component("skia") {
149 public_configs = [ ":skia_public" ]
150 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700151
152 deps = [
153 ":opts_avx",
154 ":opts_sse41",
155 ":opts_ssse3",
mtklein25c81d42016-07-27 13:55:26 -0700156 "//third_party/expat",
157 "//third_party/giflib",
mtklein7d10b9f2016-07-27 11:17:18 -0700158 "//third_party/libjpeg_turbo",
159 "//third_party/libpng",
mtklein25c81d42016-07-27 13:55:26 -0700160 "//third_party/libwebp",
abarth6fc8ff02016-07-15 15:15:15 -0700161 "//third_party/zlib",
mtkleinc04ff472016-06-23 10:29:30 -0700162 ]
163
mtklein1211e0c2016-07-26 13:55:45 -0700164 defines = [
mtklein25c81d42016-07-27 13:55:26 -0700165 "SK_HAS_GIF_LIBRARY",
mtklein1211e0c2016-07-26 13:55:45 -0700166 "SK_HAS_JPEG_LIBRARY",
167 "SK_HAS_PNG_LIBRARY",
mtklein25c81d42016-07-27 13:55:26 -0700168 "SK_HAS_WEBP_LIBRARY",
mtklein1211e0c2016-07-26 13:55:45 -0700169 ]
170
mtklein7fbfbbe2016-07-21 12:25:45 -0700171 libs = [ "pthread" ]
mtkleinc04ff472016-06-23 10:29:30 -0700172
173 sources = []
174 sources += core_gypi.sources
175 sources += effects_gypi.sources
176 sources += gpu_gypi.skgpu_sources
177 sources += opts_gypi.sse2_sources
178 sources += pdf_gypi.sources
179 sources += utils_gypi.sources
180 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700181 "src/android/SkBitmapRegionCodec.cpp",
182 "src/android/SkBitmapRegionDecoder.cpp",
183 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700184 "src/codec/SkBmpCodec.cpp",
185 "src/codec/SkBmpMaskCodec.cpp",
186 "src/codec/SkBmpRLECodec.cpp",
187 "src/codec/SkBmpStandardCodec.cpp",
188 "src/codec/SkCodec.cpp",
189 "src/codec/SkCodecImageGenerator.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700190 "src/codec/SkGifCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700191 "src/codec/SkIcoCodec.cpp",
192 "src/codec/SkJpegCodec.cpp",
193 "src/codec/SkJpegDecoderMgr.cpp",
194 "src/codec/SkJpegUtility.cpp",
195 "src/codec/SkMaskSwizzler.cpp",
196 "src/codec/SkMasks.cpp",
197 "src/codec/SkPngCodec.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700198 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700199 "src/codec/SkSampler.cpp",
200 "src/codec/SkSwizzler.cpp",
201 "src/codec/SkWbmpCodec.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700202 "src/codec/SkWebpAdapterCodec.cpp",
203 "src/codec/SkWebpCodec.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700204 "src/images/SkImageEncoder.cpp",
205 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700206 "src/images/SkJPEGImageEncoder.cpp",
207 "src/images/SkJPEGWriteUtility.cpp",
208 "src/images/SkKTXImageEncoder.cpp",
209 "src/images/SkPNGImageEncoder.cpp",
210 "src/images/SkWEBPImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700211 "src/ports/SkDiscardableMemory_none.cpp",
212 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700213 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700214 "src/ports/SkMemory_malloc.cpp",
215 "src/ports/SkOSFile_stdio.cpp",
216 "src/sfnt/SkOTTable_name.cpp",
217 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700218 "src/svg/SkSVGCanvas.cpp",
219 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700220 "src/utils/mac/SkStream_mac.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700221 "src/xml/SkDOM.cpp",
222 "src/xml/SkXMLParser.cpp",
223 "src/xml/SkXMLWriter.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700224 "third_party/etc1/etc1.cpp",
225 "third_party/ktx/ktx.cpp",
226 ]
227
228 if (is_win) {
229 sources += [
230 "src/ports/SkDebug_win.cpp",
231 "src/ports/SkFontHost_win.cpp",
232 "src/ports/SkFontMgr_win_dw.cpp",
233 "src/ports/SkFontMgr_win_dw_factory.cpp",
234 "src/ports/SkImageEncoder_WIC.cpp",
235 "src/ports/SkImageGeneratorWIC.cpp",
236 "src/ports/SkOSFile_win.cpp",
237 "src/ports/SkScalerContext_win_dw.cpp",
238 "src/ports/SkTLS_win.cpp",
239 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700240 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700241 ]
242 } else {
243 sources += [
244 "src/ports/SkDebug_stdio.cpp",
245 "src/ports/SkOSFile_posix.cpp",
246 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700247 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700248 ]
249 }
250
251 if (is_linux) {
252 deps += [
253 "third_party:fontconfig",
254 "third_party:freetype2",
mtkleinc04ff472016-06-23 10:29:30 -0700255 ]
256 sources += [
257 "src/fonts/SkFontMgr_fontconfig.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700258 "src/ports/SkFontConfigInterface_direct.cpp",
259 "src/ports/SkFontConfigInterface_direct_factory.cpp",
260 "src/ports/SkFontHost_FreeType.cpp",
261 "src/ports/SkFontHost_FreeType_common.cpp",
262 "src/ports/SkFontHost_fontconfig.cpp",
263 ]
264 }
265
266 if (is_mac) {
267 sources += [
268 "src/ports/SkFontHost_mac.cpp",
269 "src/ports/SkImageEncoder_CG.cpp",
270 "src/ports/SkImageGeneratorCG.cpp",
271 ]
272 libs += [ "ApplicationServices.framework" ]
273 }
abarth6fc8ff02016-07-15 15:15:15 -0700274
275 if (is_fuchsia) {
mtkleine817ddf2016-07-19 06:03:22 -0700276 sources += [ "src/ports/SkFontMgr_empty_factory.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700277 }
mtkleinc04ff472016-06-23 10:29:30 -0700278}
279
mtklein1211e0c2016-07-26 13:55:45 -0700280action("skia.h") {
281 script = "gn/echo_headers.py"
282 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
283 rebase_path(skia_public_includes, root_build_dir)
284 outputs = [
285 "$target_gen_dir/skia.h",
286 ]
287}
288
289executable("fiddle") {
290 include_dirs = [ "$target_gen_dir" ]
mtklein7d10b9f2016-07-27 11:17:18 -0700291 libs = []
292 if (is_linux) {
293 libs += [ "OSMesa" ]
294 }
mtklein1211e0c2016-07-26 13:55:45 -0700295
mtkleinc04ff472016-06-23 10:29:30 -0700296 sources = [
mtklein1211e0c2016-07-26 13:55:45 -0700297 "tools/fiddle/draw.cpp",
298 "tools/fiddle/fiddle_main.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700299 ]
300 deps = [
301 ":skia",
mtklein1211e0c2016-07-26 13:55:45 -0700302 ":skia.h",
mtkleinc04ff472016-06-23 10:29:30 -0700303 ]
mtkleinc04ff472016-06-23 10:29:30 -0700304}
mtklein25c81d42016-07-27 13:55:26 -0700305
306template("test_lib") {
307 config(target_name + "_config") {
308 include_dirs = invoker.public_include_dirs
309 }
310 source_set(target_name) {
311 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
312 public_configs = [
313 ":" + target_name + "_config",
314 ":skia_private",
315 ]
316
317 if (!defined(deps)) {
318 deps = []
319 }
320 deps += [ ":skia" ]
321 testonly = true
322 }
323}
324
325test_lib("gpu_tool_utils") {
326 public_include_dirs = [ "tools/gpu" ]
327 sources = [
328 "tools/gpu/GrContextFactory.cpp",
329 "tools/gpu/GrTest.cpp",
330 "tools/gpu/TestContext.cpp",
331 "tools/gpu/gl/GLTestContext.cpp",
332 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
333 "tools/gpu/gl/debug/GrBufferObj.cpp",
334 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
335 "tools/gpu/gl/debug/GrProgramObj.cpp",
336 "tools/gpu/gl/debug/GrShaderObj.cpp",
337 "tools/gpu/gl/debug/GrTextureObj.cpp",
338 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
339 "tools/gpu/gl/null/NullGLTestContext.cpp",
340 ]
341 libs = []
342
343 if (is_linux) {
344 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
345 libs += [
346 "GL",
347 "GLU",
348 "X11",
349 ]
350 } else if (is_mac) {
351 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
352 libs += [ "OpenGL.framework" ]
353 }
354}
355
356test_lib("flags") {
357 public_include_dirs = [ "tools/flags" ]
358 sources = [
359 "tools/flags/SkCommandLineFlags.cpp",
360 "tools/flags/SkCommonFlags.cpp",
361 "tools/flags/SkCommonFlagsConfig.cpp",
362 ]
363 deps = [
364 ":gpu_tool_utils",
365 ]
366}
367
368test_lib("tool_utils") {
369 public_include_dirs = [
370 "tools",
371 "tools/timer",
372 ]
373 sources = [
mtklein2b6870c2016-07-28 14:17:33 -0700374 "src/images/SkForceLinking.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700375 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtklein2b6870c2016-07-28 14:17:33 -0700376 "tools/CrashHandler.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700377 "tools/ProcStats.cpp",
378 "tools/Resources.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700379 "tools/ThermalManager.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700380 "tools/picture_utils.cpp",
381 "tools/random_parse_path.cpp",
382 "tools/sk_tool_utils.cpp",
383 "tools/sk_tool_utils_font.cpp",
384 "tools/timer/Timer.cpp",
385 ]
386 deps = [
387 ":flags",
388 ]
389}
390
391gm_sources = exec_script("gyp/find.py",
392 [
393 rebase_path("gm"),
394 "*.c*",
395 ],
396 "list lines",
397 [])
398test_lib("gm") {
399 public_include_dirs = [ "gm" ]
400 sources = gm_sources
401 deps = [
402 ":gpu_tool_utils",
403 ":skia",
404 ":tool_utils",
405 ]
406}
407
mtklein2b6870c2016-07-28 14:17:33 -0700408bench_sources = exec_script("gyp/find.py",
409 [
410 rebase_path("bench"),
411 "*.c*",
412 ],
413 "list lines",
414 [])
mtklein25c81d42016-07-27 13:55:26 -0700415
mtklein2b6870c2016-07-28 14:17:33 -0700416test_lib("bench") {
417 public_include_dirs = [ "bench" ]
418 sources = bench_sources
419 sources -= [
420 rebase_path("bench/nanobench.cpp"),
421 rebase_path("bench/nanobenchAndroid.cpp"),
422 ]
423 deps = [
424 ":flags",
425 ":gm",
426 ":gpu_tool_utils",
427 ":skia",
428 ":tool_utils",
429 ]
430}
431
432if (!is_component_build) { # Our test tools use many non-SK_API APIs...
433 executable("dm") {
434 sources = [
435 "dm/DM.cpp",
436 "dm/DMJsonWriter.cpp",
437 "dm/DMSrcSink.cpp",
438
439 # TODO: tests for real
440 "tests/Test.cpp",
441 ]
442 include_dirs = [ "tests" ]
443 deps = [
444 ":flags",
445 ":gm",
446 ":gpu_tool_utils",
447 ":skia",
448 ":tool_utils",
449 "//third_party/jsoncpp",
450 "//third_party/libpng",
451 ]
452 testonly = true
453 }
454
455 executable("monobench") {
456 sources = [
457 "tools/monobench.cpp",
458 ]
459 deps = [
460 ":bench",
461 ":skia",
462 ]
463 testonly = true
464 }
465
466 executable("nanobench") {
467 sources = [
468 "bench/nanobench.cpp",
469 ]
470 deps = [
471 ":bench",
472 ":flags",
473 ":gm",
474 ":gpu_tool_utils",
475 ":skia",
476 ":tool_utils",
477 "//third_party/jsoncpp",
478 ]
479 testonly = true
480 }
mtklein25c81d42016-07-27 13:55:26 -0700481}