Simplify built-in qmake install command
As the directory installation command also works with files as a source we can unify the external commands, resulting in simpler command lines. Change-Id: I65013626eedbdb3ce1c77ed230d46edd1603b986 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
This commit is contained in:
parent
877ef0594d
commit
50acc86804
@ -44,10 +44,7 @@ for (cp, COPIES) {
|
||||
$${pfx}.output = $$path/${QMAKE_FUNC_FILE_IN_qtStripSrcDir_$$cp}
|
||||
}
|
||||
$${pfx}.input = $${pfx}.files
|
||||
!$$dir: \
|
||||
$${pfx}.commands = $(QINSTALL_FILE) ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
|
||||
else: \
|
||||
$${pfx}.commands = $(QINSTALL_DIR) ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
|
||||
$${pfx}.commands = $(QINSTALL) ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
|
||||
$${pfx}.name = COPY ${QMAKE_FILE_IN}
|
||||
$${pfx}.CONFIG = no_link no_clean target_predeps
|
||||
QMAKE_EXTRA_COMPILERS += $${pfx}
|
||||
|
@ -1287,12 +1287,10 @@ MakefileGenerator::writeInstalls(QTextStream &t, bool noBuild)
|
||||
dst_file += Option::dir_sep;
|
||||
dst_file += fi.fileName();
|
||||
QString cmd;
|
||||
if (fi.isDir())
|
||||
cmd = "-$(QINSTALL_DIR)";
|
||||
else if (is_target || fi.isExecutable())
|
||||
cmd = "-$(QINSTALL_PROGRAM)";
|
||||
if (is_target || (!fi.isDir() && fi.isExecutable()))
|
||||
cmd = QLatin1String("-$(QINSTALL_PROGRAM)");
|
||||
else
|
||||
cmd = "-$(QINSTALL_FILE)";
|
||||
cmd = QLatin1String("-$(QINSTALL)");
|
||||
cmd += " " + escapeFilePath(wild) + " " + escapeFilePath(dst_file);
|
||||
inst << cmd;
|
||||
if (!project->isActiveConfig("debug_info") && !project->isActiveConfig("nostrip") &&
|
||||
@ -1307,17 +1305,14 @@ MakefileGenerator::writeInstalls(QTextStream &t, bool noBuild)
|
||||
QDir::NoDotAndDotDot | QDir::AllEntries);
|
||||
if (installConfigValues.contains("no_check_exist") && files.isEmpty()) {
|
||||
QString dst_file = filePrefixRoot(root, dst_dir);
|
||||
QString cmd;
|
||||
if (!dst_file.endsWith(Option::dir_sep))
|
||||
dst_file += Option::dir_sep;
|
||||
dst_file += filestr;
|
||||
if (installConfigValues.contains("directory")) {
|
||||
cmd = QLatin1String("-$(QINSTALL_DIR)");
|
||||
} else if (installConfigValues.contains("executable")) {
|
||||
QString cmd;
|
||||
if (installConfigValues.contains("executable"))
|
||||
cmd = QLatin1String("-$(QINSTALL_PROGRAM)");
|
||||
} else {
|
||||
cmd = QLatin1String("-$(QINSTALL_FILE)");
|
||||
}
|
||||
else
|
||||
cmd = QLatin1String("-$(QINSTALL)");
|
||||
cmd += " " + escapeFilePath(wild) + " " + escapeFilePath(dst_file);
|
||||
inst << cmd;
|
||||
uninst.append(rm_dir_contents + " " + escapeFilePath(filePrefixRoot(root, fileFixify(dst_dir + filestr, FileFixifyAbsolute, false))));
|
||||
@ -1330,7 +1325,7 @@ MakefileGenerator::writeInstalls(QTextStream &t, bool noBuild)
|
||||
if (!dst_file.endsWith(Option::dir_sep))
|
||||
dst_file += Option::dir_sep;
|
||||
dst_file += fi.fileName();
|
||||
QString cmd = QString(fi.isDir() ? "-$(QINSTALL_DIR)" : "-$(QINSTALL_FILE)") + " " +
|
||||
QString cmd = QLatin1String("-$(QINSTALL) ") +
|
||||
escapeFilePath(dirstr + file) + " " + escapeFilePath(dst_file);
|
||||
inst << cmd;
|
||||
if (!project->isActiveConfig("debug_info") && !project->isActiveConfig("nostrip") &&
|
||||
@ -2242,9 +2237,8 @@ MakefileGenerator::writeDefaultVariables(QTextStream &t)
|
||||
t << "INSTALL_FILE = " << var("QMAKE_INSTALL_FILE") << endl;
|
||||
t << "INSTALL_PROGRAM = " << var("QMAKE_INSTALL_PROGRAM") << endl;
|
||||
t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl;
|
||||
t << "QINSTALL_FILE = " << var("QMAKE_QMAKE") << " -install qinstall file" << endl;
|
||||
t << "QINSTALL_PROGRAM = " << var("QMAKE_QMAKE") << " -install qinstall program" << endl;
|
||||
t << "QINSTALL_DIR = " << var("QMAKE_QMAKE") << " -install qinstall directory" << endl;
|
||||
t << "QINSTALL = " << var("QMAKE_QMAKE") << " -install qinstall" << endl;
|
||||
t << "QINSTALL_PROGRAM = " << var("QMAKE_QMAKE") << " -install qinstall -exe" << endl;
|
||||
t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
|
||||
t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << endl;
|
||||
t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl;
|
||||
|
@ -600,7 +600,7 @@ UnixMakefileGenerator::defaultInstall(const QString &t)
|
||||
dst = escapeFilePath(filePrefixRoot(root, targetdir + src.section('/', -1)));
|
||||
if(!ret.isEmpty())
|
||||
ret += "\n\t";
|
||||
ret += "-$(QINSTALL_FILE) " + escapeFilePath(Option::fixPathToTargetOS(src, false)) + ' ' + dst;
|
||||
ret += "-$(QINSTALL) " + escapeFilePath(Option::fixPathToTargetOS(src, false)) + ' ' + dst;
|
||||
if(!uninst.isEmpty())
|
||||
uninst.append("\n\t");
|
||||
uninst.append("-$(DEL_FILE) " + dst);
|
||||
@ -636,9 +636,9 @@ UnixMakefileGenerator::defaultInstall(const QString &t)
|
||||
|
||||
QString copy_cmd;
|
||||
if (bundle == SolidBundle) {
|
||||
copy_cmd += "-$(QINSTALL_DIR) " + src_targ + ' ' + plain_targ;
|
||||
copy_cmd += "-$(QINSTALL) " + src_targ + ' ' + plain_targ;
|
||||
} else if (project->first("TEMPLATE") == "lib" && project->isActiveConfig("staticlib")) {
|
||||
copy_cmd += "-$(QINSTALL_FILE) " + src_targ + ' ' + dst_targ;
|
||||
copy_cmd += "-$(QINSTALL) " + src_targ + ' ' + dst_targ;
|
||||
} else if (!isAux) {
|
||||
if (bundle == SlicedBundle) {
|
||||
if (!ret.isEmpty())
|
||||
@ -698,7 +698,7 @@ UnixMakefileGenerator::defaultInstall(const QString &t)
|
||||
ret += "\n\t";
|
||||
ret += mkdir_p_asstring("\"`dirname " + dst + "`\"", false) + "\n\t";
|
||||
ret += "-$(DEL_FILE) " + dst + "\n\t"; // Can't overwrite symlinks to directories
|
||||
ret += "-$(QINSTALL_DIR) " + escapeFilePath(src) + " " + dst;
|
||||
ret += "-$(QINSTALL) " + escapeFilePath(src) + " " + dst;
|
||||
if (!uninst.isEmpty())
|
||||
uninst.append("\n\t");
|
||||
uninst.append("-$(DEL_FILE) " + dst);
|
||||
|
@ -530,9 +530,8 @@ void Win32MakefileGenerator::writeStandardParts(QTextStream &t)
|
||||
t << "INSTALL_FILE = " << var("QMAKE_INSTALL_FILE") << endl;
|
||||
t << "INSTALL_PROGRAM = " << var("QMAKE_INSTALL_PROGRAM") << endl;
|
||||
t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl;
|
||||
t << "QINSTALL_FILE = " << var("QMAKE_QMAKE") << " -install qinstall file" << endl;
|
||||
t << "QINSTALL_PROGRAM = " << var("QMAKE_QMAKE") << " -install qinstall program" << endl;
|
||||
t << "QINSTALL_DIR = " << var("QMAKE_QMAKE") << " -install qinstall directory" << endl;
|
||||
t << "QINSTALL = " << var("QMAKE_QMAKE") << " -install qinstall" << endl;
|
||||
t << "QINSTALL_PROGRAM = " << var("QMAKE_QMAKE") << " -install qinstall -exe" << endl;
|
||||
t << endl;
|
||||
|
||||
t << "####### Output directory\n\n";
|
||||
|
@ -273,7 +273,7 @@ static int installFile(const QString &source, const QString &target, bool exe =
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int installDirectory(const QString &source, const QString &target)
|
||||
static int installFileOrDirectory(const QString &source, const QString &target)
|
||||
{
|
||||
QFileInfo fi(source);
|
||||
if (false) {
|
||||
@ -299,7 +299,7 @@ static int installDirectory(const QString &source, const QString &target)
|
||||
const QFileInfo &entry = it.fileInfo();
|
||||
const QString &entryTarget = target + QDir::separator() + entry.fileName();
|
||||
|
||||
const int recursionResult = installDirectory(entry.filePath(), entryTarget);
|
||||
const int recursionResult = installFileOrDirectory(entry.filePath(), entryTarget);
|
||||
if (recursionResult != 0)
|
||||
return recursionResult;
|
||||
}
|
||||
@ -313,23 +313,24 @@ static int installDirectory(const QString &source, const QString &target)
|
||||
|
||||
static int doQInstall(int argc, char **argv)
|
||||
{
|
||||
if (argc != 3) {
|
||||
fprintf(stderr, "Error: this qinstall command requires exactly three arguments (type, source, destination)\n");
|
||||
bool installExecutable = false;
|
||||
if (argc == 3 && !strcmp(argv[0], "-exe")) {
|
||||
installExecutable = true;
|
||||
--argc;
|
||||
++argv;
|
||||
}
|
||||
|
||||
if (argc != 2 && !installExecutable) {
|
||||
fprintf(stderr, "Error: usage: [-exe] source target\n");
|
||||
return 3;
|
||||
}
|
||||
|
||||
const QString source = QString::fromLocal8Bit(argv[1]);
|
||||
const QString target = QString::fromLocal8Bit(argv[2]);
|
||||
const QString source = QString::fromLocal8Bit(argv[0]);
|
||||
const QString target = QString::fromLocal8Bit(argv[1]);
|
||||
|
||||
if (!strcmp(argv[0], "file"))
|
||||
return installFile(source, target);
|
||||
if (!strcmp(argv[0], "program"))
|
||||
if (installExecutable)
|
||||
return installFile(source, target, /*exe=*/true);
|
||||
if (!strcmp(argv[0], "directory"))
|
||||
return installDirectory(source, target);
|
||||
|
||||
fprintf(stderr, "Error: Unsupported qinstall command type %s\n", argv[0]);
|
||||
return 3;
|
||||
return installFileOrDirectory(source, target);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user