scons学习调试记录


起因:试图解决[Bug] LOCAL_CPPDEFINES组宏定义无法添加到CMakeLists.txt · Issue #9536 · RT-Thread/rt-thread · GitHub
对比了5.1.0和master版本的sconscrips,代码都是一样的,但是在LOCAL_CPPDEFINES 这里会有问题,5.1.0在cmakelists这里会少一个define导致报warning,在issue内有图,不再赘述

from building import *  
import os  
  
src = Glob('*.c')  
src += Glob('klibc/*.c')  
cwd = GetCurrentDir()  
inc = [os.path.join(cwd, '..', 'include')]  
  
if GetDepend('RT_USING_SMALL_MEM') == False:  
    SrcRemove(src, ['mem.c'])  
  
if GetDepend('RT_USING_SLAB') == False:  
    SrcRemove(src, ['slab.c'])  
  
if GetDepend('RT_USING_MEMPOOL') == False:  
    SrcRemove(src, ['mempool.c'])  
  
if GetDepend('RT_USING_MEMHEAP') == False:  
    SrcRemove(src, ['memheap.c'])  
  
if GetDepend('RT_USING_SIGNALS') == False:  
    SrcRemove(src, ['signal.c'])  
  
if GetDepend('RT_USING_DEVICE') == False:  
    SrcRemove(src, ['device.c'])  
  
if GetDepend('RT_USING_SMP') == False:  
    SrcRemove(src, ['cpu.c', 'scheduler_mp.c'])  
else:  
    SrcRemove(src, ['scheduler_up.c'])  
  
LOCAL_CFLAGS = ''  
LINKFLAGS = ''  
  
if rtconfig.PLATFORM in ['gcc']: # only for GCC    LOCAL_CFLAGS += ' -Wunused' # unused warning    LOCAL_CFLAGS += ' -Wformat -Wformat-security' # printf/scanf format warning    LOCAL_CFLAGS += ' -Warray-bounds -Wuninitialized' # memory access warning    LOCAL_CFLAGS += ' -Wreturn-type -Wcomment -Wswitch' # code style warning    LOCAL_CFLAGS += ' -Wparentheses -Wlogical-op ' # operation warning    LOCAL_CFLAGS += ' -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes' # function declaration warning    if 'mips' not in rtconfig.PREFIX: # mips toolchain does not support        LOCAL_CFLAGS += ' -Wimplicit-fallthrough' # implicit fallthrough warning        LOCAL_CFLAGS += ' -Wduplicated-cond -Wduplicated-branches' # duplicated condition warning    if rtconfig.ARCH not in ['sim']:  
        LINKFLAGS += ' -Wl,--gc-sections,--print-memory-usage' # remove unused sections and print memory usage  
group = DefineGroup('Kernel', src, depend=[''], CPPPATH=inc,  
                    LINKFLAGS=LINKFLAGS, LOCAL_CFLAGS=LOCAL_CFLAGS,  
                    CPPDEFINES=['__RTTHREAD__'], LOCAL_CPPDEFINES=['__RT_KERNEL_SOURCE__'])  
  
# print("Source files:", src)# print("Include paths:", inc)print("Local CFLAGS:", LOCAL_CFLAGS)  
# print("Local CPPDEFINES:", LOCAL_CPPDEFINES)# print("CPPDEFINES:", env['CPPDEFINES'])  
Return('group')

文章作者: Harry Zhang
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Harry Zhang !
  目录