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