Prerequisites
Before building for Fuchsia, you must have the Dart source tree set up using the standard build instructions. See Building from Source for details.
Setup
Update your .gclient file
Configure your build to download Fuchsia dependencies by editing your
.gclient file (located in the directory that contains the main dart directory):Add this to the existing
custom_vars section if you already have one, or create the section if it doesn’t exist.Building
Build the Dart SDK for Fuchsia using the--os=fuchsia flag:
Build Options
--mode: Build mode (releaseordebug)--os=fuchsia: Target Fuchsia OS--arch: Target architecture (typicallyarm64orx64)create_sdk: Build the complete SDKruntime: Build the Dart VM runtime
Supported Architectures
Fuchsia builds support:arm64- 64-bit ARM (most common for Fuchsia devices)x64- 64-bit x86 (for Fuchsia emulators)
Testing
Run tests on Fuchsia builds using the test script with the Fuchsia runtime:Test Command Breakdown
-nvm-fuchsia-release-arm64: Named configuration for Fuchsia VMvm: Use the VM runtimefuchsia: Target Fuchsia OSrelease: Release build modearm64: ARM64 architecture
-j4: Run 4 parallel test tasksffi: Run FFI tests (you can specify other test suites)
Running Different Test Suites
Build Output
The Fuchsia build artifacts are placed in:Common Build Configurations
Development Build
For faster iteration during development:Release Build with Tests
For testing a production-like build:Multi-Architecture Build
Build for both ARM64 and x64:Troubleshooting
Build fails with missing Fuchsia SDK
Build fails with missing Fuchsia SDK
Ensure you’ve configured Fuchsia dependencies:
-
Check your
.gclientfile contains: -
Re-run
gclient sync:
Tests fail to run
Tests fail to run
Verify your test configuration matches your build:
- For ARM64 release:
-nvm-fuchsia-release-arm64 - For ARM64 debug:
-nvm-fuchsia-debug-arm64 - For x64 release:
-nvm-fuchsia-release-x64
Slow build times
Slow build times
Speed up builds by:
-
Building only the runtime (omit
create_sdk): - Using a local filesystem for output (see Build Performance Tips)
- Building in release mode (faster than debug)
Fuchsia-Specific Considerations
Fuchsia SDK Version
The Fuchsia SDK version is managed by theDEPS file in the Dart SDK. When you run gclient sync, it downloads the specific Fuchsia SDK version pinned in DEPS.
Component Model
Fuchsia uses a component-based architecture. When deploying Dart applications to Fuchsia, you’ll need to package them as Fuchsia components. This build process creates the Dart runtime that can be included in such components.System Libraries
The Fuchsia build links against Fuchsia’s system libraries. The build system automatically handles this when you specify--os=fuchsia.
Integration with Fuchsia Development
If you’re developing Fuchsia itself and want to integrate a custom Dart build:- Build the Dart runtime for Fuchsia as shown above
- The build output can be integrated into Fuchsia’s build system
- Refer to Fuchsia’s documentation for details on integrating prebuilt components
For full Fuchsia development workflows, consult the Fuchsia documentation in addition to this guide.
Next Steps
Build from Source
General build instructions for all platforms
Testing
Learn about testing the Dart SDK
ARM/RISC-V
Build for other architectures
Contributing
Contribute to the Dart SDK