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 <alexandru.croitor@qt.io>
This commit is contained in:
parent
fee7844759
commit
658c166f96
@ -319,6 +319,10 @@ function(qt_internal_target_sync_headers target module_headers module_headers_ge
|
||||
list(APPEND common_syncqt_arguments -debug)
|
||||
endif()
|
||||
|
||||
set(build_time_syncqt_arguments "")
|
||||
if(WARNINGS_ARE_ERRORS)
|
||||
list(APPEND build_time_syncqt_arguments -warningsAreErrors)
|
||||
endif()
|
||||
|
||||
if(is_framework)
|
||||
list(REMOVE_ITEM module_headers "${CMAKE_CURRENT_BINARY_DIR}/${target}_fake_header.h")
|
||||
@ -344,6 +348,7 @@ function(qt_internal_target_sync_headers target module_headers module_headers_ge
|
||||
COMMAND
|
||||
${QT_CMAKE_EXPORT_NAMESPACE}::syncqt
|
||||
${common_syncqt_arguments}
|
||||
${build_time_syncqt_arguments}
|
||||
-headers "@${module_headers_rsp}"
|
||||
-generatedHeaders "@${module_headers_generated_rsp}"
|
||||
-stagingDir "${syncqt_staging_dir}"
|
||||
@ -428,7 +433,10 @@ function(qt_internal_target_sync_headers target module_headers module_headers_ge
|
||||
)
|
||||
if(NOT syncqt_result EQUAL 0)
|
||||
message(FATAL_ERROR
|
||||
"Unable to execute syncqt.cpp for module ${target}: ${syncqt_output}")
|
||||
"syncqt.cpp failed for module ${module}:\n${syncqt_output}")
|
||||
endif()
|
||||
if(syncqt_output)
|
||||
message("${syncqt_output}")
|
||||
endif()
|
||||
set_property(GLOBAL APPEND PROPERTY _qt_synced_modules ${module})
|
||||
endif()
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user