Browse Source

[kernel][SConscript] add strict warning cflags

Meco Man 1 year ago
parent
commit
4bec5f9b8f
1 changed files with 15 additions and 2 deletions
  1. 15 2
      src/SConscript

+ 15 - 2
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')