-
Notifications
You must be signed in to change notification settings - Fork 6k
Conversation
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. |
5c53a9c
to
543b02d
Compare
lib/web_ui/dev/build.dart
Outdated
} | ||
print('Running gn...'); | ||
const List<String> gnArgs = <String>[ | ||
'--wasm', |
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.
Now that this target is going to be used for all of flutter web (not just for wasm), does it make sense to change the name to flutter_web
or similar?
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 think there was some extensive discussion about this with the rest of the engine team, I'd like to ask @hterkelsen what their concerns were and why they landed on this. In any case, the --wasm
can't be immediately deleted because the recipes use it, but if we are going to migrate to some different flag I should at least add it as an option here so the recipes can switch to it.
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.
My concern with using --wasm
to mean "build the Flutter Web SDK" is that the Flutter Web SDK bits aren't WASM (for now, anyway). The fact that we can invoke kernel compiler when using the WASM toolchain seems to just be a lucky coincidence. I think we should have a --web
flag in GN which sets the default CPU to WASM and builds CanvasKit and the Flutter Web SDK.
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.
That makes sense. I think I get what you're going for. Let me make some changes and see what I can do.
…he web sdk artifact.
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.
DBC
@@ -0,0 +1,24 @@ | |||
import("//flutter/common/config.gni") |
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.
This file needs a copyright header
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.
More DBC
I'm skeptical that creating the dart_sdk
subdirectory that contains only the BUILD.gn
file is needed. What's the reasoning behind that?
@@ -12,6 +12,8 @@ import("//third_party/dart/build/dart/copy_tree.gni") | |||
|
|||
# Whether to build the dartdevc sdk, libraries, and source files | |||
# required for the flutter web sdk. | |||
# TODO(jacksongardner): remove this poorly named argument once the recipes stop | |||
# using it. |
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.
Please link to a github issue for all TODOs.
@@ -0,0 +1,24 @@ | |||
import("//flutter/common/config.gni") |
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.
Two things:
- What is the reason for moving this?
- GN files need a copyright header.
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.
The original reason for moving this was that the flutter/BUILD.gn
file is not wasm friendly (it transitively pulls in a bunch of .gni
files that have platform checks that choke when the target os/arch is wasm
). Since I was trying to build the web sdk in the wasm build, it was pulling in the flutter/BUILD.gn
file when it had a dependency on the dart-sdk
target, so I separated it out and simplified it so that we wouldn't have to pull in the whole of flutter/BUILD.gn
when building the web sdk.
After some additional changes though, the web sdk build now uses the prebuilt sdk in-place and so does not have a dependency on the dart_sdk
target anymore, so I can actually move it back if this bothers you.
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.
We want to allow Dart SDK hackers to test Dart SDK builds with local source changes, so we may end up with this dependency again. If it's better to have it split out into a standalone BUILD.gn
I think I'd rather keep it.
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.
We want to allow Dart SDK hackers to test Dart SDK builds with local source changes, so we may end up with this dependency again. If it's better to have it split out into a standalone
BUILD.gn
I think I'd rather keep it.
I don't follow how that's related. The existing way to hack on the Dart SDK in the engine tree is to make changes under third_party/dart
, and to use the --no-prebuilt-dart-sdk
flag to the gn
script. Does that not work for some reason?
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.
If the dart-sdk
target is in flutter/BUILD.gn
, then the wasm build cannot consume or use it because the wasm build can't actually touch flutter/BUILD.gn
without pulling in transitive dependencies that break under a wasm build. The transitive dependencies break even if you aren't building any of their targets, and they are dependencies we don't necessarily have control over.
That being said, we aren't actually using the dart-sdk target for the web build anymore, we just use prebuilts. I also don't actually see us adding a dependency on the dart-sdk
target in the future either, and if we did it would be in a different manner that would probably build it with the non-default toolchain, since it's weird to pull host artifacts into the wasm build tree. So actually for our purposes I don't care anymore, and if you want me to refactor that target back into flutter/BUILD.gn
I don't have any real practical objection, but I don't actually understand why that would be desirable. flutter/BUILD.gn
is a bit of a kitchen sink and probably would be easier to work with if it were broken up into smaller logical components, and so having the dart-sdk
separated into a different file seems better to me than keeping it in flutter/BUILD.gn
. But again we don't really depend on either any more, so I don't mind either way you want to go with it.
@@ -22,6 +22,8 @@ declare_args() { | |||
|
|||
# Whether to use a prebuilt Dart SDK instead of building one. | |||
flutter_prebuilt_dart_sdk = false | |||
|
|||
build_flutter_web_sdk = false |
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.
Please add a comment for this arg.
@@ -627,6 +633,12 @@ 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['flutter_prebuilt_dart_sdk'] = True | |||
|
|||
# TODO(jacksongardner): Make this based off of the input argument rather |
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.
Ditto comment about linking TODOs to github issues.
action='store_true', | ||
help='build canvaskit from source' | ||
) | ||
|
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.
For other args there's no extra newline between the arg and the --no version.
if (target_os == "wasm") { | ||
output = "flutter-web-sdk.zip" | ||
} else { | ||
# TODO(jacksongardner): remove this once we stop making platform-specific |
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.
Ditto
This reverts commit 7a1be8b.
This makes some improvements to the web build process.
felt test
no longer requires any build folder at all, unless--use-local-canvaskit
is specified. To compile tests, it now uses whatever dart sdk thatfelt.dart
is invoked with (which is by default the prebuilt dart sdk)felt build
only invokes the--wasm --runtime-mode=release
of the gn build, and that build now produces theflutter_web_sdk
and the .zip artifact. This build also no longer relies on building or copying the dart sdk to the output folder, it just uses the prebuilt sdk where it is.We need to do some followup recipe changes to take full advantage of this, which I've outlined here: flutter/flutter#113303
The ultimate goal is going to be:
flutter-web-sdk.zip
artifact that rolls into the framework, and no longer has platform specific artifacts.flutter-web-sdk.zip
artifact instead of the platform specific artifactsflutter_web_sdk
targets at all