Configure and build Fuchsia

To build Fuchsia, you need to be able to run the fx command in your terminal.

Note: If you haven't set up your build environment, see Set up environment variables.

Set build configuration

To set your build configuration, run the following command:

fx set core.x64

The fx set command takes a PRODUCT.BOARD argument, which defines the product and board configuration of your build. This configuration informs the build system what packages to build for your Fuchsia device. core is a product with a minimal feature set, which includes common network capabilities. x64 refers to the x64 architecture.

See Configure a build for more options.

Speed up the build

Note: This step is optional.

To reduce the time it takes to build Fuchsia, you can do any of the following:

Speed up the build with Goma

Goma{:.external} is a distributed compiler service for open source projects such as Chrome, Android and Fuchsia. If you have access to Goma, run the following command to enable a Goma client on your machine:

fx goma

Speed up the build with ccache

If you do not have access to Goma, but want to accelerate the Fuchsia build locally, use ccache{:.external} to cache artifacts from previous builds.

To use ccache on Linux, install the following package:

sudo apt-get install ccache

For macOS, see Using CCache on Mac{:.external} for installation instructions.

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

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

  • Force use of ccache even if other accelerators are available:

    fx set core.x64 --ccache
    
  • Disable use of ccache:

    fx set core.x64 --no-ccache
    

Build Fuchsia

Note: Building Fuchsia can take up to 90 minutes.

To build Fuchsia, run the following command:

fx build

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

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

See Execute a build for more information.

Next steps

See Explore Fuchsia in the getting started guide to learn more about how Fuchsia is structured.