SConstruct 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import os
  2. import sys
  3. import rtconfig
  4. if os.getenv('RTT_ROOT'):
  5. RTT_ROOT = os.getenv('RTT_ROOT')
  6. else:
  7. RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..')
  8. sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
  9. try:
  10. from building import *
  11. except:
  12. print('Cannot found RT-Thread root directory, please check RTT_ROOT')
  13. print(RTT_ROOT)
  14. exit(-1)
  15. TARGET = 'rt-thread.' + rtconfig.TARGET_EXT
  16. env = Environment(tools = ['mingw'],
  17. AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
  18. CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
  19. AR = rtconfig.AR, ARFLAGS = '-rc',
  20. LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
  21. env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
  22. if rtconfig.PLATFORM == 'iar':
  23. env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
  24. env.Replace(ARFLAGS = [''])
  25. env.Replace(LINKCOM = ['$LINK $SOURCES $LINKFLAGS -o $TARGET --map rt-thread.map'])
  26. Export('RTT_ROOT')
  27. Export('rtconfig')
  28. # prepare building environment
  29. objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
  30. SDK_ROOT = os.path.abspath('./')
  31. bsp_vdir = 'build'
  32. # include drivers
  33. objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/STM32F1xx_HAL/SConscript'))
  34. # include libraries
  35. objs.extend(SConscript(os.path.dirname(SDK_ROOT) + '/libraries/HAL_Drivers/SConscript'))
  36. # make a building
  37. DoBuilding(TARGET, objs)