SConscript 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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_stm32wbxx.c')]
  10. # Map microcontroller units (MCUs) to their corresponding startup files
  11. mcu_startup_files = {
  12. 'STM32WB55xx': 'startup_stm32wb55xx_cm4.s',
  13. 'STM32WB5Mxx': 'startup_stm32wb5mxx_cm4.s',
  14. 'STM32WB50xx': 'startup_stm32wb50xx_cm4.s',
  15. 'STM32WB35xx': 'startup_stm32wb35xx_cm4.s',
  16. 'STM32WB30xx': 'startup_stm32wb30xx_cm4.s',
  17. 'STM32WB15xx': 'startup_stm32wb15xx_cm4.s',
  18. 'STM32WB10xx': 'startup_stm32wb10xx_cm4.s',
  19. }
  20. # Check each defined MCU, match the platform and append the appropriate startup file
  21. cpp_defines_tuple = env.get('CPPDEFINES', [])
  22. cpp_defines_list = [item[0] if isinstance(item, tuple) else item for item in cpp_defines_tuple]
  23. for mcu, startup_file in mcu_startup_files.items():
  24. if mcu in cpp_defines_list:
  25. if rtconfig.PLATFORM in ['gcc', 'llvm-arm']:
  26. src += [os.path.join(cwd, 'Source', 'Templates', 'gcc', startup_file)]
  27. elif rtconfig.PLATFORM in ['armcc', 'armclang']:
  28. src += [os.path.join(cwd, 'Source', 'Templates', 'arm', startup_file)]
  29. elif rtconfig.PLATFORM in ['iccarm']:
  30. src += [os.path.join(cwd, 'Source', 'Templates', 'iar', startup_file)]
  31. break
  32. # Define the build group
  33. group = DefineGroup('STM32WB-CMSIS', src, depend=['PKG_USING_STM32WB_CMSIS_DRIVER'], CPPPATH=path)
  34. # Return the build group
  35. Return('group')