-
Notifications
You must be signed in to change notification settings - Fork 6k
Build Web SDK in wasm build tree #36520
Changes from all commits
543b02d
07690ee
2259916
d1a9f0a
4650b9e
1041f93
e4f0c0d
81eff9c
82812b6
f3b6cfd
a9e7f3f
9d1d6ae
8bfb22f
094c678
d81efbd
a0d5345
aeaa119
3d667d2
924697d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Please add a comment for this arg. |
||
} | ||
|
||
# feature_defines_list --------------------------------------------------------- | ||
|
@@ -114,7 +116,7 @@ if (flutter_prebuilt_dart_sdk) { | |
# There is no prebuilt Dart SDK targeting Fuchsia, but we also don't need | ||
# one, so even when the build is targeting Fuchsia, use the prebuilt | ||
# Dart SDK for the host. | ||
if (current_toolchain == host_toolchain || is_fuchsia) { | ||
if (current_toolchain == host_toolchain || is_fuchsia || is_wasm) { | ||
prebuilt_dart_sdk = host_prebuilt_dart_sdk | ||
prebuilt_dart_sdk_config = _host_prebuilt_dart_sdk_config | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import("//flutter/common/config.gni") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Two things:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original reason for moving this was that the 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the 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 |
||
import("//third_party/dart/build/dart/copy_tree.gni") | ||
|
||
if (flutter_prebuilt_dart_sdk) { | ||
copy_trees("_copy_trees") { | ||
sources = [ | ||
{ | ||
target = "copy_dart_sdk" | ||
visibility = [ ":dart_sdk" ] | ||
source = prebuilt_dart_sdk | ||
dest = "$root_out_dir/dart-sdk" | ||
ignore_patterns = "{}" | ||
}, | ||
] | ||
} | ||
} | ||
|
||
group("dart_sdk") { | ||
if (flutter_prebuilt_dart_sdk) { | ||
public_deps = [ ":copy_dart_sdk" ] | ||
} else { | ||
public_deps = [ "//third_party/dart:create_sdk" ] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ SRC_ROOT = os.path.dirname( | |
def get_out_dir(args): | ||
if args.target_os is not None: | ||
target_dir = [args.target_os] | ||
elif args.web: | ||
target_dir = ['wasm'] | ||
else: | ||
target_dir = ['host'] | ||
|
||
|
@@ -251,10 +253,15 @@ def to_gn_args(args): | |
|
||
# If building for WASM, set the GN args using 'to_gn_wasm_args' as most | ||
# of the Flutter SDK specific arguments are unused. | ||
if args.target_os == 'wasm': | ||
if args.target_os == 'wasm' or args.web: | ||
to_gn_wasm_args(args, gn_args) | ||
return gn_args | ||
|
||
gn_args['build_flutter_web_sdk'] = args.build_web_sdk | ||
gn_args['full_dart_sdk'] = args.full_dart_sdk | ||
if args.build_web_sdk or args.full_dart_sdk: | ||
gn_args['build_canvaskit'] = args.build_canvaskit | ||
|
||
if args.enable_unittests: | ||
gn_args['enable_unittests'] = args.enable_unittests | ||
|
||
|
@@ -359,7 +366,6 @@ def to_gn_args(args): | |
gn_args['embedder_for_target'] = args.embedder_for_target | ||
gn_args['dart_lib_export_symbols'] = False | ||
gn_args['flutter_runtime_mode'] = runtime_mode | ||
gn_args['full_dart_sdk'] = args.full_dart_sdk | ||
gn_args['dart_version_git_info'] = not args.no_dart_version_git_info | ||
|
||
gn_args['dart_lib_export_symbols'] = False | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Ditto comment about linking TODOs to github issues. |
||
# than forced to true, once the recipes are updated. | ||
gn_args['build_canvaskit'] = True | ||
gn_args['build_flutter_web_sdk'] = True | ||
|
||
|
||
def parse_args(args): | ||
|
@@ -702,6 +714,7 @@ def parse_args(args): | |
parser.add_argument( | ||
'--wasm', dest='target_os', action='store_const', const='wasm' | ||
) | ||
parser.add_argument('--web', action='store_true', default=False) | ||
parser.add_argument( | ||
'--windows', dest='target_os', action='store_const', const='win' | ||
) | ||
|
@@ -825,6 +838,27 @@ def parse_args(args): | |
'--no-full-dart-sdk', dest='full_dart_sdk', action='store_false' | ||
) | ||
|
||
parser.add_argument( | ||
'--build-web-sdk', | ||
default=False, | ||
action='store_true', | ||
help='build the flutter web sdk' | ||
) | ||
parser.add_argument( | ||
'--no-build-web-sdk', dest='build_web_sdk', action='store_false' | ||
) | ||
|
||
parser.add_argument( | ||
'--build-canvaskit', | ||
default=False, | ||
action='store_true', | ||
help='build canvaskit from source' | ||
) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
parser.add_argument( | ||
'--no-build-canvaskit', dest='build_canvaskit', action='store_false' | ||
) | ||
|
||
parser.add_argument( | ||
'--ide', | ||
default='', | ||
|
@@ -968,16 +1002,17 @@ def main(argv): | |
'--export-compile-commands', | ||
] | ||
|
||
if args.ide != '': | ||
command.append('--ide=%s' % args.ide) | ||
elif sys.platform == 'darwin': | ||
# On the Mac, generate an Xcode project by default. | ||
command.append('--ide=xcode') | ||
command.append('--xcode-project=flutter_engine') | ||
command.append('--xcode-build-system=new') | ||
elif sys.platform.startswith('win'): | ||
# On Windows, generate a Visual Studio project. | ||
command.append('--ide=vs') | ||
if args.target_os != 'wasm': | ||
if args.ide != '': | ||
command.append('--ide=%s' % args.ide) | ||
elif sys.platform == 'darwin': | ||
# On the Mac, generate an Xcode project by default. | ||
command.append('--ide=xcode') | ||
command.append('--xcode-project=flutter_engine') | ||
command.append('--xcode-build-system=new') | ||
elif sys.platform.startswith('win'): | ||
# On Windows, generate a Visual Studio project. | ||
command.append('--ide=vs') | ||
|
||
command.append('--export-compile-commands=default') | ||
|
||
|
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.