Skip to content

Commit

Permalink
Use buck transclusion to simplify constraint_overrides.bzl
Browse files Browse the repository at this point in the history
Summary:
This simplifies `constraint_overrides.bzl` to only depend on single configs for the input list of allowed `constraint_overrides` and `platform_overrides`.

Manually maintained configs are renamed for clarity do distinguish them from the generated configs (and because `$(config)` cannot reference the same config it's modifying).

BUCK transclusion: https://buck2.build/docs/concepts/buckconfig/#transclusion-of-values-from-one-key-to-another

Reviewed By: scottcao

Differential Revision: D68281409

fbshipit-source-id: 448ca988da7319a40ccb146428397c2f338b11cf
  • Loading branch information
Tarkan Al-Kazily authored and facebook-github-bot committed Jan 17, 2025
1 parent a90344f commit c7fa4c4
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions prelude/transitions/constraint_overrides.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
# NOTE: Currently, constraints can't be propagated via rule attrs and so need to be
# hard-coded here. We use a read_config to avoid hard-coding these repo-specific
# constraints into the prelude.
# The following configs must be set to use constraint_overrides.bzl:
# - buck2.platforms
# - buck2.constraints
# - buck2.passthrough_constraints

def _platforms() -> list[str]:
platforms = []
config = read_root_config("buck2", "platforms", "")
platforms.extend(
[platform.strip() for platform in config.split(",") if platform.strip()],
)
config = read_root_config("buck2", "generated_platforms", "")
platforms.extend(
[platform.strip() for platform in config.split(",") if platform.strip()],
)
return platforms

def _constraints() -> list[str]:
Expand All @@ -27,10 +27,6 @@ def _constraints() -> list[str]:
constraints.extend(
[constraint.strip() for constraint in config.split(",") if constraint.strip()],
)
config = read_root_config("buck2", "generated_constraints", "")
constraints.extend(
[constraint.strip() for constraint in config.split(",") if constraint.strip()],
)
return constraints

_passthrough_constraints_val = read_root_config("buck2", "passthrough_constraints", "")
Expand Down

0 comments on commit c7fa4c4

Please sign in to comment.