SConstruct 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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, CCFLAGS = rtconfig.CFLAGS,
  20. AR = rtconfig.AR, ARFLAGS = '-rc',
  21. CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
  22. LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
  23. env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
  24. if rtconfig.PLATFORM in ['iccarm']:
  25. env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
  26. env.Replace(ARFLAGS = [''])
  27. env.Replace(LINKCOM = env["LINKCOM"] + ' --map rtthread.map')
  28. Export('RTT_ROOT')
  29. Export('rtconfig')
  30. SDK_ROOT = os.path.abspath('./')
  31. if os.path.exists(SDK_ROOT + '/libraries'):
  32. libraries_path_prefix = SDK_ROOT + '/libraries'
  33. else:
  34. libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
  35. SDK_LIB = libraries_path_prefix
  36. Export('SDK_LIB')
  37. # prepare building environment
  38. objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
  39. hc32_library = 'hc32f460_ddl'
  40. rtconfig.BSP_LIBRARY_TYPE = hc32_library
  41. # include libraries
  42. objs.extend(SConscript(os.path.join(libraries_path_prefix, hc32_library, 'SConscript')))
  43. # include drivers
  44. objs.extend(SConscript(os.path.join(libraries_path_prefix, 'hc32_drivers', 'SConscript')))
  45. objs.extend(SConscript(os.path.join(os.getcwd(), 'board', 'ports', 'SConscript')))
  46. # make a building
  47. DoBuilding(TARGET, objs)