diff options
author | Alexey Edelev <[email protected]> | 2022-09-30 12:46:18 +0200 |
---|---|---|
committer | Alexey Edelev <[email protected]> | 2022-10-01 16:24:01 +0200 |
commit | 658c166f966a6081d424a3f30c6769c28134b52a (patch) | |
tree | 94b713f9c5bc63d7cb9a35042e3d46e560402749 /src | |
parent | fee7844759f3c1dbc8a00139d923211990a07775 (diff) |
Add 'warnings are errors' functionality to syncqt.cpp
Add the -warningsAreErrors command line argument to syncqt.cpp that
causes a fail at build step if any of header files doesn't fit the
syncqt standards. The argument reflects the WARNIGS_ARE_ERRORS CMake
variable state.
Output the syncqt.cpp warnings at configure time.
Fix the faulty positive IncludeChecks failure flag.
Task-number: QTBUG-107088
Change-Id: Id30af4c7b78fd44c1c99c7e9306965d03a0f992d
Reviewed-by: Alexandru Croitor <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/syncqt/main.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/tools/syncqt/main.cpp b/src/tools/syncqt/main.cpp index 05e2e395290..1e18ca2082a 100644 --- a/src/tools/syncqt/main.cpp +++ b/src/tools/syncqt/main.cpp @@ -179,6 +179,8 @@ public: bool showOnly() const { return m_showOnly; } + bool warningsAreErrors() const { return m_warningsAreErrors; } + void printHelp() const { std::cout << "Usage: syncqt -sourceDir <dir> -binaryDir <dir> -module <module name>" @@ -234,6 +236,7 @@ public: " -minimal Do not create CaMeL case headers for the\n" " public C++ symbols.\n" " -showonly Show actions, but not perform them.\n" + " -warningsAreErrors Treat all warnings as errors.\n" " -help Print this help.\n"; } @@ -286,6 +289,7 @@ private: { "-internal", { &m_isInternal, true } }, { "-all", { &m_scanAllMode, true } }, { "-copy", { &m_copy, true } }, { "-minimal", { &m_minimal, true } }, { "-showonly", { &m_showOnly, true } }, { "-showOnly", { &m_showOnly, true } }, + { "-warningsAreErrors", { &m_warningsAreErrors, true } } }; std::string *currentValue = nullptr; @@ -431,6 +435,7 @@ private: bool m_debug = false; bool m_minimal = false; bool m_showOnly = false; + bool m_warningsAreErrors = false; std::regex m_qpaHeadersRegex; std::regex m_privateHeadersRegex; std::regex m_publicNamespaceRegex; @@ -505,6 +510,8 @@ class SyncScanner enum FileType { PublicHeader = 0, PrivateHeader = 1, QpaHeader = 2, ExportHeader = 4 }; unsigned int m_currentFileType = PublicHeader; + int m_criticalChecks = CriticalChecks; + public: SyncScanner(CommandLineOptions *commandLineArgs) : m_commandLineArgs(commandLineArgs), m_masterHeaderContents(MasterHeaderIncludeComparator) @@ -519,6 +526,7 @@ public: ErrorCodes sync() { + m_criticalChecks = m_commandLineArgs->warningsAreErrors() ? AllChecks : CriticalChecks; m_versionScriptGeneratorState = m_commandLineArgs->versionScriptFile().empty() ? Stopped : Active; auto error = NoError; @@ -1123,10 +1131,10 @@ public: << " includes private header " << includedHeader << std::endl; } for (const auto &module : m_commandLineArgs->knownModules()) { - faults |= IncludeChecks; std::string suggestedHeader = "Qt" + module + '/' + includedHeader; if (std::filesystem::exists(m_commandLineArgs->includeDir() + "/../" + suggestedHeader)) { + faults |= IncludeChecks; std::cerr << m_commandLineArgs->moduleName() << ": WARNING: " << m_currentFilename << " includes " << includedHeader << " when it should include " @@ -1211,7 +1219,7 @@ public: m_headerCheckExceptions.push_back(m_currentFileString); // Exit with an error if any of critical checks are present. - return !(faults & CriticalChecks); + return !(faults & m_criticalChecks); } // The function checks if line contains the symbol that needs to have a CaMeL-style alias. |