forked from qt-creator/qt-creator
Utils: Introduce HostOsInfo class.
The class' member functions are intended to be used instead of the Q_OS_* macros in all contexts where the latter are not syntactically required. This lowers the likelihood of changes made on one platform breaking the build on another, e.g. due to the code model missing symbols in #ifdef'ed out code when refactoring. Change-Id: I4a54788591b4c8f8d589b8368a6c683d4155c9fa Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include "ui_addnewavddialog.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/persistentsettings.h>
|
||||
|
||||
#include <QDateTime>
|
||||
@@ -268,19 +269,19 @@ FileName AndroidConfigurations::adbToolPath() const
|
||||
|
||||
FileName AndroidConfigurations::androidToolPath() const
|
||||
{
|
||||
#ifdef Q_OS_WIN32
|
||||
// I want to switch from using android.bat to using an executable. All it really does is call
|
||||
// Java and I've made some progress on it. So if android.exe exists, return that instead.
|
||||
FileName path = m_config.sdkLocation;
|
||||
path.appendPath(QLatin1String("tools/android"ANDROID_EXE_SUFFIX));
|
||||
if (path.toFileInfo().exists())
|
||||
return path;
|
||||
path = m_config.sdkLocation;
|
||||
return path.appendPath(QLatin1String("tools/android"ANDROID_BAT_SUFFIX));
|
||||
#else
|
||||
FileName path = m_config.sdkLocation;
|
||||
return path.appendPath(QLatin1String("tools/android"));
|
||||
#endif
|
||||
if (HostOsInfo::isWindowsHost()) {
|
||||
// I want to switch from using android.bat to using an executable. All it really does is call
|
||||
// Java and I've made some progress on it. So if android.exe exists, return that instead.
|
||||
FileName path = m_config.sdkLocation;
|
||||
path.appendPath(QLatin1String("tools/android"ANDROID_EXE_SUFFIX));
|
||||
if (path.toFileInfo().exists())
|
||||
return path;
|
||||
path = m_config.sdkLocation;
|
||||
return path.appendPath(QLatin1String("tools/android"ANDROID_BAT_SUFFIX));
|
||||
} else {
|
||||
FileName path = m_config.sdkLocation;
|
||||
return path.appendPath(QLatin1String("tools/android"));
|
||||
}
|
||||
}
|
||||
|
||||
FileName AndroidConfigurations::antToolPath() const
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
|
||||
#include "androidconstants.h"
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QProcess>
|
||||
@@ -336,16 +338,15 @@ void AndroidSettingsWidget::browseNDKLocation()
|
||||
|
||||
void AndroidSettingsWidget::browseAntLocation()
|
||||
{
|
||||
QString dir = QDir::homePath();
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
|
||||
dir = QLatin1String("/usr/bin/ant");
|
||||
QLatin1String antApp("ant");
|
||||
#elif defined(Q_OS_WIN)
|
||||
QLatin1String antApp("ant.bat");
|
||||
#elif defined(Q_OS_DARWIN)
|
||||
dir = QLatin1String("/opt/local/bin/ant");
|
||||
QLatin1String antApp("ant");
|
||||
#endif
|
||||
QString dir;
|
||||
QString antApp;
|
||||
if (Utils::HostOsInfo::isWindowsHost()) {
|
||||
dir = QDir::homePath();
|
||||
antApp = QLatin1String("ant.bat");
|
||||
} else {
|
||||
dir = QLatin1String("/usr/bin/ant");
|
||||
antApp = QLatin1String("ant");
|
||||
}
|
||||
const QString file =
|
||||
QFileDialog::getOpenFileName(this, tr("Select ant Script"), dir, antApp);
|
||||
if (!file.length())
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
|
||||
#include <utils/environment.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFormLayout>
|
||||
@@ -53,6 +54,7 @@ namespace Internal {
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Qt4ProjectManager;
|
||||
using namespace Utils;
|
||||
|
||||
static const char ANDROID_QT_VERSION_KEY[] = "Qt4ProjectManager.Android.QtVersion";
|
||||
|
||||
@@ -85,7 +87,7 @@ bool AndroidToolChain::isValid() const
|
||||
return GccToolChain::isValid() && m_qtVersionId >= 0 && targetAbi().isValid();
|
||||
}
|
||||
|
||||
void AndroidToolChain::addToEnvironment(Utils::Environment &env) const
|
||||
void AndroidToolChain::addToEnvironment(Environment &env) const
|
||||
{
|
||||
|
||||
// TODO this vars should be configurable in projects -> build tab
|
||||
@@ -96,18 +98,23 @@ void AndroidToolChain::addToEnvironment(Utils::Environment &env) const
|
||||
|| QtSupport::QtProfileInformation::qtVersion(qt4pro->activeTarget()->profile())->type() != QLatin1String(Constants::ANDROIDQT))
|
||||
return;
|
||||
|
||||
QString ndk_host = QLatin1String(
|
||||
#if defined(Q_OS_LINUX)
|
||||
"linux-x86"
|
||||
#elif defined(Q_OS_WIN)
|
||||
"windows"
|
||||
#elif defined(Q_OS_MAC)
|
||||
"darwin-x86"
|
||||
#endif
|
||||
);
|
||||
QString ndkHost;
|
||||
switch (HostOsInfo::hostOs()) {
|
||||
case HostOsInfo::HostOsLinux:
|
||||
ndkHost = QLatin1String("linux-x86");
|
||||
break;
|
||||
case HostOsInfo::HostOsWindows:
|
||||
ndkHost = QLatin1String("windows");
|
||||
break;
|
||||
case HostOsInfo::HostOsMac:
|
||||
ndkHost = QLatin1String("darwin-x86");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// this env vars are used by qmake mkspecs to generate makefiles (check QTDIR/mkspecs/android-g++/qmake.conf for more info)
|
||||
env.set(QLatin1String("ANDROID_NDK_HOST"), ndk_host);
|
||||
env.set(QLatin1String("ANDROID_NDK_HOST"), ndkHost);
|
||||
env.set(QLatin1String("ANDROID_NDK_ROOT"), AndroidConfigurations::instance().config().ndkLocation.toUserOutput());
|
||||
env.set(QLatin1String("ANDROID_NDK_TOOLCHAIN_PREFIX"), AndroidConfigurations::toolchainPrefix(targetAbi().architecture()));
|
||||
env.set(QLatin1String("ANDROID_NDK_TOOLS_PREFIX"), AndroidConfigurations::toolsPrefix(targetAbi().architecture()));
|
||||
@@ -147,18 +154,14 @@ bool AndroidToolChain::fromMap(const QVariantMap &data)
|
||||
return isValid();
|
||||
}
|
||||
|
||||
QList<Utils::FileName> AndroidToolChain::suggestedMkspecList() const
|
||||
QList<FileName> AndroidToolChain::suggestedMkspecList() const
|
||||
{
|
||||
return QList<Utils::FileName>()<< Utils::FileName::fromString(QLatin1String("android-g++"));
|
||||
return QList<FileName>()<< FileName::fromString(QLatin1String("android-g++"));
|
||||
}
|
||||
|
||||
QString AndroidToolChain::makeCommand() const
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
return QLatin1String("ma-make.exe");
|
||||
#else
|
||||
return QLatin1String("make");
|
||||
#endif
|
||||
return HostOsInfo::isWindowsHost() ? QLatin1String("ma-make.exe") : QLatin1String("make");
|
||||
}
|
||||
|
||||
void AndroidToolChain::setQtVersionId(int id)
|
||||
|
||||
Reference in New Issue
Block a user