In some cases, you may want to override the configuration of a Fuchsia product.
To start using developer overrides for assembly:
In your Fuchsia checkout, make a //local/BUILD.gn
file:
A //local.BUILD.gn
file may look like:
Note: For the fully list of values that you can specify, see Product configuration. Additionally, you can use developer_only_options
to enable certain options including board configurations.
import("//build/assembly/developer_overrides.gni") assembly_developer_overrides("my_overrides") { kernel = { command_line_args = ["foo"] } }
This is what this BUILD.gn
file indicates:
my_overrides
. You can use any meaningful identifier for this field.kernel
, command_line_args
are all based on supported values for Platform configuration. For more information, see PlatformConfig
.Once you have made a //local/BUILD.gn
file that meets your requirements, you can set your fx set
command to use this assembly platform configuration. For example:
Note: The value used for --assembly-override
is the identifier that you used in your //local/BUILD.gn
file.
fx set --assembly-override=//local:my_overrides
Build Fuchsia:
fx build
You should now be able to build Fuchsia as you normally would.
Additionally, you can also do the following:
There may be some cases where you may need to include additional packages to your product's packages. In this case, your //local/BUILD.gn
may look like:
import("//build/assembly/developer_overrides.gni") assembly_developer_overrides("my_custom_base_packages") { base_packages = [ "//some/gn/target/for/a:package", "//some/other/target/for/a:package", "//third_party/sbase", ] }
There may be some cases where you may need to include shell commands to your product‘s configuration. When adding CLI tools for running in the Fuchsia shell, it’s necessary to both add the package and configure assembly to create the launcher stub that runs the component for the binary. This is due that most CLI tools are actually components.
To do this, define a shell_commands
list within your assembly_developer_overrides
. Each entry in this list is an object with the following keys:
package
: The name of the package that contains the shell command (for example, cp
). This is the package name, not a GN target label.components
: A list of the CLI binaries within the package that you want to register as shell commands. Assembly automatically adds the meta/
prefix and .cm
suffix to these names when looking for their component manifests. For example, foo
becomes meta/foo.cm
.For example, to add the cp
command from the cp
package, your //local/BUILD.gn
may look like:
import("//build/assembly/developer_overrides.gni") assembly_developer_overrides("my_custom_shell_commands") { shell_commands = [ { package = "cp" components = [ "cp" ] } ] }
And for adding multiple entries to the shell_commands
list, see the following example:
import("//build/assembly/developer_overrides.gni") assembly_developer_overrides("my_multiple_shell_commands") { shell_commands = [ { package = "foo" components = [ "foo_comp" ] }, { package = "bar" components = [ "bar_comp1", "bar_comp2" ] } ] }
Additionally, if making the package available through package discovery isn't sufficient, you can also add the package target to a package set. For example, to add the package to the base
package set, your //local/BUILD.gn
may look like:
import("//build/assembly/developer_overrides.gni") assembly_developer_overrides("my_custom_shell_commands") { shell_commands = [ { package = "cp" components = [ "cp" ] } ] # This GN target should define a package named "foo_cli". base_packages = [ "//some/gn/target/for/my/package:foo_cli" ] }
developer_only_options
{#use-developer_only_options}In some cases, you may want to use some of the developer_only_options
. These options can be combined with the general overrides covered in Use assembly overrides.
Note: For a full list of supported developer_only_options
see developer_overrides.gni
.
In this case, your //local/BUILD.gn
may look like:
import("//build/assembly/developer_overrides.gni") assembly_developer_overrides("my_overrides") { developer_only_options = { all_packages_in_base = true netboot_mode = true } }
all_packages_in_base
This option redirects all cache and on_demand package-set packages into the base package set. This feature allows the use of a product image that has cache or universe packages in a context where networking may be unavailable or a package server cannot be run.
The primary use case for this option is to allow debugging tools to be available on-device when networking is non-functional.
netboot_mode
This option creates a ZBI (Zircon Boot Image) that includes the fvm/fxfs image inside a ramdisk, to allow the netbooting of the product.
This is a replacement for the netboot
assembly that was previously generated with //build/images/fuchsia:netboot
.
You can also override multiple platform configuration areas within the same assembly_developer_overrides
definition.
For example, the following override customizes both development SSH keys and USB peripheral functions:
import("//build/assembly/developer_overrides.gni") assembly_developer_overrides("my_multi_overrides") { platform = { development_support = { authorized_ssh_keys_path = "//local/fuchsia_authorized_keys" } usb = { peripheral = { functions = [ "cdc" ] } } } }