blob: 3c5251e4e672d44e2d72b65108217493d99458c2 [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
mtkleinada5a442016-08-02 14:28:26 -0700288skia_h_headers = exec_script("gyp/find.py",
289 [ "*.h" ] + rebase_path(skia_public_includes),
290 "list lines",
291 []) -
292 [
293 rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
294 rebase_path("include/gpu/vk/GrVkBackendContext.h"),
295 rebase_path("include/gpu/vk/GrVkDefines.h"),
296 rebase_path("include/gpu/vk/GrVkInterface.h"),
297 rebase_path("include/gpu/vk/GrVkTypes.h"),
298 rebase_path("include/ports/SkFontMgr_fontconfig.h"),
299 ]
300
mtklein1211e0c2016-07-26 13:55:45 -0700301action("skia.h") {
302 script = "gn/echo_headers.py"
303 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
mtkleinada5a442016-08-02 14:28:26 -0700304 rebase_path(skia_h_headers, root_build_dir)
mtklein1211e0c2016-07-26 13:55:45 -0700305 outputs = [
306 "$target_gen_dir/skia.h",
307 ]
308}
309
310executable("fiddle") {
311 include_dirs = [ "$target_gen_dir" ]
mtklein7d10b9f2016-07-27 11:17:18 -0700312 libs = []
313 if (is_linux) {
314 libs += [ "OSMesa" ]
315 }
mtklein1211e0c2016-07-26 13:55:45 -0700316
mtkleinc04ff472016-06-23 10:29:30 -0700317 sources = [
mtklein1211e0c2016-07-26 13:55:45 -0700318 "tools/fiddle/draw.cpp",
319 "tools/fiddle/fiddle_main.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700320 ]
321 deps = [
322 ":skia",
mtklein1211e0c2016-07-26 13:55:45 -0700323 ":skia.h",
mtklein5dbd2742016-08-02 11:13:48 -0700324 ":tool_utils",
mtkleinc04ff472016-06-23 10:29:30 -0700325 ]
mtklein5dbd2742016-08-02 11:13:48 -0700326 testonly = true
mtkleinc04ff472016-06-23 10:29:30 -0700327}
mtklein25c81d42016-07-27 13:55:26 -0700328
329template("test_lib") {
330 config(target_name + "_config") {
331 include_dirs = invoker.public_include_dirs
332 }
333 source_set(target_name) {
334 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
335 public_configs = [
336 ":" + target_name + "_config",
337 ":skia_private",
338 ]
339
340 if (!defined(deps)) {
341 deps = []
342 }
343 deps += [ ":skia" ]
344 testonly = true
345 }
346}
347
348test_lib("gpu_tool_utils") {
349 public_include_dirs = [ "tools/gpu" ]
350 sources = [
351 "tools/gpu/GrContextFactory.cpp",
352 "tools/gpu/GrTest.cpp",
353 "tools/gpu/TestContext.cpp",
354 "tools/gpu/gl/GLTestContext.cpp",
355 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
356 "tools/gpu/gl/debug/GrBufferObj.cpp",
357 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
358 "tools/gpu/gl/debug/GrProgramObj.cpp",
359 "tools/gpu/gl/debug/GrShaderObj.cpp",
360 "tools/gpu/gl/debug/GrTextureObj.cpp",
361 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
362 "tools/gpu/gl/null/NullGLTestContext.cpp",
363 ]
364 libs = []
365
366 if (is_linux) {
367 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
368 libs += [
369 "GL",
370 "GLU",
371 "X11",
372 ]
373 } else if (is_mac) {
374 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
375 libs += [ "OpenGL.framework" ]
376 }
377}
378
379test_lib("flags") {
380 public_include_dirs = [ "tools/flags" ]
381 sources = [
382 "tools/flags/SkCommandLineFlags.cpp",
383 "tools/flags/SkCommonFlags.cpp",
384 "tools/flags/SkCommonFlagsConfig.cpp",
385 ]
386 deps = [
387 ":gpu_tool_utils",
388 ]
389}
390
391test_lib("tool_utils") {
392 public_include_dirs = [
393 "tools",
mtklein2f3416d2016-08-02 16:02:05 -0700394 "tools/debugger",
mtklein25c81d42016-07-27 13:55:26 -0700395 "tools/timer",
396 ]
397 sources = [
mtklein2b6870c2016-07-28 14:17:33 -0700398 "src/images/SkForceLinking.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700399 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
mtklein2b6870c2016-07-28 14:17:33 -0700400 "tools/CrashHandler.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700401 "tools/ProcStats.cpp",
402 "tools/Resources.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700403 "tools/ThermalManager.cpp",
mtklein2f3416d2016-08-02 16:02:05 -0700404 "tools/UrlDataManager.cpp",
405 "tools/debugger/SkDebugCanvas.cpp",
406 "tools/debugger/SkDrawCommand.cpp",
407 "tools/debugger/SkJsonWriteBuffer.cpp",
408 "tools/debugger/SkObjectParser.cpp",
409 "tools/debugger/SkOverdrawMode.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700410 "tools/picture_utils.cpp",
411 "tools/random_parse_path.cpp",
412 "tools/sk_tool_utils.cpp",
413 "tools/sk_tool_utils_font.cpp",
414 "tools/timer/Timer.cpp",
415 ]
416 deps = [
417 ":flags",
mtklein2f3416d2016-08-02 16:02:05 -0700418 "//third_party/libpng",
419 ]
420 public_deps = [
421 "//third_party/jsoncpp",
mtklein25c81d42016-07-27 13:55:26 -0700422 ]
423}
424
425gm_sources = exec_script("gyp/find.py",
426 [
mtklein25c81d42016-07-27 13:55:26 -0700427 "*.c*",
mtkleinada5a442016-08-02 14:28:26 -0700428 rebase_path("gm"),
mtklein25c81d42016-07-27 13:55:26 -0700429 ],
430 "list lines",
431 [])
432test_lib("gm") {
433 public_include_dirs = [ "gm" ]
434 sources = gm_sources
435 deps = [
436 ":gpu_tool_utils",
437 ":skia",
438 ":tool_utils",
439 ]
440}
441
mtklein2f3416d2016-08-02 16:02:05 -0700442tests_sources = exec_script("gyp/find.py",
443 [
444 "*.c*",
445 rebase_path("tests"),
446 ],
447 "list lines",
448 [])
449
450test_lib("tests") {
451 public_include_dirs = [ "tests" ]
452 sources = tests_sources - [
453 rebase_path("tests/FontMgrAndroidParserTest.cpp"), # Android only
454 rebase_path("tests/PathOpsSkpClipTest.cpp"), # alternate main
455 rebase_path("tests/RTConfRegistryTest.cpp"), # TODO: delete
456 rebase_path("tests/SkSLErrorTest.cpp"), # TODO: make work
457 rebase_path("tests/SkpSkGrTest.cpp"), # doesn't compile
458 rebase_path("tests/skia_test.cpp"), # alternate main
459 ]
460 deps = [
461 ":flags",
462 ":gpu_tool_utils",
463 ":skia",
464 ":tool_utils",
465 "//third_party/libpng",
466 "//third_party/zlib",
467 ]
468}
469
mtklein2b6870c2016-07-28 14:17:33 -0700470bench_sources = exec_script("gyp/find.py",
471 [
mtklein2b6870c2016-07-28 14:17:33 -0700472 "*.c*",
mtkleinada5a442016-08-02 14:28:26 -0700473 rebase_path("bench"),
mtklein2b6870c2016-07-28 14:17:33 -0700474 ],
475 "list lines",
476 [])
mtklein25c81d42016-07-27 13:55:26 -0700477
mtklein2b6870c2016-07-28 14:17:33 -0700478test_lib("bench") {
479 public_include_dirs = [ "bench" ]
480 sources = bench_sources
481 sources -= [
482 rebase_path("bench/nanobench.cpp"),
483 rebase_path("bench/nanobenchAndroid.cpp"),
484 ]
485 deps = [
486 ":flags",
487 ":gm",
488 ":gpu_tool_utils",
489 ":skia",
490 ":tool_utils",
491 ]
492}
493
494if (!is_component_build) { # Our test tools use many non-SK_API APIs...
495 executable("dm") {
496 sources = [
497 "dm/DM.cpp",
498 "dm/DMJsonWriter.cpp",
499 "dm/DMSrcSink.cpp",
mtklein2b6870c2016-07-28 14:17:33 -0700500 ]
501 include_dirs = [ "tests" ]
502 deps = [
503 ":flags",
504 ":gm",
505 ":gpu_tool_utils",
506 ":skia",
mtklein2f3416d2016-08-02 16:02:05 -0700507 ":tests",
mtklein2b6870c2016-07-28 14:17:33 -0700508 ":tool_utils",
509 "//third_party/jsoncpp",
510 "//third_party/libpng",
511 ]
512 testonly = true
513 }
514
515 executable("monobench") {
516 sources = [
517 "tools/monobench.cpp",
518 ]
519 deps = [
520 ":bench",
521 ":skia",
522 ]
523 testonly = true
524 }
525
526 executable("nanobench") {
527 sources = [
528 "bench/nanobench.cpp",
529 ]
530 deps = [
531 ":bench",
532 ":flags",
533 ":gm",
534 ":gpu_tool_utils",
535 ":skia",
536 ":tool_utils",
537 "//third_party/jsoncpp",
538 ]
539 testonly = true
540 }
mtklein25c81d42016-07-27 13:55:26 -0700541}