This repository serves as the central source for S-CORE Bazel platforms and constraints, designed to:
- Provide global constraints that complement the standard set offered by Bazel, enabling more precise environment description and selection.
- Define consistent platform configurations to make toolchain selection seamless and uniform across all S-CORE modules.
By using this repository, S-CORE teams can ensure compatibility, reproducibility, and clarity when specifying build environments and extending Bazel’s default capabilities.
To use predefined platforms and constraints, add score_bazel_platforms as a dependency in your MODULE.bazel file:
bazel_dep(name = "score_bazel_platforms", version = "<latest-version>")You can then load and reference the provided constraints or platforms in your BUILD or .bzl files. For example, to select a platform in your .bazelrc:
# in .bazelrc selecting the platform
build:<config> --platforms=@score_bazel_platforms//:x86_64-linuxor setting select statment based on Operating System:
my_rule(
name = "example",
data = select({
"@platforms//os:linux": ":linux_runtime_config",
"@platforms//os:qnx": ":qnx_runtime_config",
})
)NOTE: Predefined
constraint_settingandconstraint_valuelike CPU and/or OS targets can be used directly by referencing the@platformsmodule.
Platforms are typically defined by combination of operating system (OS) and CPU architecture. Our goal is to reuse Bazel's canonical definitions whenever possible, leveraging it's core platform model to ensure consistency.
Defined constraint_settings:
- CPU Architecture
- Operating System
This setting is entirely reused from Bazel upstream definitions, however, it's important to note that the specificity of constraint_values for CPU architecture can vary. In this platform module, we only refer to the ISA (Instruction Set Architecture) - such as x86_64 or arm64 - rather than microarchitecture used in some Bazel projects.
This setting is also entirely reused from Bazel upstream definitions.
- Create a new constraint_setting target in an appropriate package or directory.
- Document its purpose clearly in the
BUILDfile. - Open a pull request with:
- The new
constraint_setting - A brief explanation of why it's needed and how it should be used
- The new
- Define a new constraint_value under the relevant constraint_setting.
- Ensure it’s logically named and documented.
- Submit a pull request with the change and a short description.
Once reviewed and approved, the new constraint will be available for use across all dependent modules.