SConscript 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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_stm32h7rsxx.c')]
  10. # Map microcontroller units (MCUs) to their corresponding startup files
  11. mcu_startup_files = {
  12. 'STM32H7R3xx': 'startup_stm32h7r3xx.s',
  13. 'STM32H7R7xx': 'startup_stm32h7r7xx.s',
  14. 'STM32H7S3xx': 'startup_stm32h7s3xx.s',
  15. 'STM32H7S7xx': 'startup_stm32h7s7xx.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('STM32H7RS-CMSIS', src, depend=['PKG_USING_STM32H7RS_CMSIS_DRIVER'], CPPPATH=path)
  31. # Return the build group
  32. Return('group')