https://github.com/bazelbuild/rules_platform
https://github.com/bazelbuild/rules_platform
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/bazelbuild/rules_platform
- Owner: bazelbuild
- License: apache-2.0
- Created: 2023-11-20T20:33:29.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-12T17:03:01.000Z (over 2 years ago)
- Last Synced: 2025-01-12T01:56:38.521Z (over 1 year ago)
- Language: Starlark
- Size: 51.8 KB
- Stars: 9
- Watchers: 7
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# 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`.