This guide covers all the dependencies you need to install before building the Dart SDK from source.
Python
Dart SDK requires Python 3 to build.
On Windows, ensure that python.bat wrapper from depot_tools comes ahead of any other Python binaries in your PATH. Some steps still require Python 2 on Windows, but Python 3 must also be available.
Install the essential build tools: sudo apt-get install git python3 curl xz-utils
Chromium’s depot_tools are required for managing the Dart source tree: git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH = " $PATH : $PWD /depot_tools"
Add the export command to your shell’s rc file (.bashrc, .zshrc, etc.) to make it permanent.
Install Xcode Install Xcode from the Mac App Store. If you encounter the error: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory
'/Library/Developer/CommandLineTools' is a command line tools instance
Run this command to fix it: sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Install Chromium’s depot_tools: git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH = " $PATH : $PWD /depot_tools"
Add the export command to your shell’s rc file (.bashrc, .zshrc, etc.) to make it permanent.
Install Visual Studio Install Visual Studio 2017 or newer. Make sure to install the “Desktop development with C++” component during installation.
Install Windows 10 SDK You must have Windows 10 SDK installed. This can be installed:
Through the Visual Studio installer, or
As a standalone download
The SDK Debugging Tools are also required: Via Visual Studio installer:
Open Control Panel → Programs → Programs and Features
Select “Windows Software Development Kit”
Click Change → Change
Check “Debugging Tools For Windows”
Click Change
Via standalone installer:
Download and use the standalone SDK installer.Follow the depot_tools setup instructions for Windows. Important for non-Googlers: Set the DEPOT_TOOLS_WIN_TOOLCHAIN system variable to 0.Otherwise, depot_tools will attempt to pull down a Google-internal toolchain instead of using your local Visual Studio installation.
If using Visual Studio Community Edition, the executable may have a different name. Pass the executable name to the build script: python tools/build.py --executable=VSExpress.exe create_sdk
Visual Studio 2015 Gyp should auto-detect your Visual Studio version. If it doesn’t, set the environment variable: set gyp_msvs_version= 2015
gclient runhooks
Cross-Compilation Dependencies
Linux Cross-Compilers
For cross-compiling to different architectures on Debian/Ubuntu:
# To target x64
sudo apt-get install g++-x86-64-linux-gnu
# To target arm
sudo apt-get install g++-arm-linux-gnueabihf
# To target arm64
sudo apt-get install g++-aarch64-linux-gnu
# To target riscv64
sudo apt-get install g++-riscv64-linux-gnu
The build scripts download a Clang toolchain that can target X64, ARM, ARM64, or RISCV64 from an X64 or ARM64 host. You only need to install cross-compilers manually for other cases, like building on a RISC-V host or targeting RISCV32.
Android Dependencies
To build for Android, update your .gclient file:
"custom_vars" : {
"download_android_deps" : True ,
},
Then run:
This downloads the Android NDK and SDK (may take 10+ minutes).
Fuchsia Dependencies
To build for Fuchsia, update your .gclient file:
"custom_vars" : {
"download_fuchsia_deps" : True ,
},
Then run:
Optional Dependencies
Emscripten
If you don’t have Emscripten but need it, update your .gclient file:
"custom_vars" : {
"download_emscripten" : True ,
},
Then run gclient sync.
Verifying Your Setup
After installing dependencies, verify your setup:
# Check Python version
python3 --version
# Check depot_tools is in PATH
which gclient # Linux/macOS
where gclient # Windows
# Check git is available
git --version
Managing Third-Party Dependencies
The Dart SDK uses gclient to manage dependencies described in the DEPS file.
When you switch branches or update your SDK checkout, run gclient sync to bring dependencies in sync with the SDK version.
Adding New Dependencies
New dependencies require explicit approval from Dart leadership before being added to the DEPS file, unless they are Dart core packages .
When adding dependencies:
File an issue in the Dart SDK repo for approval
Ensure the license is compatible with Dart’s license
Add a README.google file describing the dependency
Include a LICENSE file with the actual license
CC [email protected] on the change
Updating Dependencies
To roll a specific dependency:
dart tools/manage_deps.dart bump third_party/pkg/package_config
To roll all package dependencies:
dart tools/rev_sdk_deps.dart
Next Steps
Build from Source Now that you have the dependencies installed, proceed to build the SDK from source.