SConstruct 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import os
  2. import sys
  3. import rtconfig
  4. IS_EXPORTED = False
  5. # setup RT-Thread Root Path
  6. if os.getenv('RTT_ROOT'):
  7. RTT_ROOT = os.getenv('RTT_ROOT')
  8. else:
  9. RTT_ROOT = os.getcwd() + '/../../..'
  10. sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
  11. try:
  12. from building import *
  13. except:
  14. print('Cannot found RT-Thread root directory, please check RTT_ROOT')
  15. print(RTT_ROOT)
  16. exit(-1)
  17. if RTT_ROOT == 'rt-thread':
  18. IS_EXPORTED = True # if kenrel and bsp has been exported by export_project.py
  19. # setup Phytium BSP Root Path
  20. if IS_EXPORTED:
  21. BSP_ROOT = '.'
  22. else:
  23. BSP_ROOT = RTT_ROOT + '/bsp/phytium'
  24. TARGET = 'rtthread_a64.' + rtconfig.TARGET_EXT
  25. DefaultEnvironment(tools=[])
  26. env = Environment(tools = ['mingw'],
  27. AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
  28. CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
  29. CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
  30. AR = rtconfig.AR, ARFLAGS = '-rc',
  31. LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
  32. env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
  33. env['ASCOM'] = env['ASPPCOM']
  34. Export('RTT_ROOT')
  35. Export('BSP_ROOT')
  36. Export('rtconfig')
  37. # prepare building environment
  38. objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False)
  39. if not IS_EXPORTED: # if project is not exported, libraries and board need to manually add
  40. # include libraries
  41. objs.extend(SConscript(os.path.join(BSP_ROOT + '/libraries', 'SConscript')))
  42. # include board
  43. objs.extend(SConscript(os.path.join(BSP_ROOT + '/board', 'SConscript')))
  44. if GetDepend('RT_USING_SMART'):
  45. # use smart link.lds
  46. env['LINKFLAGS'] = env['LINKFLAGS'].replace('link.lds', 'link_smart.lds')
  47. # make a building
  48. DoBuilding(TARGET, objs)