summaryrefslogtreecommitdiffstats
path: root/src/tools/c18
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/c18')
-rw-r--r--src/tools/c18/Makefile.am8
-rw-r--r--src/tools/c18/c18.cpp86
-rw-r--r--src/tools/c18/c18.h62
-rw-r--r--src/tools/c18/c18_compile.cpp65
-rw-r--r--src/tools/c18/c18_compile.h46
-rw-r--r--src/tools/c18/c18_config.cpp13
-rw-r--r--src/tools/c18/c18_config.h29
-rw-r--r--src/tools/c18/gui/Makefile.am6
-rw-r--r--src/tools/c18/gui/c18_ui.cpp50
-rw-r--r--src/tools/c18/gui/c18_ui.h40
10 files changed, 405 insertions, 0 deletions
diff --git a/src/tools/c18/Makefile.am b/src/tools/c18/Makefile.am
new file mode 100644
index 0000000..032e53a
--- /dev/null
+++ b/src/tools/c18/Makefile.am
@@ -0,0 +1,8 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+libc18_la_LDFLAGS = $(all_libraries)
+noinst_LTLIBRARIES = libc18.la
+libc18_la_SOURCES = c18_compile.cpp c18_config.cpp c18.cpp
+
+SUBDIRS = gui \ No newline at end of file
diff --git a/src/tools/c18/c18.cpp b/src/tools/c18/c18.cpp
new file mode 100644
index 0000000..4eb5bfd
--- /dev/null
+++ b/src/tools/c18/c18.cpp
@@ -0,0 +1,86 @@
+/***************************************************************************
+ * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#include "c18.h"
+
+#include <qdir.h>
+
+#include "c18_compile.h"
+#include "c18_config.h"
+#include "devices/pic/pic/pic_memory.h"
+#include "devices/list/device_list.h"
+#include "devices/pic/pic/pic_group.h"
+#include "common/global/process.h"
+
+//----------------------------------------------------------------------------
+bool C18::Compiler::checkExecutableResult(bool, QStringList &lines) const
+{
+ return ( lines.count()>0 && lines[0].startsWith("MPLAB C18") );
+}
+
+bool C18::Linker::checkExecutableResult(bool, QStringList &lines) const
+{
+ return ( lines.count()>0 && lines[0].startsWith("MPLINK") );
+}
+
+//----------------------------------------------------------------------------
+QValueList<const Device::Data *> C18::Group::getSupportedDevices(const QString &) const
+{
+ QValueVector<QString> devices = Device::lister().group("pic")->supportedDevices();
+ QValueList<const Device::Data *> list;
+ for (uint i=0; i<devices.count(); i++) {
+ const Device::Data *data = Device::lister().data(devices[i]);
+ if ( static_cast<const Pic::Data *>(data)->is18Family() ) list.append(data);
+ }
+ return list;
+}
+
+Compile::Process *C18::Group::processFactory(const Compile::Data &data) const
+{
+ if ( data.category==Tool::Category::Compiler ) return new CompileFile;
+ Q_ASSERT( data.category==Tool::Category::Linker );
+ return new Link;
+}
+
+PURL::Directory C18::Group::autodetectDirectory(Compile::DirectoryType type, const PURL::Directory &execDir, bool) const
+{
+ QDir dir(execDir.path());
+ if ( !dir.cdUp() ) return PURL::Directory();
+ switch (type.type()) {
+ case Compile::DirectoryType::LinkerScript:
+ if ( dir.cd("lkr") ) return dir.path();
+ break;
+ case Compile::DirectoryType::Header:
+ if ( dir.cd("h") ) return dir.path();
+ break;
+ case Compile::DirectoryType::Library:
+ if ( dir.cd("lib") ) return dir.path();
+ break;
+ case Compile::DirectoryType::Executable:
+ case Compile::DirectoryType::Source:
+ case Compile::DirectoryType::Nb_Types: Q_ASSERT(false); break;
+ }
+ return PURL::Directory();
+}
+
+Compile::Config *C18::Group::configFactory(::Project *project) const
+{
+ return new Config(project);
+}
+
+Tool::Group::BaseData C18::Group::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Compiler ) return BaseData(new Compiler, Both);
+ if ( category==Tool::Category::Linker ) return BaseData(new Linker, Both);
+ return BaseData();
+}
+
+QString C18::Group::informationText() const
+{
+ return i18n("<qt><a href=\"%1\">C18</a> is a C compiler distributed by Microchip.</qt>").arg("http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010014&part=SW006011");
+}
diff --git a/src/tools/c18/c18.h b/src/tools/c18/c18.h
new file mode 100644
index 0000000..fac739e
--- /dev/null
+++ b/src/tools/c18/c18.h
@@ -0,0 +1,62 @@
+/***************************************************************************
+ * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#ifndef C18_H
+#define C18_H
+
+#include "tools/base/tool_group.h"
+
+namespace C18
+{
+//----------------------------------------------------------------------------
+class Compiler : public Tool::Base
+{
+public:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const { return "mcc18"; }
+
+private:
+ virtual QStringList checkExecutableOptions(bool) const { return "-v"; }
+ virtual bool checkExecutableResult(bool withWine, QStringList &lines) const;
+};
+
+class Linker : public Tool::Base
+{
+public:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const { return "mplink"; }
+
+private:
+ virtual QStringList checkExecutableOptions(bool) const { return "/v"; }
+ virtual bool checkExecutableResult(bool withWine, QStringList &lines) const;
+};
+
+//----------------------------------------------------------------------------
+class Group : public Tool::Group
+{
+public:
+ virtual QString name() const { return "c18"; }
+ virtual QString label() const { return i18n("C18 Compiler"); }
+ virtual QString informationText() const;
+ virtual Tool::Category checkDevicesCategory() const { return Tool::Category::Nb_Types; }
+ virtual bool hasDirectory(Compile::DirectoryType type) const { return ( type!=Compile::DirectoryType::Source ); }
+ virtual PURL::FileType linkerScriptType() const { return PURL::Lkr; }
+ virtual Tool::ExecutableType preferedExecutableType() const { return Tool::ExecutableType::Windows; }
+ virtual Tool::CompileType compileType() const { return Tool::SeparateFiles; }
+ virtual PURL::Directory autodetectDirectory(Compile::DirectoryType type, const PURL::Directory &execDir, bool withWine) const;
+ virtual PURL::FileType implementationType(PURL::ToolType type) const { return (type==PURL::ToolType::Compiler ? PURL::CSource : PURL::Nb_FileTypes); }
+
+private:
+ virtual QValueList<const Device::Data *> getSupportedDevices(const QString &s) const;
+ virtual Compile::Process *processFactory(const Compile::Data &data) const;
+ virtual Compile::Config *configFactory(::Project *project) const;
+ virtual BaseData baseFactory(Tool::Category category) const;
+ virtual Tool::SourceGenerator *sourceGeneratorFactory() const { /*TODO*/ return 0; }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/c18/c18_compile.cpp b/src/tools/c18/c18_compile.cpp
new file mode 100644
index 0000000..181da36
--- /dev/null
+++ b/src/tools/c18/c18_compile.cpp
@@ -0,0 +1,65 @@
+/***************************************************************************
+ * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#include "c18_compile.h"
+
+#include "c18_config.h"
+#include "c18.h"
+#include "devices/list/device_list.h"
+
+//-----------------------------------------------------------------------------
+QStringList C18::CompileFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += config.includeDirs(Tool::Category::Compiler, "-I");
+ args += "-I" + Compile::Config::directory(group(), Compile::DirectoryType::Header).path();
+ args += "$NO_AUTO_DEVICE(-p)";
+ args += "$NO_AUTO_DEVICE(%DEVICE)";
+ args += config.customOptions(Tool::Category::Compiler);
+ args += "-fo=%OBJECT";
+ args += "%I";
+ return args;
+}
+
+QString C18::CompileFile::outputFiles() const
+{
+ return "PURL::Object";
+}
+
+void C18::CompileFile::logStderrLine(const QString &line)
+{
+ // #### TODO
+ doLog(Log::LineType::Normal, line, QString::null, 0);
+}
+
+//-----------------------------------------------------------------------------
+QStringList C18::Link::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "/k%LKR_PATH";
+ args += "%LKR_NAME";
+ args += "/l" + Compile::Config::directory(group(), Compile::DirectoryType::Library).path();
+ args += config.customOptions(Tool::Category::Linker);
+ args += "/o%COFF";
+ args += "/m%MAP";
+ args += "%OBJS";
+ args += "%LIBS";
+ args += config.customLibraries(Tool::Category::Linker);
+ return args;
+}
+
+QString C18::Link::outputFiles() const
+{
+ return "PURL::Lkr PURL::Map PURL::Hex PURL::Coff PURL::Lst PURL::Cod";
+}
+
+void C18::Link::logStderrLine(const QString &line)
+{
+ // #### TODO
+ doLog(Log::LineType::Normal, line, QString::null, 0);
+}
diff --git a/src/tools/c18/c18_compile.h b/src/tools/c18/c18_compile.h
new file mode 100644
index 0000000..74f0f06
--- /dev/null
+++ b/src/tools/c18/c18_compile.h
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#ifndef C18_COMPILE_H
+#define C18_COMPILE_H
+
+#include "tools/list/compile_process.h"
+
+namespace C18
+{
+//-----------------------------------------------------------------------------
+class Process : public Compile::Process
+{
+Q_OBJECT
+protected:
+ virtual QString deviceName() const { return _data.device.lower(); }
+};
+
+//-----------------------------------------------------------------------------
+class CompileFile : public Process
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+ virtual void logStderrLine(const QString &line);
+};
+
+//-----------------------------------------------------------------------------
+class Link : public Process
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+ virtual void logStderrLine(const QString &line);
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/c18/c18_config.cpp b/src/tools/c18/c18_config.cpp
new file mode 100644
index 0000000..fdf6164
--- /dev/null
+++ b/src/tools/c18/c18_config.cpp
@@ -0,0 +1,13 @@
+/***************************************************************************
+ * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#include "c18_config.h"
+
+const char * const C18::Config::WARNING_LEVEL_LABELS[Nb_WarningLevels] = {
+ I18N_NOOP("All messages"), I18N_NOOP("Warning and errors"), I18N_NOOP("Errors only")
+};
diff --git a/src/tools/c18/c18_config.h b/src/tools/c18/c18_config.h
new file mode 100644
index 0000000..dead1a1
--- /dev/null
+++ b/src/tools/c18/c18_config.h
@@ -0,0 +1,29 @@
+/***************************************************************************
+ * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#ifndef C18_CONFIG_H
+#define C18_CONFIG_H
+
+#include "tools/list/compile_config.h"
+
+namespace C18
+{
+
+class Config : public Compile::Config
+{
+public:
+ Config(Project *project) : Compile::Config(project) {}
+ enum { Nb_WarningLevels = 3 };
+ static const char * const WARNING_LEVEL_LABELS[Nb_WarningLevels];
+ uint warningLevel() const { return QMIN(Compile::Config::warningLevel(Tool::Category::Compiler), uint(Nb_WarningLevels)); }
+ void setWarningLevel(uint level) { Compile::Config::setWarningLevel(Tool::Category::Compiler, level); }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/c18/gui/Makefile.am b/src/tools/c18/gui/Makefile.am
new file mode 100644
index 0000000..3e97599
--- /dev/null
+++ b/src/tools/c18/gui/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libc18ui.la
+libc18ui_la_LDFLAGS = $(all_libraries)
+libc18ui_la_SOURCES = c18_ui.cpp
diff --git a/src/tools/c18/gui/c18_ui.cpp b/src/tools/c18/gui/c18_ui.cpp
new file mode 100644
index 0000000..c10f328
--- /dev/null
+++ b/src/tools/c18/gui/c18_ui.cpp
@@ -0,0 +1,50 @@
+/***************************************************************************
+ * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#include "c18_ui.h"
+
+#include <qlabel.h>
+#include "tools/c18/c18_config.h"
+
+//----------------------------------------------------------------------------
+C18::ConfigWidget::ConfigWidget(Project *project)
+ : ToolConfigWidget(project), _warningLevel(0)
+{}
+
+void C18::ConfigWidget::initEntries()
+{
+ if ( _category==Tool::Category::Compiler ) {
+ uint row = container()->numRows();
+ QLabel *label = new QLabel(i18n("Warning level:"), container());
+ container()->addWidget(label, row,row, 0,0);
+ _warningLevel = new QComboBox(container());
+ connect(_warningLevel, SIGNAL(activated(int)), SIGNAL(changed()));
+ for (uint i=0; i<Config::Nb_WarningLevels; i++)
+ _warningLevel->insertItem(i18n(Config::WARNING_LEVEL_LABELS[i]));
+ container()->addWidget(_warningLevel, row,row, 1,1);
+ createIncludeDirectoriesEntry();
+ }
+ if ( _category==Tool::Category::Linker ) {
+ createCustomLibrariesEntry();
+ createHexFormatEntry();
+ }
+}
+
+void C18::ConfigWidget::loadConfig(const Compile::Config &config)
+{
+ ToolConfigWidget::loadConfig(config);
+ if ( _category==Tool::Category::Compiler )
+ _warningLevel->setCurrentItem(static_cast<const Config &>(config).warningLevel());
+}
+
+void C18::ConfigWidget::saveConfig(Compile::Config &config) const
+{
+ ToolConfigWidget::saveConfig(config);
+ if ( _category==Tool::Category::Compiler )
+ static_cast<Config &>(config).setWarningLevel(_warningLevel->currentItem());
+}
diff --git a/src/tools/c18/gui/c18_ui.h b/src/tools/c18/gui/c18_ui.h
new file mode 100644
index 0000000..d7d45c4
--- /dev/null
+++ b/src/tools/c18/gui/c18_ui.h
@@ -0,0 +1,40 @@
+/***************************************************************************
+ * Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#ifndef C18_UI_H
+#define C18_UI_H
+
+#include "tools/gui/tool_config_widget.h"
+#include "tools/gui/tool_group_ui.h"
+
+namespace C18
+{
+//----------------------------------------------------------------------------
+class ConfigWidget : public ToolConfigWidget
+{
+Q_OBJECT
+public:
+ ConfigWidget(Project *project);
+
+private:
+ QComboBox *_warningLevel;
+ virtual void initEntries();
+ virtual void loadConfig(const Compile::Config &config);
+ virtual void saveConfig(Compile::Config &config) const;
+};
+
+//----------------------------------------------------------------------------
+class GroupUI : public Tool::GroupUI
+{
+public:
+ virtual ToolConfigWidget *configWidgetFactory(Tool::Category, ::Project *project) const { return new ConfigWidget(project); }
+};
+
+} // namespace
+
+#endif