blob: 8bf9d668cb664aef8f03b74701cabd92a6948cab [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",
68 ]
mtkleinc04ff472016-06-23 10:29:30 -070069}
70
71# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
72config("skia_library") {
73 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -070074 defines = [ "SKIA_IMPLEMENTATION=1" ]
75}
76
77skia_library_configs = [
78 ":skia_public",
79 ":skia_private",
80 ":skia_library",
81]
82
mtklein7fbfbbe2016-07-21 12:25:45 -070083core_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -070084 [
85 rebase_path("gyp/core.gypi"),
86 "--replace=<(skia_include_path)=include",
87 "--replace=<(skia_src_path)=src",
88 ],
89 "scope",
90 [ "gyp/core.gypi" ])
91
mtklein7fbfbbe2016-07-21 12:25:45 -070092effects_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -070093 [
94 rebase_path("gyp/effects.gypi"),
95 "--replace=<(skia_include_path)=include",
96 "--replace=<(skia_src_path)=src",
97 ],
98 "scope",
99 [ "gyp/effects.gypi" ])
100
mtklein7fbfbbe2016-07-21 12:25:45 -0700101gpu_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700102 [
103 rebase_path("gyp/gpu.gypi"),
104 "--replace=<(skia_include_path)=include",
105 "--replace=<(skia_src_path)=src",
106 ],
107 "scope",
108 [ "gyp/gpu.gypi" ])
109
mtklein7fbfbbe2016-07-21 12:25:45 -0700110opts_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700111 [
112 rebase_path("gyp/opts.gypi"),
113 "--replace=<(skia_include_path)=include",
114 "--replace=<(skia_src_path)=src",
115 ],
116 "scope",
117 [ "gyp/opts.gypi" ])
118
mtklein7fbfbbe2016-07-21 12:25:45 -0700119pdf_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700120 [
121 rebase_path("gyp/pdf.gypi"),
122 "--replace=<(skia_include_path)=include",
123 "--replace=<(skia_src_path)=src",
124 ],
125 "scope",
126 [ "gyp/pdf.gypi" ])
127
mtklein7fbfbbe2016-07-21 12:25:45 -0700128utils_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700129 [
130 rebase_path("gyp/utils.gypi"),
131 "--replace=<(skia_include_path)=include",
132 "--replace=<(skia_src_path)=src",
133 ],
134 "scope",
135 [ "gyp/utils.gypi" ])
136
137source_set("opts_ssse3") {
138 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700139
140 sources = opts_gypi.ssse3_sources
141 cflags = [ "-mssse3" ]
142}
143
144source_set("opts_sse41") {
145 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700146
147 sources = opts_gypi.sse41_sources
148 cflags = [ "-msse4.1" ]
149}
150
151source_set("opts_avx") {
152 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700153
154 sources = opts_gypi.avx_sources
155 cflags = [ "-mavx" ]
156}
157
158component("skia") {
159 public_configs = [ ":skia_public" ]
160 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700161
162 deps = [
163 ":opts_avx",
164 ":opts_sse41",
165 ":opts_ssse3",
mtklein25c81d42016-07-27 13:55:26 -0700166 "//third_party/expat",
167 "//third_party/giflib",
mtklein7d10b9f2016-07-27 11:17:18 -0700168 "//third_party/libjpeg_turbo",
169 "//third_party/libpng",
mtklein25c81d42016-07-27 13:55:26 -0700170 "//third_party/libwebp",
abarth6fc8ff02016-07-15 15:15:15 -0700171 "//third_party/zlib",
mtkleinc04ff472016-06-23 10:29:30 -0700172 ]
173
mtklein7fbfbbe2016-07-21 12:25:45 -0700174 libs = [ "pthread" ]
mtkleinc04ff472016-06-23 10:29:30 -0700175
176 sources = []
177 sources += core_gypi.sources
178 sources += effects_gypi.sources
179 sources += gpu_gypi.skgpu_sources
180 sources += opts_gypi.sse2_sources
181 sources += pdf_gypi.sources
182 sources += utils_gypi.sources
183 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700184 "src/android/SkBitmapRegionCodec.cpp",
185 "src/android/SkBitmapRegionDecoder.cpp",
186 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700187 "src/codec/SkBmpCodec.cpp",
188 "src/codec/SkBmpMaskCodec.cpp",
189 "src/codec/SkBmpRLECodec.cpp",
190 "src/codec/SkBmpStandardCodec.cpp",
191 "src/codec/SkCodec.cpp",
192 "src/codec/SkCodecImageGenerator.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700193 "src/codec/SkGifCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700194 "src/codec/SkIcoCodec.cpp",
195 "src/codec/SkJpegCodec.cpp",
196 "src/codec/SkJpegDecoderMgr.cpp",
197 "src/codec/SkJpegUtility.cpp",
198 "src/codec/SkMaskSwizzler.cpp",
199 "src/codec/SkMasks.cpp",
200 "src/codec/SkPngCodec.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700201 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700202 "src/codec/SkSampler.cpp",
203 "src/codec/SkSwizzler.cpp",
204 "src/codec/SkWbmpCodec.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700205 "src/codec/SkWebpAdapterCodec.cpp",
206 "src/codec/SkWebpCodec.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700207 "src/images/SkImageEncoder.cpp",
208 "src/images/SkImageEncoder_Factory.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700209 "src/images/SkJPEGImageEncoder.cpp",
210 "src/images/SkJPEGWriteUtility.cpp",
211 "src/images/SkKTXImageEncoder.cpp",
212 "src/images/SkPNGImageEncoder.cpp",
213 "src/images/SkWEBPImageEncoder.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700214 "src/ports/SkDiscardableMemory_none.cpp",
215 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700216 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700217 "src/ports/SkMemory_malloc.cpp",
218 "src/ports/SkOSFile_stdio.cpp",
219 "src/sfnt/SkOTTable_name.cpp",
220 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700221 "src/svg/SkSVGCanvas.cpp",
222 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700223 "src/utils/mac/SkStream_mac.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700224 "src/xml/SkDOM.cpp",
225 "src/xml/SkXMLParser.cpp",
226 "src/xml/SkXMLWriter.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700227 "third_party/etc1/etc1.cpp",
228 "third_party/ktx/ktx.cpp",
229 ]
230
231 if (is_win) {
232 sources += [
233 "src/ports/SkDebug_win.cpp",
234 "src/ports/SkFontHost_win.cpp",
235 "src/ports/SkFontMgr_win_dw.cpp",
236 "src/ports/SkFontMgr_win_dw_factory.cpp",
237 "src/ports/SkImageEncoder_WIC.cpp",
238 "src/ports/SkImageGeneratorWIC.cpp",
239 "src/ports/SkOSFile_win.cpp",
240 "src/ports/SkScalerContext_win_dw.cpp",
241 "src/ports/SkTLS_win.cpp",
242 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700243 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700244 ]
245 } else {
246 sources += [
247 "src/ports/SkDebug_stdio.cpp",
248 "src/ports/SkOSFile_posix.cpp",
249 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700250 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700251 ]
252 }
253
254 if (is_linux) {
255 deps += [
256 "third_party:fontconfig",
257 "third_party:freetype2",
mtkleinc04ff472016-06-23 10:29:30 -0700258 ]
259 sources += [
260 "src/fonts/SkFontMgr_fontconfig.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700261 "src/ports/SkFontConfigInterface_direct.cpp",
262 "src/ports/SkFontConfigInterface_direct_factory.cpp",
263 "src/ports/SkFontHost_FreeType.cpp",
264 "src/ports/SkFontHost_FreeType_common.cpp",
265 "src/ports/SkFontHost_fontconfig.cpp",
266 ]
267 }
268
269 if (is_mac) {
270 sources += [
271 "src/ports/SkFontHost_mac.cpp",
272 "src/ports/SkImageEncoder_CG.cpp",
273 "src/ports/SkImageGeneratorCG.cpp",
274 ]
275 libs += [ "ApplicationServices.framework" ]
276 }
abarth6fc8ff02016-07-15 15:15:15 -0700277
278 if (is_fuchsia) {
mtkleine817ddf2016-07-19 06:03:22 -0700279 sources += [ "src/ports/SkFontMgr_empty_factory.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700280 }
mtkleinc04ff472016-06-23 10:29:30 -0700281}
282
mtklein1211e0c2016-07-26 13:55:45 -0700283action("skia.h") {
284 script = "gn/echo_headers.py"
285 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
286 rebase_path(skia_public_includes, root_build_dir)
287 outputs = [
288 "$target_gen_dir/skia.h",
289 ]
290}
291
292executable("fiddle") {
293 include_dirs = [ "$target_gen_dir" ]
mtklein7d10b9f2016-07-27 11:17:18 -0700294 libs = []
295 if (is_linux) {
296 libs += [ "OSMesa" ]
297 }
mtklein1211e0c2016-07-26 13:55:45 -0700298
mtkleinc04ff472016-06-23 10:29:30 -0700299 sources = [
mtklein1211e0c2016-07-26 13:55:45 -0700300 "tools/fiddle/draw.cpp",
301 "tools/fiddle/fiddle_main.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700302 ]
303 deps = [
304 ":skia",
mtklein1211e0c2016-07-26 13:55:45 -0700305 ":skia.h",
mtkleinc04ff472016-06-23 10:29:30 -0700306 ]
mtkleinc04ff472016-06-23 10:29:30 -0700307}
mtklein25c81d42016-07-27 13:55:26 -0700308
309template("test_lib") {
310 config(target_name + "_config") {
311 include_dirs = invoker.public_include_dirs
312 }
313 source_set(target_name) {
314 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
315 public_configs = [
316 ":" + target_name + "_config",
317 ":skia_private",
318 ]
319
320 if (!defined(deps)) {
321 deps = []
322 }
323 deps += [ ":skia" ]
324 testonly = true
325 }
326}
327
328test_lib("gpu_tool_utils") {
329 public_include_dirs = [ "tools/gpu" ]
330 sources = [
331 "tools/gpu/GrContextFactory.cpp",
332 "tools/gpu/GrTest.cpp",
333 "tools/gpu/TestContext.cpp",
334 "tools/gpu/gl/GLTestContext.cpp",
335 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
336 "tools/gpu/gl/debug/GrBufferObj.cpp",
337 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
338 "tools/gpu/gl/debug/GrProgramObj.cpp",
339 "tools/gpu/gl/debug/GrShaderObj.cpp",
340 "tools/gpu/gl/debug/GrTextureObj.cpp",
341 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
342 "tools/gpu/gl/null/NullGLTestContext.cpp",
343 ]
344 libs = []
345
346 if (is_linux) {
347 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
348 libs += [
349 "GL",
350 "GLU",
351 "X11",
352 ]
353 } else if (is_mac) {
354 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
355 libs += [ "OpenGL.framework" ]
356 }
357}
358
359test_lib("flags") {
360 public_include_dirs = [ "tools/flags" ]
361 sources = [
362 "tools/flags/SkCommandLineFlags.cpp",
363 "tools/flags/SkCommonFlags.cpp",
364 "tools/flags/SkCommonFlagsConfig.cpp",
365 ]
366 deps = [
367 ":gpu_tool_utils",
368 ]
369}
370
371test_lib("tool_utils") {
372 public_include_dirs = [
373 "tools",
374 "tools/timer",
375 ]
376 sources = [
mtklein2b6870c2016-07-28 14:17:33 -0700377 "src/images/SkForceLinking.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700378 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtklein2b6870c2016-07-28 14:17:33 -0700379 "tools/CrashHandler.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700380 "tools/ProcStats.cpp",
381 "tools/Resources.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700382 "tools/ThermalManager.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700383 "tools/picture_utils.cpp",
384 "tools/random_parse_path.cpp",
385 "tools/sk_tool_utils.cpp",
386 "tools/sk_tool_utils_font.cpp",
387 "tools/timer/Timer.cpp",
388 ]
389 deps = [
390 ":flags",
391 ]
392}
393
394gm_sources = exec_script("gyp/find.py",
395 [
396 rebase_path("gm"),
397 "*.c*",
398 ],
399 "list lines",
400 [])
401test_lib("gm") {
402 public_include_dirs = [ "gm" ]
403 sources = gm_sources
404 deps = [
405 ":gpu_tool_utils",
406 ":skia",
407 ":tool_utils",
408 ]
409}
410
mtklein2b6870c2016-07-28 14:17:33 -0700411bench_sources = exec_script("gyp/find.py",
412 [
413 rebase_path("bench"),
414 "*.c*",
415 ],
416 "list lines",
417 [])
mtklein25c81d42016-07-27 13:55:26 -0700418
mtklein2b6870c2016-07-28 14:17:33 -0700419test_lib("bench") {
420 public_include_dirs = [ "bench" ]
421 sources = bench_sources
422 sources -= [
423 rebase_path("bench/nanobench.cpp"),
424 rebase_path("bench/nanobenchAndroid.cpp"),
425 ]
426 deps = [
427 ":flags",
428 ":gm",
429 ":gpu_tool_utils",
430 ":skia",
431 ":tool_utils",
432 ]
433}
434
435if (!is_component_build) { # Our test tools use many non-SK_API APIs...
436 executable("dm") {
437 sources = [
438 "dm/DM.cpp",
439 "dm/DMJsonWriter.cpp",
440 "dm/DMSrcSink.cpp",
441
442 # TODO: tests for real
443 "tests/Test.cpp",
444 ]
445 include_dirs = [ "tests" ]
446 deps = [
447 ":flags",
448 ":gm",
449 ":gpu_tool_utils",
450 ":skia",
451 ":tool_utils",
452 "//third_party/jsoncpp",
453 "//third_party/libpng",
454 ]
455 testonly = true
456 }
457
458 executable("monobench") {
459 sources = [
460 "tools/monobench.cpp",
461 ]
462 deps = [
463 ":bench",
464 ":skia",
465 ]
466 testonly = true
467 }
468
469 executable("nanobench") {
470 sources = [
471 "bench/nanobench.cpp",
472 ]
473 deps = [
474 ":bench",
475 ":flags",
476 ":gm",
477 ":gpu_tool_utils",
478 ":skia",
479 ":tool_utils",
480 "//third_party/jsoncpp",
481 ]
482 testonly = true
483 }
mtklein25c81d42016-07-27 13:55:26 -0700484}