From 50acc8680490319c8fe45615c8d6521f0101728b Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 2 May 2017 14:44:44 +0200 Subject: 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 --- qmake/main.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'qmake/main.cpp') diff --git a/qmake/main.cpp b/qmake/main.cpp index f25b128d03..13b18d018a 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp @@ -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); } -- cgit v1.2.3