@@ -92,12 +92,19 @@ def validate_boot(self, path: str) -> ValidationResult:
9292
9393 def _validate_board (self , path : Path , result : ValidationResult ):
9494 try :
95- data = yaml .safe_load (path .read_text ())
95+ data = yaml .safe_load (path .read_text (encoding = "utf-8" ))
9696 except Exception as e :
9797 result .add_error ("board.yaml" , "" , f"Parse error: { e } " )
9898 return
9999
100+ if not isinstance (data , dict ):
101+ result .add_error ("board.yaml" , "" , "Invalid format: expected YAML mapping" )
102+ return
103+
100104 board = data .get ("board" , data )
105+ if not isinstance (board , dict ):
106+ result .add_error ("board.yaml" , "board" , "Board section must be a mapping" )
107+ return
101108
102109 if not board .get ("name" ):
103110 result .add_error ("board.yaml" , "name" , "Board name is required" )
@@ -117,12 +124,19 @@ def _validate_board(self, path: Path, result: ValidationResult):
117124
118125 def _validate_boot (self , path : Path , result : ValidationResult ):
119126 try :
120- data = yaml .safe_load (path .read_text ())
127+ data = yaml .safe_load (path .read_text (encoding = "utf-8" ))
121128 except Exception as e :
122129 result .add_error ("boot.yaml" , "" , f"Parse error: { e } " )
123130 return
124131
132+ if not isinstance (data , dict ):
133+ result .add_error ("boot.yaml" , "" , "Invalid format: expected YAML mapping" )
134+ return
135+
125136 boot = data .get ("boot" , data )
137+ if not isinstance (boot , dict ):
138+ result .add_error ("boot.yaml" , "boot" , "Boot section must be a mapping" )
139+ return
126140
127141 if not boot .get ("board" ):
128142 result .add_error ("boot.yaml" , "board" , "Board name is required" )
@@ -156,11 +170,27 @@ def _validate_boot(self, path: Path, result: ValidationResult):
156170
157171 def _validate_build (self , path : Path , result : ValidationResult ):
158172 try :
159- data = yaml .safe_load (path .read_text ())
173+ data = yaml .safe_load (path .read_text (encoding = "utf-8" ))
160174 except Exception as e :
161175 result .add_error ("build.yaml" , "" , f"Parse error: { e } " )
162176 return
163177
178+ if not isinstance (data , dict ):
179+ result .add_error ("build.yaml" , "" , "Invalid format: expected YAML mapping" )
180+ return
181+
164182 project = data .get ("project" , {})
183+ if not isinstance (project , dict ):
184+ result .add_error ("build.yaml" , "project" , "Project section must be a mapping" )
185+ return
186+
165187 if not project .get ("name" ):
166188 result .add_error ("build.yaml" , "project.name" , "Project name is required" )
189+
190+ targets = data .get ("targets" , [])
191+ if not targets :
192+ result .add_warning ("build.yaml" , "targets" , "No build targets defined" )
193+
194+ toolchain = data .get ("toolchain" , {})
195+ if isinstance (toolchain , dict ) and not toolchain .get ("compiler" ):
196+ result .add_warning ("build.yaml" , "toolchain.compiler" , "Compiler not specified" )
0 commit comments