Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 11 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
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ allowed_hosts = [
]

deps = {
'src': 'https://github.com/flutter/buildroot.git' + '@' + 'b2ab6e1908b3eb268d2a2cab1ec5b63f38e1bc11',
'src': 'https://github.com/flutter/buildroot.git' + '@' + 'fbaac6aad455f77ccafc4d3f15bad31856fbcb5b',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Double check that this won't revert someone else's buildroot roll =)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the reminder! Yes, this needs to change to whatever SHA is produced once the buildroot PR lands.


# Fuchsia compatibility
#
Expand Down
2 changes: 2 additions & 0 deletions lib/web_ui/dev/steps/compile_tests_step.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ Future<void> copyCanvasKitFiles({bool useLocalCanvasKit = false}) async {
// If CanvasKit has been built locally, use that instead of the CIPD version.
final io.File localCanvasKitWasm = io.File(pathlib.join(
environment.wasmReleaseOutDir.path,
'canvaskit',
'canvaskit.wasm',
));
final bool builtLocalCanvasKit = localCanvasKitWasm.existsSync();
Expand All @@ -178,6 +179,7 @@ Future<void> copyCanvasKitFiles({bool useLocalCanvasKit = false}) async {
localCanvasKitWasm,
io.File(pathlib.join(
environment.wasmReleaseOutDir.path,
'canvaskit',
'canvaskit.js',
)),
];
Expand Down
36 changes: 36 additions & 0 deletions third_party/canvaskit/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2022 The Flutter Authors. All rights reserved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Copyright 2022 The Flutter Authors. All rights reserved.
# Copyright 2013 The Flutter Authors. All rights reserved.

# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/toolchain/wasm.gni")

# This toolchain is only to be used by the canvaskit group below.
wasm_toolchain("canvaskit") {
# Prevent accidental use of this toolchain.
assert(target_name == "canvaskit", "Only :canvaskit can use this toolchain.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think target_name here is just the string passed to the wasm_toolchain template up on line 8, so this assert is not terribly helpful. I'd suggest removing it.

I've poked around the GN docs and source. It looks like it is not possible to set the visibility of a toolchain, or of a template. Also it looks like the label of the target that the toolchain is building is only available in the tool() definitions inside the toolchain, and only as string replacements {{...}}, not as variables that an assert could reference. So I think we're a little stuck, and that the comments that are already here are the best that can be done.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think target_name here is just the string passed to the wasm_toolchain template up on line 8, so this assert is not terribly helpful. I'd suggest removing it.

Oh thanks for pointing this out. I'll remove the assert. I also think I should rename this to canvaskit_toolchain so it doesn't get confused with the canvaskit group.

I've poked around the GN docs and source. It looks like it is not possible to set the visibility of a toolchain, or of a template.

I did the same and even tried it (in case it was an oversight in the docs) but gn yelled at me lol. That's when I changed it to an assert.

So I think we're a little stuck, and that the comments that are already here are the best that can be done.

😞

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ugh.. if I change this to wasm_toolchain("canvaskit_toolchain") { the output's subfolder also changes to out/wasm_release/canvaskit_toolchain.

@zanderso Do you know how I can control the output directory for the toolchain? I couldn't find any documentation on it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No, I don't know of any way to override the name there.

extra_toolchain_args = {
skia_use_icu = true
skia_use_client_icu = false
}
}

group("canvaskit") {
visibility = [ "//flutter/web_sdk:*" ]
public_deps = [ "//third_party/skia/modules/canvaskit(:canvaskit)" ]
}

# This toolchain is only to be used by the canvaskit_lite group below.
wasm_toolchain("canvaskit_lite") {
# Prevent accidental use of this toolchain.
assert(target_name == "canvaskit_lite",
"Only :canvaskit_lite can use this toolchain.")
extra_toolchain_args = {
skia_use_icu = false
skia_use_client_icu = true
}
}

group("canvaskit_lite") {
visibility = [ "//flutter/web_sdk:*" ]
public_deps = [ "//third_party/skia/modules/canvaskit(:canvaskit_lite)" ]
}
4 changes: 3 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 Expand Up @@ -650,12 +649,15 @@ def to_gn_wasm_args(args, gn_args):
gn_args['skia_canvaskit_enable_webgpu'] = False
is_profile_build = args.runtime_mode == 'profile' or args.runtime_mode == 'debug'
gn_args['skia_canvaskit_profile_build'] = is_profile_build
gn_args['skia_icu_bidi_dir'] = '//third_party/icu'
gn_args['flutter_prebuilt_dart_sdk'] = True

# TODO(jacksongardner): Make this based off of the input argument rather
# than forced to true, once the recipes are updated.
# https://github.com/flutter/flutter/issues/113303
gn_args['build_canvaskit'] = True
# TODO(mdebbar): Read this from an input argument.
Comment thread
mdebbar marked this conversation as resolved.
gn_args['build_canvaskit_lite'] = False
gn_args['flutter_build_web_sdk'] = True


Expand Down
22 changes: 19 additions & 3 deletions web_sdk/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import("//third_party/dart/build/dart/dart_action.gni")

declare_args() {
build_canvaskit = false
build_canvaskit_lite = false
archive_flutter_web_sdk = true
}

Expand Down Expand Up @@ -559,7 +560,10 @@ if (!is_fuchsia) {
] + web_engine_libraries

if (build_canvaskit) {
deps += [ "//third_party/skia/modules/canvaskit" ]
deps += [ "//flutter/third_party/canvaskit:canvaskit" ]
}
if (build_canvaskit_lite) {
deps += [ "//flutter/third_party/canvaskit:canvaskit_lite" ]
}

# flutter_ddc_modules
Expand Down Expand Up @@ -602,15 +606,27 @@ 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"
},
]
}
if (build_canvaskit_lite) {
tmp_files += [
{
source = rebase_path("$root_out_dir/canvaskit_lite/canvaskit.js")
destination = "canvaskit_lite/canvaskit.js"
},
{
source = rebase_path("$root_out_dir/canvaskit_lite/canvaskit.wasm")
destination = "canvaskit_lite/canvaskit.wasm"
},
]
}
files = tmp_files
}
}