Dart/Flutter
Introduction
https://en.wikipedia.org/wiki/Dart_(programming_language) is a language created by Google to replace Javascript. It is targetting a VM (DartVM).
https://en.wikipedia.org/wiki/Flutter_(software) is a framework to create native, web, or mobile apps (from the same code) written in Dart.
Status
Dart: It’s supported for Windows on Arm for Dev Channel and latest binaries are available here (or on this page: https://dart.dev/get-dart/archive#dev-channel ).
Flutter: Build from source works, and flutter engine binaries are available. Compile natively flutter app is now supported (https://github.com/flutter/flutter/pull/141930 ). Cross compilation is not upstream, but you can use this PR if you’re interested: https://github.com/flutter/flutter/pull/142431.
See this design document for details: https://docs.google.com/document/d/1yuexY-EtzeVhU3V6RGBII_kH-znLSkQCspzW70jayZk/edit?resourcekey=0-8pQRSXSHQlwOo7QtCVLvBA and open issues https://github.com/flutter/flutter/issues/62597.
Flutter App
Since Dart and Flutter engine are now built upstream, we document how to simply create, build and run a flutter App.
If you’re interested in manually building dart or flutter itself, you can follow other instructions on this page.
git clone https://github.com/flutter/flutter
flutter/bin/flutter.bat create app
cd app
../flutter/bin/flutter.bat build windows
file build/windows/arm64/runner/Release/app.exe
# on windows-x64, it will build an x64 app insteadIf you’re interested in cross compilation, take a look at this PR: https://github.com/flutter/flutter/pull/142431
Setup (common to both projects)
Note: This is needed only if you intend to build dart and flutter manually. Upstream artifacts are now available for windows-arm64, so there is no need to build this manually.
Those two projects are built using chromium build system (https://gn.googlesource.com/gn/ , a cmake like, and https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up ). Both projects provide wrappers to build, without the need to call gn directly.
get visual studio components
you need to install ATL libraries for your visual studio version.
get windows sdk debuggers
you need to install debuggers from https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/ . Dart/Flutter build search for dbgcore.dll and dbghelp.dll.
get python3
python3.exe should be available on the PATH. arm64 version should be installed as it is used by depot_tools to identify cpu architecture.
When installing python on windows, only python.exe is available. You need to copy it (duplicate it) as python3.exe.
get depot_tools
First, you need to retrieve depot_tools from this URL, and unzip it
Then, add following directories to your PATH:
# contains ninja.exe and other binaries for windows
depot_tools/.cipd_bin
# main scripts (fetch, gsync, ...)
depot_tools/set environment
# force to get local toolchain (needed when you're not a Google employee)
set DEPOT_TOOLS_WIN_TOOLCHAIN=0Dart
Note: Dart artifacts are now built upstream, and it’s not needed to build this manually.
Clone
fetch dart
cd sdkBuild
python3 ./tools/build.py --arch arm64 --mode release create_sdk --no-gomaTest
python3 ./tools/test.py -mrelease --arch=arm64 --runtime=vm --compiler=none vm
# you can select other test suites than "vm"Run
Create file named hw.dart with this content:
void main() {
print('Hello, World!');
}You can run it using:
# execute directly
out/ReleaseXARM64/dart.exe run hw.dart
# compile it to bytecode
out/ReleaseXARM64/dart.exe compile kernel hw.dart -o hw.dill
# run from bytecode
out/ReleaseXARM64/dart.exe run hw.dillFlutter
Note: Flutter artifacts are now built upstream, and it’s not needed to build this manually.
Clone
fetch flutter
cd srcBuild engine
set GYP_MSVS_OVERRIDE_PATH='C:\Program Files (x86)\Microsoft Visual Studio\2019\Community'
# --no-goma: is google distributed build system (only for Googlers)
python3 ./flutter/tools/gn --no-goma --windows-cpu arm64 --target-dir host_debug
ninja -C out/host_debugCI
Flutter uses GitHub Actions https://github.com/flutter/flutter/actions
Binary availability
Flutter (prebuilt) binaries are automatically downloaded first time flutter command is run. Based on current cpu architecture, it will download native windows-x64 or windows-arm64 binaries.
git clone https://github.com/flutter/flutter
cd flutter
./bin/flutter --help
Deleted all and executed
set DEPOT_TOOLS_WIN_TOOLCHAIN=0made the fetch dart work.Now the build fails big time
python3 ./tools/build.py --arch arm64 --mode release create_sdkException: Path "C:\Program Files (x86)\Windows Kits\10\\include\10.0.20348.0\\um" from environment variable "include" does not exist. Make sure the necessary SDK is installed.
ERROR at //build/toolchain/win/BUILD.gn:248:24: Script returned non-zero exit code.
win_toolchain_data = exec_script("setup_toolchain.py",
^----------
Current dir: C:/src/sdk/out/ReleaseXARM64/
Command: C:/src/depot_tools/bootstrap-2@3_8_10_chromium_26_bin/python3/bin/python3.exe C:/src/sdk/build/toolchain/win/setup_toolchain.py "C:\Program Files/Microsoft Visual Studio/2022/Community" "C:\Program Files (x86)\Windows Kits\10" "C:\Windows\System32;C:\Windows\SysWOW64;Arm64Unused" win arm64 environment.arm64
Returned 1.
See //build/toolchain/win/BUILD.gn:284:1: whence it was called.
win_toolchains(target_cpu) {
^----------------------------
See //BUILD.gn:11:1: which caused the file to be included.
group("default") {
^------------------
Command failed: C:\src\sdk\buildtools\win\gn.exe gen out\ReleaseXARM64 --ide=vs --args=target_os="win" host_cpu="x64" target_cpu="arm64" dart_target_arch="arm64" dart_use_compressed_pointers=false dart_use_crashpad=false dart_snapshot_kind="kernel" dart_use_fallback_root_certificates=true bssl_use_clang_integrated_as=true is_debug=false is_release=true is_product=false dart_debug=false dart_runtime_mode="develop" exclude_kernel_service=false is_clang=true dart_vm_code_coverage=false is_asan=false is_lsan=false is_msan=false is_tsan=false is_ubsan=false is_qemu=false dart_platform_sdk=false use_goma=false goma_dir="None" verify_sdk_hash=true
buildtools/ninja/ninja -C out\ReleaseXARM64 create_sdk
ninja: error: loading 'build.ninja': The system cannot find the file specified.
ninja: Entering directory `out\ReleaseXARM64'
BUILD FAILED
C