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