1# Copyright 2023 Google LLC. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import("//foundation/graphic/graphic_2d/graphic_config.gni") 6import("../build_overrides/skia.gni") 7import("oh_skia.gni") 8import("platform.gni") 9 10if (!defined(is_skia_standalone)) { 11 is_skia_standalone = true 12} 13 14if (!defined(skia_android_serial)) { 15 skia_android_serial = "" 16} 17 18is_skia_dev_build = is_skia_standalone && !is_official_build 19 20declare_args() { 21 skia_compile_processors = false 22 skia_enable_api_available_macro = true 23 skia_enable_android_utils = is_skia_dev_build 24 skia_enable_skgpu_v1 = true 25 skia_enable_discrete_gpu = true 26 skia_enable_flutter_defines = false 27 skia_enable_fontmgr_empty = false 28 skia_enable_fontmgr_fuchsia = is_fuchsia 29 skia_enable_fontmgr_win = is_win || is_mingw 30 skia_enable_gpu = true 31 skia_enable_pdf = true 32 skia_enable_skottie = !((is_win || is_mingw) && is_component_build) 33 skia_enable_skrive = true 34 skia_enable_sksl = true 35 skia_enable_skvm_jit_when_possible = is_skia_dev_build 36 skia_enable_svg = !is_skia_component_build 37 skia_enable_tools = is_skia_dev_build 38 skia_enable_gpu_debug_layers = is_skia_dev_build && is_debug 39 skia_disable_vma_stl_shared_mutex = false 40 skia_enable_winuwp = false 41 skia_generate_workarounds = false 42 skia_include_multiframe_procs = true 43 skia_lex = false 44 skia_libgifcodec_path = "third_party/externals/libgifcodec" 45 skia_qt_path = getenv("QT_PATH") 46 skia_skqp_global_error_tolerance = 0 47 skia_tools_require_resources = false 48 skia_update_fuchsia_sdk = false 49 skia_use_angle = false 50 skia_use_dawn = false 51 skia_use_direct3d = false 52 skia_use_egl = false 53 skia_use_expat = true 54 skia_use_experimental_xform = false 55 skia_use_ffmpeg = false 56 skia_use_fixed_gamma_text = is_android 57 skia_use_fontconfig = is_linux 58 skia_use_fonthost_mac = is_mac || is_ios 59 skia_use_freetype = is_android || is_fuchsia || is_linux 60 skia_use_harfbuzz = true 61 skia_use_gl = !is_fuchsia 62 skia_use_icu = !is_fuchsia 63 skia_use_libheif = is_skia_dev_build 64 skia_use_libjpeg_turbo_decode = true 65 skia_use_libjpeg_turbo_encode = true 66 skia_use_libpng_decode = true 67 skia_use_libpng_encode = true 68 skia_use_libwebp_decode = true 69 skia_use_libwebp_encode = true 70 skia_use_lua = is_skia_dev_build && !is_ios 71 skia_use_metal = false 72 skia_use_ndk_images = is_android && defined(ndk_api) && ndk_api >= 30 73 skia_use_piex = !(is_win || is_mingw) 74 skia_use_sfml = false 75 skia_use_webgl = false 76 skia_use_wuffs = false 77 skia_use_x11 = is_linux 78 skia_use_xps = true 79 skia_enable_graphite = false 80 skia_use_zlib = true 81 skia_ohos_debug = false 82 skia_use_xeg = true 83 skia_vtune_path = "" 84 85 if (is_ios) { 86 skia_ios_identity = ".*Google.*" 87 skia_ios_profile = "Google Development" 88 } 89 90 if (is_mac) { 91 skia_gl_standard = "gl" 92 } else if (is_ios) { 93 skia_gl_standard = "gles" 94 } else { 95 skia_gl_standard = "" 96 } 97 98 skia_vk_enable_partialrender = false 99 if (is_android) { 100 skia_use_vulkan = defined(ndk_api) && ndk_api >= 24 101 } else if (is_fuchsia) { 102 skia_use_vulkan = true 103 } else { 104 skia_use_vulkan = false 105 if (graphic_2d_feature_enable_vulkan) { 106 skia_use_vulkan = true 107 skia_vk_enable_partialrender = true 108 } 109 } 110 111 skia_build_fuzzers = is_clang && is_linux && target_cpu == "x64" 112 skia_use_libfuzzer_defaults = true 113 114 # TODO: move to ace feature gni when ace feature is ready 115 ace_enable_skia_small_page_texture = true 116} 117 118declare_args() { 119 skia_enable_skunicode = skia_use_icu || skia_use_client_icu 120} 121 122declare_args() { 123 skia_pdf_subset_harfbuzz = skia_use_harfbuzz 124} 125 126declare_args() { 127 skia_compile_sksl_tests = skia_compile_processors 128 skia_enable_fontmgr_android = skia_use_expat && skia_use_freetype 129 if (use_oh_skia) { 130 skia_enable_fontmgr_ohos = true 131 } 132 skia_enable_fontmgr_custom_directory = skia_use_freetype && !is_fuchsia 133 skia_enable_fontmgr_custom_embedded = skia_use_freetype && !is_fuchsia 134 skia_enable_fontmgr_custom_empty = skia_use_freetype 135 skia_enable_fontmgr_fontconfig = skia_use_freetype && skia_use_fontconfig 136 skia_enable_fontmgr_win_gdi = (is_win || is_mingw) && !skia_enable_winuwp 137 skia_enable_fontmgr_FontConfigInterface = 138 skia_use_freetype && skia_use_fontconfig 139 skia_enable_spirv_validation = is_skia_dev_build && is_debug && !skia_use_dawn 140 skia_use_dng_sdk = 141 !is_fuchsia && skia_use_libjpeg_turbo_decode && skia_use_zlib 142 skia_use_libgifcodec = !skia_use_wuffs 143 skia_use_sfntly = skia_use_icu 144 skia_enable_vulkan_debug_layers = skia_enable_gpu_debug_layers 145 skia_enable_direct3d_debug_layer = skia_enable_gpu_debug_layers 146 skia_enable_metal_debug_info = skia_enable_gpu_debug_layers 147 skia_use_vma = skia_use_vulkan 148} 149 150declare_args() { 151 # skia_fontmgr_factory should define SkFontMgr::Factory() 152 if (skia_enable_fontmgr_empty) { 153 skia_fontmgr_factory = ":fontmgr_empty_factory" 154 } else if (is_android && skia_enable_fontmgr_android) { 155 skia_fontmgr_factory = ":fontmgr_android_factory" 156 } else if ((is_win || is_mingw) && skia_enable_fontmgr_win) { 157 skia_fontmgr_factory = ":fontmgr_win_factory" 158 } else if ((is_mac || is_ios) && skia_use_fonthost_mac) { 159 skia_fontmgr_factory = ":fontmgr_mac_ct_factory" 160 } else if (skia_enable_fontmgr_fontconfig) { 161 skia_fontmgr_factory = ":fontmgr_fontconfig_factory" 162 } else if (skia_enable_fontmgr_custom_directory) { 163 skia_fontmgr_factory = ":fontmgr_custom_directory_factory" 164 } else if (skia_enable_fontmgr_custom_embedded) { 165 skia_fontmgr_factory = ":fontmgr_custom_embedded_factory" 166 } else if (skia_enable_fontmgr_custom_empty) { 167 skia_fontmgr_factory = ":fontmgr_custom_empty_factory" 168 } else { 169 #"src/ports/SkFontMgr_FontConfigInterface_factory.cpp" #WontFix 170 #"src/ports/SkFontMgr_win_gdi_factory.cpp" # WontFix 171 skia_fontmgr_factory = ":fontmgr_empty_factory" 172 } 173} 174 175# Our tools require static linking (they use non-exported symbols), and the GPU backend. 176skia_enable_tools = 177 skia_enable_tools && !is_component_build && skia_enable_gpu && !is_arkui_x 178 179# The GPU build requires SkSL 180skia_enable_sksl = skia_enable_sksl || skia_enable_gpu 181 182# Skia's targets may be built inside other gn build systems. 183# Skia builds other project's build targets inside its build. 184# This is easier if the built-in target types remain generic. 185# Place Skia target specific configs in skia_target_default_configs. 186# These will be applied by the 'skia_*' templates. 187# In the Skia build these configs apply many warnings as errors. 188# Other projects may optionally set these configs as they see fit. 189template("component") { 190 _component_mode = "static_library" 191 if (is_arkui_x) { 192 _component_mode = "source_set" 193 } 194 195 if (is_skia_component_build) { 196 _component_mode = "shared_library" 197 } 198 199 target(_component_mode, target_name) { 200 forward_variables_from(invoker, "*") 201 } 202} 203 204set_defaults("component") { 205 if (is_skia_component_build) { 206 configs = [] 207 if (defined(default_compiler_configs)) { 208 configs += default_compiler_configs 209 } 210 if (!is_arkui_x) { 211 complete_static_lib = true 212 } 213 } else { 214 configs = default_shared_library_configs 215 } 216 configs += [ "${skia_root_dir}:skia_wno" ] 217} 218 219template("skia_target") { 220 target(invoker._skia_target_type, target_name) { 221 # set_defaults(invoker._skia_target_type) might not exist or set configs 222 if (!defined(configs)) { 223 configs = [] 224 } 225 226 # Explicit configs instead of set_defaults("skia_target") 227 # Allows template("skia_*") below to avoid the configs dance. 228 if (defined(skia_target_default_configs)) { 229 configs += skia_target_default_configs 230 } 231 232 # "*" clobbers the current scope; append to existing configs 233 forward_variables_from(invoker, "*", [ "configs" ]) 234 if (defined(invoker.configs)) { 235 configs += invoker.configs 236 } 237 } 238} 239 240template("skia_executable") { 241 skia_target(target_name) { 242 assert(!defined(configs), "No set_defaults(skia_target)") 243 _skia_target_type = "executable" 244 forward_variables_from(invoker, "*") 245 } 246} 247template("skia_source_set") { 248 skia_target(target_name) { 249 assert(!defined(configs), "No set_defaults(skia_target)") 250 _skia_target_type = "source_set" 251 forward_variables_from(invoker, "*") 252 } 253} 254template("skia_static_library") { 255 skia_target(target_name) { 256 assert(!defined(configs), "No set_defaults(skia_target)") 257 _skia_target_type = "static_library" 258 forward_variables_from(invoker, "*") 259 } 260} 261template("skia_shared_library") { 262 skia_target(target_name) { 263 assert(!defined(configs), "No set_defaults(skia_target)") 264 _skia_target_type = "shared_library" 265 forward_variables_from(invoker, "*") 266 } 267} 268template("skia_component") { 269 skia_target(target_name) { 270 assert(!defined(configs), "No set_defaults(skia_target)") 271 _skia_target_type = "component" 272 forward_variables_from(invoker, "*") 273 } 274} 275