SConstruct 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. def bsp_pkg_check():
  16. import subprocess
  17. check_paths = [
  18. os.path.join("packages", "nxp-mcx-cmsis-latest"),
  19. os.path.join("packages", "nxp-mcx-series-latest"),
  20. ]
  21. need_update = not all(os.path.exists(p) for p in check_paths)
  22. if need_update:
  23. print("\n==============================================================")
  24. print("Dependency packages missing, please running 'pkgs --update'...")
  25. print("==============================================================")
  26. exit(1)
  27. RegisterPreBuildingAction(bsp_pkg_check)
  28. TARGET = 'rtthread.' + rtconfig.TARGET_EXT
  29. if rtconfig.PLATFORM == 'armcc':
  30. env = Environment(tools = ['mingw'],
  31. AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
  32. CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
  33. CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
  34. AR = rtconfig.AR, ARFLAGS = '-rc',
  35. LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS,
  36. # overwrite cflags, because cflags has '--C99'
  37. CXXCOM = '$CXX -o $TARGET --cpp -c $CXXFLAGS $_CCCOMCOM $SOURCES')
  38. else:
  39. env = Environment(tools = ['mingw'],
  40. AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
  41. CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
  42. CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
  43. AR = rtconfig.AR, ARFLAGS = '-rc',
  44. LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS,
  45. CXXCOM = '$CXX -o $TARGET -c $CXXFLAGS $_CCCOMCOM $SOURCES')
  46. env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
  47. if rtconfig.PLATFORM in ['iccarm']:
  48. env.Replace(CCCOM = ['$CC $CFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
  49. env.Replace(ARFLAGS = [''])
  50. env.Replace(LINKCOM = env["LINKCOM"] + ' --map rtthread.map')
  51. Export('RTT_ROOT')
  52. Export('rtconfig')
  53. SDK_ROOT = os.path.abspath('./')
  54. if os.path.exists(SDK_ROOT + '/Libraries'):
  55. libraries_path_prefix = SDK_ROOT + '/Libraries'
  56. else:
  57. libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/Libraries'
  58. SDK_LIB = libraries_path_prefix
  59. Export('SDK_LIB')
  60. # prepare building environment
  61. objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
  62. objs.extend(SConscript(os.path.join(libraries_path_prefix, 'drivers', 'SConscript')))
  63. # make a building
  64. DoBuilding(TARGET, objs)