SConstruct 1.4 KB

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