SConscript 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. from building import *
  2. import os
  3. src = Glob('*.c')
  4. cwd = GetCurrentDir()
  5. inc = [os.path.join(cwd, '..', 'include')]
  6. if GetDepend('RT_USING_SMALL_MEM') == False:
  7. SrcRemove(src, ['mem.c'])
  8. if GetDepend('RT_USING_SLAB') == False:
  9. SrcRemove(src, ['slab.c'])
  10. if GetDepend('RT_USING_MEMPOOL') == False:
  11. SrcRemove(src, ['mempool.c'])
  12. if GetDepend('RT_USING_MEMHEAP') == False:
  13. SrcRemove(src, ['memheap.c'])
  14. if GetDepend('RT_USING_SIGNALS') == False:
  15. SrcRemove(src, ['signal.c'])
  16. if GetDepend('RT_USING_DEVICE') == False:
  17. SrcRemove(src, ['device.c'])
  18. if GetDepend('RT_USING_SMP') == False:
  19. SrcRemove(src, ['cpu_mp.c', 'scheduler_mp.c'])
  20. else:
  21. SrcRemove(src, ['cpu_up.c', 'scheduler_up.c'])
  22. LOCAL_CFLAGS = ''
  23. LINKFLAGS = ''
  24. if rtconfig.PLATFORM in ['gcc']: # only for GCC
  25. LOCAL_CFLAGS += ' -Wunused' # unused warning
  26. LOCAL_CFLAGS += ' -Wformat -Wformat-security' # printf/scanf format warning
  27. LOCAL_CFLAGS += ' -Warray-bounds -Wuninitialized' # memory access warning
  28. LOCAL_CFLAGS += ' -Wreturn-type -Wcomment -Wswitch' # code style warning
  29. LOCAL_CFLAGS += ' -Wparentheses -Wlogical-op ' # operation warning
  30. LOCAL_CFLAGS += ' -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes' # function declaration warning
  31. if 'mips' not in rtconfig.PREFIX: # mips toolchain does not support
  32. LOCAL_CFLAGS += ' -Wimplicit-fallthrough' # implicit fallthrough warning
  33. LOCAL_CFLAGS += ' -Wduplicated-cond -Wduplicated-branches' # duplicated condition warning
  34. if rtconfig.ARCH not in ['sim']:
  35. LINKFLAGS += ' -Wl,--gc-sections,--print-memory-usage' # remove unused sections and print memory usage
  36. if GetDepend('RT_USING_HOOKLIST') == True:
  37. if rtconfig.PLATFORM in ['gcc', 'armclang']:
  38. LOCAL_CFLAGS += ' -std=gnu99'
  39. elif rtconfig.PLATFORM in ['armcc']:
  40. LOCAL_CFLAGS += ' --c99 --gnu'
  41. if rtconfig.CROSS_TOOL == 'msvc':
  42. group = DefineGroup('Kernel', src, depend=[''], CPPPATH=inc,
  43. LINKFLAGS=LINKFLAGS, LOCAL_CFLAGS=LOCAL_CFLAGS,
  44. CPPDEFINES=['__RTTHREAD__', '__RT_KERNEL_SOURCE__'])
  45. else:
  46. group = DefineGroup('Kernel', src, depend=[''], CPPPATH=inc,
  47. LINKFLAGS=LINKFLAGS, LOCAL_CFLAGS=LOCAL_CFLAGS,
  48. CPPDEFINES=['__RTTHREAD__'], LOCAL_CPPDEFINES=['__RT_KERNEL_SOURCE__'])
  49. list = os.listdir(cwd)
  50. for item in list:
  51. if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
  52. group = group + SConscript(os.path.join(item, 'SConscript'))
  53. Return('group')