@@ -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,16 +185,26 @@ 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 ):
165- for filename in os .listdir (directory ):
166- if filename .endswith ('attachconfig.yml' ):
167- file_path = os .path .join (directory , filename )
168- if os .path .exists (file_path ):
169- with open (file_path , 'r' ) as file :
170- content = yaml .safe_load (file )
171- yml_files_content .append (content )
172-
190+ for root , dirs , files in os .walk (directory ):
191+ for filename in files :
192+ if filename .endswith ('attachconfig.yml' ):
193+ file_path = os .path .join (root , filename )
194+ if os .path .exists (file_path ):
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
207+
173208 config_file = os .path .join (rtt_root , 'bsp' , bsp , '.config' )
174209
175210 for projects in yml_files_content :
@@ -178,10 +213,18 @@ def build_bsp_attachconfig(bsp, attach_file):
178213 config_bacakup = config_file + '.origin'
179214 shutil .copyfile (config_file , config_bacakup )
180215 with open (config_file , 'a' ) as destination :
181- for line in details .get ('kconfig' ):
182- destination .write (line + '\n ' )
183- scons_arg = details .get ('scons_arg' )
184- 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 ' '
185228 print (f"::group::\t Compiling yml project: =={ count } ==={ name } =scons_arg={ scons_arg_str } ==" )
186229 res = build_bsp (bsp , scons_arg_str )
187230 if not res :
0 commit comments