Skip to content

Commit 80df43a

Browse files
committed
variables: handle defaults better
Signed-off-by: Øyvind Harboe <[email protected]>
1 parent 5a162b5 commit 80df43a

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

flow/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ $(foreach line,$(shell \
206206
ADDITIONAL_LIBS="$(ADDITIONAL_LIBS)" \
207207
ADDITIONAL_GDS="$(ADDITIONAL_GDS)" \
208208
ADDITIONAL_LEFS="$(ADDITIONAL_LEFS)" \
209+
LIB_FILES="$(LIB_FILES)" \
209210
CORNER=$(CORNER) \
210211
LIB_MODEL=$(LIB_MODEL) \
211212
VOLTAGE=$(VOLTAGE) \
@@ -214,6 +215,7 @@ $(foreach line,$(shell \
214215
BC_ADDITIONAL_LIBS="$(BC_ADDITIONAL_LIBS)" \
215216
WC_ADDITIONAL_LIBS="$(WC_ADDITIONAL_LIBS)" \
216217
ASAP7_USELVT=$(ASAP7_USELVT) \
218+
FLOW_VARIANT=$(FLOW_VARIANT) \
217219
$(SCRIPTS_DIR)/defaults.py make),$(eval export $(subst __SPACE__, ,$(line))))
218220

219221
KLAYOUT_FOUND = $(if $(KLAYOUT_CMD),,$(error KLayout not found in PATH))

flow/scripts/defaults.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import subprocess
55
import sys
66
import yaml
7+
from types import MappingProxyType
78

89
# fewer edge cases as unset env vars are passed in as blank env vars
910
# from make
@@ -108,7 +109,7 @@ def main():
108109
else:
109110
variables["FLOW_HOME"] = env_get("FLOW_HOME")
110111

111-
for name in ["PLATFORM", "DESIGN_NAME"]:
112+
for name in ["PLATFORM", "DESIGN_NAME", "PLATFORM_DIR", "FLOW_VARIANT"]:
112113
variables[name] = env_get(name)
113114

114115
if env_blank("DESIGN_NICKNAME"):
@@ -130,10 +131,24 @@ def main():
130131
variables["FLOW_VARIANT"],
131132
)
132133

134+
append_semantics = (
135+
"ADDITIONAL_LEFS",
136+
"ADDITIONAL_LIBS",
137+
"ADDITIONAL_GDS",
138+
"LIB_FILES",
139+
"GDS_FILES"
140+
)
141+
for key in env_canonical:
142+
if key in append_semantics:
143+
variables[key] = " ".join(
144+
([variables.get[key]] if key in variables else [])
145+
+ [env_canonical[key]]
146+
)
147+
133148
# the platform overrides the defaults from variables.yaml, but need
134149
# OBJECTS_DIR. make handles such dependencies differently, it has
135150
# late and immediate expansion of variables.
136-
variables |= get_platform_defaults(env_canonical | variables)
151+
variables |= get_platform_defaults(MappingProxyType(variables))
137152

138153
if env_blank("NUM_CORES"):
139154
variables["NUM_CORES"] = get_num_cores()
@@ -231,10 +246,16 @@ def main():
231246
variables["ORFS_DEFAULTS_LOADED"] = "1"
232247

233248
for key, value in variables.items():
249+
value = str(value).replace(" ", "__SPACE__")
250+
append = key in append_semantics
234251
if sys.argv[1] == "make":
235-
print(f'export {key}?={str(value).replace(" ", "__SPACE__")}')
252+
print(f'export {key}{"" if append else "?"}={value}')
236253
elif sys.argv[1] == "bash":
237-
print(f'export {key}="${{{key}:-{str(value).replace(" ", "__SPACE__")}}}"')
254+
print(
255+
f'export {key}="'
256+
+ (f"{value}" if append else ("${" + f"{key}:-{value}" + "}"))
257+
+ '"'
258+
)
238259
else:
239260
print(f"{key}={value}")
240261

0 commit comments

Comments
 (0)