SConscript 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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_stm32wlxx.c')]
  10. # Map microcontroller units (MCUs) to their corresponding startup files
  11. mcu_startup_files = {
  12. 'STM32WL55xx': 'startup_stm32wle5xx.s',
  13. 'STM32WLE5xx': 'startup_stm32wle5xx.s',
  14. 'STM32WL54xx': 'startup_stm32wle4xx.s',
  15. 'STM32WLE4xx': 'startup_stm32wle4xx.s',
  16. }
  17. # Check each defined MCU, match the platform and append the appropriate startup file
  18. cpp_defines_tuple = env.get('CPPDEFINES', [])
  19. cpp_defines_list = [item[0] if isinstance(item, tuple) else item for item in cpp_defines_tuple]
  20. for mcu, startup_file in mcu_startup_files.items():
  21. if mcu in cpp_defines_list:
  22. if rtconfig.PLATFORM in ['gcc', 'llvm-arm']:
  23. src += [os.path.join(cwd, 'Source', 'Templates', 'gcc', startup_file)]
  24. elif rtconfig.PLATFORM in ['armcc', 'armclang']:
  25. src += [os.path.join(cwd, 'Source', 'Templates', 'arm', startup_file)]
  26. elif rtconfig.PLATFORM in ['iccarm']:
  27. src += [os.path.join(cwd, 'Source', 'Templates', 'iar', startup_file)]
  28. break
  29. # Define the build group
  30. group = DefineGroup('STM32WL-CMSIS', src, depend=['PKG_USING_STM32WL_CMSIS_DRIVER'], CPPPATH=path)
  31. # Return the build group
  32. Return('group')