SConstruct 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. DefaultEnvironment(tools=[])
  17. env = Environment(tools = ['mingw'],
  18. AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
  19. CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
  20. AR = rtconfig.AR, ARFLAGS = '-rc',
  21. CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
  22. LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
  23. env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
  24. if rtconfig.PLATFORM == 'iar':
  25. env.Replace(CCCOM = ['$CC $CFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
  26. env.Replace(ARFLAGS = [''])
  27. env.Replace(LINKCOM = env["LINKCOM"] + ' --map rt-thread.map')
  28. Export('RTT_ROOT')
  29. Export('rtconfig')
  30. SDK_ROOT = os.path.abspath('./')
  31. if os.path.exists(SDK_ROOT + '/libraries'):
  32. libraries_path_prefix = SDK_ROOT + '/libraries'
  33. else:
  34. libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
  35. SDK_LIB = libraries_path_prefix
  36. Export('SDK_LIB')
  37. # prepare building environment
  38. objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
  39. stm32_library = 'STM32L5xx_HAL'
  40. rtconfig.BSP_LIBRARY_TYPE = stm32_library
  41. # include libraries
  42. objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript')))
  43. # include drivers
  44. objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript')))
  45. # make a building
  46. DoBuilding(TARGET, objs)