From b4cec19bdc4f0fb8f45c66048882b16a4b9617c9 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Thu, 3 May 2018 12:02:21 +0200 Subject: Disable all warnings for generated Qt files This includes compilation of MOC generated source files and adjusting the UIC generated header files with compiler pragmas that ignore all warnings. Test-Information: Tested no warnings are emitted for generated files on macOS 10.13.4 with Qt 5.5.1 and clang trunk. Change-Id: Ib49ba7bc2017e018ebd857837fbe2d9640fba2bb diff --git a/BuildTools/SCons/Tools/qt4.py b/BuildTools/SCons/Tools/qt4.py index d5c14e2..e859017 100644 --- a/BuildTools/SCons/Tools/qt4.py +++ b/BuildTools/SCons/Tools/qt4.py @@ -37,6 +37,7 @@ __revision__ = "/home/scons/scons/branch.0/branch.96/baseline/src/engine/SCons/T import os.path import re import subprocess +from string import Template import SCons.Action import SCons.Builder @@ -129,7 +130,9 @@ class _Automoc: # The following is kind of hacky to get builders working properly (FIXME) objBuilderEnv = objBuilder.env - objBuilder.env = env + objBuilder.env = env.Clone() + if os.path.basename(objBuilder.env ["CXX"]).startswith(("gcc", "clang")): + objBuilder.env.Append(CXXFLAGS = "-w") mocBuilderEnv = env.Moc4.env env.Moc4.env = env @@ -368,8 +371,30 @@ def generate(env): env.Append( BUILDERS = { 'Qrc': qrcbuilder } ) # Interface builder + def addDisableWarningsPragmaToFile(target, source, env): + assert( len(target) == 1 ) + assert( len(source) == 1 ) + srcf = str(source[0]) + dstf = str(target[0]) + with open(dstf, 'r+') as uiHeader: + data=uiHeader.read() + + template = Template( +"""#pragma once +#pragma warning(push, 0) +#pragma GCC system_header +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wall" +$uiheadertext +#pragma clang diagnostic pop +#pragma warning(pop) +""") + uiHeader.seek(0) + uiHeader.write(template.substitute(uiheadertext=data)) + uiHeader.truncate() + uic4builder = Builder( - action = SCons.Action.Action('$QT4_UICCOM', cmdstr = '$QT4_UICCOMSTR'), + action = [SCons.Action.Action('$QT4_UICCOM', cmdstr = '$QT4_UICCOMSTR'), SCons.Action.Action(addDisableWarningsPragmaToFile, None)], src_suffix='$QT4_UISUFFIX', suffix='$QT4_UICDECLSUFFIX', prefix='$QT4_UICDECLPREFIX', -- cgit v0.10.2-6-g49f6