blob: d4ccf63ef50976839946dac6b9cd919760f5b39c [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",
52 "src/ports",
53 "src/sfnt",
54 "src/utils",
55 "third_party/etc1",
56 "third_party/ktx",
57 ]
58}
59
60# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
61config("skia_library") {
62 visibility = [ ":*" ]
mtkleinc04ff472016-06-23 10:29:30 -070063 defines = [ "SKIA_IMPLEMENTATION=1" ]
64}
65
66skia_library_configs = [
67 ":skia_public",
68 ":skia_private",
69 ":skia_library",
70]
71
mtklein7fbfbbe2016-07-21 12:25:45 -070072core_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -070073 [
74 rebase_path("gyp/core.gypi"),
75 "--replace=<(skia_include_path)=include",
76 "--replace=<(skia_src_path)=src",
77 ],
78 "scope",
79 [ "gyp/core.gypi" ])
80
mtklein7fbfbbe2016-07-21 12:25:45 -070081effects_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -070082 [
83 rebase_path("gyp/effects.gypi"),
84 "--replace=<(skia_include_path)=include",
85 "--replace=<(skia_src_path)=src",
86 ],
87 "scope",
88 [ "gyp/effects.gypi" ])
89
mtklein7fbfbbe2016-07-21 12:25:45 -070090gpu_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -070091 [
92 rebase_path("gyp/gpu.gypi"),
93 "--replace=<(skia_include_path)=include",
94 "--replace=<(skia_src_path)=src",
95 ],
96 "scope",
97 [ "gyp/gpu.gypi" ])
98
mtklein7fbfbbe2016-07-21 12:25:45 -070099opts_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700100 [
101 rebase_path("gyp/opts.gypi"),
102 "--replace=<(skia_include_path)=include",
103 "--replace=<(skia_src_path)=src",
104 ],
105 "scope",
106 [ "gyp/opts.gypi" ])
107
mtklein7fbfbbe2016-07-21 12:25:45 -0700108pdf_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700109 [
110 rebase_path("gyp/pdf.gypi"),
111 "--replace=<(skia_include_path)=include",
112 "--replace=<(skia_src_path)=src",
113 ],
114 "scope",
115 [ "gyp/pdf.gypi" ])
116
mtklein7fbfbbe2016-07-21 12:25:45 -0700117utils_gypi = exec_script("gn/gypi_to_gn.py",
mtkleinc04ff472016-06-23 10:29:30 -0700118 [
119 rebase_path("gyp/utils.gypi"),
120 "--replace=<(skia_include_path)=include",
121 "--replace=<(skia_src_path)=src",
122 ],
123 "scope",
124 [ "gyp/utils.gypi" ])
125
126source_set("opts_ssse3") {
127 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700128
129 sources = opts_gypi.ssse3_sources
130 cflags = [ "-mssse3" ]
131}
132
133source_set("opts_sse41") {
134 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700135
136 sources = opts_gypi.sse41_sources
137 cflags = [ "-msse4.1" ]
138}
139
140source_set("opts_avx") {
141 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700142
143 sources = opts_gypi.avx_sources
144 cflags = [ "-mavx" ]
145}
146
147component("skia") {
148 public_configs = [ ":skia_public" ]
149 configs += skia_library_configs
mtkleinc04ff472016-06-23 10:29:30 -0700150
151 deps = [
152 ":opts_avx",
153 ":opts_sse41",
154 ":opts_ssse3",
mtklein25c81d42016-07-27 13:55:26 -0700155 "//third_party/expat",
156 "//third_party/giflib",
mtklein7d10b9f2016-07-27 11:17:18 -0700157 "//third_party/libjpeg_turbo",
158 "//third_party/libpng",
mtklein25c81d42016-07-27 13:55:26 -0700159 "//third_party/libwebp",
abarth6fc8ff02016-07-15 15:15:15 -0700160 "//third_party/zlib",
mtkleinc04ff472016-06-23 10:29:30 -0700161 ]
162
mtklein1211e0c2016-07-26 13:55:45 -0700163 defines = [
mtklein25c81d42016-07-27 13:55:26 -0700164 "SK_HAS_GIF_LIBRARY",
mtklein1211e0c2016-07-26 13:55:45 -0700165 "SK_HAS_JPEG_LIBRARY",
166 "SK_HAS_PNG_LIBRARY",
mtklein25c81d42016-07-27 13:55:26 -0700167 "SK_HAS_WEBP_LIBRARY",
mtklein1211e0c2016-07-26 13:55:45 -0700168 ]
169
mtklein7fbfbbe2016-07-21 12:25:45 -0700170 libs = [ "pthread" ]
mtkleinc04ff472016-06-23 10:29:30 -0700171
172 sources = []
173 sources += core_gypi.sources
174 sources += effects_gypi.sources
175 sources += gpu_gypi.skgpu_sources
176 sources += opts_gypi.sse2_sources
177 sources += pdf_gypi.sources
178 sources += utils_gypi.sources
179 sources += [
mtklein25c81d42016-07-27 13:55:26 -0700180 "src/android/SkBitmapRegionCodec.cpp",
181 "src/android/SkBitmapRegionDecoder.cpp",
182 "src/codec/SkAndroidCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700183 "src/codec/SkBmpCodec.cpp",
184 "src/codec/SkBmpMaskCodec.cpp",
185 "src/codec/SkBmpRLECodec.cpp",
186 "src/codec/SkBmpStandardCodec.cpp",
187 "src/codec/SkCodec.cpp",
188 "src/codec/SkCodecImageGenerator.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700189 "src/codec/SkGifCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700190 "src/codec/SkIcoCodec.cpp",
191 "src/codec/SkJpegCodec.cpp",
192 "src/codec/SkJpegDecoderMgr.cpp",
193 "src/codec/SkJpegUtility.cpp",
194 "src/codec/SkMaskSwizzler.cpp",
195 "src/codec/SkMasks.cpp",
196 "src/codec/SkPngCodec.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700197 "src/codec/SkSampledCodec.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700198 "src/codec/SkSampler.cpp",
199 "src/codec/SkSwizzler.cpp",
200 "src/codec/SkWbmpCodec.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700201 "src/codec/SkWebpAdapterCodec.cpp",
202 "src/codec/SkWebpCodec.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700203 "src/images/SkImageEncoder.cpp",
204 "src/images/SkImageEncoder_Factory.cpp",
205 "src/ports/SkDiscardableMemory_none.cpp",
206 "src/ports/SkGlobalInitialization_default.cpp",
mtklein1211e0c2016-07-26 13:55:45 -0700207 "src/ports/SkImageGenerator_skia.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700208 "src/ports/SkMemory_malloc.cpp",
209 "src/ports/SkOSFile_stdio.cpp",
210 "src/sfnt/SkOTTable_name.cpp",
211 "src/sfnt/SkOTUtils.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700212 "src/svg/SkSVGCanvas.cpp",
213 "src/svg/SkSVGDevice.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700214 "src/utils/mac/SkStream_mac.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700215 "src/xml/SkDOM.cpp",
216 "src/xml/SkXMLParser.cpp",
217 "src/xml/SkXMLWriter.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700218 "third_party/etc1/etc1.cpp",
219 "third_party/ktx/ktx.cpp",
220 ]
221
222 if (is_win) {
223 sources += [
224 "src/ports/SkDebug_win.cpp",
225 "src/ports/SkFontHost_win.cpp",
226 "src/ports/SkFontMgr_win_dw.cpp",
227 "src/ports/SkFontMgr_win_dw_factory.cpp",
228 "src/ports/SkImageEncoder_WIC.cpp",
229 "src/ports/SkImageGeneratorWIC.cpp",
230 "src/ports/SkOSFile_win.cpp",
231 "src/ports/SkScalerContext_win_dw.cpp",
232 "src/ports/SkTLS_win.cpp",
233 "src/ports/SkTypeface_win_dw.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700234 "src/xps/SkDocument_XPS.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700235 ]
236 } else {
237 sources += [
238 "src/ports/SkDebug_stdio.cpp",
239 "src/ports/SkOSFile_posix.cpp",
240 "src/ports/SkTLS_pthread.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700241 "src/xps/SkDocument_XPS_None.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700242 ]
243 }
244
245 if (is_linux) {
246 deps += [
247 "third_party:fontconfig",
248 "third_party:freetype2",
mtkleinc04ff472016-06-23 10:29:30 -0700249 ]
250 sources += [
251 "src/fonts/SkFontMgr_fontconfig.cpp",
252 "src/images/SkJPEGImageEncoder.cpp",
253 "src/images/SkJPEGWriteUtility.cpp",
254 "src/images/SkPNGImageEncoder.cpp",
255 "src/ports/SkFontConfigInterface_direct.cpp",
256 "src/ports/SkFontConfigInterface_direct_factory.cpp",
257 "src/ports/SkFontHost_FreeType.cpp",
258 "src/ports/SkFontHost_FreeType_common.cpp",
259 "src/ports/SkFontHost_fontconfig.cpp",
260 ]
261 }
262
263 if (is_mac) {
264 sources += [
265 "src/ports/SkFontHost_mac.cpp",
266 "src/ports/SkImageEncoder_CG.cpp",
267 "src/ports/SkImageGeneratorCG.cpp",
268 ]
269 libs += [ "ApplicationServices.framework" ]
270 }
abarth6fc8ff02016-07-15 15:15:15 -0700271
272 if (is_fuchsia) {
mtkleine817ddf2016-07-19 06:03:22 -0700273 sources += [ "src/ports/SkFontMgr_empty_factory.cpp" ]
abarth6fc8ff02016-07-15 15:15:15 -0700274 }
mtkleinc04ff472016-06-23 10:29:30 -0700275}
276
mtklein1211e0c2016-07-26 13:55:45 -0700277action("skia.h") {
278 script = "gn/echo_headers.py"
279 args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
280 rebase_path(skia_public_includes, root_build_dir)
281 outputs = [
282 "$target_gen_dir/skia.h",
283 ]
284}
285
286executable("fiddle") {
287 include_dirs = [ "$target_gen_dir" ]
mtklein7d10b9f2016-07-27 11:17:18 -0700288 libs = []
289 if (is_linux) {
290 libs += [ "OSMesa" ]
291 }
mtklein1211e0c2016-07-26 13:55:45 -0700292
mtkleinc04ff472016-06-23 10:29:30 -0700293 sources = [
mtklein1211e0c2016-07-26 13:55:45 -0700294 "tools/fiddle/draw.cpp",
295 "tools/fiddle/fiddle_main.cpp",
mtkleinc04ff472016-06-23 10:29:30 -0700296 ]
297 deps = [
298 ":skia",
mtklein1211e0c2016-07-26 13:55:45 -0700299 ":skia.h",
mtkleinc04ff472016-06-23 10:29:30 -0700300 ]
mtkleinc04ff472016-06-23 10:29:30 -0700301}
mtklein25c81d42016-07-27 13:55:26 -0700302
303template("test_lib") {
304 config(target_name + "_config") {
305 include_dirs = invoker.public_include_dirs
306 }
307 source_set(target_name) {
308 forward_variables_from(invoker, "*", [ "public_include_dirs" ])
309 public_configs = [
310 ":" + target_name + "_config",
311 ":skia_private",
312 ]
313
314 if (!defined(deps)) {
315 deps = []
316 }
317 deps += [ ":skia" ]
318 testonly = true
319 }
320}
321
322test_lib("gpu_tool_utils") {
323 public_include_dirs = [ "tools/gpu" ]
324 sources = [
325 "tools/gpu/GrContextFactory.cpp",
326 "tools/gpu/GrTest.cpp",
327 "tools/gpu/TestContext.cpp",
328 "tools/gpu/gl/GLTestContext.cpp",
329 "tools/gpu/gl/debug/DebugGLTestContext.cpp",
330 "tools/gpu/gl/debug/GrBufferObj.cpp",
331 "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
332 "tools/gpu/gl/debug/GrProgramObj.cpp",
333 "tools/gpu/gl/debug/GrShaderObj.cpp",
334 "tools/gpu/gl/debug/GrTextureObj.cpp",
335 "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
336 "tools/gpu/gl/null/NullGLTestContext.cpp",
337 ]
338 libs = []
339
340 if (is_linux) {
341 sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
342 libs += [
343 "GL",
344 "GLU",
345 "X11",
346 ]
347 } else if (is_mac) {
348 sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
349 libs += [ "OpenGL.framework" ]
350 }
351}
352
353test_lib("flags") {
354 public_include_dirs = [ "tools/flags" ]
355 sources = [
356 "tools/flags/SkCommandLineFlags.cpp",
357 "tools/flags/SkCommonFlags.cpp",
358 "tools/flags/SkCommonFlagsConfig.cpp",
359 ]
360 deps = [
361 ":gpu_tool_utils",
362 ]
363}
364
365test_lib("tool_utils") {
366 public_include_dirs = [
367 "tools",
368 "tools/timer",
369 ]
370 sources = [
371 "src/utils/SkMultiPictureDocumentReader.cpp", # TODO(halcanary): move to tools?
372 "tools/ProcStats.cpp",
373 "tools/Resources.cpp",
374 "tools/picture_utils.cpp",
375 "tools/random_parse_path.cpp",
376 "tools/sk_tool_utils.cpp",
377 "tools/sk_tool_utils_font.cpp",
378 "tools/timer/Timer.cpp",
379 ]
380 deps = [
381 ":flags",
382 ]
383}
384
385gm_sources = exec_script("gyp/find.py",
386 [
387 rebase_path("gm"),
388 "*.c*",
389 ],
390 "list lines",
391 [])
392test_lib("gm") {
393 public_include_dirs = [ "gm" ]
394 sources = gm_sources
395 deps = [
396 ":gpu_tool_utils",
397 ":skia",
398 ":tool_utils",
399 ]
400}
401
mtklein8796ff12016-07-27 14:59:08 -0700402if (!is_component_build) { # DM uses many non-SK_API APIs...
403 executable("dm") {
404 sources = [
405 "dm/DM.cpp",
406 "dm/DMJsonWriter.cpp",
407 "dm/DMSrcSink.cpp",
mtklein25c81d42016-07-27 13:55:26 -0700408
mtklein8796ff12016-07-27 14:59:08 -0700409 # TODO: tests for real
410 "tests/Test.cpp",
411 ]
412 include_dirs = [ "tests" ]
413 deps = [
414 ":flags",
415 ":gm",
416 ":gpu_tool_utils",
417 ":skia",
418 ":tool_utils",
419 "//third_party/jsoncpp",
420 "//third_party/libpng",
421 ]
422 testonly = true
423 }
mtklein25c81d42016-07-27 13:55:26 -0700424}