Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[web] Build multiple CanvasKit variants (using toolchain_args) #38448

Merged
merged 21 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tools/gn
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@ def to_gn_wasm_args(args, gn_args):
gn_args['skia_gl_standard'] = 'webgl'
gn_args['skia_enable_gpu'] = True
gn_args['skia_enable_sksl_tracing'] = False
gn_args['skia_use_icu'] = True
gn_args['icu_use_data_file'] = False
gn_args['skia_use_freetype'] = True
gn_args['skia_use_harfbuzz'] = True
Expand Down
13 changes: 13 additions & 0 deletions wasm/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# //flutter/BUILD.gn pulls in Flutter SDK dependencies which will crash
# when the target CPU is WASM.

import("//build/toolchain/wasm.gni")
import("//flutter/common/config.gni")

# This is the default target when building when the target CPU is WASM.
Expand All @@ -14,3 +15,15 @@ group("wasm") {
deps = [ "//flutter/web_sdk" ]
}
}

wasm_toolchain("canvaskit") {
extra_toolchain_args = {
skia_use_icu = true
}
}

wasm_toolchain("canvaskit_lite") {
extra_toolchain_args = {
skia_use_icu = false
}
}
7 changes: 4 additions & 3 deletions web_sdk/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,8 @@ if (!is_fuchsia) {
] + web_engine_libraries

if (build_canvaskit) {
deps += [ "//third_party/skia/modules/canvaskit" ]
deps +=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would need to investigate more to make specific suggestions about how to guard the canvaskit toolchain definitions with visibility annotations or asserts, but one thing that will probably help in any case is putting the targets you want to build with those toolchains right next to the toolchain definitions, with comments saying not to use those toolchains for anything else.

So here, you'd depend on a group target, where the group has a public_deps on //third_party/skia/..., and the group target is in the same file as the toolchain definitions.

[ "//third_party/skia/modules/canvaskit(//flutter/wasm:canvaskit)" ]
}

# flutter_ddc_modules
Expand Down Expand Up @@ -602,11 +603,11 @@ if (!is_fuchsia) {
if (build_canvaskit) {
tmp_files += [
{
source = rebase_path("$root_out_dir/canvaskit.js")
source = rebase_path("$root_out_dir/canvaskit/canvaskit.js")
destination = "canvaskit/canvaskit.js"
},
{
source = rebase_path("$root_out_dir/canvaskit.wasm")
source = rebase_path("$root_out_dir/canvaskit/canvaskit.wasm")
destination = "canvaskit/canvaskit.wasm"
},
]
Expand Down