IAR toolchain implementation.
| 256 | |
| 257 | |
| 258 | class IarToolchain(Toolchain): |
| 259 | """IAR toolchain implementation.""" |
| 260 | |
| 261 | def get_name(self) -> str: |
| 262 | return "iar" |
| 263 | |
| 264 | def detect(self) -> bool: |
| 265 | """Detect IAR toolchain.""" |
| 266 | iccarm_path = shutil.which("iccarm") |
| 267 | if not iccarm_path: |
| 268 | # Try common IAR installation paths |
| 269 | iar_paths = [ |
| 270 | r"C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.0\arm\bin", |
| 271 | r"C:\Program Files\IAR Systems\Embedded Workbench 8.0\arm\bin", |
| 272 | "/opt/iar/bin" |
| 273 | ] |
| 274 | for path in iar_paths: |
| 275 | test_path = os.path.join(path, "iccarm.exe" if os.name == 'nt' else "iccarm") |
| 276 | if os.path.exists(test_path): |
| 277 | iccarm_path = test_path |
| 278 | break |
| 279 | |
| 280 | if not iccarm_path: |
| 281 | return False |
| 282 | |
| 283 | self.info = ToolchainInfo( |
| 284 | name="iar", |
| 285 | version="8.x", # IAR version detection is complex |
| 286 | path=os.path.dirname(iccarm_path) |
| 287 | ) |
| 288 | return True |
| 289 | |
| 290 | def configure_environment(self, env) -> None: |
| 291 | """Configure environment for IAR.""" |
| 292 | env['CC'] = 'iccarm' |
| 293 | env['CXX'] = 'iccarm' |
| 294 | env['AS'] = 'iasmarm' |
| 295 | env['AR'] = 'iarchive' |
| 296 | env['LINK'] = 'ilinkarm' |
| 297 | |
| 298 | # IAR specific settings |
| 299 | env['LIBPREFIX'] = '' |
| 300 | env['LIBSUFFIX'] = '.a' |
| 301 | env['LIBLINKPREFIX'] = '' |
| 302 | env['LIBLINKSUFFIX'] = '.a' |
| 303 | |
| 304 | # Path |
| 305 | if self.info and self.info.path: |
| 306 | env.PrependENVPath('PATH', self.info.path) |
| 307 | |
| 308 | def get_compile_flags(self, cpu: str, fpu: str = None, float_abi: str = None) -> Dict[str, str]: |
| 309 | """Get IAR flags.""" |
| 310 | flags = { |
| 311 | 'CFLAGS': [], |
| 312 | 'CXXFLAGS': [], |
| 313 | 'ASFLAGS': [], |
| 314 | 'LDFLAGS': [] |
| 315 | } |