SConstruct 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. if rtconfig.PLATFORM == 'armcc':
  21. env = Environment(tools = ['mingw'],
  22. AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
  23. CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
  24. CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
  25. AR = rtconfig.AR, ARFLAGS = '-rc',
  26. LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS,
  27. # overwrite cflags, because cflags has '--C99'
  28. CXXCOM = '$CXX -o $TARGET --cpp -c $CXXFLAGS $_CCCOMCOM $SOURCES')
  29. else:
  30. env = Environment(tools = ['mingw'],
  31. AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
  32. CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
  33. CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
  34. AR = rtconfig.AR, ARFLAGS = '-rc',
  35. LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS,
  36. CXXCOM = '$CXX -o $TARGET -c $CXXFLAGS $_CCCOMCOM $SOURCES')
  37. env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
  38. if rtconfig.PLATFORM == 'iar':
  39. env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
  40. env.Replace(ARFLAGS = [''])
  41. env.Replace(LINKCOM = env["LINKCOM"] + ' --map rtthread.map')
  42. Export('RTT_ROOT')
  43. Export('rtconfig')
  44. SDK_ROOT = os.path.abspath('./')
  45. if os.path.exists(SDK_ROOT + '/libraries'):
  46. libraries_path_prefix = SDK_ROOT + '/libraries'
  47. else:
  48. libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
  49. SDK_LIB = libraries_path_prefix
  50. Export('SDK_LIB')
  51. # prepare building environment
  52. objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
  53. imxrt_library = 'MIMXRT1050'
  54. rtconfig.BSP_LIBRARY_TYPE = imxrt_library
  55. # include libraries
  56. objs.extend(SConscript(os.path.join(libraries_path_prefix, imxrt_library, 'SConscript')))
  57. # include drivers
  58. objs.extend(SConscript(os.path.join(libraries_path_prefix, 'drivers', 'SConscript')))
  59. # make a building
  60. DoBuilding(TARGET, objs)