@@ -13,14 +13,27 @@ def get_configurations(dir):
1313# alias(
1414# name = "include",
1515# actual = select({
16- # ":musl-latest": "//runtimes/musl/1.2.5:include", # used to generate this
17- # ":musl-1.2.5": "//runtimes/musl/1.2.5:include", # line or this line
16+ # ":musl-latest": "//runtimes/musl/1.2.5:include", # used to generate this line
17+ # ":musl-1.2.5": "//runtimes/musl/1.2.5:include", # or this line
1818# }),
1919# )
2020def create_single_select_config (condition , target ):
2121 eight_spaces = " "
2222 return f"{ eight_spaces } \" { condition } \" : \" { target } \" ,\n "
2323
24+ # Used to create a single label for various things
25+ # Example:
26+ # selects.config_setting_group(
27+ # name = "musl",
28+ # match_any = [
29+ # ":musl-latest", # used to generate this line
30+ # ":musl-1.2.5", # or this line
31+ # ],
32+ # )
33+ def create_single_label (label , num_spaces ):
34+ spaces = " " * num_spaces
35+ return f"{ spaces } \" { label } \" ,\n "
36+
2437# ===============
2538# || Templates ||
2639# ===============
@@ -189,7 +202,7 @@ def create_version(row):
189202
190203 version_tags = ""
191204 for config in configs :
192- version_tags += f" \" :{ config } \" , \n "
205+ version_tags += create_single_label ( f" :{ config } " , 8 )
193206
194207 settings += config_settings_group_tpl .format (
195208 name = f"{ name } -{ version } " ,
@@ -231,19 +244,20 @@ def create_version_with_configurations(row, dir):
231244
232245# this does way too much and should probably be broken up
233246def create_version_configs (row ):
247+ if "configurations" not in row :
248+ return ""
249+
234250 name = row ["name" ]
235-
236251 settings = ""
237- if "configurations" in row :
238- for config , info in row ["configurations" ].items ():
239- versions = f" \" :{ name } -{ config } -latest\" ,\n "
240- for version , _ in row ["versions" ].items ():
241- versions += f" \" :{ name } -{ config } -{ version } \" ,\n "
252+ for config , _ in row ["configurations" ].items ():
253+ versions = create_single_label (f":{ name } -{ config } -latest" , 8 )
254+ for version , _ in row ["versions" ].items ():
255+ versions += create_single_label (f":{ name } -{ config } -{ version } " , 8 )
242256
243- settings += config_settings_group_tpl .format (
244- name = f"{ name } -{ config } " ,
245- targets = versions .strip ()
246- )
257+ settings += config_settings_group_tpl .format (
258+ name = f"{ name } -{ config } " ,
259+ targets = versions .strip ()
260+ )
247261 return settings
248262
249263# Used in //toolchain/<toolchain>/BUILD and //runtimes/<runtime>/BUILD files
@@ -268,9 +282,9 @@ def create_version_configs(row):
268282def create_top_level_config_settings_group (row ):
269283 name = row ["name" ]
270284
271- version_tags = f" \" :{ name } -latest\" , \n "
285+ version_tags = create_single_label ( f" :{ name } -latest" , 8 )
272286 for version , _ in row ["versions" ].items ():
273- version_tags += f" \" :{ name } -{ version } \" , \n "
287+ version_tags += create_single_label ( f" :{ name } -{ version } " , 8 )
274288
275289 return config_settings_group_tpl .format (
276290 name = name ,
0 commit comments