SConscript 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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_stm32l0xx.c')]
  10. # Map microcontroller units (MCUs) to their corresponding startup files
  11. mcu_startup_files = {
  12. 'STM32L010x4': 'startup_stm32l010x4.s',
  13. 'STM32L010x6': 'startup_stm32l010x6.s',
  14. 'STM32L010x8': 'startup_stm32l010x8.s',
  15. 'STM32L010xB': 'startup_stm32l010xb.s',
  16. 'STM32L011xx': 'startup_stm32l011xx.s',
  17. 'STM32L021xx': 'startup_stm32l021xx.s',
  18. 'STM32L031xx': 'startup_stm32l031xx.s',
  19. 'STM32L041xx': 'startup_stm32l041xx.s',
  20. 'STM32L051xx': 'startup_stm32l051xx.s',
  21. 'STM32L052xx': 'startup_stm32l052xx.s',
  22. 'STM32L053xx': 'startup_stm32l053xx.s',
  23. 'STM32L062xx': 'startup_stm32l062xx.s',
  24. 'STM32L063xx': 'startup_stm32l063xx.s',
  25. 'STM32L071xx': 'startup_stm32l071xx.s',
  26. 'STM32L072xx': 'startup_stm32l072xx.s',
  27. 'STM32L073xx': 'startup_stm32l073xx.s',
  28. 'STM32L081xx': 'startup_stm32l081xx.s',
  29. 'STM32L082xx': 'startup_stm32l082xx.s',
  30. 'STM32L083xx': 'startup_stm32l083xx.s',
  31. }
  32. # Check each defined MCU, match the platform and append the appropriate startup file
  33. cpp_defines_tuple = env.get('CPPDEFINES', [])
  34. cpp_defines_list = [item[0] if isinstance(item, tuple) else item for item in cpp_defines_tuple]
  35. for mcu, startup_file in mcu_startup_files.items():
  36. if mcu in cpp_defines_list:
  37. if rtconfig.PLATFORM in ['gcc', 'llvm-arm']:
  38. src += [os.path.join(cwd, 'Source', 'Templates', 'gcc', startup_file)]
  39. elif rtconfig.PLATFORM in ['armcc', 'armclang']:
  40. src += [os.path.join(cwd, 'Source', 'Templates', 'arm', startup_file)]
  41. elif rtconfig.PLATFORM in ['iccarm']:
  42. src += [os.path.join(cwd, 'Source', 'Templates', 'iar', startup_file)]
  43. break
  44. # Define the build group
  45. group = DefineGroup('STM32L0-CMSIS', src, depend=['PKG_USING_STM32L0_CMSIS_DRIVER'], CPPPATH=path)
  46. # Return the build group
  47. Return('group')