Przeglądaj źródła

[env] add scons --strict

此commit意图在脚本中增加 scons --strict命令,使用该命令编译工程时,会自动将CFLAGS CXXFLAGS设置为 Werrors,即较为严格的编译模式,任何警告都会当做错误来处理。

该命令主要用于CI,在CI执行bsp编译时,可以使用 scons --strict命令。现在QEMU的rtconfig.py 为了CI检查,直接将CFLAGS加上了Werrors,导致正常编译过程中也把警告当做了错误,对日常使用该bsp造成了影响。
Meco Man 2 lat temu
rodzic
commit
b310541471

+ 1 - 1
bsp/stm32/stm32f411-st-nucleo/rtconfig.py

@@ -44,7 +44,7 @@ if PLATFORM == 'gcc':
     OBJCPY = PREFIX + 'objcopy'
     OBJCPY = PREFIX + 'objcopy'
 
 
     DEVICE = ' -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections'
     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 '
     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'
     LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,Reset_Handler -T board/linker_scripts/link.lds'
 
 

+ 7 - 1
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
     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
     # after update rtconfig.py's variables, those env variables need to synchronize
     if exec_prefix:
     if exec_prefix:
         env['CC'] = rtconfig.CC
         env['CC'] = rtconfig.CC
@@ -234,6 +234,12 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
     if exec_path:
     if exec_path:
         env.PrependENVPath('PATH', rtconfig.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
     # add compability with Keil MDK 4.6 which changes the directory of armcc.exe
     if rtconfig.PLATFORM in ['armcc', 'armclang']:
     if rtconfig.PLATFORM in ['armcc', 'armclang']:
         if rtconfig.PLATFORM == 'armcc' and not os.path.isfile(os.path.join(rtconfig.EXEC_PATH, 'armcc.exe')):
         if rtconfig.PLATFORM == 'armcc' and not os.path.isfile(os.path.join(rtconfig.EXEC_PATH, 'armcc.exe')):

+ 5 - 0
tools/options.py

@@ -85,6 +85,11 @@ def AddOptions():
                       dest = 'target',
                       dest = 'target',
                       type = 'string',
                       type = 'string',
                       help = 'set target project: mdk/mdk4/mdk5/iar/vs/vsc/ua/cdk/ses/makefile/eclipse/codelite/cmake')
                       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',
     AddOption('--cc-prefix', '--exec-prefix',
                 dest = 'exec-prefix',
                 dest = 'exec-prefix',
                 type = 'string',
                 type = 'string',