Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 0fffa0d84a8ae7d342b6a64d7ce1c4778545d0dd Konstantin Tokarev committed Feb 8, 2012
Showing with 347 additions and 0 deletions.
  1. +12 −0 EnzoToolChain.pluginspec.in
  2. +123 −0 enzotoolchain.cpp
  3. +47 −0 enzotoolchain.h
  4. +40 −0 enzotoolchain.pro
  5. +13 −0 enzotoolchain_global.h
  6. +16 −0 enzotoolchainconstants.h
  7. +68 −0 enzotoolchainplugin.cpp
  8. +28 −0 enzotoolchainplugin.h
@@ -0,0 +1,12 @@
+<plugin name=\"EnzoToolChain\" version=\"0.0.1\" compatVersion=\"0.0.1\">
+ <vendor>PathScale</vendor>
+ <copyright>(C) PathScale inc.</copyright>
+ <license></license>
+ <description></description>
+ <url>http://www.mycompany.com</url>
+ <dependencyList>
+ <dependency name=\"Core\" version=\"$$QTCREATOR_VERSION\"/>
+ <dependency name=\"ProjectExplorer\" version=\"$$QTCREATOR_VERSION\"/>
+ </dependencyList>
+</plugin>
+
@@ -0,0 +1,123 @@
+#include "enzotoolchain.h"
+
+#include "enzotoolchainconstants.h"
+
+#include <projectexplorer/clangparser.h>
+#include <projectexplorer/toolchainmanager.h>
+#include <utils/environment.h>
+
+#include <QDirIterator>
+#include <QDebug>
+
+using namespace Enzo;
+using namespace Enzo::Internal;
+using namespace ProjectExplorer;
+
+EnzoToolChain::EnzoToolChain(bool autodetected)
+ : GccToolChain(QLatin1String(Constants::ENZO_TOOLCHAIN_ID), autodetected)
+{
+}
+
+QString EnzoToolChain::type() const
+{
+ return QLatin1String("enzo");
+}
+
+QString EnzoToolChain::typeDisplayName() const
+{
+ return EnzoToolChainFactory::tr("Enzo");
+}
+
+QString EnzoToolChain::makeCommand() const
+{
+#if defined(Q_OS_WIN)
+ return QLatin1String("mingw32-make.exe");
+#else
+ return QLatin1String("make");
+#endif
+}
+
+Utils::FileName EnzoToolChain::mkspec() const
+{
+ return Utils::FileName();
+}
+
+IOutputParser *EnzoToolChain::outputParser() const
+{
+ return new ProjectExplorer::ClangParser;
+}
+
+ToolChain *EnzoToolChain::clone() const
+{
+ return new EnzoToolChain(*this);
+}
+
+// --------------------------------------------------------------------------
+
+QString EnzoToolChainFactory::displayName() const
+{
+ return tr("Enzo");
+}
+
+
+QString EnzoToolChainFactory::id() const
+{
+ return QLatin1String(Constants::ENZO_TOOLCHAIN_ID);
+}
+
+QList<ToolChain *> EnzoToolChainFactory::autoDetect()
+{
+ qDebug() << Q_FUNC_INFO;
+ QList<ToolChain *> result;
+
+ QStringList extraPaths;
+#ifndef Q_OS_WIN
+ // Search for /opt/enzo-* directories
+ extraPaths = QDir("/opt").entryList(QStringList() << QLatin1String("enzo-*"), QDir::Dirs);
+ for (int i = 0; i < extraPaths.size(); ++i) {
+ extraPaths[i].prepend("/opt/");
+ extraPaths[i].append("/bin");
+ }
+ qDebug() << Q_FUNC_INFO << extraPaths;
+#endif
+ Utils::FileName fullPath =
+ Utils::FileName::fromString(Utils::Environment::systemEnvironment()
+ .searchInPath(QLatin1String("pathcc"), extraPaths));
+// QString version = pathccVersion(fullPath);
+ if (!fullPath.isEmpty() /*&& !version.isEmpty()*/) {
+ EnzoToolChain *tc = new EnzoToolChain(true);
+ tc->setCompilerCommand(fullPath);
+ tc->setDisplayName(tr("Enzo"));
+ tc->setDebuggerCommand(ProjectExplorer::ToolChainManager::instance()->defaultDebugger(tc->targetAbi()));
+ qDebug() << "bingo!" << tc->compilerCommand().toString();
+ result.append(tc);
+ }
+ return result;
+}
+
+bool EnzoToolChainFactory::canCreate()
+{
+ return true;
+}
+
+ToolChain *EnzoToolChainFactory::create()
+{
+ EnzoToolChain *tc = new EnzoToolChain(false);
+ tc->setDisplayName(tr("Enzo"));
+ return tc;
+}
+
+bool EnzoToolChainFactory::canRestore(const QVariantMap &data)
+{
+ return idFromMap(data).startsWith(QLatin1String(Constants::ENZO_TOOLCHAIN_ID) + QLatin1Char(':'));
+}
+
+ToolChain *EnzoToolChainFactory::restore(const QVariantMap &data)
+{
+ EnzoToolChain *tc = new EnzoToolChain(false);
+ if (tc->fromMap(data))
+ return tc;
+
+ delete tc;
+ return 0;
+}
@@ -0,0 +1,47 @@
+#ifndef ENZOTOOLCHAIN_H
+#define ENZOTOOLCHAIN_H
+
+#include <projectexplorer/gcctoolchain.h>
+#include <projectexplorer/gcctoolchainfactories.h>
+
+namespace Enzo {
+namespace Internal {
+
+class EnzoToolChain : public ProjectExplorer::GccToolChain
+{
+public:
+ QString type() const;
+ QString typeDisplayName() const;
+ QString makeCommand() const;
+ Utils::FileName mkspec() const;
+
+ ProjectExplorer::IOutputParser *outputParser() const;
+
+ ToolChain *clone() const;
+
+private:
+ explicit EnzoToolChain(bool autodetected);
+ friend class EnzoToolChainFactory;
+};
+
+class EnzoToolChainFactory : public ProjectExplorer::ToolChainFactory
+{
+ Q_OBJECT
+
+public:
+ QString displayName() const;
+ QString id() const;
+
+ QList<ProjectExplorer::ToolChain *> autoDetect();
+
+ bool canCreate();
+ ProjectExplorer::ToolChain *create();
+
+ bool canRestore(const QVariantMap &data);
+ ProjectExplorer::ToolChain *restore(const QVariantMap &data);
+};
+
+} // namespace Internal
+} // namespace Enzo
+
+#endif // ENZOTOOLCHAIN_H
@@ -0,0 +1,40 @@
+TARGET = EnzoToolChain
+TEMPLATE = lib
+
+DEFINES += ENZOTOOLCHAIN_LIBRARY
+
+# EnzoToolChain files
+
+SOURCES += enzotoolchainplugin.cpp \
+ enzotoolchain.cpp
+
+HEADERS += enzotoolchainplugin.h\
+ enzotoolchain_global.h\
+ enzotoolchainconstants.h \
+ enzotoolchain.h
+
+# Qt Creator linking
+
+## set the QTC_SOURCE environment variable to override the setting here
+QTCREATOR_SOURCES = $$QTC_SOURCE
+
+## set the QTC_BUILD environment variable to override the setting here
+IDE_BUILD_TREE = $$QTC_BUILD
+isEmpty(IDE_BUILD_TREE):IDE_BUILD_TREE = $$QTC_SOURCE
+
+## uncomment to build plugin into user config directory
+## <localappdata>/plugins/<ideversion>
+## where <localappdata> is e.g.
+## "%LOCALAPPDATA%\Nokia\qtcreator" on Windows Vista and later
+## "$XDG_DATA_HOME/Nokia/qtcreator" or "~/.local/share/data/Nokia/qtcreator" on Linux
+## "~/Library/Application Support/Nokia/Qt Creator" on Mac
+# USE_USER_DESTDIR = yes
+
+PROVIDER = PathScale
+
+include($$QTCREATOR_SOURCES/src/qtcreatorplugin.pri)
+include($$QTCREATOR_SOURCES/src/plugins/coreplugin/coreplugin.pri)
+include($$QTCREATOR_SOURCES/src/plugins/projectexplorer/projectexplorer.pri)
+
+LIBS += -L$$IDE_PLUGIN_PATH/Nokia
+
@@ -0,0 +1,13 @@
+#ifndef ENZOTOOLCHAIN_GLOBAL_H
+#define ENZOTOOLCHAIN_GLOBAL_H
+
+#include <QtCore/QtGlobal>
+
+#if defined(ENZOTOOLCHAIN_LIBRARY)
+# define ENZOTOOLCHAINSHARED_EXPORT Q_DECL_EXPORT
+#else
+# define ENZOTOOLCHAINSHARED_EXPORT Q_DECL_IMPORT
+#endif
+
+#endif // ENZOTOOLCHAIN_GLOBAL_H
+
@@ -0,0 +1,16 @@
+#ifndef ENZOTOOLCHAINCONSTANTS_H
+#define ENZOTOOLCHAINCONSTANTS_H
+
+namespace Enzo {
+namespace Constants {
+
+const char ACTION_ID[] = "EnzoToolChain.Action";
+const char MENU_ID[] = "EnzoToolChain.Menu";
+
+const char ENZO_TOOLCHAIN_ID[] = "EnzoToolChain.ToolChain.Enzo";
+
+} // namespace EnzoToolChain
+} // namespace Constants
+
+#endif // ENZOTOOLCHAINCONSTANTS_H
+
@@ -0,0 +1,68 @@
+#include "enzotoolchainplugin.h"
+
+#include "enzotoolchain.h"
+#include "enzotoolchainconstants.h"
+
+#include <coreplugin/icore.h>
+#include <coreplugin/icontext.h>
+#include <coreplugin/actionmanager/actionmanager.h>
+#include <coreplugin/actionmanager/command.h>
+#include <coreplugin/actionmanager/actioncontainer.h>
+#include <coreplugin/coreconstants.h>
+
+#include <QtGui/QAction>
+#include <QtGui/QMessageBox>
+#include <QtGui/QMainWindow>
+#include <QtGui/QMenu>
+
+#include <QtCore/QtPlugin>
+
+using namespace Enzo;
+using namespace Enzo::Internal;
+
+EnzoToolChainPlugin::EnzoToolChainPlugin()
+{
+ // Create your members
+}
+
+EnzoToolChainPlugin::~EnzoToolChainPlugin()
+{
+ // Unregister objects from the plugin manager's object pool
+ // Delete members
+}
+
+bool EnzoToolChainPlugin::initialize(const QStringList &arguments, QString *errorString)
+{
+ // Register objects in the plugin manager's object pool
+ // Load settings
+ // Add actions to menus
+ // Connect to other plugins' signals
+ // In the initialize method, a plugin can be sure that the plugins it
+ // depends on have initialized their members.
+
+ Q_UNUSED(arguments)
+ Q_UNUSED(errorString)
+
+ EnzoToolChainFactory *f = new EnzoToolChainFactory;
+ addAutoReleasedObject(new EnzoToolChainFactory);
+
+ return true;
+}
+
+void EnzoToolChainPlugin::extensionsInitialized()
+{
+ // Retrieve objects from the plugin manager's object pool
+ // In the extensionsInitialized method, a plugin can be sure that all
+ // plugins that depend on it are completely initialized.
+}
+
+ExtensionSystem::IPlugin::ShutdownFlag EnzoToolChainPlugin::aboutToShutdown()
+{
+ // Save settings
+ // Disconnect from signals that are not needed during shutdown
+ // Hide UI (if you add UI that is not in the main window directly)
+ return SynchronousShutdown;
+}
+
+Q_EXPORT_PLUGIN2(EnzoToolChain, EnzoToolChainPlugin)
+
@@ -0,0 +1,28 @@
+#ifndef ENZOTOOLCHAINPLUGIN_H
+#define ENZOTOOLCHAINPLUGIN_H
+
+#include "enzotoolchain_global.h"
+
+#include <extensionsystem/iplugin.h>
+
+namespace Enzo {
+namespace Internal {
+
+class EnzoToolChainPlugin : public ExtensionSystem::IPlugin
+{
+ Q_OBJECT
+
+public:
+ EnzoToolChainPlugin();
+ ~EnzoToolChainPlugin();
+
+ bool initialize(const QStringList &arguments, QString *errorString);
+ void extensionsInitialized();
+ ShutdownFlag aboutToShutdown();
+};
+
+} // namespace Internal
+} // namespace EnzoToolChain
+
+#endif // ENZOTOOLCHAINPLUGIN_H
+

0 comments on commit 0fffa0d

Please sign in to comment.