• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 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(ios_use_simulator)) {
14  ios_use_simulator =
15    target_os == "ios" && (target_cpu == "x86" || target_cpu == "x64")
16}
17is_skia_dev_build = is_skia_standalone && !is_official_build
18
19declare_args() {
20  skia_android_serial = ""
21  skia_compile_modules = false
22  skia_compile_sksl_tests = false
23  skia_dwritecore_sdk = ""
24  skia_enable_api_available_macro = true
25  skia_enable_android_utils = is_skia_dev_build
26  skia_enable_discrete_gpu = true
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_debug_layers = is_skia_dev_build && is_debug
31  skia_enable_optimize_size = false
32  skia_enable_pdf = !is_wasm
33  skia_enable_precompile = true
34  skia_enable_sksl = true
35  skia_enable_skottie = !is_component_build
36  skia_enable_svg = !is_skia_component_build
37  skia_enable_tools = is_skia_dev_build
38  skia_disable_tracing = is_official_build
39  skia_enable_vello_shaders = false
40  skia_disable_vma_stl_shared_mutex = false
41  skia_enable_winuwp = false
42  skia_generate_workarounds = false
43  skia_include_multiframe_procs = true
44  skia_lex = false
45  skia_print_sksl_shaders = false
46  skia_print_native_shaders = false
47  skia_tools_require_resources = false
48  skia_update_fuchsia_sdk = false
49  skia_use_angle = false
50  skia_use_client_icu = false
51  skia_use_crabbyavif = false
52  skia_use_dawn = false
53  skia_use_direct3d = false
54  skia_use_egl = false
55  skia_use_epoxy_egl = false
56  skia_use_expat = !is_wasm
57  skia_use_ffmpeg = false
58  skia_use_fixed_gamma_text = is_android
59  skia_use_fontconfig = is_linux
60  skia_use_fontations = false
61  skia_use_fonthost_mac = is_mac || is_ios
62  skia_use_freetype = is_android || is_fuchsia || is_linux || is_wasm
63  skia_use_harfbuzz = true
64  skia_use_gl = !is_fuchsia
65  skia_use_icu = !is_fuchsia
66  skia_use_icu4x = false
67  skia_use_jpeg_gainmaps = is_skia_dev_build
68  skia_use_libavif = false
69  skia_use_libgrapheme = false
70  skia_use_libheif = is_skia_dev_build
71  skia_use_libjpeg_turbo_decode = true
72  skia_use_libjpeg_turbo_encode = true
73  skia_use_no_jpeg_encode = false
74  skia_use_libjxl_decode = false
75  skia_use_libpng_decode = true
76  skia_use_libpng_encode = true
77  skia_use_no_png_encode = false
78  skia_use_libwebp_decode = true
79  skia_use_libwebp_encode = !is_wasm
80  skia_use_no_webp_encode = false
81  skia_use_lua = is_skia_dev_build && !is_ios
82  skia_use_metal = false
83  skia_use_ndk_images = is_android && defined(ndk_api) && ndk_api >= 30
84  skia_use_perfetto = is_linux || is_mac || is_android
85
86  # Currently only supported in Android framework
87  skia_android_framework_use_perfetto = false
88  skia_use_piex = !(is_win || is_mingw) && !is_wasm
89  skia_use_rust_png_decode = false
90  skia_use_rust_png_encode = false
91  skia_use_sfml = false
92  skia_use_webgl = is_wasm
93  skia_use_webgpu = is_wasm
94  skia_use_wuffs = true
95  skia_use_x11 = is_linux
96  skia_use_xps = true
97
98  # Use the safe mode for libcxx
99  # See: https://libcxx.llvm.org/UsingLibcxx.html#enabling-the-safe-libc-mode
100  skia_use_safe_libcxx = false
101
102  # deprecated, we will eventually use just skia_enable_ganesh
103  skia_enable_gpu = true
104  skia_enable_graphite = false
105  skia_use_zlib = true
106  skia_ohos_debug = false
107  skia_enable_standard_fonts = true
108
109  if (is_ios) {
110    skia_ios_identity = ".*Google.*"
111    skia_ios_profile = "Google Development"
112
113    # should only code sign when running on a device, not the simulator
114    skia_ios_use_signing = !ios_use_simulator
115  }
116
117  skia_build_rust_targets = false
118}
119
120declare_args() {
121  skia_enable_ganesh = skia_enable_gpu
122}
123
124declare_args() {
125  gm_test_enable_font = true
126}
127
128declare_args() {
129  # This is now a no-op. TODO(kjlubick) remove after Flutter stops using this.
130  skia_enable_sksl_tracing = false
131}
132
133declare_args() {
134  if (is_mac) {
135    skia_gl_standard = "gl"
136  } else if (is_ios) {
137    skia_gl_standard = "gles"
138  } else if (is_wasm && skia_enable_ganesh) {
139    skia_gl_standard = "webgl"
140  } else {
141    skia_gl_standard = ""
142  }
143
144  skia_vk_enable_partialrender = false
145  if (is_fuchsia) {
146    skia_use_vulkan = true
147  } else {
148    skia_use_vulkan = false
149    if (skia_feature_product == "phone" || skia_feature_product == "pc" ||
150        skia_feature_product == "tablet" ||
151        skia_feature_product == "wearable" || skia_feature_use_vulkan) {
152      skia_use_vulkan = true
153      skia_vk_enable_partialrender = true
154    }
155  }
156
157  skia_build_fuzzers = is_clang && is_linux && target_cpu == "x64"
158  skia_use_libfuzzer_defaults = true
159
160  # TODO: move to ace feature gni when ace feature is ready
161  ace_enable_skia_small_page_texture = true
162}
163
164declare_args() {
165  skia_enable_skunicode = skia_use_icu || skia_use_client_icu ||
166                          skia_use_libgrapheme || skia_use_icu4x
167}
168
169if (skia_use_angle && skia_gl_standard != "gles") {
170  skia_gl_standard = ""
171}
172
173declare_args() {
174  skia_pdf_subset_harfbuzz = skia_use_harfbuzz
175}
176
177declare_args() {
178  skia_enable_fontmgr_android = skia_use_expat && skia_use_freetype
179  skia_enable_fontmgr_android_ndk = is_android && skia_use_freetype
180  skia_enable_fontmgr_ohos = false
181  if (use_oh_skia) {
182    skia_enable_fontmgr_ohos = true
183  }
184  skia_enable_fontmgr_custom_directory =
185      skia_use_freetype && !is_fuchsia && !is_wasm
186  skia_enable_fontmgr_custom_embedded = skia_use_freetype && !is_fuchsia
187  skia_enable_fontmgr_custom_empty = skia_use_freetype && !is_wasm
188  skia_enable_fontmgr_fontconfig = skia_use_freetype && skia_use_fontconfig
189  skia_enable_fontmgr_win_gdi = (is_win || is_mingw) && !skia_enable_winuwp
190  skia_enable_fontmgr_FontConfigInterface =
191      skia_use_freetype && skia_use_fontconfig
192  skia_enable_spirv_validation = is_skia_dev_build && is_debug && !skia_use_dawn
193  skia_use_dng_sdk =
194      !is_fuchsia && !is_wasm && skia_use_libjpeg_turbo_decode && skia_use_zlib
195  skia_enable_vulkan_debug_layers = skia_enable_gpu_debug_layers
196  skia_enable_direct3d_debug_layer = skia_enable_gpu_debug_layers
197  skia_enable_metal_debug_info = skia_enable_gpu_debug_layers
198  skia_use_vma = skia_use_vulkan
199  skia_vulkan_memory_allocator_dir =
200      "${skia_third_party_dir}/externals/vulkanmemoryallocator"
201  skia_build_for_debugger = false
202
203  # icu_bidi sources
204  skia_icu_bidi_third_party_dir = "${skia_third_party_dir}/icu_bidi"
205
206  # libgrapheme sources
207  skia_libgrapheme_third_party_dir = "${skia_third_party_dir}/libgrapheme"
208}
209
210declare_args() {
211  # skia_fontmgr_factory should define SkFontMgr::Factory()
212  if (skia_enable_fontmgr_empty) {
213    skia_fontmgr_factory = ":fontmgr_empty_factory"
214  } else if (is_android && skia_enable_fontmgr_android) {
215    skia_fontmgr_factory = ":fontmgr_android_factory"
216  } else if ((is_win || is_mingw) && skia_enable_fontmgr_win) {
217    skia_fontmgr_factory = ":fontmgr_win_factory"
218  } else if ((is_mac || is_ios) && skia_use_fonthost_mac) {
219    skia_fontmgr_factory = ":fontmgr_mac_ct_factory"
220  } else if (skia_enable_fontmgr_fontconfig && !use_oh_skia) {
221    skia_fontmgr_factory = ":fontmgr_fontconfig_factory"
222  } else if (skia_enable_fontmgr_custom_directory) {
223    skia_fontmgr_factory = ":fontmgr_custom_directory_factory"
224  } else if (skia_enable_fontmgr_custom_embedded) {
225    skia_fontmgr_factory = ":fontmgr_custom_embedded_factory"
226  } else if (skia_enable_fontmgr_custom_empty) {
227    skia_fontmgr_factory = ":fontmgr_custom_empty_factory"
228  } else {
229    #"src/ports/SkFontMgr_FontConfigInterface_factory.cpp" #WontFix
230    #"src/ports/SkFontMgr_win_gdi_factory.cpp" # WontFix
231    skia_fontmgr_factory = ":fontmgr_empty_factory"
232  }
233}
234
235assert(!skia_use_dawn || skia_enable_graphite)  # Dawn is Graphite-only
236
237# Our tools require static linking (they use non-exported symbols), and the Ganesh backend.
238skia_enable_tools = true # TODO: 133.`is_component_build` is false (//build/config/BUILDCONFIG.gn is set to false and Skia's BUILDCONFIG.gn is not used)
239    #skia_enable_tools && !is_component_build && skia_enable_ganesh
240skia_enable_tools =
241    skia_enable_tools && !is_arkui_x
242
243if (skia_enable_optimize_size) {
244  assert(
245      !is_debug,
246      "Must set is_debug to false for skia_enable_optimize_size to do anything. If you want to build with debug mode and the correct define, add extra_cflags=['-DSK_ENABLE_OPTIMIZE_SIZE'] to your GN args.")
247}
248
249# Current Perfetto integrations are mutually exclusive
250assert(!skia_use_perfetto || !skia_android_framework_use_perfetto)
251
252# Skia's targets may be built inside other gn build systems.
253# Skia builds other project's build targets inside its build.
254# This is easier if the built-in target types remain generic.
255# Place Skia target specific configs in skia_target_default_configs.
256# These will be applied by the 'skia_*' templates.
257# In the Skia build these configs apply many warnings as errors.
258# Other projects may optionally set these configs as they see fit.
259template("component") {
260  _component_mode = "static_library"
261  if (is_arkui_x) {
262    _component_mode = "source_set"
263  }
264
265  if (is_skia_component_build) {
266    _component_mode = "shared_library"
267  }
268
269  target(_component_mode, target_name) {
270    forward_variables_from(invoker, "*")
271  }
272}
273
274set_defaults("component") {
275  if (is_skia_component_build) {
276    configs = []
277    if (defined(default_compiler_configs)) {
278      configs += default_compiler_configs
279    }
280    if (!is_arkui_x) {
281      complete_static_lib = true
282    }
283  } else {
284    configs = default_shared_library_configs
285  }
286  configs += [ "${skia_root_dir}:skia_wno" ]
287}
288
289template("skia_target") {
290  target(invoker._skia_target_type, target_name) {
291    # set_defaults(invoker._skia_target_type) might not exist or set configs
292    if (!defined(configs)) {
293      configs = []
294    }
295
296    # Explicit configs instead of set_defaults("skia_target")
297    # Allows template("skia_*") below to avoid the configs dance.
298    if (defined(skia_target_default_configs)) {
299      configs += skia_target_default_configs
300    }
301
302    # "*" clobbers the current scope; append to existing configs
303    forward_variables_from(invoker, "*", [ "configs" ])
304    if (defined(invoker.configs)) {
305      configs += invoker.configs
306    }
307  }
308}
309
310template("skia_executable") {
311  skia_target(target_name) {
312    assert(!defined(configs), "No set_defaults(skia_target)")
313    _skia_target_type = "executable"
314    forward_variables_from(invoker, "*")
315  }
316}
317template("skia_source_set") {
318  skia_target(target_name) {
319    assert(!defined(configs), "No set_defaults(skia_target)")
320    _skia_target_type = "source_set"
321    forward_variables_from(invoker, "*")
322  }
323}
324template("skia_static_library") {
325  skia_target(target_name) {
326    assert(!defined(configs), "No set_defaults(skia_target)")
327    _skia_target_type = "static_library"
328    forward_variables_from(invoker, "*")
329  }
330}
331template("skia_shared_library") {
332  skia_target(target_name) {
333    assert(!defined(configs), "No set_defaults(skia_target)")
334    _skia_target_type = "shared_library"
335    forward_variables_from(invoker, "*")
336  }
337}
338template("skia_component") {
339  skia_target(target_name) {
340    assert(!defined(configs), "No set_defaults(skia_target)")
341    _skia_target_type = "component"
342    forward_variables_from(invoker, "*")
343  }
344}
345