Clone this repo:
  1. 013f12d Merge pull request #16 from gregestren/patch-1 by Ara Nguyen · 3 months ago upstream/main
  2. bb635db Update load() reference to the right repo by Greg · 3 months ago
  3. e24a280 Allow `platform_data` to also transition generated files. (#15) by John Cater · 4 months ago
  4. 3647cf9 set strip_prefix to be empty as we do not rely on Github generated source archives and dont have a prefix to strip https://github.com/bazel-contrib/publish-to-bcr/tree/main/templates (#9) by Ara Nguyen · 1 year, 6 months ago 0.1.0
  5. edbf298 Merge pull request #8 from aranguyen/main by Ara Nguyen · 1 year, 6 months ago

rules_platform

This repository contains all platforms-related rules or transitions that rules author/Bazel users could use. The README should be kept updated as new rules/transition get added to the repo.

For questions or concern, please email bazel-discuss@googlegroups.com.

Motivation

Many rule authors and users want to create targets that can easily change the target platform: rule authors may want to add convenient rule attributes for this, whereas users frequently need to bundle together executables for multiple platforms in a single high-level artifact. This repo houses new rules/transition which rules authors and Bazel users can import and use. Because these are Starlark implementations, with no Bazel changes, rules authos can feel free to extend or ignore these as needed.

Rules

Use case: Depend on a target built for a different platform

The platform_data rule can be used to change the target platform of a target, and then depend on that elsewhere in the build tree.

cc_binary(name = "foo")

platform_data(
    name = "foo_embedded",
    target = ":foo",
    platform = "//my/new:platform",
)

py_binary(
    name = "flasher",
    srcs = ...,
    data = [
        ":foo_embedded",
    ],
)

Regardless of what platform the top-level :flasher binary is built for, the :foo_embedded target will be built for //my/new:platform.