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_vtune_path = "" 82 83 if (is_ios) { 84 skia_ios_identity = ".*Google.*" 85 skia_ios_profile = "Google Development" 86 } 87 88 if (is_mac) { 89 skia_gl_standard = "gl" 90 } else if (is_ios) { 91 skia_gl_standard = "gles" 92 } else { 93 skia_gl_standard = "" 94 } 95 96 if (is_android) { 97 skia_use_vulkan = defined(ndk_api) && ndk_api >= 24 98 } else if (is_fuchsia) { 99 skia_use_vulkan = true 100 } else { 101 skia_use_vulkan = false 102 } 103 104 skia_build_fuzzers = is_clang && is_linux && target_cpu == "x64" 105 skia_use_libfuzzer_defaults = true 106 107 # TODO: move to ace feature gni when ace feature is ready 108 ace_enable_skia_small_page_texture = true 109} 110 111declare_args() { 112 skia_pdf_subset_harfbuzz = skia_use_harfbuzz 113} 114 115declare_args() { 116 skia_compile_sksl_tests = skia_compile_processors 117 skia_enable_fontmgr_android = skia_use_expat && skia_use_freetype 118 if (use_oh_skia) { 119 skia_enable_fontmgr_ohos = true 120 } 121 skia_enable_fontmgr_custom_directory = skia_use_freetype && !is_fuchsia 122 skia_enable_fontmgr_custom_embedded = skia_use_freetype && !is_fuchsia 123 skia_enable_fontmgr_custom_empty = skia_use_freetype 124 skia_enable_fontmgr_fontconfig = skia_use_freetype && skia_use_fontconfig 125 skia_enable_fontmgr_win_gdi = (is_win || is_mingw) && !skia_enable_winuwp 126 skia_enable_fontmgr_FontConfigInterface = 127 skia_use_freetype && skia_use_fontconfig 128 skia_enable_spirv_validation = is_skia_dev_build && is_debug && !skia_use_dawn 129 skia_use_dng_sdk = 130 !is_fuchsia && skia_use_libjpeg_turbo_decode && skia_use_zlib 131 skia_use_libgifcodec = !skia_use_wuffs 132 skia_use_sfntly = skia_use_icu 133 skia_enable_vulkan_debug_layers = skia_enable_gpu_debug_layers 134 skia_enable_direct3d_debug_layer = skia_enable_gpu_debug_layers 135 skia_enable_metal_debug_info = skia_enable_gpu_debug_layers 136 skia_use_vma = skia_use_vulkan 137} 138 139declare_args() { 140 # skia_fontmgr_factory should define SkFontMgr::Factory() 141 if (skia_enable_fontmgr_empty) { 142 skia_fontmgr_factory = ":fontmgr_empty_factory" 143 } else if (is_android && skia_enable_fontmgr_android) { 144 skia_fontmgr_factory = ":fontmgr_android_factory" 145 } else if ((is_win || is_mingw) && skia_enable_fontmgr_win) { 146 skia_fontmgr_factory = ":fontmgr_win_factory" 147 } else if ((is_mac || is_ios) && skia_use_fonthost_mac) { 148 skia_fontmgr_factory = ":fontmgr_mac_ct_factory" 149 } else if (skia_enable_fontmgr_fontconfig) { 150 skia_fontmgr_factory = ":fontmgr_fontconfig_factory" 151 } else if (skia_enable_fontmgr_custom_directory) { 152 skia_fontmgr_factory = ":fontmgr_custom_directory_factory" 153 } else if (skia_enable_fontmgr_custom_embedded) { 154 skia_fontmgr_factory = ":fontmgr_custom_embedded_factory" 155 } else if (skia_enable_fontmgr_custom_empty) { 156 skia_fontmgr_factory = ":fontmgr_custom_empty_factory" 157 } else { 158 #"src/ports/SkFontMgr_FontConfigInterface_factory.cpp" #WontFix 159 #"src/ports/SkFontMgr_win_gdi_factory.cpp" # WontFix 160 skia_fontmgr_factory = ":fontmgr_empty_factory" 161 } 162} 163 164# Our tools require static linking (they use non-exported symbols), and the GPU backend. 165skia_enable_tools = 166 skia_enable_tools && !is_component_build && skia_enable_gpu && !is_arkui_x 167 168# The GPU build requires SkSL 169skia_enable_sksl = skia_enable_sksl || skia_enable_gpu 170 171# Skia's targets may be built inside other gn build systems. 172# Skia builds other project's build targets inside its build. 173# This is easier if the built-in target types remain generic. 174# Place Skia target specific configs in skia_target_default_configs. 175# These will be applied by the 'skia_*' templates. 176# In the Skia build these configs apply many warnings as errors. 177# Other projects may optionally set these configs as they see fit. 178template("component") { 179 _component_mode = "static_library" 180 if (is_arkui_x) { 181 _component_mode = "source_set" 182 } 183 184 if (is_skia_component_build) { 185 _component_mode = "shared_library" 186 } 187 188 target(_component_mode, target_name) { 189 forward_variables_from(invoker, "*") 190 } 191} 192 193set_defaults("component") { 194 if (is_skia_component_build) { 195 configs = [] 196 if (defined(default_compiler_configs)) { 197 configs += default_compiler_configs 198 } 199 if (!is_arkui_x) { 200 complete_static_lib = true 201 } 202 } else { 203 configs = default_shared_library_configs 204 } 205 configs += [ "${skia_root_dir}:skia_wno" ] 206} 207 208template("skia_target") { 209 target(invoker._skia_target_type, target_name) { 210 # set_defaults(invoker._skia_target_type) might not exist or set configs 211 if (!defined(configs)) { 212 configs = [] 213 } 214 215 # Explicit configs instead of set_defaults("skia_target") 216 # Allows template("skia_*") below to avoid the configs dance. 217 if (defined(skia_target_default_configs)) { 218 configs += skia_target_default_configs 219 } 220 221 # "*" clobbers the current scope; append to existing configs 222 forward_variables_from(invoker, "*", [ "configs" ]) 223 if (defined(invoker.configs)) { 224 configs += invoker.configs 225 } 226 } 227} 228 229template("skia_executable") { 230 skia_target(target_name) { 231 assert(!defined(configs), "No set_defaults(skia_target)") 232 _skia_target_type = "executable" 233 forward_variables_from(invoker, "*") 234 } 235} 236template("skia_source_set") { 237 skia_target(target_name) { 238 assert(!defined(configs), "No set_defaults(skia_target)") 239 _skia_target_type = "source_set" 240 forward_variables_from(invoker, "*") 241 } 242} 243template("skia_static_library") { 244 skia_target(target_name) { 245 assert(!defined(configs), "No set_defaults(skia_target)") 246 _skia_target_type = "static_library" 247 forward_variables_from(invoker, "*") 248 } 249} 250template("skia_shared_library") { 251 skia_target(target_name) { 252 assert(!defined(configs), "No set_defaults(skia_target)") 253 _skia_target_type = "shared_library" 254 forward_variables_from(invoker, "*") 255 } 256} 257template("skia_component") { 258 skia_target(target_name) { 259 assert(!defined(configs), "No set_defaults(skia_target)") 260 _skia_target_type = "component" 261 forward_variables_from(invoker, "*") 262 } 263} 264