1
0

SConstruct 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import os
  2. import sys
  3. import rtconfig
  4. from SCons.Script import *
  5. if os.getenv('RTT_ROOT'):
  6. RTT_ROOT = os.getenv('RTT_ROOT')
  7. else:
  8. RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..')
  9. print(RTT_ROOT)
  10. sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]# 模块搜索路径
  11. try:
  12. from building import *
  13. except:
  14. print('Cannot found RT-Thread root directory, please check RTT_ROOT')
  15. print(RTT_ROOT)
  16. exit(-1)
  17. TARGET = 'rtthread.' + rtconfig.TARGET_EXT
  18. DefaultEnvironment(tools=[])
  19. env = Environment(tools = ['mingw'],
  20. AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
  21. CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
  22. AR = rtconfig.AR, ARFLAGS = '-rc',
  23. CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
  24. LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
  25. env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
  26. if rtconfig.PLATFORM in ['iccarm']:
  27. env.Replace(CCCOM = ['$CC $CFLAGS $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. #SDK_ROOT = E:\rt-thread\bsp\core-v-mcu\core-v-cv32e40p
  34. if os.path.exists(SDK_ROOT + '/Libraries'):
  35. libraries_path_prefix = SDK_ROOT + '/Libraries'
  36. else:
  37. libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/Libraries'
  38. #libraries_path_prefix = E:\rt-thread\bsp\core-v-mcu\Libraries
  39. SDK_LIB = libraries_path_prefix
  40. Export('SDK_LIB')
  41. #SDK_LIB = E:\rt-thread\bsp\core-v-mcu\Libraries
  42. # prepare building environment
  43. objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
  44. core_v_library = 'core_v_hal_libraries'
  45. rtconfig.BSP_LIBRARY_TYPE = core_v_library
  46. bsp_vdir = 'build'
  47. library_vdir = 'build/libraries'
  48. #libraries_path_prefix = E:\rt-thread\bsp\core-v-mcu\Libraries
  49. #objs.extend 将扩展列表的元素都加到 objs列表中
  50. # include libraries
  51. objs.extend(SConscript(os.path.join(libraries_path_prefix, core_v_library, 'SConscript'), variant_dir=library_vdir + '/core_v_hal_libraries', duplicate=0))
  52. # common include drivers
  53. objs.extend(SConscript(os.path.join(libraries_path_prefix, 'core_v_drivers', 'SConscript'), variant_dir=library_vdir + '/core_v_drivers', duplicate=0))
  54. # make a building
  55. DoBuilding(TARGET, objs)