SConstruct 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. from building import *
  10. TARGET = 'rtthread-realview.' + rtconfig.TARGET_EXT
  11. env = Environment(tools = ['mingw'],
  12. AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
  13. CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
  14. AR = rtconfig.AR, ARFLAGS = '-rc',
  15. LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
  16. env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
  17. Export('RTT_ROOT')
  18. Export('rtconfig')
  19. # prepare building environment
  20. objs = PrepareBuilding(env, RTT_ROOT)
  21. if GetDepend('RT_USING_VMM'):
  22. if os.system('{cppcmd} -P -C -E -I. -D__ASSEMBLY__ {ldfile}.S -o {ldfile}'.format(
  23. cppcmd = os.path.join(rtconfig.EXEC_PATH, 'arm-none-eabi-gcc'),
  24. ldfile = rtconfig.LINK_SCRIPT)) != 0:
  25. print('failed to generate linker script %s' % rtconfig.LINK_SCRIPT)
  26. sys.exit(255)
  27. # if the linker script changed, relink the target
  28. Depends(TARGET, rtconfig.LINK_SCRIPT)
  29. else:
  30. # we should use none-vmm link script
  31. link_flags = str(env['LINKFLAGS'])
  32. env['LINKFLAGS'] = link_flags.replace('_vmm.lds', '.lds')
  33. # make a building
  34. DoBuilding(TARGET, objs)