@@ -100,6 +100,32 @@ def check_scons_args(file_path):
100100 args .append (match .group (1 ).strip ())
101101 return ' ' .join (args )
102102
103+ def get_details_and_dependencies (details , projects , seen = None ):
104+ if seen is None :
105+ seen = set ()
106+ detail_list = []
107+ scons_arg_list = []
108+ if details is not None :
109+ for dep in details :
110+ if dep not in seen :
111+ dep_details = projects .get (dep )
112+ seen .add (dep )
113+ if dep_details is not None :
114+ if dep_details .get ('depends' ) is not None :
115+ detail_temp ,scons_arg_temp = get_details_and_dependencies (dep_details .get ('depends' ), projects , seen )
116+ for line in detail_temp :
117+ detail_list .append (line )
118+ for line in scons_arg_temp :
119+ scons_arg_list .append (line )
120+ if dep_details .get ('kconfig' ) is not None :
121+ for line in dep_details .get ('kconfig' ):
122+ detail_list .append (line )
123+ if dep_details .get ('depend_scons_arg' ) is not None :
124+ for line in dep_details .get ('depend_scons_arg' ):
125+ scons_arg_list .append (line )
126+ else :
127+ print (f"::error::There are some problems with attachconfig depend: { dep } " );
128+ return detail_list ,scons_arg_list
103129
104130def build_bsp_attachconfig (bsp , attach_file ):
105131 """
@@ -167,9 +193,18 @@ def build_bsp_attachconfig(bsp, attach_file):
167193 if filename .endswith ('attachconfig.yml' ):
168194 file_path = os .path .join (root , filename )
169195 if os .path .exists (file_path ):
170- with open (file_path , 'r' ) as file :
171- content = yaml .safe_load (file )
172- yml_files_content .append (content )
196+ try :
197+ with open (file_path , 'r' ) as file :
198+ content = yaml .safe_load (file )
199+ if content is None :
200+ continue
201+ yml_files_content .append (content )
202+ except yaml .YAMLError as e :
203+ print (f"::error::Error parsing YAML file: { e } " )
204+ continue
205+ except Exception as e :
206+ print (f"::error::Error reading file: { e } " )
207+ continue
173208
174209 config_file = os .path .join (rtt_root , 'bsp' , bsp , '.config' )
175210
@@ -179,10 +214,18 @@ def build_bsp_attachconfig(bsp, attach_file):
179214 config_bacakup = config_file + '.origin'
180215 shutil .copyfile (config_file , config_bacakup )
181216 with open (config_file , 'a' ) as destination :
182- for line in details .get ('kconfig' ):
183- destination .write (line + '\n ' )
184- scons_arg = details .get ('scons_arg' )
185- scons_arg_str = scons_arg [0 ] if scons_arg else ' '
217+ if (projects .get (name ) is not None ):
218+ detail_list ,scons_arg_list = get_details_and_dependencies ([name ],projects )
219+ for line in detail_list :
220+ destination .write (line + '\n ' )
221+ scons_arg = []
222+ if details .get ('scons_arg' ) is not None :
223+ for line in details .get ('scons_arg' ):
224+ scons_arg .append (line )
225+ if scons_arg_list is not None :
226+ for line in scons_arg_list :
227+ scons_arg .append (line )
228+ scons_arg_str = ' ' .join (scons_arg ) if scons_arg else ' '
186229 print (f"::group::\t Compiling yml project: =={ count } ==={ name } =scons_arg={ scons_arg_str } ==" )
187230 res = build_bsp (bsp , scons_arg_str )
188231 if not res :
0 commit comments