From 4bec5f9b8f74065713974181480622db98b7b548 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 19 Feb 2024 14:51:05 -0500 Subject: [PATCH] [kernel][SConscript] add strict warning cflags --- src/SConscript | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/SConscript b/src/SConscript index 7f7098aaab..5ab18ef52a 100644 --- a/src/SConscript +++ b/src/SConscript @@ -1,9 +1,9 @@ from building import * +from gcc import GetGCCLikePLATFORM import os src = Glob('*.c') cwd = GetCurrentDir() - inc = [os.path.join(cwd, '..', 'include')] if GetDepend('RT_USING_SMALL_MEM') == False: @@ -30,6 +30,19 @@ if GetDepend('RT_USING_SMP') == False: if GetDepend('RT_USING_SMP') == True: SrcRemove(src, ['scheduler_up.c']) -group = DefineGroup('Kernel', src, depend = [''], CPPPATH = inc, CPPDEFINES = ['__RTTHREAD__']) +LOCAL_CFLAGS = '' + +if rtconfig.PLATFORM in GetGCCLikePLATFORM(): + 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 + +group = DefineGroup('Kernel', src, depend=[''], CPPPATH=inc, CPPDEFINES=['__RTTHREAD__'], LOCAL_CFLAGS=LOCAL_CFLAGS) Return('group')