SConstruct 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. import os
  2. import rtconfig
  3. RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
  4. if rtconfig.CC == 'armcc':
  5. device = '--device DARMSTM'
  6. device_type = 'STM32F10X_HD'
  7. # assemble flag for ARCC(Keil)
  8. aflags = '--dwarf2 ' + device
  9. cc_path = 'C:/Keil'
  10. cc_exec_path = cc_path + '/arm/bin40/'
  11. cc_cpath = cc_path + '/ARM/RV31/INC'
  12. # compiler flag for ARMCC(Keil)
  13. cc_cflags = '-g -O0 --apcs=interwork ' + device + ' -DUSE_STDPERIPH_DRIVER -DSTM32F10X_HD'
  14. cc_lflags = ' --keep __fsym_* --keep __vsym_* --info sizes --info totals --info unused --info veneers --list rtthread-stm32.map --scatter stm32_rom.sct --libpath ' + cc_path + '/ARM/RV31/LIB'
  15. cc_target = 'rtthread-stm32.axf'
  16. elif rtconfig.CC == 'gcc':
  17. device = '-mcpu=cortex-m3'
  18. device_type = 'STM32F10X_HD'
  19. aflags = device + ' -c -gdwarf-2 -mthumb -x assembler-with-cpp'
  20. cc_path = ''
  21. cc_cpath = ''
  22. cc_exec_path = 'D:/SourceryGCC/bin'
  23. cc_cflags = device + ' -mthumb -gdwarf-2 -DUSE_STDPERIPH_DRIVER -DSTM32F10X_HD -D__thumb__ -Wall -nostdinc -fno-builtin'
  24. cc_lflags = cc_cflags + ' -MMD -MP -MF -static -nostdlib -Wl,--gc-sections,-Map=main.elf.map,-cref,-u,Reset_Handler -T stm32_rom.ld --output rtthread-stm32.elf'
  25. cc_target = 'rtthread-stm32.elf'
  26. elif rtconfig.CC == 'iar':
  27. device = ''
  28. device_type = 'STM32F10X_HD'
  29. aflags = ''
  30. cc_path = ''
  31. cc_cpath = ''
  32. cc_exec_path = ''
  33. cc_cflags = device + ''
  34. cc_lflags = ''
  35. cc_target = 'rtthread-stm32.elf'
  36. aflags = aflags
  37. cflags = cc_cflags
  38. # search path for C compiler
  39. kernel_path = [RTT_ROOT + '/include', RTT_ROOT + '/libcpu/' + rtconfig.ARCH + '/' + rtconfig.CPU]
  40. finsh_path = [RTT_ROOT + '/finsh']
  41. dfs_path = [RTT_ROOT + '/filesystem/dfs/include', RTT_ROOT + '/filesystem/dfs']
  42. lwip_path = [RTT_ROOT + '/net/lwip/src', RTT_ROOT + '/net/lwip/src/include', RTT_ROOT + '/net/lwip/src/include/ipv4', RTT_ROOT + '/net/lwip/src/arch/include']
  43. bsp_path = [RTT_ROOT + '/bsp/stm3210', RTT_ROOT + '/bsp/stm3210/Libraries/STM32F10x_StdPeriph_Driver/inc', RTT_ROOT + '/bsp/stm3210/Libraries/CMSIS/Core/CM3']
  44. minilibc_path = [RTT_ROOT + '/libc/minilibc']
  45. cpath = kernel_path
  46. if rtconfig.RT_USING_FINSH:
  47. cpath = cpath + finsh_path
  48. if rtconfig.RT_USING_DFS:
  49. cpath = cpath + dfs_path
  50. if rtconfig.RT_USING_LWIP:
  51. cpath = cpath + lwip_path
  52. if rtconfig.RT_USING_MINILIBC:
  53. cpath = cpath + minilibc_path
  54. cpath = cpath + [cc_cpath] + bsp_path
  55. # link flag
  56. lflags = device + cc_lflags
  57. if rtconfig.CC == 'armcc':
  58. env = Environment(tools = ['mingw'],
  59. AS='armasm', ASFLAGS = aflags,
  60. CC='armcc', CCFLAGS = cflags, CPPPATH = cpath,
  61. AR='armar', ARFLAGS = '-rc',
  62. LINK='armlink', LINKFLAGS=lflags)
  63. env.PrependENVPath('PATH', cc_exec_path)
  64. if rtconfig.CC == 'gcc':
  65. env = Environment(tools = ['mingw'],
  66. AS='arm-none-eabi-gcc', ASFLAGS = aflags,
  67. CC='arm-none-eabi-gcc', CCFLAGS = cflags, CPPPATH = cpath,
  68. AR='arm-none-eabi-ar', ARFLAGS = '-rc',
  69. LINK='arm-none-eabi-gcc', LINKFLAGS=lflags)
  70. env.PrependENVPath('PATH', cc_exec_path)
  71. Export('env')
  72. Export('RTT_ROOT')
  73. Export('rtconfig')
  74. objs = SConscript(RTT_ROOT + '/src/SConscript', variant_dir='build/src', duplicate=0)
  75. objs = objs + SConscript(RTT_ROOT + '/libcpu/SConscript', variant_dir='build/libcpu', duplicate=0)
  76. objs = objs + SConscript(RTT_ROOT + '/bsp/stm3210/Libraries/SConscript', variant_dir='build/Libraries', duplicate=0)
  77. if rtconfig.RT_USING_MINILIBC:
  78. objs = objs + SConscript(RTT_ROOT + '/libc/minilibc/SConscript', variant_dir='build/minilibc', duplicate=0)
  79. if rtconfig.RT_USING_FINSH:
  80. objs = objs + SConscript(RTT_ROOT + '/finsh/SConscript', variant_dir='build/finsh', duplicate=0)
  81. if rtconfig.RT_USING_DFS:
  82. objs = objs + SConscript(RTT_ROOT + '/filesystem/dfs/SConscript', variant_dir='build/filesystem', duplicate=0)
  83. if rtconfig.RT_USING_LWIP:
  84. objs = objs + SConscript(RTT_ROOT + '/net/lwip/SConscript', variant_dir='build/net/lwip', duplicate=0)
  85. source_bsp = ['application.c', 'startup.c', 'board.c', 'stm32f10x_it.c']
  86. source_drv = ['rtc.c', 'usart.c']
  87. if rtconfig.RT_USING_DFS:
  88. if device_type == 'STM32F10X_HD':
  89. source_drv = source_drv + ['sdcard.c']
  90. else:
  91. source_drv = source_drv + ['msd.c']
  92. if rtconfig.RT_USING_LWIP:
  93. if device_type == 'STM32F10X_CL':
  94. source_drv = source_drv + ['stm32_eth.c']
  95. else:
  96. source_drv = source_drv + ['enc28j60.c']
  97. objs = objs + env.Object(source_bsp + source_drv)
  98. env.Program(cc_target, objs)