Skip to content

Commit

Permalink
Add WASM target in gn (flutter#31670)
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry Terkelsen authored Mar 16, 2022
1 parent 81547d1 commit 2309bcc
Show file tree
Hide file tree
Showing 13 changed files with 329 additions and 82 deletions.
16 changes: 8 additions & 8 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ config("export_dynamic_symbols") {
}
}

# Flutter SDK artifacts should only be built when either doing host builds, or
# for cross-compiled desktop targets.
# TODO: We can't build the engine artifacts for arm (32-bit) right now;
# see https://github.com/flutter/flutter/issues/74322
_build_engine_artifacts =
current_toolchain == host_toolchain ||
(is_linux && !is_chromeos && current_cpu != "arm") || is_mac

if (flutter_prebuilt_dart_sdk) {
copy_trees("_copy_trees") {
sources = [
Expand All @@ -45,14 +53,6 @@ if (flutter_prebuilt_dart_sdk) {
}
}

# Flutter SDK artifacts should only be built when either doing host builds, or
# for cross-compiled desktop targets.
# TODO: We can't build the engine artifacts for arm (32-bit) right now;
# see https://github.com/flutter/flutter/issues/74322
_build_engine_artifacts =
current_toolchain == host_toolchain ||
(is_linux && !is_chromeos && current_cpu != "arm") || is_mac

group("dart_sdk") {
if (build_engine_artifacts) {
if (flutter_prebuilt_dart_sdk) {
Expand Down
22 changes: 21 additions & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ vars = {
# See `lib/web_ui/README.md` for how to roll CanvasKit to a new version.
'canvaskit_cipd_instance': '8MSYGWVWzrTJIoVL00ZquruZs-weuwLBy1kt1AawJiIC',

# Do not download the Emscripten SDK by default.
# This prevents us from downloading the Emscripten toolchain for builds
# which do not build for the web. This toolchain is needed to build CanvasKit
# for the web engine.
'download_emsdk': False,

# When updating the Dart revision, ensure that all entries that are
# dependencies of Dart are also updated to match the entries in the
# Dart SDK's DEPS file for that revision of Dart. The DEPS file for
Expand Down Expand Up @@ -155,7 +161,7 @@ deps = {
# Chromium-style dependencies.

'src/third_party/icu':
Var('chromium_git') + '/chromium/deps/icu.git' + '@' + '2e0f2989441ec2f55abec30f48e89981dbac2c34',
Var('chromium_git') + '/chromium/deps/icu.git' + '@' + '1fa4e3959ec6637182b7318ac1d382799454806d',

'src/third_party/khronos':
Var('chromium_git') + '/chromium/src/third_party/khronos.git' + '@' + '7122230e90547962e0f0c627f62eeed3c701f275',
Expand Down Expand Up @@ -565,6 +571,11 @@ deps = {
'dep_type': 'cipd',
},

'src/buildtools/emsdk': {
'url': Var('skia_git') + '/external/github.com/emscripten-core/emsdk.git' + '@' + 'fc645b7626ebf86530dbd82fbece74d457e7ae07',
'condition': 'download_emsdk',
},

# Clang on mac and linux are expected to typically be the same revision.
# They are separated out so that the autoroller can more easily manage them.
'src/buildtools/mac-x64/clang': {
Expand Down Expand Up @@ -739,6 +750,15 @@ hooks = [
Var('fuchsia_sdk_path'),
]
},
{
'name': 'Activate Emscripten SDK',
'pattern': '.',
'condition': 'download_emsdk',
'action': [
'python3',
'src/flutter/tools/activate_emsdk.py',
]
},
{
'name': 'Setup githooks',
'pattern': '.',
Expand Down
47 changes: 40 additions & 7 deletions ci/licenses_golden/licenses_skia
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,17 @@ FILE: ../../../third_party/skia/BUILD.bazel
FILE: ../../../third_party/skia/CQ_COMMITTERS
FILE: ../../../third_party/skia/DEPS
FILE: ../../../third_party/skia/DIR_METADATA
FILE: ../../../third_party/skia/OWNERS.android
FILE: ../../../third_party/skia/WORKSPACE.bazel
FILE: ../../../third_party/skia/animations/checkbox.xml
FILE: ../../../third_party/skia/animations/chest#1.jpg
FILE: ../../../third_party/skia/animations/fire#1.jpg
FILE: ../../../third_party/skia/animations/images#1.xml
FILE: ../../../third_party/skia/animations/jet#1.jpg
FILE: ../../../third_party/skia/animations/lines#1.xml
FILE: ../../../third_party/skia/animations/movie#1.xml
FILE: ../../../third_party/skia/animations/paths#1.xml
FILE: ../../../third_party/skia/animations/redcross#1.jpg
FILE: ../../../third_party/skia/animations/text#1.xml
FILE: ../../../third_party/skia/bazel/BUILD.bazel
FILE: ../../../third_party/skia/bazel/cc_binary_with_flags.bzl
FILE: ../../../third_party/skia/bazel/common_config_settings/BUILD.bazel
Expand Down Expand Up @@ -754,6 +763,16 @@ FILE: ../../../third_party/skia/experimental/tskit/package.json
FILE: ../../../third_party/skia/experimental/tskit/tsconfig.json
FILE: ../../../third_party/skia/experimental/wasm-hello-world/BUILD.bazel
FILE: ../../../third_party/skia/experimental/wasm-hello-world/hello_world.html
FILE: ../../../third_party/skia/experimental/wasm-skp-debugger/cpu.js
FILE: ../../../third_party/skia/experimental/wasm-skp-debugger/debugger/anim.mskp
FILE: ../../../third_party/skia/experimental/wasm-skp-debugger/debugger/index.html
FILE: ../../../third_party/skia/experimental/wasm-skp-debugger/debugger/sample.skp
FILE: ../../../third_party/skia/experimental/wasm-skp-debugger/externs.js
FILE: ../../../third_party/skia/experimental/wasm-skp-debugger/fonts/NotoMono-Regular.ttf
FILE: ../../../third_party/skia/experimental/wasm-skp-debugger/gpu.js
FILE: ../../../third_party/skia/experimental/wasm-skp-debugger/helper.js
FILE: ../../../third_party/skia/experimental/wasm-skp-debugger/karma.conf.js
FILE: ../../../third_party/skia/experimental/wasm-skp-debugger/package.json
FILE: ../../../third_party/skia/experimental/webgpu-bazel/example/index.html
FILE: ../../../third_party/skia/experimental/webgpu-bazel/src/BUILD
FILE: ../../../third_party/skia/gm/BUILD.bazel
Expand Down Expand Up @@ -784,7 +803,6 @@ FILE: ../../../third_party/skia/include/private/BUILD.bazel
FILE: ../../../third_party/skia/include/private/chromium/BUILD.bazel
FILE: ../../../third_party/skia/include/sksl/BUILD.bazel
FILE: ../../../third_party/skia/include/svg/BUILD.bazel
FILE: ../../../third_party/skia/include/third_party/BUILD.bazel
FILE: ../../../third_party/skia/include/utils/BUILD.bazel
FILE: ../../../third_party/skia/include/utils/mac/BUILD.bazel
FILE: ../../../third_party/skia/infra/bots/BUILD.bazel
Expand Down Expand Up @@ -1893,6 +1911,7 @@ FILE: ../../../third_party/skia/bench/StreamBench.cpp
FILE: ../../../third_party/skia/bench/SwizzleBench.cpp
FILE: ../../../third_party/skia/bench/TileImageFilterBench.cpp
FILE: ../../../third_party/skia/bench/VertexColorSpaceBench.cpp
FILE: ../../../third_party/skia/experimental/xps_to_png/xps_to_png.cs
FILE: ../../../third_party/skia/fuzz/Fuzz.cpp
FILE: ../../../third_party/skia/fuzz/Fuzz.h
FILE: ../../../third_party/skia/fuzz/FuzzGradients.cpp
Expand Down Expand Up @@ -3247,7 +3266,7 @@ FILE: ../../../third_party/skia/src/effects/imagefilters/SkComposeImageFilter.cp
FILE: ../../../third_party/skia/src/effects/imagefilters/SkDisplacementMapImageFilter.cpp
FILE: ../../../third_party/skia/src/effects/imagefilters/SkDropShadowImageFilter.cpp
FILE: ../../../third_party/skia/src/effects/imagefilters/SkTileImageFilter.cpp
FILE: ../../../third_party/skia/src/gpu/Blend.h
FILE: ../../../third_party/skia/src/gpu/GrBlend.h
FILE: ../../../third_party/skia/src/gpu/GrCaps.h
FILE: ../../../third_party/skia/src/gpu/GrGeometryProcessor.h
FILE: ../../../third_party/skia/src/gpu/GrPaint.cpp
Expand Down Expand Up @@ -3326,6 +3345,7 @@ TYPE: LicenseType.bsd
FILE: ../../../third_party/skia/bench/BulkRectBench.cpp
FILE: ../../../third_party/skia/bench/DDLRecorderBench.cpp
FILE: ../../../third_party/skia/bench/SkSLBench.cpp
FILE: ../../../third_party/skia/experimental/wasm-skp-debugger/debugger_bindings.cpp
FILE: ../../../third_party/skia/gm/asyncrescaleandread.cpp
FILE: ../../../third_party/skia/gm/crbug_908646.cpp
FILE: ../../../third_party/skia/gm/crbug_946965.cpp
Expand Down Expand Up @@ -3445,6 +3465,7 @@ FILE: ../../../third_party/skia/bench/PathOpsBench.cpp
FILE: ../../../third_party/skia/bench/PolyUtilsBench.cpp
FILE: ../../../third_party/skia/bench/ShaderMaskFilterBench.cpp
FILE: ../../../third_party/skia/bench/TypefaceBench.cpp
FILE: ../../../third_party/skia/experimental/pvg/draw_msg.proto
FILE: ../../../third_party/skia/fuzz/FuzzCommon.cpp
FILE: ../../../third_party/skia/fuzz/FuzzPathMeasure.cpp
FILE: ../../../third_party/skia/fuzz/FuzzRegionOp.cpp
Expand Down Expand Up @@ -4182,6 +4203,21 @@ TYPE: LicenseType.bsd
FILE: ../../../third_party/skia/bench/FindCubicConvex180ChopsBench.cpp
FILE: ../../../third_party/skia/bench/GlyphQuadFillBench.cpp
FILE: ../../../third_party/skia/bench/TessellateBench.cpp
FILE: ../../../third_party/skia/experimental/skrive/include/SkRive.h
FILE: ../../../third_party/skia/experimental/skrive/src/Artboard.cpp
FILE: ../../../third_party/skia/experimental/skrive/src/Color.cpp
FILE: ../../../third_party/skia/experimental/skrive/src/Component.cpp
FILE: ../../../third_party/skia/experimental/skrive/src/Drawable.cpp
FILE: ../../../third_party/skia/experimental/skrive/src/Ellipse.cpp
FILE: ../../../third_party/skia/experimental/skrive/src/Node.cpp
FILE: ../../../third_party/skia/experimental/skrive/src/Paint.cpp
FILE: ../../../third_party/skia/experimental/skrive/src/Rectangle.cpp
FILE: ../../../third_party/skia/experimental/skrive/src/Shape.cpp
FILE: ../../../third_party/skia/experimental/skrive/src/SkRive.cpp
FILE: ../../../third_party/skia/experimental/skrive/src/reader/BinaryReader.cpp
FILE: ../../../third_party/skia/experimental/skrive/src/reader/JsonReader.cpp
FILE: ../../../third_party/skia/experimental/skrive/src/reader/StreamReader.cpp
FILE: ../../../third_party/skia/experimental/skrive/src/reader/StreamReader.h
FILE: ../../../third_party/skia/fuzz/FuzzSkParagraph.cpp
FILE: ../../../third_party/skia/gm/3d.cpp
FILE: ../../../third_party/skia/gm/bc1_transparency.cpp
Expand Down Expand Up @@ -6091,8 +6127,6 @@ FILE: ../../../third_party/skia/experimental/graphite/src/UploadTask.h
FILE: ../../../third_party/skia/experimental/graphite/src/mtl/MtlSampler.h
FILE: ../../../third_party/skia/experimental/graphite/src/mtl/MtlSampler.mm
FILE: ../../../third_party/skia/gm/bug12866.cpp
FILE: ../../../third_party/skia/include/core/SkAlphaType.h
FILE: ../../../third_party/skia/include/core/SkColorType.h
FILE: ../../../third_party/skia/include/private/SkUniquePaintParamsID.h
FILE: ../../../third_party/skia/src/core/SkBuiltInCodeSnippetID.h
FILE: ../../../third_party/skia/src/core/SkDebugUtils.h
Expand All @@ -6102,8 +6136,6 @@ FILE: ../../../third_party/skia/src/core/SkKeyHelpers.cpp
FILE: ../../../third_party/skia/src/core/SkKeyHelpers.h
FILE: ../../../third_party/skia/src/core/SkPaintParamsKey.cpp
FILE: ../../../third_party/skia/src/core/SkPaintParamsKey.h
FILE: ../../../third_party/skia/src/core/SkPipelineData.cpp
FILE: ../../../third_party/skia/src/core/SkPipelineData.h
FILE: ../../../third_party/skia/src/core/SkSLTypeShared.h
FILE: ../../../third_party/skia/src/core/SkShaderCodeDictionary.cpp
FILE: ../../../third_party/skia/src/core/SkShaderCodeDictionary.h
Expand Down Expand Up @@ -6181,6 +6213,7 @@ FILE: ../../../third_party/skia/src/gpu/ops/PathStencilCoverOp.h
FILE: ../../../third_party/skia/src/gpu/ops/PathTessellateOp.cpp
FILE: ../../../third_party/skia/src/gpu/ops/PathTessellateOp.h
FILE: ../../../third_party/skia/src/gpu/tessellate/AffineMatrix.h
FILE: ../../../third_party/skia/src/gpu/tessellate/PatchWriter.cpp
FILE: ../../../third_party/skia/src/gpu/tessellate/PatchWriter.h
FILE: ../../../third_party/skia/src/gpu/tessellate/PathCurveTessellator.cpp
FILE: ../../../third_party/skia/src/gpu/tessellate/PathCurveTessellator.h
Expand Down
12 changes: 11 additions & 1 deletion ci/licenses_golden/licenses_third_party
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Signature: 80ac7a3b149c4cac0af4058b3b4a4bb6
Signature: 63800bcd154af7272865369dc774c2c4

UNUSED LICENSES:

Expand Down Expand Up @@ -18098,6 +18098,7 @@ FILE: ../../../third_party/icu/android_small/icudtl_extra.dat
FILE: ../../../third_party/icu/cast/brkitr.patch
FILE: ../../../third_party/icu/cast/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat.hash
FILE: ../../../third_party/icu/common/icudtb.dat
FILE: ../../../third_party/icu/common/icudtl.dat
FILE: ../../../third_party/icu/flutter/brkitr.patch
Expand Down Expand Up @@ -18227,6 +18228,7 @@ FILE: ../../../third_party/icu/android_small/icudtl_extra.dat
FILE: ../../../third_party/icu/cast/brkitr.patch
FILE: ../../../third_party/icu/cast/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat.hash
FILE: ../../../third_party/icu/common/icudtb.dat
FILE: ../../../third_party/icu/common/icudtl.dat
FILE: ../../../third_party/icu/flutter/brkitr.patch
Expand Down Expand Up @@ -18366,6 +18368,7 @@ FILE: ../../../third_party/icu/android_small/icudtl_extra.dat
FILE: ../../../third_party/icu/cast/brkitr.patch
FILE: ../../../third_party/icu/cast/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat.hash
FILE: ../../../third_party/icu/common/icudtb.dat
FILE: ../../../third_party/icu/common/icudtl.dat
FILE: ../../../third_party/icu/flutter/brkitr.patch
Expand Down Expand Up @@ -18500,6 +18503,7 @@ FILE: ../../../third_party/icu/android_small/icudtl_extra.dat
FILE: ../../../third_party/icu/cast/brkitr.patch
FILE: ../../../third_party/icu/cast/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat.hash
FILE: ../../../third_party/icu/common/icudtb.dat
FILE: ../../../third_party/icu/common/icudtl.dat
FILE: ../../../third_party/icu/flutter/brkitr.patch
Expand Down Expand Up @@ -18633,6 +18637,7 @@ FILE: ../../../third_party/icu/android_small/icudtl_extra.dat
FILE: ../../../third_party/icu/cast/brkitr.patch
FILE: ../../../third_party/icu/cast/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat.hash
FILE: ../../../third_party/icu/common/icudtb.dat
FILE: ../../../third_party/icu/common/icudtl.dat
FILE: ../../../third_party/icu/flutter/brkitr.patch
Expand Down Expand Up @@ -18771,6 +18776,7 @@ FILE: ../../../third_party/icu/android_small/icudtl_extra.dat
FILE: ../../../third_party/icu/cast/brkitr.patch
FILE: ../../../third_party/icu/cast/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat.hash
FILE: ../../../third_party/icu/common/icudtb.dat
FILE: ../../../third_party/icu/common/icudtl.dat
FILE: ../../../third_party/icu/flutter/brkitr.patch
Expand Down Expand Up @@ -18905,6 +18911,7 @@ FILE: ../../../third_party/icu/android_small/icudtl_extra.dat
FILE: ../../../third_party/icu/cast/brkitr.patch
FILE: ../../../third_party/icu/cast/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat.hash
FILE: ../../../third_party/icu/common/icudtb.dat
FILE: ../../../third_party/icu/common/icudtl.dat
FILE: ../../../third_party/icu/flutter/brkitr.patch
Expand Down Expand Up @@ -19038,6 +19045,7 @@ FILE: ../../../third_party/icu/android_small/icudtl_extra.dat
FILE: ../../../third_party/icu/cast/brkitr.patch
FILE: ../../../third_party/icu/cast/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat.hash
FILE: ../../../third_party/icu/common/icudtb.dat
FILE: ../../../third_party/icu/common/icudtl.dat
FILE: ../../../third_party/icu/flutter/brkitr.patch
Expand Down Expand Up @@ -19144,6 +19152,7 @@ FILE: ../../../third_party/icu/android_small/icudtl_extra.dat
FILE: ../../../third_party/icu/cast/brkitr.patch
FILE: ../../../third_party/icu/cast/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat.hash
FILE: ../../../third_party/icu/common/icudtb.dat
FILE: ../../../third_party/icu/common/icudtl.dat
FILE: ../../../third_party/icu/flutter/brkitr.patch
Expand Down Expand Up @@ -19317,6 +19326,7 @@ FILE: ../../../third_party/icu/android_small/icudtl_extra.dat
FILE: ../../../third_party/icu/cast/brkitr.patch
FILE: ../../../third_party/icu/cast/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat
FILE: ../../../third_party/icu/chromeos/icudtl.dat.hash
FILE: ../../../third_party/icu/common/icudtb.dat
FILE: ../../../third_party/icu/common/icudtl.dat
FILE: ../../../third_party/icu/flutter/brkitr.patch
Expand Down
2 changes: 1 addition & 1 deletion ci/licenses_golden/tool_signature
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Signature: 270842a9eb9687ced20abdf5f131bafd
Signature: 5efe7843d99ba138e2bb7dac2441b5b8

7 changes: 7 additions & 0 deletions lib/web_ui/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright 2022 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.

group("canvaskit") {
deps = [ "//third_party/skia/modules/canvaskit" ]
}
53 changes: 53 additions & 0 deletions lib/web_ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,59 @@ environment variable:
FELT_USE_SNAPSHOT=false felt <command>
```
## Building CanvasKit
To build CanvasKit locally, you must first set up your gclient config to
activate the Emscripten SDK, which is the toolchain used to build CanvasKit.
To do this, replace the contents of your .gclient file at the root of the
project (i.e. in the parent directory of the `src` directory) with:
```
solutions = [
{
"managed": False,
"name": "src/flutter",
"url": "[email protected]:<your_username_here>/engine.git",
"custom_deps": {},
"deps_file": "DEPS",
"safesync_url": "",
"custom_vars": {
"download_emsdk": True,
},
},
]
```
Now run `gclient sync` and it should pull in the Emscripten SDK and activate it.
To build CanvasKit with `felt`, run:
```
felt build --build-canvaskit
```
This will build CanvasKit in `out/wasm_debug`. If you now run
```
felt test
```
it will detect that you have built CanvasKit and use that instead of the one
from CIPD to run the tests against.
### Upgrading the Emscripten SDK for the CanvasKit build
The version of the Emscripten SDK should be kept up to date with the version
used in the Skia build. That version can be found in
`third_party/skia/bin/activate-emsdk`. It will probably also be necessary to
roll the dependency on `third_party/emsdk` in DEPS to the same version as in
`third_party/skia/DEPS`.
Once you know the version for the Emscripten SDK, change the line in
`tools/activate_emsdk.py` which defines `EMSDK_VERSION` to match Skia.
[1]: https://github.com/flutter/flutter/wiki/Setting-up-the-Engine-development-environment
[2]: https://github.com/flutter/engine/blob/main/lib/web_ui/dev/browser_lock.yaml
[4]: https://chrome-infra-packages.appspot.com/p/flutter_internal
Expand Down
Loading

0 comments on commit 2309bcc

Please sign in to comment.