Make sure that the 3rdparty directory belongs to the module

If the path where Qt sources are located has 3rdparty in it we skip
headers processing since all headers are treated as 3rdparty.

Use path relative to the source directory when indentifying the 3rdparty
header files using regex.

Fixes: QTBUG-115324
Change-Id: If97328cb9a9ece01d43c56022f4613da9b29c03f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit ea4a3d78a776e10955caf6cf9b1054ddb50f40d3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexey Edelev 2023-07-19 16:05:39 +02:00 committed by Qt Cherry-pick Bot
parent 95befb165b
commit 4d2c405fe5

View File

@ -780,7 +780,7 @@ public:
[[nodiscard]] bool processHeader(const std::filesystem::path &headerFile)
{
// This regex filters any paths that contain the '3rdparty' directory.
static const std::regex ThirdPartyFolderRegex(".+/3rdparty/.+");
static const std::regex ThirdPartyFolderRegex("(^|.+/)3rdparty/.+");
// This regex filters '-config.h' and '-config_p.h' header files.
static const std::regex ConfigHeaderRegex("^(q|.+-)config(_p)?\\.h");
@ -872,7 +872,14 @@ public:
}
bool isGenerated = isHeaderGenerated(m_currentFileString);
bool is3rdParty = std::regex_match(m_currentFileString, ThirdPartyFolderRegex);
// Make sure that we detect the '3rdparty' directory inside the source directory only,
// since full path to the Qt sources might contain '/3rdparty/' too.
bool is3rdParty = std::regex_match(
std::filesystem::relative(headerFile, m_commandLineArgs->sourceDir())
.generic_string(),
ThirdPartyFolderRegex);
// No processing of generated Qt config header files.
if (!std::regex_match(m_currentFilename, ConfigHeaderRegex)) {
unsigned int skipChecks = m_commandLineArgs->scanAllMode() ? AllChecks : NoChecks;