SConstruct 2.3 KB

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