diff --git a/bsp/stm32/stm32f411-st-nucleo/rtconfig.py b/bsp/stm32/stm32f411-st-nucleo/rtconfig.py index 78b61b7d2f..72a60ae53f 100644 --- a/bsp/stm32/stm32f411-st-nucleo/rtconfig.py +++ b/bsp/stm32/stm32f411-st-nucleo/rtconfig.py @@ -44,7 +44,7 @@ if PLATFORM == 'gcc': OBJCPY = PREFIX + 'objcopy' DEVICE = ' -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections' - CFLAGS = DEVICE + ' -Dgcc' + ' -Wall -Werror' + CFLAGS = DEVICE + ' -Dgcc' + ' -Wall' AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb ' LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,Reset_Handler -T board/linker_scripts/link.lds' diff --git a/tools/building.py b/tools/building.py index 4a9609bba1..1bfff2c2ce 100644 --- a/tools/building.py +++ b/tools/building.py @@ -223,7 +223,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ utils.ReloadModule(rtconfig) # update environment variables to rtconfig.py - # some env variables have loaded in SConsctruct Environment() before re-load rtconfig.py; + # some env variables have loaded in Environment() of SConstruct before re-load rtconfig.py; # after update rtconfig.py's variables, those env variables need to synchronize if exec_prefix: env['CC'] = rtconfig.CC @@ -234,6 +234,12 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ if exec_path: env.PrependENVPath('PATH', rtconfig.EXEC_PATH) + if GetOption('strict-compiling'): + STRICT_FLAGS = '' + if rtconfig.PLATFORM in ['gcc']: + STRICT_FLAGS += ' -Werror' #-Wextra + env.Append(CFLAGS=STRICT_FLAGS, CXXFLAGS=STRICT_FLAGS) + # add compability with Keil MDK 4.6 which changes the directory of armcc.exe if rtconfig.PLATFORM in ['armcc', 'armclang']: if rtconfig.PLATFORM == 'armcc' and not os.path.isfile(os.path.join(rtconfig.EXEC_PATH, 'armcc.exe')): diff --git a/tools/options.py b/tools/options.py index 3d705a792f..b02b81b5a3 100644 --- a/tools/options.py +++ b/tools/options.py @@ -85,6 +85,11 @@ def AddOptions(): dest = 'target', type = 'string', help = 'set target project: mdk/mdk4/mdk5/iar/vs/vsc/ua/cdk/ses/makefile/eclipse/codelite/cmake') + AddOption('--strict', + dest='strict-compiling', + help='Compiling project with strict mode and ALL warning will be errors', + action='store_true', + default=False) AddOption('--cc-prefix', '--exec-prefix', dest = 'exec-prefix', type = 'string',