44import subprocess
55import sys
66import 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