SConstruct 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. # set RTT_ROOT
  9. if not os.getenv("RTT_ROOT"):
  10. RTT_ROOT="rt-thread"
  11. sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
  12. try:
  13. from building import *
  14. except:
  15. print('Cannot found RT-Thread root directory, please check RTT_ROOT')
  16. print(RTT_ROOT)
  17. exit(-1)
  18. TARGET = 'rtthread.' + rtconfig.TARGET_EXT
  19. DefaultEnvironment(tools=[])
  20. env = Environment(tools = ['mingw'],
  21. AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
  22. CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
  23. AR = rtconfig.AR, ARFLAGS = '-rc',
  24. LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
  25. env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
  26. if rtconfig.PLATFORM == 'iar':
  27. env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
  28. env.Replace(ARFLAGS = [''])
  29. env.Replace(LINKCOM = env["LINKCOM"] + ' --map project.map')
  30. Export('RTT_ROOT')
  31. Export('rtconfig')
  32. SDK_ROOT = os.path.abspath('./')
  33. if os.path.exists(SDK_ROOT + '/Libraries'):
  34. libraries_path_prefix = SDK_ROOT + '/Libraries'
  35. else:
  36. libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/Libraries'
  37. SDK_LIB = libraries_path_prefix
  38. Export('SDK_LIB')
  39. # prepare building environment
  40. objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
  41. at32_library = 'AT32_Std_Driver'
  42. rtconfig.BSP_LIBRARY_TYPE = at32_library
  43. # include libraries
  44. objs.extend(SConscript(os.path.join(libraries_path_prefix, at32_library, 'SConscript')))
  45. # common include drivers
  46. objs.extend(SConscript(os.path.join(libraries_path_prefix, 'rt_drivers', 'SConscript')))
  47. # make a building
  48. DoBuilding(TARGET, objs)