/**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the tools applications of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3 as published by the Free Software ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "configureapp.h" #include "environment.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include QT_BEGIN_NAMESPACE std::ostream &operator<<(std::ostream &s, const QString &val) { s << val.toLocal8Bit().data(); return s; } using namespace std; Configure::Configure(int& argc, char** argv) { int i; for (i = 1; i < argc; i++) configCmdLine += argv[ i ]; if (configCmdLine.size() >= 2 && configCmdLine.at(0) == "-srcdir") { sourcePath = QDir::cleanPath(configCmdLine.at(1)); sourceDir = QDir(sourcePath); configCmdLine.erase(configCmdLine.begin(), configCmdLine.begin() + 2); } else { // Get the path to the executable wchar_t module_name[MAX_PATH]; GetModuleFileName(0, module_name, sizeof(module_name) / sizeof(wchar_t)); QFileInfo sourcePathInfo = QString::fromWCharArray(module_name); sourcePath = sourcePathInfo.absolutePath(); sourceDir = sourcePathInfo.dir(); } buildPath = QDir::currentPath(); if (sourceDir != buildDir) { //shadow builds! QDir(buildPath).mkpath("bin"); buildDir.mkpath("mkspecs"); } if (dictionary[ "QMAKESPEC" ].size() == 0) { dictionary[ "QMAKESPEC" ] = Environment::detectQMakeSpec(); dictionary[ "QMAKESPEC_FROM" ] = "detected"; } dictionary[ "SYNCQT" ] = "auto"; QString tmp = dictionary[ "QMAKESPEC" ]; if (tmp.contains("\\")) { tmp = tmp.mid(tmp.lastIndexOf("\\") + 1); } else { tmp = tmp.mid(tmp.lastIndexOf("/") + 1); } dictionary[ "QMAKESPEC" ] = tmp; } Configure::~Configure() { } void Configure::parseCmdLine() { sourcePathMangled = sourcePath; buildPathMangled = buildPath; if (configCmdLine.size() && configCmdLine.at(0) == "-top-level") { dictionary[ "TOPLEVEL" ] = "yes"; configCmdLine.removeAt(0); sourcePathMangled = QFileInfo(sourcePath).path(); buildPathMangled = QFileInfo(buildPath).path(); } qmakeCmdLine = configCmdLine; int argCount = configCmdLine.size(); int i = 0; // Look first for -redo for (int k = 0 ; k < argCount; ++k) { if (configCmdLine.at(k) == "-redo") { configCmdLine.removeAt(k); if (!reloadCmdLine(k)) { dictionary["DONE"] = "error"; return; } argCount = configCmdLine.size(); break; } } for (; i