SConscript 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. from building import *
  2. import os
  3. # Import environment variables
  4. Import('env')
  5. # Get the current working directory
  6. cwd = GetCurrentDir()
  7. # Initialize include paths and source files list
  8. path = [os.path.join(cwd, 'Include')]
  9. src = [os.path.join(cwd, 'Source', 'Templates', 'system_stm32u5xx.c')]
  10. # Map microcontroller units (MCUs) to their corresponding startup files
  11. mcu_startup_files = {
  12. 'STM32U575xx': 'startup_stm32u575xx.s',
  13. 'STM32U585xx': 'startup_stm32u585xx.s',
  14. }
  15. # Check each defined MCU, match the platform and append the appropriate startup file
  16. cpp_defines_tuple = env.get('CPPDEFINES', [])
  17. cpp_defines_list = [item[0] if isinstance(item, tuple) else item for item in cpp_defines_tuple]
  18. for mcu, startup_file in mcu_startup_files.items():
  19. if mcu in cpp_defines_list:
  20. if rtconfig.PLATFORM in ['gcc', 'llvm-arm']:
  21. src += [os.path.join(cwd, 'Source', 'Templates', 'gcc', startup_file)]
  22. elif rtconfig.PLATFORM in ['armcc', 'armclang']:
  23. src += [os.path.join(cwd, 'Source', 'Templates', 'arm', startup_file)]
  24. elif rtconfig.PLATFORM in ['iccarm']:
  25. src += [os.path.join(cwd, 'Source', 'Templates', 'iar', startup_file)]
  26. break
  27. # Define the build group
  28. group = DefineGroup('STM32U5-CMSIS', src, depend=['PKG_USING_STM32U5_CMSIS_DRIVER'], CPPPATH=path)
  29. # Return the build group
  30. Return('group')