diff options
author | Christian Kandeler <christian.kandeler@digia.com> | 2013-01-07 15:48:45 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@digia.com> | 2013-01-22 12:21:38 +0100 |
commit | 5cdf94de300e72987dfbe5c0fec5b86317ad6280 (patch) | |
tree | e484cd9ccd2faae387dd3978b6eb7783c99b84b3 /src/app/qbs/parser/commandlineoption.cpp | |
parent | 49060f9b1e2881a5e7801f59f6d237fd85da1ae1 (diff) |
Introduce the "install" command.
This decouples building and installing, e.g. allowing
the latter to be executed by a privileged user
to a system-wide directory.
In addition, the ability to install build artifacts
(typically executables or libraries) has been added.
Change-Id: I28e725e4c1168eebe88e12c75e3d3e9f5fe28ca5
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/app/qbs/parser/commandlineoption.cpp')
-rw-r--r-- | src/app/qbs/parser/commandlineoption.cpp | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/src/app/qbs/parser/commandlineoption.cpp b/src/app/qbs/parser/commandlineoption.cpp index 5bc08c2c2..eafa198cd 100644 --- a/src/app/qbs/parser/commandlineoption.cpp +++ b/src/app/qbs/parser/commandlineoption.cpp @@ -31,6 +31,7 @@ #include <logging/logger.h> #include <logging/translator.h> #include <tools/error.h> +#include <tools/installoptions.h> namespace qbs { using namespace Internal; @@ -233,12 +234,15 @@ QString ChangedFilesOption::longRepresentation() const QString ProductsOption::description(CommandType command) const { const QString prefix = Tr::tr("%1|%2").arg(longRepresentation(), shortRepresentation()); - if (command == ShellCommandType || command == RunCommandType) { - return Tr::tr("%1 <name>\n" - "\tUse the specified product.\n").arg(prefix); + switch (command) { + case InstallCommandType: + case RunCommandType: + case ShellCommandType: + return Tr::tr("%1 <name>\n\tUse the specified product.\n").arg(prefix); + default: + return Tr::tr("%1 <name>[,<name>...]\n" + "\tTake only the specified products into account.\n").arg(prefix); } - return Tr::tr("%1 <name>[,<name>...]\n" - "\tTake only the specified products into account.\n").arg(prefix); } QString ProductsOption::shortRepresentation() const @@ -306,4 +310,42 @@ QString AllArtifactsOption::longRepresentation() const return QLatin1String("--all-artifacts"); } +QString InstallRootOption::description(CommandType command) const +{ + Q_ASSERT(command == InstallCommandType || command == RunCommandType); + Q_UNUSED(command); + return Tr::tr("%1 <directory>\n" + "\tInstall into the given directory. The default value is qbs.sysroot, " + "if it is defined; otherwise '<build dir>/%2' is used.\n" + "\tIf the directory does not exist, it will be created.\n") + .arg(longRepresentation(), InstallOptions::defaultInstallRoot()); +} + +QString InstallRootOption::longRepresentation() const +{ + return QLatin1String("--install-root"); +} + +void InstallRootOption::doParse(const QString &representation, QStringList &input) +{ + if (input.isEmpty()) { + throw Error(Tr::tr("Invalid use of option '%1: Argument expected.\n" + "Usage: %2").arg(representation, description(command()))); + } + m_installRoot = input.takeFirst(); +} + +QString RemoveFirstOption::description(CommandType command) const +{ + Q_ASSERT(command == InstallCommandType || command == RunCommandType); + Q_UNUSED(command); + return Tr::tr("%1\n\tRemove the installation base directory before installing.\n") + .arg(longRepresentation()); +} + +QString RemoveFirstOption::longRepresentation() const +{ + return QLatin1String("--remove-first"); +} + } // namespace qbs |