@@ -100,7 +100,32 @@ def check_scons_args(file_path):
100100 args .append (match .group (1 ).strip ())
101101 return ' ' .join (args )
102102
103-
103+ def get_details_and_dependencies (details , projects , seen = None ):
104+ if seen is None :
105+ seen = set ()
106+ result = []
107+ scons_arg = []
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+ temp ,temp1 = get_details_and_dependencies (dep_details .get ('depends' ), projects , seen )
116+ for line in temp :
117+ result .append (line )
118+ for line in temp1 :
119+ scons_arg .append (line )
120+ if dep_details .get ('kconfig' ) is not None :
121+ for line in dep_details .get ('kconfig' ):
122+ result .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 .append (line )
126+ else :
127+ print (f"::error::There are some problems with attachconfig depend: { dep } " );
128+ return result ,scons_arg
104129def build_bsp_attachconfig (bsp , attach_file ):
105130 """
106131 build bsp with attach config.
@@ -160,35 +185,46 @@ def build_bsp_attachconfig(bsp, attach_file):
160185 print ("::endgroup::" )
161186
162187 yml_files_content = []
163- directory = os .path .join (rtt_root , 'bsp' , bsp , ' .ci/attachconfig' )
188+ directory = os .path .join (rtt_root , '.ci/attachconfig' )
164189 if os .path .exists (directory ):
165190 for root , dirs , files in os .walk (directory ):
166191 for filename in files :
167192 if filename .endswith ('attachconfig.yml' ):
168193 file_path = os .path .join (root , filename )
169194 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 )
195+ try :
196+ with open (file_path , 'r' ) as file :
197+ content = yaml .safe_load (file )
198+ if content is None :
199+ continue
200+ yml_files_content .append (content )
201+ except yaml .YAMLError as e :
202+ print (f"::error::Error parsing YAML file: { e } " )
203+ continue
204+ except Exception as e :
205+ print (f"::error::Error reading file: { e } " )
206+ continue
173207
174208 config_file = os .path .join (rtt_root , 'bsp' , bsp , '.config' )
175209
176210 for projects in yml_files_content :
177211 for name , details in projects .items ():
178- for line in details .get ('depends' ):
179- depends_item = projects .get (line )
180- if (depends_item ):
181- for depends_line in depends_item .get ('kconfig' ):
182- details ['kconfig' ].append (depends_line )
183212 count += 1
184213 config_bacakup = config_file + '.origin'
185214 shutil .copyfile (config_file , config_bacakup )
186215 with open (config_file , 'a' ) as destination :
187- for line in details .get ('kconfig' ):
188- print (f"::group::\t { line } " )
189- destination .write (line + '\n ' )
190- scons_arg = details .get ('scons_arg' )
191- scons_arg_str = scons_arg [0 ] if scons_arg else ' '
216+ if (projects .get (name ) is not None ):
217+ result_list ,scons_arg_list = get_details_and_dependencies ([name ],projects )
218+ for line in result_list :
219+ destination .write (line + '\n ' )
220+ scons_arg = []
221+ if details .get ('scons_arg' ) is not None :
222+ for line in details .get ('scons_arg' ):
223+ scons_arg .append (line )
224+ if scons_arg_list is not None :
225+ for line in scons_arg_list :
226+ scons_arg .append (line )
227+ scons_arg_str = ' ' .join (scons_arg ) if scons_arg else ' '
192228 print (f"::group::\t Compiling yml project: =={ count } ==={ name } =scons_arg={ scons_arg_str } ==" )
193229 res = build_bsp (bsp , scons_arg_str )
194230 if not res :
0 commit comments