This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[fuchsia] Update fuchsia instruction in Compiling-the-engine.md #55365
Uh oh!
There was an error while loading. Please reload this page.
[fuchsia] Update fuchsia instruction in Compiling-the-engine.md #55365
Changes from all commits
115d396b375b80daf053eFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
If you've never built the engine before, first see Setting up the Engine development environment.
Contents
Depending on the platform you are making changes for, you may be interested in all or only some of the sections below:
General Compilation Tips
--unoptbuilds. These builds will have additional logging and checks enabled, and generally use build and link flags that lead to faster compilation and better debugging symbols. If you are trying to do performance testing with a local build, do not use the--unoptflag.--no-ltoflag.hostandandroid(orios) build. It is critical to recompile the host build after upgrading the Dart SDK (e.g. via agclient syncafter merging up to head), since artifacts from the host build need to be version matched to artifacts in the Android/iOS build.hostorfuchsia).outdirectory from any backup scripts, as many large binary artifacts are generated. This is also generally true for all of the directories outside of theengine/src/flutterdirectory.Using a custom Dart SDK
When targeting the host and desktop, on CI we use a pre-built Dart SDK vended by the Dart team. To build and use the SDK from the Dart sources downloaded by
gclient sync, after editing those source files, pass the flag--no-prebuilt-dart-sdkto//flutter/tools/gn.Compiling for Android (from macOS or Linux)
These steps build the engine used by
flutter runfor Android devices.Run the following steps, from the
srcdirectory created in Setting up the Engine development environment:git pull upstream maininsrc/flutterto update the Flutter Engine repo.gclient syncto update dependencies.Prepare your build files
./flutter/tools/gn --android --unoptimizedfor device-side executables../flutter/tools/gn --android --android-cpu arm64 --unoptimizedfor newer 64-bit Android devices../flutter/tools/gn --android --android-cpu x86 --unoptimizedfor x86 emulators../flutter/tools/gn --android --android-cpu x64 --unoptimizedfor x64 emulators../flutter/tools/gn --unoptimizedfor host-side executables, needed to compile the code.--mac-cpu arm64to avoid using emulation. This will generatehost_debug_unopt_arm64.ninja -C out/android_debug_unoptfor device-side executables.ninja -C out/android_debug_unopt_arm64for newer 64-bit Android devices.ninja -C out/android_debug_unopt_x86for x86 emulators.ninja -C out/android_debug_unopt_x64for x64 emulators.ninja -C out/host_debug_unopt(orninja -C out/host_debug_unopt_arm64, see above) for host-side executables.ninja -C out/android_debug_unopt && ninja -C out/host_debug_unoptThis builds a debug-enabled ("unoptimized") binary configured to run Dart in checked mode ("debug"). There are other versions, see Flutter's modes.
If you're going to be debugging crashes in the engine, make sure you add
android:debuggable="true"to the<application>element in theandroid/AndroidManifest.xmlfile for the Flutter app you are using to test the engine.See The flutter tool for instructions on how to use the
fluttertool with a local engine. You will typically use theandroid_debug_unoptbuild to debug the engine on a device, andandroid_debug_unopt_x64to debug in on a simulator. Modifying dart sources in the engine will require adding adependency_overridesection in you app'spubspec.yamlas detailed here.Note that if you use particular android or ios engine build, you will need to have corresponding host build available next to it: if you use
android_debug_unopt, you should have builthost_debug_unopt,android_profile->host_profile, etc. One caveat concerns cpu-flavored builds likeandroid_debug_unopt_x86: you won't be able to buildhost_debug_unopt_x86as that configuration is not supported. What you are expected to do is to buildhost_debug_unoptand symlinkhost_debug_unopt_x86to it.Compiling everything that matters on Linux
The following script will update all the builds that matter if you're developing on Linux and testing on Android and created the
.gclientfile in~/dev/engine:For
--runtime-mode=profilebuild, please also consider adding--no-ltooption to thegncommand. It will make linking much faster with a small sacrifice on the binary size and memory usage (which probably doesn't matter for debugging or performance benchmark purposes.)Compiling for iOS (from macOS)
These steps build the engine used by
flutter runfor iOS devices.Run the following steps, from the
srcdirectory created in the steps above:git pull upstream maininsrc/flutterto update the Flutter Engine repo.gclient syncto update dependencies../flutter/tools/gn --ios --unoptimizedto prepare build files for device-side executables (or--ios --simulator --unoptimizedfor simulator).out/ios_debug_unopt/flutter_engine.xcodeproj--simulator-cpu=arm64argument for an arm64 Mac simulator to output toout/ios_debug_sim_unopt_arm64../flutter/tools/gn --unoptimizedto prepare the build files for host-side executables.--mac-cpu arm64to avoid using emulation. This will generatehost_debug_unopt_arm64.ninja -C out/ios_debug_unopt && ninja -C out/host_debug_unoptto build all artifacts (useout/ios_debug_sim_unoptfor Simulator).See The flutter tool for instructions on how to use the
fluttertool with a local engine. You will typically use theios_debug_unoptbuild to debug the engine on a device, andios_debug_sim_unoptto debug in on a simulator. Modifying dart sources in the engine will require adding adependency_overridesection in you app'spubspec.yamlas detailed here.See also instructions for debugging the engine in a Flutter app in Xcode.
Compiling for macOS or Linux
These steps build the desktop embedding, and the engine used by
flutter teston a host workstation.git pull upstream maininsrc/flutterto update the Flutter Engine repo.gclient syncto update your dependencies../flutter/tools/gn --unoptimizedto prepare your build files.--unoptimizeddisables C++ compiler optimizations. On macOS, binaries are emitted unstripped; on Linux, unstripped binaries are emitted to anexe.unstrippedsubdirectory of the build.ninja -C out/host_debug_unoptto build a desktop unoptimized binary.--unoptimized, useninja -C out/host_debuginstead.See The flutter tool for instructions on how to use the
fluttertool with a local engine. You will typically use thehost_debug_unoptbuild in this setup. Modifying dart sources in the engine will require adding adependency_overridesection in you app'spubspec.yamlas detailed here.Compiling for Windows
Warning
You can only build selected binaries on Windows (mainly
gen_snapshotand the desktop embedding).On Windows, ensure that the engine checkout is not deeply nested. This avoid the issue of the build scripts working with excessively long paths.
Make sure you have Visual Studio installed (non-Googlers only). Debugging Tools for Windows 10 must be installed.
git pull upstream maininsrc/flutterto update the Flutter Engine repo.Ensure long path support is enabled on your machine. Launch PowerShell as an administrator and run:
Also, be sure that Python27 is before any other python in your Path.
gclient syncto update your dependencies.switch to
src/directory.python .\flutter\tools\gn --unoptimizedto prepare your build files.gen_snapshot:python .\flutter\tools\gn [--unoptimized] --runtime-mode=[debug|profile|release] [--android].ninja -C .\out\<dir created by previous step>to build.ninja -C .\out\<dir created by previous step> gen_snapshot. Release and profile are not yet supported for the desktop shell.Compiling for Fuchsia
Build components for Fuchsia
gclient config --custom-var=download_fuchsia_deps=Truethengclient sync.It will set
"download_fuchsia_deps": Truein"custom_vars"section in.gclientfile, and download necessary binaries to build fuchsia components.gclient config --custom-var=run_fuchsia_emu=Truethengclient sync.It will set
"run_fuchsia_emu": Truein"custom_vars"section in.gclientfile, and download necessary binaries and images to run tests on fuchsia emulators. You can set bothcustom_varsand rungclient synconly once.engine/.gclient, or../.gclientif current directory isengine/src, withcustom_vars.Run
gclient sync.Warning
YouWhen running tests locally, you will also need kvm enabled, or nested virtualization on the gcloud VMs. Fuchsia and the tests will all be executed on the qemu.out/fuchsia_debug_x64.--fuchsia-cpu arm64to build components for arm64. It will be created in a folderout/fuchsia_debug_arm64.--runtime-mode=releaseor--runtime-mode=profileto select other profiles as other platforms.--no-ltoto use lto or link-time optimization.-k 0.autoninjaif it's available.-C out/fuchsia_release_x64for release build; other configurations are similar with a different folder name inout/.out/fuchsia_debug_x64by default. According to the configuration, it may take 5 minutes with regular gtest output to the terminal.fuchsia_release_x64at the end of the command for release build; other configurations are similar with a different folder name inout/.Compiling for the Web
For building the engine for the Web we use the felt tool.
To test Flutter with a local build of the Web engine, add
--local-web-sdk=wasm_releaseto yourfluttercommand, e.g.:Compiling for the Web on Windows
Compiling the web engine might take a few extra steps on Windows. Use cmd.exe and "run as administrator".
GYP_MSVS_OVERRIDE_PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"GYP_MSVS_VERSION = 2017DEPOT_TOOLS_WIN_TOOLCHAIN = 0git pull upstream maininsrc/flutterto update the Flutter Engine repo.gclient syncto update your dependencies.python .\flutter\tools\gn --unoptimized --full-dart-sdkto prepare your build files.ninja -C .\out\<dir created by previous step>to build.To test Flutter with a local build of the Web engine, add
--local-web-sdk=wasm_releaseto yourfluttercommand, e.g.:For testing the engine again use felt tool this time with felt_windows.bat.
Compiling for testing
Dart tests
To run dart tests, build the engine:
execute
run_testsfor native:and
feltfor web:Troubleshooting Compile Errors
Version Solving Failed
From time to time, as the Dart versions increase, you might see dependency errors such as:
Running
gclient syncdoes not update the tags, there are two solutions:engine/src/third_party/dartrungit fetch --tags origingclient sync --with_tagsSee also: Debugging the engine, which includes instructions on running a Flutter app with a local engine.