SConscript 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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_stm32f0xx.c')]
  10. # Map microcontroller units (MCUs) to their corresponding startup files
  11. mcu_startup_files = {
  12. 'STM32F030x6': 'startup_stm32f030x6.s',
  13. 'STM32F030x8': 'startup_stm32f030x8.s',
  14. 'STM32F030xC': 'startup_stm32f030xc.s',
  15. 'STM32F031x6': 'startup_stm32f031x6.s',
  16. 'STM32F038xx': 'startup_stm32f038xx.s',
  17. 'STM32F042x6': 'startup_stm32f042x6.s',
  18. 'STM32F048xx': 'startup_stm32f048xx.s',
  19. 'STM32F051x8': 'startup_stm32f051x8.s',
  20. 'STM32F058xx': 'startup_stm32f058xx.s',
  21. 'STM32F070x6': 'startup_stm32f070x6.s',
  22. 'STM32F070xB': 'startup_stm32f070xb.s',
  23. 'STM32F071xB': 'startup_stm32f071xb.s',
  24. 'STM32F072xB': 'startup_stm32f072xb.s',
  25. 'STM32F078xx': 'startup_stm32f078xx.s',
  26. 'STM32F091xC': 'startup_stm32f091xc.s',
  27. 'STM32F098xx': 'startup_stm32f098xx.s',
  28. }
  29. # Check each defined MCU, match the platform and append the appropriate startup file
  30. for mcu, startup_file in mcu_startup_files.items():
  31. if mcu in env.get('CPPDEFINES', []):
  32. if rtconfig.PLATFORM in ['gcc', 'llvm-arm']:
  33. src += [os.path.join(cwd, 'Source', 'Templates', 'gcc', startup_file)]
  34. elif rtconfig.PLATFORM in ['armcc', 'armclang']:
  35. src += [os.path.join(cwd, 'Source', 'Templates', 'arm', startup_file)]
  36. elif rtconfig.PLATFORM in ['iccarm']:
  37. src += [os.path.join(cwd, 'Source', 'Templates', 'iar', startup_file)]
  38. break
  39. # Define the build group
  40. group = DefineGroup('STM32F0-CMSIS', src, depend=['PKG_USING_STM32F0_CMSIS_DRIVER'], CPPPATH=path)
  41. # Return the build group
  42. Return('group')