| # Copyright 2016 Google Inc. | 
 | # | 
 | # Use of this source code is governed by a BSD-style license that can be | 
 | # found in the LICENSE file. | 
 |  | 
 | declare_args() { | 
 | } | 
 |  | 
 | skia_public_includes = [ | 
 |   "include/android", | 
 |   "include/c", | 
 |   "include/codec", | 
 |   "include/config", | 
 |   "include/core", | 
 |   "include/effects", | 
 |   "include/gpu", | 
 |   "include/gpu/gl", | 
 |   "include/images", | 
 |   "include/pathops", | 
 |   "include/ports", | 
 |   "include/svg", | 
 |   "include/utils", | 
 |   "include/utils/mac", | 
 |   "include/xml", | 
 | ] | 
 |  | 
 | # Skia public API, generally provided by :skia. | 
 | config("skia_public") { | 
 |   include_dirs = skia_public_includes | 
 |   defines = [ "SKIA_DLL" ] | 
 | } | 
 |  | 
 | # Skia internal APIs, used by Skia itself and a few test tools. | 
 | config("skia_private") { | 
 |   visibility = [ ":*" ] | 
 |  | 
 |   include_dirs = [ | 
 |     "include/private", | 
 |     "src/c", | 
 |     "src/codec", | 
 |     "src/config", | 
 |     "src/core", | 
 |     "src/effects", | 
 |     "src/effects/gradients", | 
 |     "src/fonts", | 
 |     "src/gpu", | 
 |     "src/image", | 
 |     "src/images", | 
 |     "src/lazy", | 
 |     "src/opts", | 
 |     "src/pathops", | 
 |     "src/pdf", | 
 |     "src/ports", | 
 |     "src/sfnt", | 
 |     "src/utils", | 
 |     "third_party/etc1", | 
 |     "third_party/ktx", | 
 |   ] | 
 |  | 
 |   defines = [ | 
 |     "SK_GAMMA_APPLY_TO_A8", | 
 |  | 
 |     "SK_HAS_GIF_LIBRARY", | 
 |     "SK_HAS_JPEG_LIBRARY", | 
 |     "SK_HAS_PNG_LIBRARY", | 
 |     "SK_HAS_WEBP_LIBRARY", | 
 |  | 
 |     "TURBO_HAS_565", | 
 |     "TURBO_HAS_CROP", | 
 |     "TURBO_HAS_SKIP", | 
 |   ] | 
 | } | 
 |  | 
 | # Any code that's linked into Skia-the-library should use this config via += skia_library_configs. | 
 | config("skia_library") { | 
 |   visibility = [ ":*" ] | 
 |   defines = [ "SKIA_IMPLEMENTATION=1" ] | 
 | } | 
 |  | 
 | skia_library_configs = [ | 
 |   ":skia_public", | 
 |   ":skia_private", | 
 |   ":skia_library", | 
 | ] | 
 |  | 
 | core_gypi = exec_script("gn/gypi_to_gn.py", | 
 |                         [ | 
 |                           rebase_path("gyp/core.gypi"), | 
 |                           "--replace=<(skia_include_path)=include", | 
 |                           "--replace=<(skia_src_path)=src", | 
 |                         ], | 
 |                         "scope", | 
 |                         [ "gyp/core.gypi" ]) | 
 |  | 
 | effects_gypi = exec_script("gn/gypi_to_gn.py", | 
 |                            [ | 
 |                              rebase_path("gyp/effects.gypi"), | 
 |                              "--replace=<(skia_include_path)=include", | 
 |                              "--replace=<(skia_src_path)=src", | 
 |                            ], | 
 |                            "scope", | 
 |                            [ "gyp/effects.gypi" ]) | 
 |  | 
 | gpu_gypi = exec_script("gn/gypi_to_gn.py", | 
 |                        [ | 
 |                          rebase_path("gyp/gpu.gypi"), | 
 |                          "--replace=<(skia_include_path)=include", | 
 |                          "--replace=<(skia_src_path)=src", | 
 |                        ], | 
 |                        "scope", | 
 |                        [ "gyp/gpu.gypi" ]) | 
 |  | 
 | opts_gypi = exec_script("gn/gypi_to_gn.py", | 
 |                         [ | 
 |                           rebase_path("gyp/opts.gypi"), | 
 |                           "--replace=<(skia_include_path)=include", | 
 |                           "--replace=<(skia_src_path)=src", | 
 |                         ], | 
 |                         "scope", | 
 |                         [ "gyp/opts.gypi" ]) | 
 |  | 
 | pdf_gypi = exec_script("gn/gypi_to_gn.py", | 
 |                        [ | 
 |                          rebase_path("gyp/pdf.gypi"), | 
 |                          "--replace=<(skia_include_path)=include", | 
 |                          "--replace=<(skia_src_path)=src", | 
 |                        ], | 
 |                        "scope", | 
 |                        [ "gyp/pdf.gypi" ]) | 
 |  | 
 | utils_gypi = exec_script("gn/gypi_to_gn.py", | 
 |                          [ | 
 |                            rebase_path("gyp/utils.gypi"), | 
 |                            "--replace=<(skia_include_path)=include", | 
 |                            "--replace=<(skia_src_path)=src", | 
 |                          ], | 
 |                          "scope", | 
 |                          [ "gyp/utils.gypi" ]) | 
 |  | 
 | source_set("opts_ssse3") { | 
 |   configs += skia_library_configs | 
 |  | 
 |   sources = opts_gypi.ssse3_sources | 
 |   cflags = [ "-mssse3" ] | 
 | } | 
 |  | 
 | source_set("opts_sse41") { | 
 |   configs += skia_library_configs | 
 |  | 
 |   sources = opts_gypi.sse41_sources | 
 |   cflags = [ "-msse4.1" ] | 
 | } | 
 |  | 
 | source_set("opts_avx") { | 
 |   configs += skia_library_configs | 
 |  | 
 |   sources = opts_gypi.avx_sources | 
 |   cflags = [ "-mavx" ] | 
 | } | 
 |  | 
 | component("skia") { | 
 |   public_configs = [ ":skia_public" ] | 
 |   configs += skia_library_configs | 
 |  | 
 |   deps = [ | 
 |     ":opts_avx", | 
 |     ":opts_sse41", | 
 |     ":opts_ssse3", | 
 |     "//third_party/expat", | 
 |     "//third_party/giflib", | 
 |     "//third_party/libjpeg_turbo", | 
 |     "//third_party/libpng", | 
 |     "//third_party/libwebp", | 
 |     "//third_party/zlib", | 
 |   ] | 
 |  | 
 |   libs = [ "pthread" ] | 
 |  | 
 |   sources = [] | 
 |   sources += core_gypi.sources | 
 |   sources += effects_gypi.sources | 
 |   sources += gpu_gypi.skgpu_sources | 
 |   sources += opts_gypi.sse2_sources | 
 |   sources += pdf_gypi.sources | 
 |   sources += utils_gypi.sources | 
 |   sources += [ | 
 |     "src/android/SkBitmapRegionCodec.cpp", | 
 |     "src/android/SkBitmapRegionDecoder.cpp", | 
 |     "src/codec/SkAndroidCodec.cpp", | 
 |     "src/codec/SkBmpCodec.cpp", | 
 |     "src/codec/SkBmpMaskCodec.cpp", | 
 |     "src/codec/SkBmpRLECodec.cpp", | 
 |     "src/codec/SkBmpStandardCodec.cpp", | 
 |     "src/codec/SkCodec.cpp", | 
 |     "src/codec/SkCodecImageGenerator.cpp", | 
 |     "src/codec/SkGifCodec.cpp", | 
 |     "src/codec/SkIcoCodec.cpp", | 
 |     "src/codec/SkJpegCodec.cpp", | 
 |     "src/codec/SkJpegDecoderMgr.cpp", | 
 |     "src/codec/SkJpegUtility.cpp", | 
 |     "src/codec/SkMaskSwizzler.cpp", | 
 |     "src/codec/SkMasks.cpp", | 
 |     "src/codec/SkPngCodec.cpp", | 
 |     "src/codec/SkSampledCodec.cpp", | 
 |     "src/codec/SkSampler.cpp", | 
 |     "src/codec/SkSwizzler.cpp", | 
 |     "src/codec/SkWbmpCodec.cpp", | 
 |     "src/codec/SkWebpAdapterCodec.cpp", | 
 |     "src/codec/SkWebpCodec.cpp", | 
 |     "src/images/SkImageEncoder.cpp", | 
 |     "src/images/SkImageEncoder_Factory.cpp", | 
 |     "src/images/SkJPEGImageEncoder.cpp", | 
 |     "src/images/SkJPEGWriteUtility.cpp", | 
 |     "src/images/SkKTXImageEncoder.cpp", | 
 |     "src/images/SkPNGImageEncoder.cpp", | 
 |     "src/images/SkWEBPImageEncoder.cpp", | 
 |     "src/ports/SkDiscardableMemory_none.cpp", | 
 |     "src/ports/SkGlobalInitialization_default.cpp", | 
 |     "src/ports/SkImageGenerator_skia.cpp", | 
 |     "src/ports/SkMemory_malloc.cpp", | 
 |     "src/ports/SkOSFile_stdio.cpp", | 
 |     "src/sfnt/SkOTTable_name.cpp", | 
 |     "src/sfnt/SkOTUtils.cpp", | 
 |     "src/svg/SkSVGCanvas.cpp", | 
 |     "src/svg/SkSVGDevice.cpp", | 
 |     "src/utils/mac/SkStream_mac.cpp", | 
 |     "src/xml/SkDOM.cpp", | 
 |     "src/xml/SkXMLParser.cpp", | 
 |     "src/xml/SkXMLWriter.cpp", | 
 |     "third_party/etc1/etc1.cpp", | 
 |     "third_party/ktx/ktx.cpp", | 
 |   ] | 
 |  | 
 |   if (is_win) { | 
 |     sources += [ | 
 |       "src/ports/SkDebug_win.cpp", | 
 |       "src/ports/SkFontHost_win.cpp", | 
 |       "src/ports/SkFontMgr_win_dw.cpp", | 
 |       "src/ports/SkFontMgr_win_dw_factory.cpp", | 
 |       "src/ports/SkImageEncoder_WIC.cpp", | 
 |       "src/ports/SkImageGeneratorWIC.cpp", | 
 |       "src/ports/SkOSFile_win.cpp", | 
 |       "src/ports/SkScalerContext_win_dw.cpp", | 
 |       "src/ports/SkTLS_win.cpp", | 
 |       "src/ports/SkTypeface_win_dw.cpp", | 
 |       "src/xps/SkDocument_XPS.cpp", | 
 |     ] | 
 |   } else { | 
 |     sources += [ | 
 |       "src/ports/SkDebug_stdio.cpp", | 
 |       "src/ports/SkOSFile_posix.cpp", | 
 |       "src/ports/SkTLS_pthread.cpp", | 
 |       "src/xps/SkDocument_XPS_None.cpp", | 
 |     ] | 
 |   } | 
 |  | 
 |   if (is_linux) { | 
 |     deps += [ | 
 |       "third_party:fontconfig", | 
 |       "third_party:freetype2", | 
 |     ] | 
 |     sources += [ | 
 |       "src/ports/SkFontConfigInterface_direct.cpp", | 
 |       "src/ports/SkFontConfigInterface_direct_factory.cpp", | 
 |       "src/ports/SkFontHost_FreeType.cpp", | 
 |       "src/ports/SkFontHost_FreeType_common.cpp", | 
 |       "src/ports/SkFontMgr_FontConfigInterface.cpp", | 
 |       "src/ports/SkFontMgr_fontconfig.cpp", | 
 |       "src/ports/SkFontMgr_fontconfig_factory.cpp", | 
 |     ] | 
 |   } | 
 |  | 
 |   if (is_mac) { | 
 |     sources += [ | 
 |       "src/ports/SkFontHost_mac.cpp", | 
 |       "src/ports/SkImageEncoder_CG.cpp", | 
 |       "src/ports/SkImageGeneratorCG.cpp", | 
 |     ] | 
 |     libs += [ "ApplicationServices.framework" ] | 
 |   } | 
 |  | 
 |   if (is_fuchsia) { | 
 |     sources += [ "src/ports/SkFontMgr_empty_factory.cpp" ] | 
 |   } | 
 | } | 
 |  | 
 | skia_h_headers = exec_script("gyp/find.py", | 
 |                              [ "*.h" ] + rebase_path(skia_public_includes), | 
 |                              "list lines", | 
 |                              []) - | 
 |                  [ | 
 |                    rebase_path("include/gpu/gl/GrGLConfig_chrome.h"), | 
 |                    rebase_path("include/gpu/vk/GrVkBackendContext.h"), | 
 |                    rebase_path("include/gpu/vk/GrVkDefines.h"), | 
 |                    rebase_path("include/gpu/vk/GrVkInterface.h"), | 
 |                    rebase_path("include/gpu/vk/GrVkTypes.h"), | 
 |                    rebase_path("include/ports/SkFontMgr_fontconfig.h"), | 
 |                  ] | 
 |  | 
 | action("skia.h") { | 
 |   script = "gn/echo_headers.py" | 
 |   args = [ rebase_path("$target_gen_dir/skia.h", root_build_dir) ] + | 
 |          rebase_path(skia_h_headers, root_build_dir) | 
 |   outputs = [ | 
 |     "$target_gen_dir/skia.h", | 
 |   ] | 
 | } | 
 |  | 
 | executable("fiddle") { | 
 |   include_dirs = [ "$target_gen_dir" ] | 
 |   libs = [] | 
 |   if (is_linux) { | 
 |     libs += [ "OSMesa" ] | 
 |   } | 
 |  | 
 |   sources = [ | 
 |     "tools/fiddle/draw.cpp", | 
 |     "tools/fiddle/fiddle_main.cpp", | 
 |   ] | 
 |   deps = [ | 
 |     ":skia", | 
 |     ":skia.h", | 
 |     ":tool_utils", | 
 |   ] | 
 |   testonly = true | 
 | } | 
 |  | 
 | template("test_lib") { | 
 |   config(target_name + "_config") { | 
 |     include_dirs = invoker.public_include_dirs | 
 |   } | 
 |   source_set(target_name) { | 
 |     forward_variables_from(invoker, "*", [ "public_include_dirs" ]) | 
 |     public_configs = [ | 
 |       ":" + target_name + "_config", | 
 |       ":skia_private", | 
 |     ] | 
 |  | 
 |     if (!defined(deps)) { | 
 |       deps = [] | 
 |     } | 
 |     deps += [ ":skia" ] | 
 |     testonly = true | 
 |   } | 
 | } | 
 |  | 
 | test_lib("gpu_tool_utils") { | 
 |   public_include_dirs = [ "tools/gpu" ] | 
 |   sources = [ | 
 |     "tools/gpu/GrContextFactory.cpp", | 
 |     "tools/gpu/GrTest.cpp", | 
 |     "tools/gpu/TestContext.cpp", | 
 |     "tools/gpu/gl/GLTestContext.cpp", | 
 |     "tools/gpu/gl/debug/DebugGLTestContext.cpp", | 
 |     "tools/gpu/gl/debug/GrBufferObj.cpp", | 
 |     "tools/gpu/gl/debug/GrFrameBufferObj.cpp", | 
 |     "tools/gpu/gl/debug/GrProgramObj.cpp", | 
 |     "tools/gpu/gl/debug/GrShaderObj.cpp", | 
 |     "tools/gpu/gl/debug/GrTextureObj.cpp", | 
 |     "tools/gpu/gl/debug/GrTextureUnitObj.cpp", | 
 |     "tools/gpu/gl/null/NullGLTestContext.cpp", | 
 |   ] | 
 |   libs = [] | 
 |  | 
 |   if (is_linux) { | 
 |     sources += [ | 
 |         "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp", | 
 |         "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp", | 
 |     ] | 
 |     libs += [ | 
 |       "GL", | 
 |       "GLU", | 
 |       "X11", | 
 |     ] | 
 |   } else if (is_mac) { | 
 |     sources += [ | 
 |         "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp", | 
 |         "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp", | 
 |     ] | 
 |     libs += [ "OpenGL.framework" ] | 
 |   } | 
 | } | 
 |  | 
 | test_lib("flags") { | 
 |   public_include_dirs = [ "tools/flags" ] | 
 |   sources = [ | 
 |     "tools/flags/SkCommandLineFlags.cpp", | 
 |     "tools/flags/SkCommonFlags.cpp", | 
 |     "tools/flags/SkCommonFlagsConfig.cpp", | 
 |   ] | 
 |   deps = [ | 
 |     ":gpu_tool_utils", | 
 |   ] | 
 | } | 
 |  | 
 | test_lib("tool_utils") { | 
 |   public_include_dirs = [ | 
 |     "tools", | 
 |     "tools/debugger", | 
 |     "tools/timer", | 
 |   ] | 
 |   sources = [ | 
 |     "src/images/SkForceLinking.cpp", | 
 |     "src/utils/SkMultiPictureDocumentReader.cpp",  # TODO(halcanary): move to tools? | 
 |     "tools/CrashHandler.cpp", | 
 |     "tools/ProcStats.cpp", | 
 |     "tools/Resources.cpp", | 
 |     "tools/ThermalManager.cpp", | 
 |     "tools/UrlDataManager.cpp", | 
 |     "tools/debugger/SkDebugCanvas.cpp", | 
 |     "tools/debugger/SkDrawCommand.cpp", | 
 |     "tools/debugger/SkJsonWriteBuffer.cpp", | 
 |     "tools/debugger/SkObjectParser.cpp", | 
 |     "tools/debugger/SkOverdrawMode.cpp", | 
 |     "tools/picture_utils.cpp", | 
 |     "tools/random_parse_path.cpp", | 
 |     "tools/sk_tool_utils.cpp", | 
 |     "tools/sk_tool_utils_font.cpp", | 
 |     "tools/timer/Timer.cpp", | 
 |   ] | 
 |   deps = [ | 
 |     ":flags", | 
 |     "//third_party/libpng", | 
 |   ] | 
 |   public_deps = [ | 
 |     "//third_party/jsoncpp", | 
 |   ] | 
 | } | 
 |  | 
 | gm_sources = exec_script("gyp/find.py", | 
 |                          [ | 
 |                            "*.c*", | 
 |                            rebase_path("gm"), | 
 |                          ], | 
 |                          "list lines", | 
 |                          []) | 
 | test_lib("gm") { | 
 |   public_include_dirs = [ "gm" ] | 
 |   sources = gm_sources | 
 |   deps = [ | 
 |     ":gpu_tool_utils", | 
 |     ":skia", | 
 |     ":tool_utils", | 
 |   ] | 
 | } | 
 |  | 
 | tests_sources = exec_script("gyp/find.py", | 
 |                             [ | 
 |                               "*.c*", | 
 |                               rebase_path("tests"), | 
 |                             ], | 
 |                             "list lines", | 
 |                             []) | 
 |  | 
 | test_lib("tests") { | 
 |   public_include_dirs = [ "tests" ] | 
 |   sources = tests_sources - [ | 
 |               rebase_path("tests/FontMgrAndroidParserTest.cpp"),  # Android only | 
 |               rebase_path("tests/PathOpsSkpClipTest.cpp"),  # alternate main | 
 |               rebase_path("tests/RTConfRegistryTest.cpp"),  # TODO: delete | 
 |               rebase_path("tests/SkSLErrorTest.cpp"),   # TODO: make work | 
 |               rebase_path("tests/SkSLGLSLTest.cpp"),   # TODO: make work | 
 |               rebase_path("tests/SkpSkGrTest.cpp"),  # doesn't compile | 
 |               rebase_path("tests/skia_test.cpp"),  # alternate main | 
 |             ] | 
 |   deps = [ | 
 |     ":flags", | 
 |     ":gpu_tool_utils", | 
 |     ":skia", | 
 |     ":tool_utils", | 
 |     "//third_party/libpng", | 
 |     "//third_party/zlib", | 
 |   ] | 
 | } | 
 |  | 
 | bench_sources = exec_script("gyp/find.py", | 
 |                             [ | 
 |                               "*.c*", | 
 |                               rebase_path("bench"), | 
 |                             ], | 
 |                             "list lines", | 
 |                             []) | 
 |  | 
 | test_lib("bench") { | 
 |   public_include_dirs = [ "bench" ] | 
 |   sources = bench_sources | 
 |   sources -= [ | 
 |     rebase_path("bench/nanobench.cpp"), | 
 |     rebase_path("bench/nanobenchAndroid.cpp"), | 
 |   ] | 
 |   deps = [ | 
 |     ":flags", | 
 |     ":gm", | 
 |     ":gpu_tool_utils", | 
 |     ":skia", | 
 |     ":tool_utils", | 
 |   ] | 
 | } | 
 |  | 
 | if (!is_component_build) {  # Our test tools use many non-SK_API APIs... | 
 |   executable("dm") { | 
 |     sources = [ | 
 |       "dm/DM.cpp", | 
 |       "dm/DMJsonWriter.cpp", | 
 |       "dm/DMSrcSink.cpp", | 
 |     ] | 
 |     include_dirs = [ "tests" ] | 
 |     deps = [ | 
 |       ":flags", | 
 |       ":gm", | 
 |       ":gpu_tool_utils", | 
 |       ":skia", | 
 |       ":tests", | 
 |       ":tool_utils", | 
 |       "//third_party/jsoncpp", | 
 |       "//third_party/libpng", | 
 |     ] | 
 |     testonly = true | 
 |   } | 
 |  | 
 |   executable("monobench") { | 
 |     sources = [ | 
 |       "tools/monobench.cpp", | 
 |     ] | 
 |     deps = [ | 
 |       ":bench", | 
 |       ":skia", | 
 |     ] | 
 |     testonly = true | 
 |   } | 
 |  | 
 |   executable("nanobench") { | 
 |     sources = [ | 
 |       "bench/nanobench.cpp", | 
 |     ] | 
 |     deps = [ | 
 |       ":bench", | 
 |       ":flags", | 
 |       ":gm", | 
 |       ":gpu_tool_utils", | 
 |       ":skia", | 
 |       ":tool_utils", | 
 |       "//third_party/jsoncpp", | 
 |     ] | 
 |     testonly = true | 
 |   } | 
 | } |