The body of the
Setting up the Engine development environment · Flutter/Flutter Wiki
If you’ve already configured your environment and built the Engine, just to review the compiled code, see:
Compiling the Engine
Compiling the Engine translation is completed later.Copy the code
Make sure you have added the following dependencies:
-
Linux, macOS, or Windows.
-
Linux supports cross-compilation, generating Android and Fuchsia artifacts, but not IOS.
-
MacOS supports cross-compilation, generating Android and IOS artifacts.
-
Windows does not support cross-compilation to generate Android,Fuchsia or IOS. (Mac is on its way….)
-
-
Git (source control).
-
An IDE. For syntax highlighting (jump correlating) Settings when editing Engine, see the bottom of this page.
-
An SSH client (for Github authentication).
-
Chromium’s depot_tools (make sure environment variables are configured). Use gClient.
-
Python(used by most of our tools, including GClient).
-
MacOS and Linux require: curl and unzip (for gClient sync).
-
The Windows need to:
-
Visual Studio 2017 or later (non-Google users only)
-
Windows 10 SDK (non-Google users only).
- Make sure it’s installed
Debugging Tools for Windows
- Make sure it’s installed
-
-
MacOS requires: the latest version of Xcode.
-
Advice for Googlers: Goma decentralized build. See compiling Page for installation details.
Goma can increase build speed.Copy the code
You don’t need to install Dart, the Dart toolchain will download automatically during the Getting the Code phase. Again, the Android SDK will be installed during the GClient Sync phase.
Follow these steps to configure your environment:
-
Use your own Github account Fork github.com/flutter/eng… . If you already Fork and have a completely new development environment, make sure your Fork repository is updated to avoid using ancient versions. Do not clone the repository locally, the script will take care of this.
-
If you have not configured SSH keys, please refer to the following article:
Help.github.com/articles/ge… .
-
Create an empty engine folder for the Clone project and CD it into that folder. (Folder names can also be customized, although some tools use Engine by default. If you want to change the name of engine, you need to synchronize the related configuration.
-
Create a. Gclient file in the engine folder that contains the following content and replace
with your Github account:
solutions = [
{
"managed": False,
"name": "src/flutter",
"url": "[email protected]:<your_name_here>/engine.git",
"custom_deps": {},
"deps_file": "DEPS",
"safesync_url": "",
},
]
Copy the code
-
In the engine directory, execute gClient sync. It pulls all the source code that Flutter depends on. Do not interrupt its execution, or it will cause inconsistencies. (Git Clone is also executed automatically.)
-
Add an upstream warehouse:
-
CD SRC /flutter (this path will be created in your engine directory after gClient sync.)
-
Git remote add upstream [email protected]: flutter/engine. The git (so that when you run the git fetch, will pull from flutter/engine warehouse, rather than you clone, other.)
-
cd .. (Return to the parent SRC directory.)
-
-
If you use Linux, the following may help you install the dependencies you need. Note: These scripts are version-specific and there is no guarantee that all versions of the configuration will work. If the script fails, you may need to fill in the missing packages yourself. You can update them yourself if you need them for production, but it is much easier to install the packages you need directly, especially the install-build-deps.sh script.
sudo ./build/install-build-deps-android.sh
sudo ./build/install-build-deps.sh
sudo ./flutter/build/install-build-deps-linux-desktop.sh
-
If you use a Mac:
- Install Oracle’s Java JDK, version 1.8 or later
-
If you also plan to work on the Buildroot repository and already have a local checkout, run the following command in the SRC directory to update your Git remotes:
git remote rename origin upstream
git remote add origin [email protected]:<your_name_here>/buildroot.git
Copy the code
The next step
- Compiling the engineHow do you really build what you have
engine code
. - The Flutter Tool has a section that explains how to use your custom engine.
Editor auto-complete function
Xcode [Objective-C++]
For Mac, use Xcode directly (e.g., open out/host_debug_unopt/ products.xcodeProj).
I was a staunch Windows... All this, I began to waver...)Copy the code
VSCode with C/C++ Intellisense [C/C++]
Some IDE features are available through C/C++ extension VSCode. These basic features are added at installation time and require no additional configuration. However, there are some problems, such as header not finding errors and jumping to wrong method definitions.
Intellisense provides powerful functionality via compile_commands.json. This can be done either by connecting SRC /out/compile_commands.json to the project root under SRC via symlink or by providing its absolute path in c_cpp_properties.json. See “compile Commands “in the c_cpp_properties.json reference. This article should solve the above problems.
Java support needs to be added to VSCode (in engine development), see “Using VSCode as an IDE for the Android Embedding”.
Cquery/CCLS (most editors) [C/C++/Objective-C++]
In addition, CQuery and derived CCLS are IDE supported highly extensible language service plug-ins such as jump to definition, call hierarchy, auto-completion, reference lookup, and so on, which work well in our Engine Repo.
They (github.com/cquery-proj…). Supports VSCode, Emacs, Vim and other editors.
Configuration:
-
Install cquery
i.
brew install cquery
orbrew install ccls
on osx; orii. Build from source
-
Generate compile_commands. Json. Our GN tool can also do this with its SRC /flutter/tools/ GN –ios –unoptimized.
-
Install an editor plug-in (extension) such as VScode-cQuery or vscode-ccls
I.vscode-query and vscode-ccls require compile_commands.json to be stored at the root of the project. Symlink or copy SRC /out/compile_commands.json to the SRC/or SRC /flutter folder, depending on which one you want to open.
Ii. Further configure vscode-query with Setting up the extension.
VSCode for Android Embedding development [Java]
-
Install vscjava.vscode-java-pack and vscjava.vscode-java-dependency plug-ins.
-
Right-click the shell/ Platform/Android folder under Engine, and then click to add the folder to Java Path. This will create an anonymous workspace and switch those files from “syntax mode” to “compile mode”. At this point, you’ll see a bunch of errors because the external dependencies didn’t import.
-
Locate the Java Dependencies panel in the Explorer View. If hidden, use the “Explorer: Focus on Java Dependencies View” command.
-
Refresh the window and find the “Flutter_ *” item. There should be a “_/shell/platform/ Android “source folder.
-
At the node next to Referenced Libraries, click + and go to engine/ SRC /third_party/ Android_embedding_dependencies then add the entire folder. This is equivalent to adding the following to VSCode’s settings.json.
"java.project.referencedLibraries": [
"{path to engine}/src/third_party/android_embedding_dependencies/lib/**/*.jar"
]
Copy the code
- If you already have
shell/platform/android/.classpath
Delete it.
The end of the
This section describes how to configure the Engine development environment.
Setting up the Engine development environment · Flutter/Flutter Wiki