Make fuchsia_product_image() slightly more hermetic.

The `ffx assembly` plugin invoked by the action generated by the
fuchsia_product_image() rule needs to call the host `cmc` tool
at runtime. To ensure this works when the action is run inside
a Bazel sandbox, expose both the `cmc` host tool, as well as
the `cmc-meta.json` file that is used to point to it.

The latter is required because ffx looks for SDK host tools
by parsing the top-level metadata file, which will point to
`tools/x64/cmc-meta.json`, which will point to `tools/x64/cmc`.

To fix this, the CL does the following:

- Add a `cmc_manifest` entry to the FuchsiaToolchainInfo
  provider, and populate it with an label attribute in
  the fuchsia_toolchain_info() rule definition. This ensures
  that the value is a File object, as required by Bazel.

- Modify repository_template.BUILD to expose the
  `cmc-meta.json` file from @fuchsia_sdk through the provider.

- Modify _fuchsia_product_image_impl to use the toolchain
  instance to access the host tool and its manifest, and
  add them as inputs to the shell action generated by
  the function.

To verify this, apply [1] to your local fuchsia.git tree, then
try to build an assembly command with bazel (see examples in
the second bug below). Before this CL, this would fail with
an error message that looks like:

Product Assembly Failed
    1.  Building Image Assembly config
    2.  Getting host tool from the SDK: cmc
    3.  Tool 'cmc' not found in SDK dir

After the CL, this fails later, because expanded prebuilt
package content are not available in the sandbox, which will
be addressed by future changes.

[1] htps://

Bug: 115151
Bug: 120613
Change-Id: I4e83100a0f3fd8c434862c71f2ba43b47b214f69
Reviewed-by: Jiaming Li <>
Commit-Queue: David Turner <>
3 files changed
tree: 79b0be19e955b282626604de7f7d2e7f94bd96d7
  1. bazel_rules_fuchsia/
  2. bazel_rules_fuchsia_experimental/
  3. manifests/
  4. scripts/
  5. tests/
  6. .gitignore
  7. .gitmodules
  9. BUILD.bazel

Fuchsia SDK Integration Repository

This repository provides environment-specific (e.g. Bazel, GN) tools for the SDK and associated integration tests in a public repo.

Visit Contributing to Fuchsia to learn how to contribute to this repository.