11import os
22import stat
33from collections .abc import Mapping
4- from typing import Any , Dict , List
4+ from typing import Any , Dict , Generator , List
55
66from tests .util import *
77from jinja2 import Template
@@ -94,16 +94,16 @@ def render_script(template: str, out_path: str, params: Dict):
9494 os .chmod (out_path , stat .S_IREAD | stat .S_IWRITE | stat .S_IEXEC )
9595
9696
97- def autogen_cargo (conf_file , yaml : Dict ):
98- def render_stage (stage_conf : Mapping [str , Any ] | None , filename : str ) -> bool :
97+ def autogen_cargo (conf_file , yaml : Dict ) -> Generator [ str ] :
98+ def render_stage (stage_conf : Mapping [str , Any ] | None , filename : str ) -> Generator [ str ] :
9999 if not isinstance (stage_conf , Mapping ):
100- return False
100+ return
101101 if not stage_conf :
102- return False
102+ return
103103
104104 ag = stage_conf .get ("autogen" )
105105 if not (ag and isinstance (ag , bool )):
106- return False
106+ return
107107
108108 params : Dict [str , str ] = {}
109109 rustflags = stage_conf .get ("rustflags" )
@@ -115,16 +115,16 @@ def render_stage(stage_conf: Mapping[str, Any] | None, filename: str) -> bool:
115115 filename
116116 )
117117 render_script (CARGO_SH , out_path , params )
118- return True
118+ yield out_path
119119
120120 for key , fname in (
121121 ("cargo.transpile" , "cargo.transpile.gen.sh" ),
122122 ("cargo.refactor" , "cargo.refactor.gen.sh" ),
123123 ):
124- render_stage (yaml .get (key ), fname )
124+ yield from render_stage (yaml .get (key ), fname )
125125
126126
127- def autogen_refactor (conf_file , yaml : Dict ):
127+ def autogen_refactor (conf_file , yaml : Dict ) -> Generator [ str ] :
128128 refactor = yaml .get ("refactor" )
129129 if refactor and isinstance (refactor , Dict ):
130130 ag = refactor .get ("autogen" )
@@ -149,9 +149,10 @@ def autogen_refactor(conf_file, yaml: Dict):
149149 "refactor.gen.sh"
150150 )
151151 render_script (REFACTOR_SH , out_path , params )
152+ yield out_path
152153
153154
154- def autogen_transpile (conf_file , yaml : Dict ):
155+ def autogen_transpile (conf_file , yaml : Dict ) -> Generator [ str ] :
155156 transpile = yaml .get ("transpile" )
156157 if transpile and isinstance (transpile , Dict ):
157158 ag = transpile .get ("autogen" )
@@ -180,10 +181,11 @@ def autogen_transpile(conf_file, yaml: Dict):
180181 "transpile.gen.sh"
181182 )
182183 render_script (TRANSPILE_SH , out_path , params )
184+ yield out_path
183185
184186
185- def autogen (conf : Config ):
187+ def autogen (conf : Config ) -> Generator [ str ] :
186188 for (cf , yaml ) in conf .project_conf .items ():
187- autogen_transpile (cf , yaml )
188- autogen_refactor (cf , yaml )
189- autogen_cargo (cf , yaml )
189+ yield from autogen_transpile (cf , yaml )
190+ yield from autogen_refactor (cf , yaml )
191+ yield from autogen_cargo (cf , yaml )
0 commit comments