[bazel_sdk] Add `use_rules_fuchsia` attribute to `fuchsia_sdk_repository()`.

Add a new boolean attribute to the `fuchsia_sdk_repository()` rule
to ensure that the generated BUILD.bazel files it contains use
`@rules_fuchsia//...` instead of `@fuchsia_sdk/...` to load Bazel
SDK rules.

It also ensures that the @fuchsia_sdk//fuchsia:foo.bzl files
re-export symbols from @rules_fuchsia/... instead of //fuchsia/...
in order to ensure backwards compatibility for client BUILD files
that still load the rules from @fuchsia_sdk.

A few special cases are still preserved to ensure backwards
compatibility and avoid breaking the build. For example:

- @fuchsia_sdk//fuchsia:fuchsia_api_level is still used to
  set and access the Fuchsia API level value.

- @rules_fuchsia//fuchsia/constraints:BUILD.bazel requires
  a @fuchsia_sdk//:api_level.bzl file to load properly.

- fuchsia_cc_driver() and fuchsia_devicetree_visitor()
  use a @fuchsia_sdk label to access their linker scripts.

- The fuchsia_wrap_cc_binary() macro still hard-codes references
  to @fuchsia_sdk and @fuchsia_clang by default in the targets
  it generates.

For more, see the comments in `_merge_rules_fuchsia()` function of
`generate_sdk_build_rules.bzl`.

This *only* modifies the content of the @fuchsia_sdk repository
in the in-tree Bazel workspace. The final version of the SDK, generated
by `fx build generate_fuchsia_sdk_repository`, is unchanged.

A future CL will change the rest of fuchsia.git to load all rules
from @rules_fuchsia directly. Then others will do the same for
various //vendor/* repositories.

Bug: 381126633
Change-Id: I4a51afd4e9fce815007dfcefd20e63855b3b48f0
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1168332
Reviewed-by: Jiaming Li <lijiaming@google.com>
Reviewed-by: Chase Latta <chaselatta@google.com>
Commit-Queue: David Turner <digit@google.com>
34 files changed
tree: a31148a7ef874e543911a09c3526919a254f1191
  1. boards/
  2. build/
  3. bundles/
  4. docs/
  5. examples/
  6. infra/
  7. products/
  8. scripts/
  9. sdk/
  10. src/
  11. third_party/
  12. tools/
  13. zircon/
  14. .clang-format
  15. .clang-tidy
  16. .editorconfig
  17. .git-blame-ignore-revs
  18. .gitattributes
  19. .gitignore
  20. .gitmodules
  21. .gn
  22. .ignore
  23. analysis_options.yaml
  24. AUTHORS
  25. BUILD.gn
  26. CODE_OF_CONDUCT.md
  27. CONTRIBUTING.md
  28. fuchsia.code-workspace
  29. LICENSE
  30. OWNERS
  31. PATENTS
  32. pyproject.toml
  33. pyrightconfig.json
  34. README.md
  35. rustfmt.toml
  36. shac.star
  37. shac.textproto
README.md

Fuchsia

What is Fuchsia?

Fuchsia is an open source, general purpose operating system supporting modern 64-bit Intel and ARM processors.

We expect everyone interacting with our project to respect our code of conduct.

Read more about Fuchsia's principles.

How can I build and run Fuchsia?

See Getting Started.

Where can I learn more about Fuchsia?

See fuchsia.dev.