syncqt: Use absolute paths to aliased header files in corner cases
If source and build directories are located on different Windows disks, or one of them contains a symbolic link in the path, std::filesystem:relative is unable to calculate the relative path. So the generated header files contain empty entries. In this cases use the absolute file paths for include directives in the header file aliases. Fixes: QTBUG-108452 Change-Id: Iefc8f0ce2b54dcc31971d4a1944bf7fa55f8164e Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
f6fefbc6ca
commit
5a72b327fd
@ -505,6 +505,7 @@ class SyncScanner
|
|||||||
|
|
||||||
enum { Active, Stopped, IgnoreNext, Ignore } m_versionScriptGeneratorState = Active;
|
enum { Active, Stopped, IgnoreNext, Ignore } m_versionScriptGeneratorState = Active;
|
||||||
|
|
||||||
|
std::filesystem::path m_outputRootName;
|
||||||
std::filesystem::path m_currentFile;
|
std::filesystem::path m_currentFile;
|
||||||
std::string m_currentFilename;
|
std::string m_currentFilename;
|
||||||
std::string m_currentFileString;
|
std::string m_currentFileString;
|
||||||
@ -521,7 +522,9 @@ public:
|
|||||||
SyncScanner(CommandLineOptions *commandLineArgs)
|
SyncScanner(CommandLineOptions *commandLineArgs)
|
||||||
: m_commandLineArgs(commandLineArgs),
|
: m_commandLineArgs(commandLineArgs),
|
||||||
m_masterHeaderContents(MasterHeaderIncludeComparator),
|
m_masterHeaderContents(MasterHeaderIncludeComparator),
|
||||||
m_warningMessagePreamble(WarningMessagePreamble)
|
m_warningMessagePreamble(WarningMessagePreamble),
|
||||||
|
m_outputRootName(
|
||||||
|
std::filesystem::weakly_canonical(m_commandLineArgs->includeDir()).root_name())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -739,6 +742,7 @@ public:
|
|||||||
FileStamp originalStamp = std::filesystem::last_write_time(headerFile, ec);
|
FileStamp originalStamp = std::filesystem::last_write_time(headerFile, ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
originalStamp = FileStamp::clock::now();
|
originalStamp = FileStamp::clock::now();
|
||||||
|
ec.clear();
|
||||||
|
|
||||||
bool isPrivate = m_currentFileType & PrivateHeader;
|
bool isPrivate = m_currentFileType & PrivateHeader;
|
||||||
bool isQpa = m_currentFileType & QpaHeader;
|
bool isQpa = m_currentFileType & QpaHeader;
|
||||||
@ -758,8 +762,14 @@ public:
|
|||||||
std::filesystem::create_directories(outputDir);
|
std::filesystem::create_directories(outputDir);
|
||||||
|
|
||||||
bool headerFileExists = std::filesystem::exists(headerFile);
|
bool headerFileExists = std::filesystem::exists(headerFile);
|
||||||
std::string aliasedFilepath =
|
|
||||||
std::filesystem::relative(headerFile, outputDir).generic_string();
|
std::filesystem::path headerFileRootName =
|
||||||
|
std::filesystem::weakly_canonical(headerFile, ec).root_name();
|
||||||
|
std::string aliasedFilepath = !ec && headerFileRootName == m_outputRootName
|
||||||
|
? std::filesystem::relative(headerFile, outputDir).generic_string()
|
||||||
|
: headerFile.generic_string();
|
||||||
|
ec.clear();
|
||||||
|
|
||||||
std::string aliasPath = outputDir + '/' + m_currentFilename;
|
std::string aliasPath = outputDir + '/' + m_currentFilename;
|
||||||
|
|
||||||
// If the '-copy' argument is passed, we copy the original file to a corresponding output
|
// If the '-copy' argument is passed, we copy the original file to a corresponding output
|
||||||
|
Loading…
x
Reference in New Issue
Block a user