Configure and build Fuchsia

This guide provide instructions on how to configure and build Fuchsia on a host machine.

The steps are:

  1. Prerequisites.
  2. Set your build configuration.
  3. Speed up the build (Optional).
  4. Build Fuchsia.

Prerequisites {#prerequisites .numbered}

This guide requires the following prerequisite items:

Source code setup

Complete the Download the Fuchsia source code guide. This guide helps you download the Fuchsia source code and set up the Fuchsia development environment on your host machine.

Hardware requirements

You can build Fuchsia on a host machine with the x86-64 Linux architecture (Debian-based distributions only).

Windows is not supported.

Set your build configuration {#set-your-build-configuration .numbered}

Fuchsia's build configuration informs the build system which product to build and which architecture to use.

To set your Fuchsia build configuration, run the following fx set command:

fx set {{ '<var>' }}PRODUCT{{ '</var>' }}.{{ '<var>' }}BOARD{{ '</var>' }}

Replace the following:

  • PRODUCT: The Fuchsia product that you want to build; for example, core and workbench_eng.
  • BOARD: The architecture of the product; for example, x64.

The example command below sets the build configuration to core.x64:

fx set core.x64
  • core is a product with the minimum feature set of Fuchsia, which includes network capabilities.
  • x64 is a board that can run on a wide range of x64 devices, including the Fuchsia emulator (FEMU).

On the other hand, the example below sets the build configuration to workbench_eng.x64:

fx set workbench_eng.x64

The lists of possible boards and products are aggregated from the root of the Fuchsia source repository. For more information, see Configure a build.

Speed up the build (Optional) {#speed-up-the-build .numbered}

Note: This step is not required for building Fuchsia.

To accelerate the Fuchsia build locally, use ccache{:.external} to cache C and C++ artifacts from previous builds.

Install the ccache package:

sudo apt install ccache

ccache is enabled automatically if your CCACHE_DIR environment variable refers to an existing directory.

To override this default behavior, specify the following flags to fx set:

  • Force the use of ccache even when other accelerators are available:

  • Disable the use of ccache:

Build Fuchsia {#build-fuchsia .numbered}

The fx build command executes the build to transform source code into packages and other build artifacts.

To build Fuchsia, run the following command:

fx build

Note: Building Fuchsia can take up to 90 minutes.

When you modify source code, run the fx build command again to perform an incremental build, or run the fx -i build command to start a watcher, which automatically builds whenever you update the source code.

For more information on building Fuchsia, see Execute a build.

Next steps

To launch the Fuchsia emulator (FEMU) on your machine, see Start the Fuchsia emulator.

However, if you want to run Fuchsia on a hardware device, see Install Fuchsia on a device instead.