SConscript 1.9 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_stm32f7xx.c')]
  10. # Map microcontroller units (MCUs) to their corresponding startup files
  11. mcu_startup_files = {
  12. 'STM32F722xx': 'startup_stm32f722xx.s',
  13. 'STM32F723xx': 'startup_stm32f723xx.s',
  14. 'STM32F730xx': 'startup_stm32f730xx.s',
  15. 'STM32F732xx': 'startup_stm32f732xx.s',
  16. 'STM32F733xx': 'startup_stm32f733xx.s',
  17. 'STM32F745xx': 'startup_stm32f745xx.s',
  18. 'STM32F746xx': 'startup_stm32f746xx.s',
  19. 'STM32F750xx': 'startup_stm32f750xx.s',
  20. 'STM32F756xx': 'startup_stm32f756xx.s',
  21. 'STM32F765xx': 'startup_stm32f765xx.s',
  22. 'STM32F767xx': 'startup_stm32f767xx.s',
  23. 'STM32F769xx': 'startup_stm32f769xx.s',
  24. 'STM32F777xx': 'startup_stm32f777xx.s',
  25. 'STM32F779xx': 'startup_stm32f779xx.s',
  26. }
  27. # Check each defined MCU, match the platform and append the appropriate startup file
  28. cpp_defines_tuple = env.get('CPPDEFINES', [])
  29. cpp_defines_list = [item[0] if isinstance(item, tuple) else item for item in cpp_defines_tuple]
  30. for mcu, startup_file in mcu_startup_files.items():
  31. if mcu in cpp_defines_list:
  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('STM32F7-CMSIS', src, depend=['PKG_USING_STM32F7_CMSIS_DRIVER'], CPPPATH=path)
  41. # Return the build group
  42. Return('group')