Fix make install to be deterministic
The result of "make install" should be the same regardless of whether it has been run multiple times and the destination exists already. This is done by making the file installation calls always take canonical source and target paths and not look at the target directory. Task-number: QTBUG-60370 Change-Id: I83a584c0dbc4fd10c79976d4169bf6bc051884a1 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
This commit is contained in:
parent
63b94c5772
commit
0942f44454
@ -1283,7 +1283,7 @@ MakefileGenerator::writeInstalls(QTextStream &t, bool noBuild)
|
||||
if(is_target || exists(wild)) { //real file or target
|
||||
QFileInfo fi(fileInfo(wild));
|
||||
QString dst_file = filePrefixRoot(root, dst_dir);
|
||||
if(fi.isDir() && project->isActiveConfig("copy_dir_files")) {
|
||||
if (!fi.isDir() || project->isActiveConfig("copy_dir_files")) {
|
||||
if(!dst_file.endsWith(Option::dir_sep))
|
||||
dst_file += Option::dir_sep;
|
||||
dst_file += fi.fileName();
|
||||
@ -1317,11 +1317,16 @@ MakefileGenerator::writeInstalls(QTextStream &t, bool noBuild)
|
||||
dst_file += Option::dir_sep;
|
||||
dst_file += filestr;
|
||||
}
|
||||
} else if (installConfigValues.contains("executable")) {
|
||||
} else {
|
||||
if (installConfigValues.contains("executable")) {
|
||||
cmd = QLatin1String("-$(QINSTALL_PROGRAM)");
|
||||
} else {
|
||||
cmd = QLatin1String("-$(QINSTALL_FILE)");
|
||||
}
|
||||
if (!dst_file.endsWith(Option::dir_sep))
|
||||
dst_file += Option::dir_sep;
|
||||
dst_file += filestr;
|
||||
}
|
||||
cmd += " " + escapeFilePath(wild) + " " + escapeFilePath(dst_file);
|
||||
inst << cmd;
|
||||
uninst.append(rm_dir_contents + " " + escapeFilePath(filePrefixRoot(root, fileFixify(dst_dir + filestr, FileFixifyAbsolute, false))));
|
||||
@ -1331,7 +1336,7 @@ MakefileGenerator::writeInstalls(QTextStream &t, bool noBuild)
|
||||
uninst.append(rm_dir_contents + " " + escapeFilePath(filePrefixRoot(root, fileFixify(dst_dir + file, FileFixifyAbsolute, false))));
|
||||
QFileInfo fi(fileInfo(dirstr + file));
|
||||
QString dst_file = filePrefixRoot(root, fileFixify(dst_dir, FileFixifyAbsolute, false));
|
||||
if(fi.isDir() && project->isActiveConfig("copy_dir_files")) {
|
||||
if (!fi.isDir() || project->isActiveConfig("copy_dir_files")) {
|
||||
if(!dst_file.endsWith(Option::dir_sep))
|
||||
dst_file += Option::dir_sep;
|
||||
dst_file += fi.fileName();
|
||||
|
@ -236,17 +236,11 @@ static int doLink(int argc, char **argv)
|
||||
|
||||
#endif
|
||||
|
||||
static int installFile(const QString &source, const QString &targetFileOrDirectory, bool exe = false)
|
||||
static int installFile(const QString &source, const QString &target, bool exe = false)
|
||||
{
|
||||
QFile sourceFile(source);
|
||||
|
||||
QString target(targetFileOrDirectory);
|
||||
if (QFileInfo(target).isDir())
|
||||
target += QDir::separator() + QFileInfo(sourceFile.fileName()).fileName();
|
||||
|
||||
if (QFile::exists(target))
|
||||
QFile::remove(target);
|
||||
|
||||
QDir::root().mkpath(QFileInfo(target).absolutePath());
|
||||
|
||||
if (!sourceFile.copy(target)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user