summaryrefslogtreecommitdiffstats
path: root/src/qtchooser/main.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-12-20 16:01:21 -0800
committerThiago Macieira <thiago.macieira@intel.com>2013-01-18 12:57:58 +0100
commit8e5e765eae4af7a2cf68da07d999e1c62d196e4a (patch)
tree725ac99ed948e9b0da369778e5db30c248fa59e5 /src/qtchooser/main.cpp
parente69cda9f13fa47d4c5ab0c34ed7592563ab90770 (diff)
Accept -run-tool if and only if the tool wasn't already selected
That means we invert the order of overriding. Previously, -run-tool overrode the environment, which overrode argv[0]. Now, argv[0] overrides the environment, which overrides -run-tool. Change-Id: I60bd5e1397cb5a6cb8b0df9c1c3ebba6210ed920 Reviewed-by: Sune Vuorela <sune@vuorela.dk> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qtchooser/main.cpp')
-rw-r--r--src/qtchooser/main.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/qtchooser/main.cpp b/src/qtchooser/main.cpp
index 9b7688c..33b2f62 100644
--- a/src/qtchooser/main.cpp
+++ b/src/qtchooser/main.cpp
@@ -332,11 +332,15 @@ int main(int argc, char **argv)
Mode operatingMode = Unknown;
argv0 = basename(argv[0]);
const char *targetSdk = getenv("QT_SELECT");
- const char *targetTool = getenv("QTCHOOSER_RUNTOOL");
- // if the target tool wasn't set in the environment, use argv[0]
- if (!targetTool || !*targetTool)
- targetTool = argv0;
+ // the default tool is the one in argv[0]
+ const char *targetTool = argv0;
+
+ // if argv[0] points back to us, use the environment
+ if (strcmp(targetTool, myName) == 0)
+ targetTool = getenv("QTCHOOSER_RUNTOOL");
+ else
+ operatingMode = RunTool;
// check the arguments to see if there's an override
int optind = 1;
@@ -355,7 +359,7 @@ int main(int argc, char **argv)
// -qtX or -qt=X argument
arg += 2;
targetSdk = *arg == '=' ? arg + 1 : arg;
- } else if (beginsWith(arg, "run-tool=")) {
+ } else if (!targetTool && beginsWith(arg, "run-tool=")) {
// -run-tool= argument
targetTool = arg + strlen("run-tool=");
operatingMode = RunTool;
@@ -372,15 +376,9 @@ int main(int argc, char **argv)
if (!targetSdk)
targetSdk = "";
- bool haveTargetTool = true;
- if (strcmp(targetTool, myName) == 0)
- haveTargetTool = false;
- else if (endsWith(targetTool, myName) && targetTool[strlen(targetTool) - sizeof(myName)] == PATH_SEP[0])
- haveTargetTool = false;
-
ToolWrapper wrapper;
- if (operatingMode == RunTool || haveTargetTool) {
- if (!haveTargetTool) {
+ if (operatingMode == RunTool || targetTool) {
+ if (!targetTool) {
fprintf(stderr, "%s: no tool selected. Stop.\n", argv0);
return 1;
}