Fix fuchsia_prebuilt_package() rule

This fixes the implementation of the rule in several ways:

- Use ctx.actions.declare_directory() to declare an output directory
  where all input .far archive content is extracted (using `pm expand`).
  This allows Bazel to track all these files properly, even if their
  names cannot be known in advance. In particular, if the command is
  run in a sandbox, all files are properly copied into the final
  output base location, instead of being removed at the end of the
  command.

  This also ensures that any Bazel target that depends on the
  `rebased_package_manifest.json` file will also see the content files
  it points to (see associated bug). Note however that this does not
  translate to GN unfortunately at the moment!

- Simplify the _COMPONENT_VALIDATION_SCRIPT to directly read the
  meta.far file that was extracted by a previous action, instead of
  re-extracting the full prebuilt package archive (!) for any component
  or driver item to be validated.

- Improve the same script to detect components using the
  `meta/${COMPONENT}.cm` fgrep pattern, to avoid false positives,
  which  could happen trivially if the component name passed to
  fuchsia_prebuilt_package() was shorter than the ones found in the
  package (e.g. 'foo' would validate 'meta/foobar.cm' even though
  these do not correspond to the same component name).

Bug: 120613
Change-Id: Icca4503d4ae8c74172ea3cbe437e88301950ed04
Reviewed-on: https://fuchsia-review.googlesource.com/c/sdk-integration/+/791984
Commit-Queue: David Turner <digit@google.com>
Reviewed-by: Jiaming Li <lijiaming@google.com>
4 files changed
tree: 4079a24339ded789804260a226d026c9c77a49e3
  1. bazel_rules_fuchsia/
  2. bazel_rules_fuchsia_experimental/
  3. manifests/
  4. scripts/
  5. tests/
  6. .gitignore
  7. .gitmodules
  8. AUTHORS
  9. BUILD.bazel
  10. CONTRIBUTING.md
  11. LICENSE
  12. PATENTS
  13. README.md
  14. using_local_sdk.md
README.md

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.