- Move "gclient bootstrap" out of engine/README.md into a section in the "Setting up the Engine development environment" doc. - In the "gclient bootstrap" section, instruct Googlers to follow the RBE setup docs. - Update the "Additional Steps for Web Engine" to reflect the fact that the user's gclient file is copied from a template that contains a commented-out web engine entry. - Link to the "Engine Tool" docs instead of to "Compiling the engine" for the next steps. - In the RBE doc: - Update the gclient instructions to reflect that the gclient file may be copied from rbe.gclient. - Move the "gcloud" section into the "Getting started" parent section. The gcloud setup is required before any of the next steps. - Instead of suggested the "gcloud auth application-default login" command in case of an error, directly instruct the user to run this command. It's required for things to work. - Add a "Too many open files" section to the Troubleshooting parent section. <!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> *Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.* *List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.* *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
11 KiB
If you've already built the engine and have the configuration set up but merely need a refresher on actually compiling the code, see Compiling the engine or Engine Tool.
If you are checking these instructions to refresh your memory and your fork of the engine is stale,
make sure to merge up to HEAD before doing a gclient sync.
Getting dependencies
Make sure you have the following dependencies available:
- A Linux, macOS, or Windows host
- Linux supports cross-compiling artifacts for Android and Fuchsia, but not iOS.
- macOS supports cross-compiling artifacts for Android and iOS.
- Windows doesn't support cross-compiling artifacts for any of Android, Fuchsia, or iOS.
git(used for source version control).- An ssh client (used to authenticate with GitHub).
python3(used by many of our tools, includinggclient).- Chromium's
depot_tools (Which includes gclient)
- Add the
depot_toolsdirectory to the front of yourPATH.
- Add the
- On macOS and Linux:
curlandunzip(used bygclient sync). - On Linux: The
pkg-configpackage. - On Windows:
- Visual Studio 2017 or later (required for non-Googlers only).
- Windows 10 SDK (required for non-Googlers only). Be sure to install the "Debugging Tools for Windows" feature.
- On macOS:
- Install the latest Xcode.
- On Apple Silicon arm64 Macs, install the Rosetta translation environment by running
softwareupdate --install-rosetta.
You do not need to install Dart.
A Dart toolchain is automatically downloaded as part of the "Getting the source"
step. Similarly for the Android SDK, it is downloaded by the gclient sync step below.
Getting the source
Run the following steps to set up your environment:
Important
Non-Googler Windows users should set the following environment variables to point
depot_toolsto their Visual Studio installation directory:
DEPOT_TOOLS_WIN_TOOLCHAIN=0GYP_MSVS_OVERRIDE_PATH=C:\Program Files\Microsoft Visual Studio\2022\Community
- Use the path of your installation.
Clone the Flutter source code. As of late 2024, the engine source is part of the main flutter/flutter repo. The convention is to fork this repo and point origin to your fork and upstream to git@github.com:flutter/flutter.git. See Setting up the Framework development environment for more.
Important
On Windows, the following must be run as an Administrator due to a known issue.
gclient bootstrap
Flutter engine uses gclient to manage dependencies.
- Copy one of the
engine/scripts/*.gclientto the repository root as.gclient:- Googlers: copy
rbe.gclientto enable faster builds with RBE. Follow RBE Getting started to set up RBE. - Everyone else: copy
standard.gclient
- Googlers: copy
- Run
gclient syncfrom the root folder
Add et to PATH
The "Engine Tool" called et is useful when working with the engine. It is located in the flutter/engine/src/flutter/bin directory. Add this to your $PATH in your .rc file: e.g. on UNIX, using export PATH=/path/to/flutter/engine/src/flutter/bin:$PATH.
Additional Steps for Web Engine
Open the .gclient file in the repository root. Uncomment the lines indicated for building the web engine.
Now, run:
gclient sync
Next steps:
- Use
et, the Engine Tool, to actually get builds, now that you have the code. - The docs for the flutter tool have a section on using a locally built engine with the flutter tool.
- Signing commits, to configure your environment to securely sign your commits.
Editor autocomplete support
Xcode [Objective-C++]
On Mac, you can simply use Xcode (e.g., open out/host_debug_unopt/flutter_engine.xcodeproj).
VSCode with C/C++ Intellisense [C/C++]
VSCode can provide some IDE features using the C/C++ extension. It will provide basic support on install without needing any additional configuration. There will probably be some issues, like header not found errors and incorrect jump to definitions.
Intellisense can also use our compile_commands.json for more robust functionality. Either symlink src/out/compile_commands.json to the project root at src or provide an absolute path to it in the c_cpp_properties.json config file. See "compile commands" in the c_cpp_properties.json reference. This will likely resolve the basic issues mentioned above.
The easiest way to do this is create a multi-root workspace that includes the Flutter SDK. For example, something like this:
# flutter.code-workspace
{
"folders": [
{
"path": "path/to/the/flutter/sdk"
}
],
"settings": {}
}
Then, install the clangd extension and edit the "settings" key:
"settings": {
"html.format.enable": false,
"githubPullRequests.ignoredPullRequestBranches": [
"master"
],
"clangd.path": "engine/src/flutter/buildtools/mac-arm64/clang/bin/clangd",
"clangd.arguments": [
"--compile-commands-dir=engine/src/out/host_debug_unopt_arm64"
],
"clang-format.executable": "engine/src/flutter/buildtools/mac-arm64/clang/bin/clang-format"
}
... which is built with:
# M1 Mac (host_debug_unopt_arm64)
et build -c host_debug_unopt_arm64
Some files (such as the Android embedder) will require an Android clangd configuration.
For adding IDE support to the Java code in the engine with VSCode, see "Using VSCode as an IDE for the Android Embedding".
Zed Editor
Zed can be used to edit C++ code in the Engine. To enable analysis and auto-completion, symlink src/out/compile_commands.json to the project root at src.
cquery/ccls (multiple editors) [C/C++/Objective-C++]
Alternatively, cquery and a derivative ccls are highly scalable C/C++/Objective-C language server that supports IDE features like go-to-definition, call hierarchy, autocomplete, find reference etc that works reasonably well with our engine repo.
They(https://github.com/cquery-project/cquery/wiki/Editor-configuration) supports editors like VSCode, emacs, vim etc.
To set up:
- Install cquery
brew install cqueryorbrew install cclson osx; or- Build from source
- Generate compile_commands.json which our GN tool already does such as via
src/flutter/tools/gn --ios --unoptimized - Install an editor extension such as VSCode-cquery or vscode-ccls
- VSCode-query and vscode-ccls requires the compile_commands.json to be at the project root. Copy or symlink
src/out/compile_commands.jsontosrc/orsrc/flutterdepending on which folder you want to open. - Follow Setting up the extension to configure VSCode-query.
- VSCode-query and vscode-ccls requires the compile_commands.json to be at the project root. Copy or symlink
Using VSCode as an IDE for the Android Embedding [Java]
-
Install the extensions vscjava.vscode-java-pack (Extension Pack for Java) and vscjava.vscode-java-dependency (Project Manager for Java).
-
Right click on the
shell/platform/androidfolder in the engine source and click onAdd Folder to Java Source Path. This creates an anonymous workspace and turns those files from "syntax mode" to "compile mode". At this point, you should see a lot of errors since none of the external imports are found. -
Find the "Java Dependencies" pane in your Explorer view. Use the "Explorer: Focus on Java Dependencies View" command if hidden.
-
Refresh the view and find the "flutter_*" project. There should be a "_/shell/platform/android" source folder there.
-
In the "Referenced Libraries" sibling node, click the + button, navigate to
engine/src/third_party/android_embedding_dependenciesand add the entire folder. This is the equivalent of adding"java.project.referencedLibraries": [ "{path to engine}/src/third_party/android_embedding_dependencies/lib/**/*.jar" ]to your VSCode's settings.json for your user or for your workspace.
-
If you previously had a
shell/platform/android/.classpath, delete it.
Using Android Studio as an IDE for the Android Embedding [Java]
Alternatively, Android Studio can be used as an IDE for the Android Embedding Java code. See docs at https://github.com/flutter/flutter/blob/main/engine/src/flutter/shell/platform/android/README.md#editing-java-code for instructions.
VSCode Additional Useful Configuration
-
Create snippets for header files with this configuration. This will let you use
hdrkeyboard macro to create the boiler plate header code. Also consider some of these settings and more tips. -
To format GN files on save, consider using this extension.
