blob: d1daccb59874f7d102465741c997f0bf716c2344 [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",
bungeman7d0e3bc2016-08-02 07:07:33 -0700268 "src/ports/SkFontMgr_FontConfigInterface.cpp",
mtklein7a34b1c2016-08-01 13:08:46 -0700269 "src/ports/SkFontMgr_fontconfig.cpp",
270 "src/ports/SkFontMgr_fontconfig_factory.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700271 ]
272 }
273
274 if (is_mac) {
275 sources += [
276 "src/ports/SkFontHost_mac.cpp",
277 "src/ports/SkImageEncoder_CG.cpp",
278 "src/ports/SkImageGeneratorCG.cpp",
279 ]
280 libs += [ "ApplicationServices.framework" ]
281 }
abarth6fc8ff02016-07-15 15:15:15 -0700282
283 if (is_fuchsia) {
mtkleine817ddf2016-07-19 06:03:22 -0700284 sources += [ "src/ports/SkFontMgr_empty_factory.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700285 }
mtkleinc04ff472016-06-23 10:29:30 -0700286}
287
mtklein1211e0c2016-07-26 13:55:45 -0700288action("skia.h") {
289 script = "gn/echo_headers.py"
290 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
291 rebase_path(skia_public_includes, root_build_dir)
292 outputs = [
293 "$target_gen_dir/skia.h",
294 ]
295}
296
297executable("fiddle") {
298 include_dirs = [ "$target_gen_dir" ]
mtklein7d10b9f2016-07-27 11:17:18 -0700299 libs = []
300 if (is_linux) {
301 libs += [ "OSMesa" ]
302 }
mtklein1211e0c2016-07-26 13:55:45 -0700303
mtkleinc04ff472016-06-23 10:29:30 -0700304 sources = [
mtklein1211e0c2016-07-26 13:55:45 -0700305 "tools/fiddle/draw.cpp",
306 "tools/fiddle/fiddle_main.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700307 ]
308 deps = [
309 ":skia",
mtklein1211e0c2016-07-26 13:55:45 -0700310 ":skia.h",
mtklein5dbd2742016-08-02 11:13:48 -0700311 ":tool_utils",
mtkleinc04ff472016-06-23 10:29:30 -0700312 ]
mtklein5dbd2742016-08-02 11:13:48 -0700313 testonly = true
mtkleinc04ff472016-06-23 10:29:30 -0700314}
mtklein25c81d42016-07-27 13:55:26 -0700315
316template("test_lib") {
317 config(target_name + "_config") {
318 include_dirs = invoker.public_include_dirs
319 }
320 source_set(target_name) {
321 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
322 public_configs = [
323 ":" + target_name + "_config",
324 ":skia_private",
325 ]
326
327 if (!defined(deps)) {
328 deps = []
329 }
330 deps += [ ":skia" ]
331 testonly = true
332 }
333}
334
335test_lib("gpu_tool_utils") {
336 public_include_dirs = [ "tools/gpu" ]
337 sources = [
338 "tools/gpu/GrContextFactory.cpp",
339 "tools/gpu/GrTest.cpp",
340 "tools/gpu/TestContext.cpp",
341 "tools/gpu/gl/GLTestContext.cpp",
342 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
343 "tools/gpu/gl/debug/GrBufferObj.cpp",
344 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
345 "tools/gpu/gl/debug/GrProgramObj.cpp",
346 "tools/gpu/gl/debug/GrShaderObj.cpp",
347 "tools/gpu/gl/debug/GrTextureObj.cpp",
348 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
349 "tools/gpu/gl/null/NullGLTestContext.cpp",
350 ]
351 libs = []
352
353 if (is_linux) {
354 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
355 libs += [
356 "GL",
357 "GLU",
358 "X11",
359 ]
360 } else if (is_mac) {
361 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
362 libs += [ "OpenGL.framework" ]
363 }
364}
365
366test_lib("flags") {
367 public_include_dirs = [ "tools/flags" ]
368 sources = [
369 "tools/flags/SkCommandLineFlags.cpp",
370 "tools/flags/SkCommonFlags.cpp",
371 "tools/flags/SkCommonFlagsConfig.cpp",
372 ]
373 deps = [
374 ":gpu_tool_utils",
375 ]
376}
377
378test_lib("tool_utils") {
379 public_include_dirs = [
380 "tools",
381 "tools/timer",
382 ]
383 sources = [
mtklein2b6870c2016-07-28 14:17:33 -0700384 "src/images/SkForceLinking.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700385 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtklein2b6870c2016-07-28 14:17:33 -0700386 "tools/CrashHandler.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700387 "tools/ProcStats.cpp",
388 "tools/Resources.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700389 "tools/ThermalManager.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700390 "tools/picture_utils.cpp",
391 "tools/random_parse_path.cpp",
392 "tools/sk_tool_utils.cpp",
393 "tools/sk_tool_utils_font.cpp",
394 "tools/timer/Timer.cpp",
395 ]
396 deps = [
397 ":flags",
398 ]
399}
400
401gm_sources = exec_script("gyp/find.py",
402 [
403 rebase_path("gm"),
404 "*.c*",
405 ],
406 "list lines",
407 [])
408test_lib("gm") {
409 public_include_dirs = [ "gm" ]
410 sources = gm_sources
411 deps = [
412 ":gpu_tool_utils",
413 ":skia",
414 ":tool_utils",
415 ]
416}
417
mtklein2b6870c2016-07-28 14:17:33 -0700418bench_sources = exec_script("gyp/find.py",
419 [
420 rebase_path("bench"),
421 "*.c*",
422 ],
423 "list lines",
424 [])
mtklein25c81d42016-07-27 13:55:26 -0700425
mtklein2b6870c2016-07-28 14:17:33 -0700426test_lib("bench") {
427 public_include_dirs = [ "bench" ]
428 sources = bench_sources
429 sources -= [
430 rebase_path("bench/nanobench.cpp"),
431 rebase_path("bench/nanobenchAndroid.cpp"),
432 ]
433 deps = [
434 ":flags",
435 ":gm",
436 ":gpu_tool_utils",
437 ":skia",
438 ":tool_utils",
439 ]
440}
441
442if (!is_component_build) { # Our test tools use many non-SK_API APIs...
443 executable("dm") {
444 sources = [
445 "dm/DM.cpp",
446 "dm/DMJsonWriter.cpp",
447 "dm/DMSrcSink.cpp",
448
449 # TODO: tests for real
450 "tests/Test.cpp",
451 ]
452 include_dirs = [ "tests" ]
453 deps = [
454 ":flags",
455 ":gm",
456 ":gpu_tool_utils",
457 ":skia",
458 ":tool_utils",
459 "//third_party/jsoncpp",
460 "//third_party/libpng",
461 ]
462 testonly = true
463 }
464
465 executable("monobench") {
466 sources = [
467 "tools/monobench.cpp",
468 ]
469 deps = [
470 ":bench",
471 ":skia",
472 ]
473 testonly = true
474 }
475
476 executable("nanobench") {
477 sources = [
478 "bench/nanobench.cpp",
479 ]
480 deps = [
481 ":bench",
482 ":flags",
483 ":gm",
484 ":gpu_tool_utils",
485 ":skia",
486 ":tool_utils",
487 "//third_party/jsoncpp",
488 ]
489 testonly = true
490 }
mtklein25c81d42016-07-27 13:55:26 -0700491}