Skip to content

Commit

Permalink
Rename go buildtags constraints to make them more human-friendly
Browse files Browse the repository at this point in the history
Summary:
Before `prelude//go/constraints:tag_sqlite__value`
After `prelude//go/tags/constraints:sqlite`

Reviewed By: awalterschulze

Differential Revision: D62521040

fbshipit-source-id: 41cbc4b93a6f1e01b4c8c6d82147321811cf6644
  • Loading branch information
podtserkovskiy authored and facebook-github-bot committed Sep 16, 2024
1 parent b5309cc commit 6be21df
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
3 changes: 0 additions & 3 deletions prelude/go/constraints/BUCK.v2
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@prelude//utils:source_listing.bzl", "source_listing")
load(":defs.bzl", "generate_tag_constraints")

oncall("build_infra")

Expand Down Expand Up @@ -95,5 +94,3 @@ constraint_value(
constraint_setting = ":coverage_mode",
visibility = ["PUBLIC"],
)

generate_tag_constraints()
8 changes: 8 additions & 0 deletions prelude/go/tags/constraints/BUCK.v2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@prelude//utils:source_listing.bzl", "source_listing")
load(":defs.bzl", "generate_tag_constraints")

oncall("build_infra")

source_listing()

generate_tag_constraints()
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ load("@prelude//go/transitions:tags_helper.bzl", "allowed_tags")

def generate_tag_constraints():
for tag in allowed_tags:
setting_name = "tag_" + tag
setting_name = "setting__" + tag
native.constraint_setting(
name = "tag_" + tag,
name = setting_name,
visibility = ["PUBLIC"],
)

native.constraint_value(
name = setting_name + "__value",
name = tag,
constraint_setting = ":" + setting_name,
visibility = ["PUBLIC"],
)
4 changes: 2 additions & 2 deletions prelude/go/transitions/tags_helper.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ load("@prelude//utils:buckconfig.bzl", "read_list")
allowed_tags = read_list("go", "allowed_tags", default = [], root_cell = True)

def tag_to_constrant_value():
return {tag: "prelude//go/constraints:tag_{}__value".format(tag) for tag in allowed_tags}
return {tag: "prelude//go/tags/constraints:{}".format(tag) for tag in allowed_tags}

def selects_for_tags():
selects = []
for tag in allowed_tags:
selects += select({
"DEFAULT": [],
"prelude//go/constraints:tag_{}__value".format(tag): [tag],
"prelude//go/tags/constraints:{}".format(tag): [tag],
})

return selects

0 comments on commit 6be21df

Please sign in to comment.