blob: e6defbf604b61957c0facf2f310b1224d53213ca [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",
mtkleinc04ff472016-06-23 10:29:30 -0700311 ]
mtkleinc04ff472016-06-23 10:29:30 -0700312}
mtklein25c81d42016-07-27 13:55:26 -0700313
314template("test_lib") {
315 config(target_name + "_config") {
316 include_dirs = invoker.public_include_dirs
317 }
318 source_set(target_name) {
319 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
320 public_configs = [
321 ":" + target_name + "_config",
322 ":skia_private",
323 ]
324
325 if (!defined(deps)) {
326 deps = []
327 }
328 deps += [ ":skia" ]
329 testonly = true
330 }
331}
332
333test_lib("gpu_tool_utils") {
334 public_include_dirs = [ "tools/gpu" ]
335 sources = [
336 "tools/gpu/GrContextFactory.cpp",
337 "tools/gpu/GrTest.cpp",
338 "tools/gpu/TestContext.cpp",
339 "tools/gpu/gl/GLTestContext.cpp",
340 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
341 "tools/gpu/gl/debug/GrBufferObj.cpp",
342 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
343 "tools/gpu/gl/debug/GrProgramObj.cpp",
344 "tools/gpu/gl/debug/GrShaderObj.cpp",
345 "tools/gpu/gl/debug/GrTextureObj.cpp",
346 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
347 "tools/gpu/gl/null/NullGLTestContext.cpp",
348 ]
349 libs = []
350
351 if (is_linux) {
352 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
353 libs += [
354 "GL",
355 "GLU",
356 "X11",
357 ]
358 } else if (is_mac) {
359 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
360 libs += [ "OpenGL.framework" ]
361 }
362}
363
364test_lib("flags") {
365 public_include_dirs = [ "tools/flags" ]
366 sources = [
367 "tools/flags/SkCommandLineFlags.cpp",
368 "tools/flags/SkCommonFlags.cpp",
369 "tools/flags/SkCommonFlagsConfig.cpp",
370 ]
371 deps = [
372 ":gpu_tool_utils",
373 ]
374}
375
376test_lib("tool_utils") {
377 public_include_dirs = [
378 "tools",
379 "tools/timer",
380 ]
381 sources = [
mtklein2b6870c2016-07-28 14:17:33 -0700382 "src/images/SkForceLinking.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700383 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtklein2b6870c2016-07-28 14:17:33 -0700384 "tools/CrashHandler.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700385 "tools/ProcStats.cpp",
386 "tools/Resources.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700387 "tools/ThermalManager.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700388 "tools/picture_utils.cpp",
389 "tools/random_parse_path.cpp",
390 "tools/sk_tool_utils.cpp",
391 "tools/sk_tool_utils_font.cpp",
392 "tools/timer/Timer.cpp",
393 ]
394 deps = [
395 ":flags",
396 ]
397}
398
399gm_sources = exec_script("gyp/find.py",
400 [
401 rebase_path("gm"),
402 "*.c*",
403 ],
404 "list lines",
405 [])
406test_lib("gm") {
407 public_include_dirs = [ "gm" ]
408 sources = gm_sources
409 deps = [
410 ":gpu_tool_utils",
411 ":skia",
412 ":tool_utils",
413 ]
414}
415
mtklein2b6870c2016-07-28 14:17:33 -0700416bench_sources = exec_script("gyp/find.py",
417 [
418 rebase_path("bench"),
419 "*.c*",
420 ],
421 "list lines",
422 [])
mtklein25c81d42016-07-27 13:55:26 -0700423
mtklein2b6870c2016-07-28 14:17:33 -0700424test_lib("bench") {
425 public_include_dirs = [ "bench" ]
426 sources = bench_sources
427 sources -= [
428 rebase_path("bench/nanobench.cpp"),
429 rebase_path("bench/nanobenchAndroid.cpp"),
430 ]
431 deps = [
432 ":flags",
433 ":gm",
434 ":gpu_tool_utils",
435 ":skia",
436 ":tool_utils",
437 ]
438}
439
440if (!is_component_build) { # Our test tools use many non-SK_API APIs...
441 executable("dm") {
442 sources = [
443 "dm/DM.cpp",
444 "dm/DMJsonWriter.cpp",
445 "dm/DMSrcSink.cpp",
446
447 # TODO: tests for real
448 "tests/Test.cpp",
449 ]
450 include_dirs = [ "tests" ]
451 deps = [
452 ":flags",
453 ":gm",
454 ":gpu_tool_utils",
455 ":skia",
456 ":tool_utils",
457 "//third_party/jsoncpp",
458 "//third_party/libpng",
459 ]
460 testonly = true
461 }
462
463 executable("monobench") {
464 sources = [
465 "tools/monobench.cpp",
466 ]
467 deps = [
468 ":bench",
469 ":skia",
470 ]
471 testonly = true
472 }
473
474 executable("nanobench") {
475 sources = [
476 "bench/nanobench.cpp",
477 ]
478 deps = [
479 ":bench",
480 ":flags",
481 ":gm",
482 ":gpu_tool_utils",
483 ":skia",
484 ":tool_utils",
485 "//third_party/jsoncpp",
486 ]
487 testonly = true
488 }
mtklein25c81d42016-07-27 13:55:26 -0700489}