SConstruct 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import os
  2. import sys
  3. import rtconfig
  4. from rtconfig import RTT_ROOT
  5. sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
  6. from building import *
  7. TARGET = 'rtthread.' + rtconfig.TARGET_EXT
  8. DefaultEnvironment(tools=[])
  9. env = Environment(tools = ['mingw'],
  10. AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
  11. CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
  12. CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
  13. AR = rtconfig.AR, ARFLAGS = '-rc',
  14. LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
  15. env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
  16. env['ASCOM'] = env['ASPPCOM']
  17. Export('RTT_ROOT')
  18. Export('rtconfig')
  19. rtconfig.CPU='virt64'
  20. rtconfig.ARCH='risc-v'
  21. # prepare building environment
  22. objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False)
  23. stack_size = 4096
  24. if GetDepend('RT_USING_SMART'):
  25. # use smart link.lds
  26. env['LINKFLAGS'] = env['LINKFLAGS'].replace('link.lds', 'link_smart.lds')
  27. stack_lds = open('link_stacksize.lds', 'w')
  28. if GetDepend('__STACKSIZE__'): stack_size = GetDepend('__STACKSIZE__')
  29. stack_lds.write('__STACKSIZE__ = %d;\n' % stack_size)
  30. stack_lds.close()
  31. # Obtain the number of harts from rtconfig.h and write
  32. # it into link_cpus.lds for the linker script
  33. try:
  34. with open('rtconfig.h', 'r') as f:
  35. rtconfig_content = f.readlines()
  36. except FileNotFoundError:
  37. cpus_nr = 1
  38. else:
  39. cpus_nr = 1 # default value
  40. for line in rtconfig_content:
  41. line = line.strip()
  42. if line.startswith('#define') and 'RT_CPUS_NR' in line:
  43. parts = line.split()
  44. if len(parts) >= 3 and parts[2].isdigit():
  45. cpus_nr = int(parts[2])
  46. break
  47. with open('link_cpus.lds', 'w') as cpus_lds:
  48. cpus_lds.write(f'RT_CPUS_NR = {cpus_nr};\n')
  49. # make a building
  50. DoBuilding(TARGET, objs)