diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2017-05-02 14:44:44 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-05-04 09:40:48 +0000 |
commit | 50acc8680490319c8fe45615c8d6521f0101728b (patch) | |
tree | 6d99ba428dbc28e11adc22ed4795a3ba9fa894b6 /qmake/main.cpp | |
parent | 877ef0594d94f48bf063446b1f8a4b5e1941a8cd (diff) |
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>
Diffstat (limited to 'qmake/main.cpp')
-rw-r--r-- | qmake/main.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
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); } |