-
Notifications
You must be signed in to change notification settings - Fork 6k
[web] Build multiple CanvasKit variants (using toolchain_args) #38448
Conversation
|
The straightforward, though more expensive, way to accomplish this in our current build system, as well as with the We haven't done this in the Flutter engine build, yet, but the idiomatic way to do this in GN without doing two completely separate builds is (2). AFAIK it isn't a big concern, but we can take steps to alleviate confusion about the contents of |
|
@zanderso thanks for the suggestion! I updated the PR to use I haven't looked at the visibility thing yet, and I'm not familiar with it. I'll read about it and see how it can be used in this PR. |
zanderso
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is roughly what I was thinking. Let's talk more next year =)
web_sdk/BUILD.gn
Outdated
|
|
||
| if (build_canvaskit) { | ||
| deps += [ "//third_party/skia/modules/canvaskit" ] | ||
| deps += |
There was a problem hiding this comment.
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.
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
third_party/canvaskit/BUILD.gn
Outdated
| @@ -0,0 +1,36 @@ | |||
| # Copyright 2022 The Flutter Authors. All rights reserved. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # Copyright 2022 The Flutter Authors. All rights reserved. | |
| # Copyright 2013 The Flutter Authors. All rights reserved. |
zanderso
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
DEPS
Outdated
|
|
||
| deps = { | ||
| 'src': 'https://github.com/flutter/buildroot.git' + '@' + 'b2ab6e1908b3eb268d2a2cab1ec5b63f38e1bc11', | ||
| 'src': 'https://github.com/flutter/buildroot.git' + '@' + 'fbaac6aad455f77ccafc4d3f15bad31856fbcb5b', |
There was a problem hiding this comment.
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 =)
There was a problem hiding this comment.
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.
harryterkelsen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I'm not sure if this is the right way to do it, but I wanted to start the conversation and iterate based on feedback from people who know more about the gn world than I do
The end goal here is to be able to build multiple CanvasKit variants for Flutter Web (e.g. one light, stripped down variant for Chromium; and one for other browsers).
I've found multiple ways to do this:
1. Python or shell script
The script would
cdinto//third_party/skia/modules/canvaskitand build CanvasKit in there (similar to how the CanvasKit team does it via compile.sh). The script has full control over the flags it passes to the CanvasKit build.The script can then be called from
web_sdk/BUILD.gnusing anaction(target_name). It can be called multiple times, one for each variant we need.Pros/cons:
./bin/syncinside//third_party/skiato install all its deps (equivalent ofgclient sync).2. Using
toolchain_argsToday, we add CanvasKit as a
depinweb_sdk/BUILD.gnand we rely on the global gn args set bytools/gnto configure the CanvasKit/Skia build. This means we can only have a single variant of CanvasKit.In order to be able to have multiple variants of CanvasKit with different flags, we could use a different
toolchainwith differenttoolchain_args. To my (limited) knowledge,toolchain_argscan override the global gn args.This is the approach I'm taking in this PR.
Pros/cons:
tools/gn.args.gn.3. Separate
gnfor building CanvasKit aloneBypass
tools/gnand create acanvaskittarget that can be built alone without all the other ceremony that Flutter does. This newgncan be called multiple times to build multiple variants of CanvasKit with different flags. It can also be pointed to anoutfolder that makes sense (e.g.out/wasm_release/canvaskit1) so that it looks like part of thewasm_releasebuild (and potentially easier for the flutter tool to deal with).This is the approach I'm taking in this PR.Pros/cons:
Might be the idiomatic way of doing things in gn?gnalong with the usual invocations oftools/gn(this tool would probably befeltfor the flutter web engine).A full flutter web engine build would like:
tools/gn --webto build the Flutter Web Engine atout/wasm_release.third_party/canvaskit/gnto build a full variant of CanvasKit atout/wasm_release/canvaskit.third_party/canvaskit/gn --no-icu --no-decodersto build a light variant of CanvasKit atout/wasm_release/canvaskit_light.Depends on flutter/buildroot#663
Depends on https://skia-review.googlesource.com/c/skia/+/616799
Fixes flutter/flutter#118746