Merge from google/chrome/m55
[platform/upstream/libSkiaSharp.git] / BUILD.gn
1 # 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
6 import("gn/shared_sources.gni")
7
8 if (!defined(is_skia_standalone)) {
9   is_skia_standalone = false
10 }
11
12 declare_args() {
13   skia_use_angle = false
14   skia_use_expat = true
15   skia_use_fontconfig = is_linux
16   skia_use_freetype = is_android || is_fuchsia || is_linux
17   skia_use_giflib = !is_fuchsia
18   skia_use_libjpeg_turbo = true
19   skia_use_libpng = true
20   skia_use_libwebp = !is_fuchsia
21   skia_use_mesa = false
22   skia_use_sfntly = !is_fuchsia
23   skia_use_vulkan = is_android && defined(ndk_api) && ndk_api >= 24
24   skia_use_zlib = true
25
26   skia_enable_android_framework_defines = false
27   skia_enable_gpu = true
28   skia_enable_tools = is_skia_standalone
29   skia_enable_vulkan_debug_layers = is_skia_standalone && is_debug
30   skia_vulkan_sdk = ""
31 }
32
33 skia_use_vulkan = skia_use_vulkan || skia_vulkan_sdk != ""
34
35 # Our tools require static linking (they use non-exported symbols).
36 skia_enable_tools = skia_enable_tools && !is_component_build
37
38 fontmgr_android_enabled = skia_use_expat && skia_use_freetype
39
40 skia_public_includes = [
41   "include/android",
42   "include/c",
43   "include/codec",
44   "include/config",
45   "include/core",
46   "include/effects",
47   "include/gpu",
48   "include/gpu/gl",
49   "include/images",
50   "include/pathops",
51   "include/ports",
52   "include/svg",
53   "include/utils",
54   "include/utils/mac",
55   "include/xml",
56 ]
57
58 # Skia public API, generally provided by :skia.
59 config("skia_public") {
60   include_dirs = skia_public_includes
61   defines = [ "SKIA_DLL" ]
62   if (is_fuchsia || is_linux) {
63     defines += [ "SK_SAMPLES_FOR_X" ]
64   }
65   if (skia_enable_android_framework_defines) {
66     defines += skia_android_framework_defines
67   }
68   if (!skia_enable_gpu) {
69     defines += [ "SK_SUPPORT_GPU=0" ]
70   }
71 }
72
73 # Skia internal APIs, used by Skia itself and a few test tools.
74 config("skia_private") {
75   visibility = [ ":*" ]
76
77   include_dirs = [
78     "include/private",
79     "src/c",
80     "src/codec",
81     "src/config",
82     "src/core",
83     "src/effects",
84     "src/effects/gradients",
85     "src/fonts",
86     "src/gpu",
87     "src/image",
88     "src/images",
89     "src/lazy",
90     "src/opts",
91     "src/pathops",
92     "src/pdf",
93     "src/ports",
94     "src/sfnt",
95     "src/sksl",
96     "src/utils",
97     "src/utils/win",
98     "third_party/etc1",
99     "third_party/ktx",
100   ]
101
102   defines = [ "SK_GAMMA_APPLY_TO_A8" ]
103   if (is_android) {
104     defines += [
105       "SK_GAMMA_EXPONENT=1.4",
106       "SK_GAMMA_CONTRAST=0.0",
107     ]
108   }
109   if (is_official_build || is_android) {
110     # TODO(bsalomon): it'd be nice to make Android normal.
111     defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
112   }
113   libs = []
114   lib_dirs = []
115   if (skia_use_vulkan) {
116     if (skia_vulkan_sdk != "") {
117       include_dirs += [ "$skia_vulkan_sdk/x86_64/include/" ]
118       lib_dirs += [ "$skia_vulkan_sdk/x86_64/lib/" ]
119     }
120     libs += [ "vulkan" ]
121   }
122 }
123
124 # Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
125 config("skia_library") {
126   visibility = [ ":*" ]
127   defines = [ "SKIA_IMPLEMENTATION=1" ]
128 }
129
130 skia_library_configs = [
131   ":skia_public",
132   ":skia_private",
133   ":skia_library",
134 ]
135
136 # Use for CPU-specific Skia code that needs particular compiler flags.
137 template("opts") {
138   if (invoker.enabled) {
139     source_set(target_name) {
140       forward_variables_from(invoker, "*")
141       configs += skia_library_configs
142     }
143   } else {
144     # If not enabled, a phony empty target that swallows all otherwise unused variables.
145     source_set(target_name) {
146       forward_variables_from(invoker,
147                              "*",
148                              [
149                                "sources",
150                                "cflags",
151                              ])
152     }
153   }
154 }
155
156 is_x86 = current_cpu == "x64" || current_cpu == "x86"
157
158 opts("none") {
159   enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
160   sources = skia_opts.none_sources
161   cflags = []
162 }
163
164 opts("armv7") {
165   enabled = current_cpu == "arm"
166   sources = skia_opts.armv7_sources + skia_opts.neon_sources
167   cflags = []
168 }
169
170 opts("arm64") {
171   enabled = current_cpu == "arm64"
172   sources = skia_opts.arm64_sources
173   cflags = []
174 }
175
176 opts("crc32") {
177   enabled = current_cpu == "arm64"
178   sources = skia_opts.crc32_sources
179   cflags = [ "-march=armv8-a+crc" ]
180 }
181
182 opts("sse2") {
183   enabled = is_x86
184   sources = skia_opts.sse2_sources
185   cflags = [ "-msse2" ]
186 }
187
188 opts("ssse3") {
189   enabled = is_x86
190   sources = skia_opts.ssse3_sources
191   cflags = [ "-mssse3" ]
192 }
193
194 opts("sse41") {
195   enabled = is_x86
196   sources = skia_opts.sse41_sources
197   cflags = [ "-msse4.1" ]
198 }
199
200 opts("sse42") {
201   enabled = is_x86
202   sources = skia_opts.sse42_sources
203   cflags = [ "-msse4.2" ]
204 }
205
206 opts("avx") {
207   enabled = is_x86
208   sources = skia_opts.avx_sources
209   cflags = [ "-mavx" ]
210 }
211
212 opts("hsw") {
213   enabled = is_x86
214   sources = skia_opts.hsw_sources
215   cflags = [
216     "-mavx2",
217     "-mbmi",
218     "-mbmi2",
219     "-mf16c",
220     "-mfma",
221   ]
222 }
223
224 opts("dsp") {
225   enabled = current_cpu == "mipsel"
226   sources = skia_opts.mips_dsp_sources
227   cflags = []
228 }
229
230 # Any feature of Skia that requires third-party code should be optional and use this template.
231 template("optional") {
232   if (invoker.enabled) {
233     config(target_name + "_public") {
234       if (defined(invoker.public_defines)) {
235         defines = invoker.public_defines
236       }
237     }
238     source_set(target_name) {
239       forward_variables_from(invoker,
240                              "*",
241                              [
242                                "public_defines",
243                                "sources_when_disabled",
244                              ])
245       all_dependent_configs = [ ":" + target_name + "_public" ]
246       configs += skia_library_configs
247     }
248   } else {
249     source_set(target_name) {
250       forward_variables_from(invoker,
251                              "*",
252                              [
253                                "public_defines",
254                                "deps",
255                                "libs",
256                                "sources",
257                                "sources_when_disabled",
258                              ])
259       if (defined(invoker.sources_when_disabled)) {
260         sources = invoker.sources_when_disabled
261       }
262       configs += skia_library_configs
263     }
264   }
265 }
266
267 optional("fontmgr_android") {
268   enabled = fontmgr_android_enabled
269
270   deps = [
271     "//third_party/expat",
272     "//third_party/freetype2",
273   ]
274   sources = [
275     "src/ports/SkFontMgr_android.cpp",
276     "src/ports/SkFontMgr_android_factory.cpp",
277     "src/ports/SkFontMgr_android_parser.cpp",
278   ]
279 }
280
281 optional("fontmgr_custom") {
282   enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
283
284   deps = [
285     "//third_party/freetype2",
286   ]
287   sources = [
288     "src/ports/SkFontMgr_custom.cpp",
289     "src/ports/SkFontMgr_custom_directory_factory.cpp",
290   ]
291 }
292
293 optional("fontmgr_fontconfig") {
294   enabled = skia_use_freetype && skia_use_fontconfig
295
296   deps = [
297     "//third_party:fontconfig",
298     "//third_party/freetype2",
299   ]
300   sources = [
301     "src/ports/SkFontConfigInterface.cpp",
302     "src/ports/SkFontConfigInterface_direct.cpp",
303     "src/ports/SkFontConfigInterface_direct_factory.cpp",
304     "src/ports/SkFontMgr_FontConfigInterface.cpp",
305     "src/ports/SkFontMgr_fontconfig.cpp",
306     "src/ports/SkFontMgr_fontconfig_factory.cpp",
307   ]
308 }
309
310 optional("fontmgr_fuchsia") {
311   enabled = is_fuchsia && skia_use_freetype
312
313   deps = [
314     "//third_party/freetype2",
315   ]
316   sources = [
317     "src/ports/SkFontMgr_custom.cpp",
318     "src/ports/SkFontMgr_custom_empty_factory.cpp",
319   ]
320 }
321
322 optional("gif") {
323   enabled = skia_use_giflib
324   public_defines = [ "SK_HAS_GIF_LIBRARY" ]
325
326   deps = [
327     "//third_party/giflib",
328   ]
329   sources = [
330     "src/codec/SkGifCodec.cpp",
331   ]
332 }
333
334 optional("gpu") {
335   enabled = skia_enable_gpu
336   public_defines = []
337
338   sources = skia_gpu_sources + [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ]
339
340   # These paths need to be absolute to match the ones produced by shared_sources.gni.
341   sources -= get_path_info([
342                              "src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
343                              "src/gpu/gl/GrGLDefaultInterface_none.cpp",
344                            ],
345                            "abspath")
346   if (is_android) {
347     sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
348   } else if (is_linux) {
349     sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
350   } else if (is_mac) {
351     sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
352   } else {
353     sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
354   }
355   libs = []
356
357   if (skia_use_vulkan) {
358     public_defines += [ "SK_VULKAN" ]
359     sources += skia_vk_sources
360     if (skia_enable_vulkan_debug_layers) {
361       public_defines += [ "SK_ENABLE_VK_LAYERS" ]
362     }
363   }
364 }
365
366 optional("jpeg") {
367   enabled = skia_use_libjpeg_turbo
368   public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
369
370   deps = [
371     "//third_party/libjpeg-turbo:libjpeg",
372   ]
373   sources = [
374     "src/codec/SkJpegCodec.cpp",
375     "src/codec/SkJpegDecoderMgr.cpp",
376     "src/codec/SkJpegUtility.cpp",
377     "src/images/SkJPEGImageEncoder.cpp",
378     "src/images/SkJPEGWriteUtility.cpp",
379   ]
380 }
381
382 optional("pdf") {
383   enabled = skia_use_zlib
384
385   deps = [
386     "//third_party/zlib",
387   ]
388   sources = skia_pdf_sources
389   sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
390
391   if (skia_use_sfntly) {
392     deps += [ "//third_party/sfntly" ]
393     public_defines = [ "SK_PDF_USE_SFNTLY" ]
394   }
395 }
396
397 optional("png") {
398   enabled = skia_use_libpng
399   public_defines = [ "SK_HAS_PNG_LIBRARY" ]
400
401   deps = [
402     "//third_party/libpng",
403   ]
404   sources = [
405     "src/codec/SkIcoCodec.cpp",
406     "src/codec/SkPngCodec.cpp",
407     "src/images/SkPNGImageEncoder.cpp",
408   ]
409 }
410
411 optional("typeface_freetype") {
412   enabled = skia_use_freetype
413
414   deps = [
415     "//third_party/freetype2",
416   ]
417   sources = [
418     "src/ports/SkFontHost_FreeType.cpp",
419     "src/ports/SkFontHost_FreeType_common.cpp",
420   ]
421 }
422
423 optional("webp") {
424   enabled = skia_use_libwebp
425   public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
426
427   deps = [
428     "//third_party/libwebp",
429   ]
430   sources = [
431     "src/codec/SkWebpAdapterCodec.cpp",
432     "src/codec/SkWebpCodec.cpp",
433     "src/images/SkWEBPImageEncoder.cpp",
434   ]
435 }
436
437 optional("xml") {
438   enabled = skia_use_expat
439
440   deps = [
441     "//third_party/expat",
442   ]
443   sources = [
444     "src/xml/SkDOM.cpp",
445     "src/xml/SkXMLParser.cpp",
446     "src/xml/SkXMLWriter.cpp",
447   ]
448 }
449
450 component("skia") {
451   public_configs = [ ":skia_public" ]
452   configs += skia_library_configs
453
454   deps = [
455     ":arm64",
456     ":armv7",
457     ":avx",
458     ":crc32",
459     ":dsp",
460     ":fontmgr_android",
461     ":fontmgr_custom",
462     ":fontmgr_fontconfig",
463     ":fontmgr_fuchsia",
464     ":gif",
465     ":gpu",
466     ":hsw",
467     ":jpeg",
468     ":none",
469     ":pdf",
470     ":png",
471     ":sse2",
472     ":sse41",
473     ":sse42",
474     ":ssse3",
475     ":typeface_freetype",
476     ":webp",
477     ":xml",
478   ]
479
480   sources = []
481   sources += skia_core_sources
482   sources += skia_effects_sources
483   sources += skia_sksl_sources
484   sources += skia_utils_sources
485   sources += [
486     "src/android/SkBitmapRegionCodec.cpp",
487     "src/android/SkBitmapRegionDecoder.cpp",
488     "src/codec/SkAndroidCodec.cpp",
489     "src/codec/SkBmpCodec.cpp",
490     "src/codec/SkBmpMaskCodec.cpp",
491     "src/codec/SkBmpRLECodec.cpp",
492     "src/codec/SkBmpStandardCodec.cpp",
493     "src/codec/SkCodec.cpp",
494     "src/codec/SkCodecImageGenerator.cpp",
495     "src/codec/SkMaskSwizzler.cpp",
496     "src/codec/SkMasks.cpp",
497     "src/codec/SkSampledCodec.cpp",
498     "src/codec/SkSampler.cpp",
499     "src/codec/SkSwizzler.cpp",
500     "src/codec/SkWbmpCodec.cpp",
501     "src/images/SkImageEncoder.cpp",
502     "src/images/SkImageEncoder_Factory.cpp",
503     "src/images/SkKTXImageEncoder.cpp",
504     "src/ports/SkDiscardableMemory_none.cpp",
505     "src/ports/SkGlobalInitialization_default.cpp",
506     "src/ports/SkImageGenerator_skia.cpp",
507     "src/ports/SkMemory_malloc.cpp",
508     "src/ports/SkOSFile_stdio.cpp",
509     "src/sfnt/SkOTTable_name.cpp",
510     "src/sfnt/SkOTUtils.cpp",
511     "src/svg/SkSVGCanvas.cpp",
512     "src/svg/SkSVGDevice.cpp",
513     "src/utils/mac/SkStream_mac.cpp",
514     "third_party/etc1/etc1.cpp",
515     "third_party/ktx/ktx.cpp",
516   ]
517
518   libs = []
519
520   if (is_win) {
521     sources += [
522       "src/ports/SkDebug_win.cpp",
523       "src/ports/SkFontHost_win.cpp",
524       "src/ports/SkFontMgr_win_dw.cpp",
525       "src/ports/SkFontMgr_win_dw_factory.cpp",
526       "src/ports/SkImageEncoder_WIC.cpp",
527       "src/ports/SkImageGeneratorWIC.cpp",
528       "src/ports/SkOSFile_win.cpp",
529       "src/ports/SkOSLibrary_win.cpp",
530       "src/ports/SkScalerContext_win_dw.cpp",
531       "src/ports/SkTLS_win.cpp",
532       "src/ports/SkTypeface_win_dw.cpp",
533       "src/xps/SkDocument_XPS.cpp",
534     ]
535     sources -=
536         [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
537   } else {
538     sources += [
539       "src/ports/SkOSFile_posix.cpp",
540       "src/ports/SkOSLibrary_posix.cpp",
541       "src/ports/SkTLS_pthread.cpp",
542       "src/xps/SkDocument_XPS_None.cpp",
543     ]
544   }
545
546   if (is_android) {
547     deps += [
548       "//third_party/cpu-features",
549       "//third_party/expat",
550     ]
551     sources += [ "src/ports/SkDebug_android.cpp" ]
552     libs += [
553       "EGL",
554       "GLESv2",
555       "log",
556     ]
557   }
558
559   if (is_linux) {
560     libs += [
561       "GL",
562       "GLU",
563       "X11",
564     ]
565     sources += [ "src/ports/SkDebug_stdio.cpp" ]
566   }
567
568   if (is_mac) {
569     sources += [
570       "src/ports/SkDebug_stdio.cpp",
571       "src/ports/SkFontHost_mac.cpp",
572       "src/ports/SkImageEncoder_CG.cpp",
573       "src/ports/SkImageGeneratorCG.cpp",
574     ]
575     libs += [
576       "ApplicationServices.framework",
577       "OpenGL.framework",
578     ]
579   }
580
581   if (is_fuchsia) {
582     sources += [ "src/ports/SkDebug_stdio.cpp" ]
583   }
584 }
585
586 skia_h_headers = exec_script("gyp/find.py",
587                              [ "*.h" ] + rebase_path(skia_public_includes),
588                              "list lines",
589                              []) -
590                  [
591                    rebase_path("include/gpu/gl/GrGLConfig_chrome.h"),
592                    rebase_path("include/gpu/vk/GrVkBackendContext.h"),
593                    rebase_path("include/gpu/vk/GrVkDefines.h"),
594                    rebase_path("include/gpu/vk/GrVkInterface.h"),
595                    rebase_path("include/gpu/vk/GrVkTypes.h"),
596                    rebase_path("include/ports/SkFontMgr_fontconfig.h"),
597                  ]
598
599 action("skia.h") {
600   script = "gn/echo_headers.py"
601   args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] +
602          rebase_path(skia_h_headers, target_gen_dir)
603   inputs = skia_h_headers
604   outputs = [
605     "$target_gen_dir/skia.h",
606   ]
607 }
608
609 if (skia_enable_gpu && target_cpu == "x64") {
610   # Our bots only have 64-bit libOSMesa installed.
611   # TODO: worth fixing?
612   executable("fiddle") {
613     include_dirs = [ "$target_gen_dir" ]
614     libs = []
615     if (is_linux) {
616       libs += [ "OSMesa" ]
617     }
618
619     sources = [
620       "src/images/SkForceLinking.cpp",
621       "tools/fiddle/draw.cpp",
622       "tools/fiddle/fiddle_main.cpp",
623     ]
624     deps = [
625       ":skia",
626       ":skia.h",
627     ]
628   }
629 }
630
631 # Targets guarded by skia_enable_tools may use //third_party freely.
632 if (skia_enable_tools) {
633   template("test_lib") {
634     config(target_name + "_config") {
635       include_dirs = invoker.public_include_dirs
636       if (defined(invoker.public_defines)) {
637         defines = invoker.public_defines
638       }
639     }
640     source_set(target_name) {
641       forward_variables_from(invoker, "*", [ "public_include_dirs" ])
642       public_configs = [
643         ":" + target_name + "_config",
644         ":skia_private",
645       ]
646
647       if (!defined(deps)) {
648         deps = []
649       }
650       deps += [ ":skia" ]
651       testonly = true
652     }
653   }
654
655   test_lib("gpu_tool_utils") {
656     public_include_dirs = []
657     if (skia_enable_gpu) {
658       public_defines = []
659       public_include_dirs += [ "tools/gpu" ]
660
661       deps = []
662       sources = [
663         "tools/gpu/GrContextFactory.cpp",
664         "tools/gpu/GrTest.cpp",
665         "tools/gpu/TestContext.cpp",
666         "tools/gpu/gl/GLTestContext.cpp",
667         "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
668         "tools/gpu/gl/debug/DebugGLTestContext.cpp",
669         "tools/gpu/gl/debug/GrBufferObj.cpp",
670         "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
671         "tools/gpu/gl/debug/GrProgramObj.cpp",
672         "tools/gpu/gl/debug/GrShaderObj.cpp",
673         "tools/gpu/gl/debug/GrTextureObj.cpp",
674         "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
675         "tools/gpu/gl/null/NullGLTestContext.cpp",
676       ]
677       libs = []
678
679       if (is_android) {
680         sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
681       } else if (is_linux) {
682         sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
683       } else if (is_mac) {
684         sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
685       }
686
687       if (skia_use_angle) {
688         public_defines += [ "SK_ANGLE" ]
689         deps += [ "//third_party/angle2" ]
690         sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
691       }
692       if (skia_use_mesa) {
693         public_defines += [ "SK_MESA" ]
694         sources += [ "tools/gpu/gl/mesa/GLTestContext_mesa.cpp" ]
695         libs += [ "OSMesa" ]
696       }
697       if (skia_use_vulkan) {
698         sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
699       }
700     }
701   }
702
703   test_lib("flags") {
704     public_include_dirs = [ "tools/flags" ]
705     sources = [
706       "tools/flags/SkCommandLineFlags.cpp",
707     ]
708   }
709   test_lib("common_flags") {
710     public_include_dirs = [ "tools/flags" ]
711     sources = [
712       "tools/flags/SkCommonFlags.cpp",
713       "tools/flags/SkCommonFlagsConfig.cpp",
714     ]
715     deps = [
716       ":flags",
717       ":gpu_tool_utils",
718     ]
719   }
720
721   test_lib("tool_utils") {
722     public_include_dirs = [
723       "tools",
724       "tools/debugger",
725       "tools/timer",
726     ]
727     sources = [
728       "src/images/SkForceLinking.cpp",
729       "src/utils/SkMultiPictureDocumentReader.cpp",  # TODO(halcanary): move to tools?
730       "tools/AndroidSkDebugToStdOut.cpp",
731       "tools/CrashHandler.cpp",
732       "tools/LsanSuppressions.cpp",
733       "tools/ProcStats.cpp",
734       "tools/Resources.cpp",
735       "tools/ThermalManager.cpp",
736       "tools/UrlDataManager.cpp",
737       "tools/debugger/SkDebugCanvas.cpp",
738       "tools/debugger/SkDrawCommand.cpp",
739       "tools/debugger/SkJsonWriteBuffer.cpp",
740       "tools/debugger/SkObjectParser.cpp",
741       "tools/debugger/SkOverdrawMode.cpp",
742       "tools/picture_utils.cpp",
743       "tools/random_parse_path.cpp",
744       "tools/sk_tool_utils.cpp",
745       "tools/sk_tool_utils_font.cpp",
746       "tools/timer/Timer.cpp",
747     ]
748     deps = [
749       ":common_flags",
750       ":flags",
751       "//third_party/libpng",
752     ]
753     public_deps = [
754       "//third_party/jsoncpp",
755     ]
756   }
757
758   gm_sources = exec_script("gyp/find.py",
759                            [
760                              "*.c*",
761                              rebase_path("gm"),
762                            ],
763                            "list lines",
764                            [])
765   test_lib("gm") {
766     public_include_dirs = [ "gm" ]
767     sources = gm_sources
768     deps = [
769       ":gpu_tool_utils",
770       ":skia",
771       ":tool_utils",
772     ]
773   }
774
775   tests_sources = exec_script("gyp/find.py",
776                               [
777                                 "*.c*",
778                                 rebase_path("tests"),
779                               ],
780                               "list lines",
781                               [])
782
783   test_lib("tests") {
784     public_include_dirs = [ "tests" ]
785     sources = tests_sources - [
786                 rebase_path("tests/PathOpsSkpClipTest.cpp"),  # alternate main
787                 rebase_path("tests/SkpSkGrTest.cpp"),  # doesn't compile
788                 rebase_path("tests/skia_test.cpp"),  # alternate main
789               ]
790     if (!fontmgr_android_enabled) {
791       sources -= [ rebase_path("tests/FontMgrAndroidParserTest.cpp") ]
792     }
793     deps = [
794       ":experimental_svg_model",
795       ":flags",
796       ":gpu_tool_utils",
797       ":skia",
798       ":tool_utils",
799       "//third_party/libpng",
800       "//third_party/zlib",
801     ]
802   }
803
804   bench_sources = exec_script("gyp/find.py",
805                               [
806                                 "*.c*",
807                                 rebase_path("bench"),
808                               ],
809                               "list lines",
810                               [])
811
812   test_lib("bench") {
813     public_include_dirs = [ "bench" ]
814     sources = bench_sources
815     sources -= [
816       rebase_path("bench/nanobench.cpp"),
817       rebase_path("bench/nanobenchAndroid.cpp"),
818     ]
819     deps = [
820       ":flags",
821       ":gm",
822       ":gpu_tool_utils",
823       ":skia",
824       ":tool_utils",
825     ]
826   }
827
828   test_lib("experimental_svg_model") {
829     public_include_dirs = [ "experimental/svg/model" ]
830     sources = [
831       "experimental/svg/model/SkSVGAttribute.cpp",
832       "experimental/svg/model/SkSVGAttributeParser.cpp",
833       "experimental/svg/model/SkSVGCircle.cpp",
834       "experimental/svg/model/SkSVGContainer.cpp",
835       "experimental/svg/model/SkSVGDOM.cpp",
836       "experimental/svg/model/SkSVGEllipse.cpp",
837       "experimental/svg/model/SkSVGLine.cpp",
838       "experimental/svg/model/SkSVGLinearGradient.cpp",
839       "experimental/svg/model/SkSVGNode.cpp",
840       "experimental/svg/model/SkSVGPath.cpp",
841       "experimental/svg/model/SkSVGPoly.cpp",
842       "experimental/svg/model/SkSVGRect.cpp",
843       "experimental/svg/model/SkSVGRenderContext.cpp",
844       "experimental/svg/model/SkSVGSVG.cpp",
845       "experimental/svg/model/SkSVGShape.cpp",
846       "experimental/svg/model/SkSVGStop.cpp",
847       "experimental/svg/model/SkSVGTransformableNode.cpp",
848       "experimental/svg/model/SkSVGValue.cpp",
849     ]
850     deps = [
851       ":skia",
852     ]
853   }
854
855   executable("dm") {
856     sources = [
857       "dm/DM.cpp",
858       "dm/DMJsonWriter.cpp",
859       "dm/DMSrcSink.cpp",
860     ]
861     include_dirs = [ "tests" ]
862     deps = [
863       ":common_flags",
864       ":experimental_svg_model",
865       ":flags",
866       ":gm",
867       ":gpu_tool_utils",
868       ":skia",
869       ":tests",
870       ":tool_utils",
871       "//third_party/jsoncpp",
872       "//third_party/libpng",
873     ]
874     testonly = true
875   }
876
877   if (!is_debug) {  # I've benchmarked debug code once too many times...
878     executable("monobench") {
879       sources = [
880         "tools/monobench.cpp",
881       ]
882       deps = [
883         ":bench",
884         ":skia",
885       ]
886       testonly = true
887     }
888   }
889
890   executable("nanobench") {
891     sources = [
892       "bench/nanobench.cpp",
893     ]
894     deps = [
895       ":bench",
896       ":common_flags",
897       ":experimental_svg_model",
898       ":flags",
899       ":gm",
900       ":gpu_tool_utils",
901       ":skia",
902       ":tool_utils",
903       "//third_party/jsoncpp",
904     ]
905     testonly = true
906   }
907
908   if (skia_enable_gpu) {
909     executable("skpbench") {
910       sources = [
911         "tools/skpbench/skpbench.cpp",
912       ]
913       deps = [
914         ":flags",
915         ":gpu_tool_utils",
916         ":skia",
917         ":tool_utils",
918       ]
919       testonly = true
920     }
921   }
922
923   if (current_cpu != "mipsel") {  # Clang 3.8 crashes while compiling hb-icu.cc for mipsel.
924     executable("sktexttopdf-hb") {
925       sources = [
926         "tools/SkShaper_harfbuzz.cpp",
927         "tools/using_skia_and_harfbuzz.cpp",
928       ]
929       deps = [
930         ":skia",
931         "//third_party/harfbuzz",
932       ]
933       testonly = true
934     }
935   }
936   executable("sktexttopdf") {
937     sources = [
938       "tools/SkShaper_primitive.cpp",
939       "tools/using_skia_and_harfbuzz.cpp",
940     ]
941     deps = [
942       ":skia",
943     ]
944     testonly = true
945   }
946
947   executable("get_images_from_skps") {
948     sources = [
949       "tools/get_images_from_skps.cpp",
950     ]
951     deps = [
952       ":flags",
953       ":skia",
954       "//third_party/jsoncpp",
955     ]
956     testonly = true
957   }
958
959   executable("skiaserve") {
960     sources = [
961       "tools/skiaserve/Request.cpp",
962       "tools/skiaserve/Response.cpp",
963       "tools/skiaserve/skiaserve.cpp",
964       "tools/skiaserve/urlhandlers/BatchBoundsHandler.cpp",
965       "tools/skiaserve/urlhandlers/BatchesHandler.cpp",
966       "tools/skiaserve/urlhandlers/BreakHandler.cpp",
967       "tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp",
968       "tools/skiaserve/urlhandlers/CmdHandler.cpp",
969       "tools/skiaserve/urlhandlers/ColorModeHandler.cpp",
970       "tools/skiaserve/urlhandlers/DataHandler.cpp",
971       "tools/skiaserve/urlhandlers/DownloadHandler.cpp",
972       "tools/skiaserve/urlhandlers/EnableGPUHandler.cpp",
973       "tools/skiaserve/urlhandlers/ImgHandler.cpp",
974       "tools/skiaserve/urlhandlers/InfoHandler.cpp",
975       "tools/skiaserve/urlhandlers/PostHandler.cpp",
976       "tools/skiaserve/urlhandlers/QuitHandler.cpp",
977       "tools/skiaserve/urlhandlers/RootHandler.cpp",
978     ]
979     deps = [
980       ":flags",
981       ":gpu_tool_utils",
982       ":skia",
983       ":tool_utils",
984       "//third_party/jsoncpp",
985       "//third_party/libmicrohttpd",
986       "//third_party/libpng",
987     ]
988     testonly = true
989   }
990
991   executable("fuzz") {
992     sources = [
993       "fuzz/FilterFuzz.cpp",
994       "fuzz/FuzzGradients.cpp",
995       "fuzz/FuzzParsePath.cpp",
996       "fuzz/FuzzPathop.cpp",
997       "fuzz/FuzzScaleToSides.cpp",
998       "fuzz/fuzz.cpp",
999     ]
1000     deps = [
1001       ":flags",
1002       ":skia",
1003     ]
1004     testonly = true
1005   }
1006 }