xref: /aosp_15_r20/external/skia/gn/toolchain/wasm.gni (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1# Copyright (c) 2022 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("../../modules/canvaskit/canvaskit.gni")
6
7# Defines the configuration of emscripten for building WASM targets.
8import("../skia.gni")
9declare_args() {
10  # The location of an activated emsdk. We default to the one brought in by
11  # DEPS and bin/activate-emsdk.
12  skia_emsdk_dir = rebase_path("../../third_party/externals/emsdk")
13}
14
15# Defines a WASM library target.
16template("skia_wasm_lib") {
17  _vars_to_forward = [
18    "cflags",
19    "ldflags",
20    "defines",
21    "deps",
22    "includes",
23    "sources",
24    "include_dirs",
25    "public_configs",
26    "testonly",
27    "visibility",
28  ]
29
30  _lib_name = target_name
31
32  executable("${_lib_name}_js") {
33    forward_variables_from(invoker, _vars_to_forward)
34    output_extension = "js"
35    output_name = "${_lib_name}"
36  }
37
38  group("$_lib_name") {
39    public_deps = [ ":${_lib_name}_js" ]
40  }
41}
42
43wasm_defines = [
44  "SKNX_NO_SIMD",
45  "SK_FORCE_8_BYTE_ALIGNMENT",
46]
47
48if (!is_debug && !skia_canvaskit_force_tracing) {
49  wasm_defines += [ "SK_DISABLE_TRACING" ]
50}
51
52if (skia_enable_ganesh) {
53  wasm_defines += [ "SK_DISABLE_LEGACY_SHADERCONTEXT" ]
54}
55
56if (!skia_canvaskit_enable_effects_deserialization ||
57    !skia_canvaskit_enable_skp_serialization) {
58  wasm_defines += [ "SK_DISABLE_EFFECT_DESERIALIZATION" ]
59}
60
61if (!skia_canvaskit_enable_alias_font) {
62  wasm_defines += [ "CANVASKIT_NO_ALIAS_FONT" ]
63}
64