tree: 5ed5edeb25a94ddbbe2b6d987f6a16a4eaf3a130 [path history] [tgz]
  1. BUILD.bazel
  2. README.md
products/codelab/README.md

Create a product with the Fuchsia SDK

This codelab explains how you can create your own product bundle and build your target with a custom configuration.

A Fuchsia product bundle includes system images, packages, and metadata that can be used to flash, emulate, or update a Fuchsia target. Product Bundles are built by providing:

  • Product configurations which describe the user experience
  • Board configurations which describe the target hardware

Besides providing product-specific code, product configurations can configure the Fuchsia platform and indicate requirements from the product. Board configurations identify available capabilities of the target hardware. When a product bundle is being constructed, the Fuchsia tooling will assert that all the requirements of the product are met by the board.

Write first product rules

In the //products/reference/BUILD.bazel file, you can see the fuchsia_product and fuchsia_product_bundle Bazel rules.

A fuchsia_product combines a product and board configuration to create a set of images for a single physical slot (A, B, or R). On bootup, the bootloader typically chooses which slot to boot into. When we flash a target, we typically provide A and R slots, which is the “main” product and the “recovery” product.

A fuchsia_product_bundle takes multiple fuchsia_products and puts them into a single distributable directory. It also contains the packages and metadata that are used to emulate, flash, and ota these products to a fuchsia target.

The //products/reference/BUILD.bazel file contains examples of attributes you can use in your product.

For more information on the fuchsia_product and fuchsia_product_bundle Bazel rules, see the fuchsia_product and fuchsia_product_bundle, respectively.

Choose board configuration

In the //boards/BUILD.bazel file, there is a Bazel rule for prebuilt boards. Using this file as an example, you can choose one of the boards for your product. Alternatively, you can also download a different prebuilt board definition from the CIPD repository. Start by going to this CIPD link for the boards. After that, look into the manifests directory and WORKSPACE.bazel file to look at how to import these boards.

Specify product configuration

In the //products/reference/BUILD.bazel there is a Bazel rule called fuchsia_product_configuration that was written for the existing reference product. Using this as an example, you can make your own product definition in the //products/codelab/BUILD.bazel file. See the ProductConfig for a list of supported fields for the product_config attribute.

Build

After specifying board and product configurations, you are now ready to build your product with the following command.

tools/bazel build products/codelab:your_product_name

Depending on your product, you may also want to add additional attributes like virtual devices and binaries that you may want to run. To learn more about developing on Fuchsia, see:

Congratulations on writing your first product!

You have created your own product on Fuchsia using only the Fuchsia SDK!