123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- /****************************************************************************
- **
- ** Copyright (C) 2013 Jarek Pelczar <jpelczar@gmail.com>
- ** Copyright (C) 2014 Tomasz Olszak <olszak.tomasz@gmail.com>
- **
- ** This file is part of Qt Creator.
- **
- ** 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 Digia. For licensing terms and
- ** conditions see http://qt.digia.com/licensing. For further information
- ** use the contact form at http://qt.digia.com/contact-us.
- **
- ** GNU Lesser General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU Lesser
- ** General Public License version 2.1 as published by the Free Software
- ** Foundation and appearing in the file LICENSE.LGPL included in the
- ** packaging of this file. Please review the following information to
- ** ensure the GNU Lesser General Public License version 2.1 requirements
- ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- **
- ** In addition, as a special exception, Digia gives you certain additional
- ** rights. These rights are described in the Digia Qt LGPL Exception
- ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
- **
- ****************************************************************************/
- #include "tizendebug.h"
- #include "tizenqtversion.h"
- #include "tizentoolchain.h"
- #include "tizenconstants.h"
- #include "tizenconfigurations.h"
- #include <coreplugin/icore.h>
- #include <utils/environment.h>
- #include <projectexplorer/devicesupport/devicemanager.h>
- #include <projectexplorer/abi.h>
- #include <utils/hostosinfo.h>
- #include <projectexplorer/kit.h>
- #include <projectexplorer/devicesupport/devicemanager.h>
- #include <projectexplorer/kitinformation.h>
- #include <projectexplorer/kitmanager.h>
- #include <qtsupport/qtkitinformation.h>
- #include <qtsupport/qtversionmanager.h>
- #include <projectexplorer/toolchainmanager.h>
- #include <projectexplorer/toolchain.h>
- #include <QDebug>
- #include <QFileInfo>
- #include <QDir>
- #include <QFile>
- Q_LOGGING_CATEGORY(QTC_TIZEN, "qtcreator.plugin.tizen")
- namespace Tizen {
- namespace Internal {
- namespace {
- const QLatin1String TizenGroupKey("TizenPluginSettings");
- const QLatin1String TizenSDKLocationKey("TizenSDKLocation");
- const QLatin1String TizenSDKDataLocationKey("TizenSDKDataLocation");
- const QLatin1String TizenSDBLocationKey("TizenSDBLocation");
- const QLatin1String TizenNativePackagingLocationKey("TizenNativePackagingLocation");
- const QLatin1String TizenSDBPortKey("TizenSDBPort");
- const QLatin1String TizenAuthorCertificateLocationKey("TizenAuthorCertificateLocation");
- const QLatin1String TizenAuthorCertificatePasswordKey("TizenAuthorCertificatePassword");
- const QLatin1String ArmToolchainPrefix("arm-linux-gnueabi");
- const QLatin1String X86ToolchainPrefix("i386-linux-gnueabi");
- }
- TizenConfigurations * TizenConfigurations::m_instance;
- TizenConfig::TizenConfig() :
- m_sdbPort(26099)
- {
- }
- Utils::FileName TizenConfig::sdkLocation() const
- {
- return m_sdkLocation;
- }
- void TizenConfig::setSdkLocation(const Utils::FileName &sdkLocation)
- {
- m_sdkLocation = sdkLocation;
- }
- Utils::FileName TizenConfig::sdkDataLocation() const
- {
- return m_sdkDataLocation;
- }
- void TizenConfig::setSdkDataLocation(const Utils::FileName &sdkDataLocation)
- {
- m_sdkDataLocation = sdkDataLocation;
- }
- Utils::FileName TizenConfig::sdbLocation() const
- {
- return m_sdbLocation;
- }
- void TizenConfig::setSdbLocation(const Utils::FileName &sdbLocation)
- {
- m_sdbLocation = sdbLocation;
- }
- int TizenConfig::sdbPort() const
- {
- return m_sdbPort;
- }
- void TizenConfig::setSdbPort(int port)
- {
- m_sdbPort = port;
- }
- Utils::FileName TizenConfig::nativePackagingLocation() const
- {
- return m_nativePackagingLocation;
- }
- void TizenConfig::setNativePackagingLocation(const Utils::FileName &nativePackaging)
- {
- m_nativePackagingLocation = nativePackaging;
- }
- Utils::FileName TizenConfig::authorCertificateLocation() const
- {
- return m_authorCertificateLocation;
- }
- void TizenConfig::setAuthorCertificateLocation(const Utils::FileName &authorCertificateLocation)
- {
- m_authorCertificateLocation = authorCertificateLocation;
- }
- QString TizenConfig::authorCertificatePassword() const
- {
- return m_authorCertificatePassword;
- }
- void TizenConfig::setAuthorCertificatePassword(const QString &authorCertificatePassword)
- {
- m_authorCertificatePassword = authorCertificatePassword;
- }
- void TizenConfig::save(QSettings &settings) const
- {
- settings.setValue(TizenSDKLocationKey, m_sdkLocation.toString());
- settings.setValue(TizenSDKDataLocationKey, m_sdkDataLocation.toString());
- settings.setValue(TizenSDBLocationKey, m_sdbLocation.toString());
- settings.setValue(TizenNativePackagingLocationKey, m_nativePackagingLocation.toString());
- settings.setValue(TizenSDBPortKey, m_sdbPort);
- settings.setValue(TizenAuthorCertificateLocationKey, m_authorCertificateLocation.toString());
- settings.setValue(TizenAuthorCertificatePasswordKey, m_authorCertificatePassword);
- }
- void TizenConfig::load(const QSettings &settings)
- {
- m_sdkLocation = Utils::FileName::fromString(settings.value(TizenSDKLocationKey).toString());
- m_sdkDataLocation = Utils::FileName::fromString(settings.value(TizenSDKDataLocationKey).toString());
- m_sdbLocation = Utils::FileName::fromString(settings.value(TizenSDBLocationKey).toString());
- m_nativePackagingLocation = Utils::FileName::fromString(settings.value(TizenNativePackagingLocationKey).toString());
- m_authorCertificateLocation = Utils::FileName::fromString(settings.value(TizenAuthorCertificateLocationKey).toString());
- m_authorCertificatePassword = settings.value(TizenAuthorCertificatePasswordKey).toString();
- m_sdbPort = settings.value(TizenSDBPortKey).toInt();
- }
- ProjectExplorer::Abi::Architecture TizenConfig::architectureForToolChainPrefix(const QString &toolchainprefix)
- {
- if (toolchainprefix == ArmToolchainPrefix)
- return ProjectExplorer::Abi::ArmArchitecture;
- if (toolchainprefix == X86ToolchainPrefix)
- return ProjectExplorer::Abi::X86Architecture;
- return ProjectExplorer::Abi::UnknownArchitecture;
- }
- TizenConfigurations::TizenConfigurations(QObject *parent) :
- QObject(parent)
- {
- Q_ASSERT(!m_instance);
- m_instance = this;
- load();
- }
- TizenConfigurations::~TizenConfigurations()
- {
- Q_ASSERT(m_instance == this);
- m_instance = NULL;
- }
- void TizenConfigurations::updateAutomaticKitList()
- {
- qCDebug(QTC_TIZEN);
- QMap<Utils::FileName, TizenQtVersion *> tizenGbsQtVersions;
- foreach(QtSupport::BaseQtVersion *qtVersion, QtSupport::QtVersionManager::versions()) {
- if (qtVersion->type() == QLatin1String(Constants::TIZEN_QT)) {
- qCDebug(QTC_TIZEN) << qtVersion;
- TizenQtVersion *tmp = static_cast<TizenQtVersion *>(qtVersion);
- qCDebug(QTC_TIZEN) << tmp << tmp->gbsBuildRoot().toString();
- if (!tmp->gbsBuildRoot().isEmpty())
- tizenGbsQtVersions.insert(tmp->gbsBuildRoot(), tmp);
- }
- }
- foreach (ProjectExplorer::Kit * kit, ProjectExplorer::KitManager::kits()) {
- if (kit->isAutoDetected() && kit->hasValue(Core::Id(Constants::TIZEN_KIT_GBS_ID))) {
- TizenGccToolChain *toolchain = static_cast<TizenGccToolChain *>(ProjectExplorer::ToolChainKitInformation::toolChain(kit));
- if (toolchain && !toolchain->gbsBuildRoot().isEmpty()) {
- if (!tizenGbsQtVersions.contains(toolchain->gbsBuildRoot())) {
- ProjectExplorer::KitManager::deregisterKit(kit);
- ProjectExplorer::ToolChainManager::deregisterToolChain(toolchain);
- } else
- tizenGbsQtVersions.remove(toolchain->gbsBuildRoot());
- } else {
- ProjectExplorer::KitManager::deregisterKit(kit);
- }
- }
- }
- foreach(Utils::FileName gbsBuildRoot, tizenGbsQtVersions.keys()) {
- ProjectExplorer::ToolChain *toolchain = TizenToolChainFactory::createToolChainForGbs(gbsBuildRoot.toString());
- Q_ASSERT(toolchain);
- ProjectExplorer::ToolChainManager::registerToolChain(toolchain);
- TizenQtVersion * qtVersion = tizenGbsQtVersions.value(gbsBuildRoot);
- ProjectExplorer::Kit *tizenGbsAutodetectedKit = new ProjectExplorer::Kit();
- tizenGbsAutodetectedKit->setValue(Core::Id(Constants::TIZEN_KIT_GBS_ID), true);
- tizenGbsAutodetectedKit->setDisplayName(QString(QStringLiteral("Tizen GBS Kit(from %1)"))
- .arg(qtVersion->displayName()));
- tizenGbsAutodetectedKit->setAutoDetected(true);
- ProjectExplorer::DeviceTypeKitInformation::setDeviceTypeId(tizenGbsAutodetectedKit, Core::Id(Constants::TIZEN_DEVICE_TYPE));
- ProjectExplorer::ToolChainKitInformation::setToolChain(tizenGbsAutodetectedKit, toolchain);
- QtSupport::QtKitInformation::setQtVersion(tizenGbsAutodetectedKit, qtVersion);
- ProjectExplorer::DeviceKitInformation::setDevice(tizenGbsAutodetectedKit,
- ProjectExplorer::DeviceManager::instance()->find(Core::Id(Constants::TIZEN_DEVICE_ID)));
- tizenGbsAutodetectedKit->setup();
- tizenGbsAutodetectedKit->fix();
- ProjectExplorer::KitManager::registerKit(tizenGbsAutodetectedKit);
- }
- }
- void TizenConfigurations::load()
- {
- QSettings * settings = Core::ICore::instance()->settings();
- settings->beginGroup(TizenGroupKey);
- m_config = TizenConfig();
- m_config.load(*settings);
- settings->endGroup();
- }
- void TizenConfigurations::save()
- {
- QSettings * settings = Core::ICore::instance()->settings();
- settings->beginGroup(TizenGroupKey);
- m_config.save(*settings);
- settings->endGroup();
- }
- void TizenConfigurations::clearDefaultDevices(ProjectExplorer::Project */*project*/)
- {
- }
- TizenConfig TizenConfigurations::currentConfig()
- {
- return m_instance->m_config;
- }
- void TizenConfigurations::setConfig(const TizenConfig &config)
- {
- m_instance->m_config = config;
- m_instance->save();
- m_instance->updateAutomaticKitList();
- // m_instance->updateAndroidDevice();
- emit m_instance->updated();
- }
- } //namespace Internal
- } // namespace Tizen
|