SConstruct 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. from utils import _make_path_relative
  36. libraries_path_prefix = _make_path_relative(os.path.abspath('./'), libraries_path_prefix)
  37. SDK_LIB = libraries_path_prefix
  38. Export('SDK_LIB')
  39. # prepare building environment
  40. objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
  41. stm32_library = 'STM32H7xx_HAL'
  42. rtconfig.BSP_LIBRARY_TYPE = stm32_library
  43. bsp_vdir = 'build'
  44. # include libraries
  45. objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript'),
  46. variant_dir=bsp_vdir + '/libraries/'+ stm32_library, duplicate=0))
  47. # include drivers
  48. objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript'),
  49. variant_dir=bsp_vdir + '/libraries/HAL_Drivers', duplicate=0))
  50. bsp_port_script = os.path.join(os.getcwd(), 'board', 'ports', 'SConscript')
  51. if os.path.isfile(bsp_port_script):
  52. objs.extend(SConscript(bsp_port_script, variant_dir=bsp_vdir + '/board/ports', duplicate=0))
  53. # make a building
  54. DoBuilding(TARGET, objs)