SConstruct 1.7 KB

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