summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 18:42:24 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 18:42:24 +0000
commitf508189682b6fba62e08feeb1596f682bad5fff9 (patch)
tree28aeb0e6c19386c385c1ce5edf8a92c1bca15281 /src/tools
downloadpiklab-f508189682b6fba62e08feeb1596f682bad5fff9.tar.gz
piklab-f508189682b6fba62e08feeb1596f682bad5fff9.zip
Added KDE3 version of PikLab
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1095639 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/Makefile.am3
-rw-r--r--src/tools/base/Makefile.am6
-rw-r--r--src/tools/base/generic_tool.cpp60
-rw-r--r--src/tools/base/generic_tool.h104
-rw-r--r--src/tools/base/tool_group.cpp140
-rw-r--r--src/tools/base/tool_group.h85
-rw-r--r--src/tools/boost/Makefile.am9
-rw-r--r--src/tools/boost/boost.cpp102
-rw-r--r--src/tools/boost/boost.h74
-rw-r--r--src/tools/boost/boost_config.cpp9
-rw-r--r--src/tools/boost/boost_config.h24
-rw-r--r--src/tools/boost/boost_generator.cpp81
-rw-r--r--src/tools/boost/boost_generator.h37
-rw-r--r--src/tools/boost/boostbasic.cpp42
-rw-r--r--src/tools/boost/boostbasic.h72
-rw-r--r--src/tools/boost/boostc.cpp42
-rw-r--r--src/tools/boost/boostc.h72
-rw-r--r--src/tools/boost/boostc_compile.cpp56
-rw-r--r--src/tools/boost/boostc_compile.h46
-rw-r--r--src/tools/boost/boostcpp.cpp43
-rw-r--r--src/tools/boost/boostcpp.h71
-rw-r--r--src/tools/boost/gui/Makefile.am6
-rw-r--r--src/tools/boost/gui/boost_ui.cpp19
-rw-r--r--src/tools/boost/gui/boost_ui.h35
-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
-rw-r--r--src/tools/cc5x/Makefile.am8
-rw-r--r--src/tools/cc5x/cc5x.cpp62
-rw-r--r--src/tools/cc5x/cc5x.h50
-rw-r--r--src/tools/cc5x/cc5x_compile.cpp37
-rw-r--r--src/tools/cc5x/cc5x_compile.h29
-rw-r--r--src/tools/cc5x/cc5x_config.cpp9
-rw-r--r--src/tools/cc5x/cc5x_config.h25
-rw-r--r--src/tools/cc5x/gui/Makefile.am6
-rw-r--r--src/tools/cc5x/gui/cc5x_ui.cpp19
-rw-r--r--src/tools/cc5x/gui/cc5x_ui.h35
-rw-r--r--src/tools/ccsc/Makefile.am8
-rw-r--r--src/tools/ccsc/ccsc.cpp106
-rw-r--r--src/tools/ccsc/ccsc.h57
-rw-r--r--src/tools/ccsc/ccsc_compile.cpp107
-rw-r--r--src/tools/ccsc/ccsc_compile.h37
-rw-r--r--src/tools/ccsc/ccsc_config.cpp9
-rw-r--r--src/tools/ccsc/ccsc_config.h25
-rw-r--r--src/tools/ccsc/gui/Makefile.am6
-rw-r--r--src/tools/ccsc/gui/ccsc_ui.cpp19
-rw-r--r--src/tools/ccsc/gui/ccsc_ui.h35
-rw-r--r--src/tools/custom/Makefile.am6
-rw-r--r--src/tools/custom/custom.cpp23
-rw-r--r--src/tools/custom/custom.h38
-rw-r--r--src/tools/gputils/Makefile.am9
-rw-r--r--src/tools/gputils/gputils.cpp107
-rw-r--r--src/tools/gputils/gputils.h54
-rw-r--r--src/tools/gputils/gputils_compile.cpp109
-rw-r--r--src/tools/gputils/gputils_compile.h73
-rw-r--r--src/tools/gputils/gputils_config.cpp19
-rw-r--r--src/tools/gputils/gputils_config.h30
-rw-r--r--src/tools/gputils/gputils_generator.cpp256
-rw-r--r--src/tools/gputils/gputils_generator.h29
-rw-r--r--src/tools/gputils/gui/Makefile.am6
-rw-r--r--src/tools/gputils/gui/gputils_ui.cpp53
-rw-r--r--src/tools/gputils/gui/gputils_ui.h41
-rw-r--r--src/tools/gui/Makefile.am7
-rw-r--r--src/tools/gui/tool_config_widget.cpp181
-rw-r--r--src/tools/gui/tool_config_widget.h79
-rw-r--r--src/tools/gui/tool_group_ui.cpp25
-rw-r--r--src/tools/gui/tool_group_ui.h32
-rw-r--r--src/tools/gui/toolchain_config_center.cpp111
-rw-r--r--src/tools/gui/toolchain_config_center.h45
-rw-r--r--src/tools/gui/toolchain_config_widget.cpp301
-rw-r--r--src/tools/gui/toolchain_config_widget.h85
-rw-r--r--src/tools/jal/Makefile.am8
-rw-r--r--src/tools/jal/gui/Makefile.am6
-rw-r--r--src/tools/jal/gui/jal_ui.cpp14
-rw-r--r--src/tools/jal/gui/jal_ui.h35
-rw-r--r--src/tools/jal/jal.cpp72
-rw-r--r--src/tools/jal/jal.h49
-rw-r--r--src/tools/jal/jal_compile.cpp26
-rw-r--r--src/tools/jal/jal_compile.h29
-rw-r--r--src/tools/jal/jal_config.cpp9
-rw-r--r--src/tools/jal/jal_config.h25
-rw-r--r--src/tools/jal/jal_generator.cpp35
-rw-r--r--src/tools/jal/jal_generator.h27
-rw-r--r--src/tools/jalv2/Makefile.am8
-rw-r--r--src/tools/jalv2/gui/Makefile.am6
-rw-r--r--src/tools/jalv2/gui/jalv2_ui.cpp19
-rw-r--r--src/tools/jalv2/gui/jalv2_ui.h35
-rw-r--r--src/tools/jalv2/jalv2.cpp77
-rw-r--r--src/tools/jalv2/jalv2.h50
-rw-r--r--src/tools/jalv2/jalv2_compile.cpp43
-rw-r--r--src/tools/jalv2/jalv2_compile.h28
-rw-r--r--src/tools/jalv2/jalv2_config.cpp9
-rw-r--r--src/tools/jalv2/jalv2_config.h25
-rw-r--r--src/tools/list/Makefile.am7
-rw-r--r--src/tools/list/compile_config.cpp189
-rw-r--r--src/tools/list/compile_config.h84
-rw-r--r--src/tools/list/compile_manager.cpp292
-rw-r--r--src/tools/list/compile_manager.h74
-rw-r--r--src/tools/list/compile_process.cpp376
-rw-r--r--src/tools/list/compile_process.h179
-rw-r--r--src/tools/list/device_info.cpp63
-rw-r--r--src/tools/list/device_info.h22
-rw-r--r--src/tools/list/tool_list.cpp69
-rw-r--r--src/tools/list/tool_list.h28
-rw-r--r--src/tools/list/tools_config_widget.cpp144
-rw-r--r--src/tools/list/tools_config_widget.h60
-rw-r--r--src/tools/mpc/Makefile.am8
-rw-r--r--src/tools/mpc/gui/Makefile.am6
-rw-r--r--src/tools/mpc/gui/mpc_ui.cpp14
-rw-r--r--src/tools/mpc/gui/mpc_ui.h35
-rw-r--r--src/tools/mpc/mpc.cpp57
-rw-r--r--src/tools/mpc/mpc.h49
-rw-r--r--src/tools/mpc/mpc_compile.cpp51
-rw-r--r--src/tools/mpc/mpc_compile.h35
-rw-r--r--src/tools/mpc/mpc_config.cpp9
-rw-r--r--src/tools/mpc/mpc_config.h25
-rw-r--r--src/tools/pic30/Makefile.am9
-rw-r--r--src/tools/pic30/gui/Makefile.am6
-rw-r--r--src/tools/pic30/gui/pic30_ui.cpp26
-rw-r--r--src/tools/pic30/gui/pic30_ui.h36
-rw-r--r--src/tools/pic30/pic30.cpp137
-rw-r--r--src/tools/pic30/pic30.h54
-rw-r--r--src/tools/pic30/pic30_compile.cpp196
-rw-r--r--src/tools/pic30/pic30_compile.h128
-rw-r--r--src/tools/pic30/pic30_config.cpp9
-rw-r--r--src/tools/pic30/pic30_config.h25
-rw-r--r--src/tools/pic30/pic30_generator.cpp111
-rw-r--r--src/tools/pic30/pic30_generator.h27
-rw-r--r--src/tools/picc/Makefile.am8
-rw-r--r--src/tools/picc/gui/Makefile.am6
-rw-r--r--src/tools/picc/gui/picc_ui.cpp20
-rw-r--r--src/tools/picc/gui/picc_ui.h35
-rw-r--r--src/tools/picc/picc.cpp127
-rw-r--r--src/tools/picc/picc.h97
-rw-r--r--src/tools/picc/picc_compile.cpp136
-rw-r--r--src/tools/picc/picc_compile.h83
-rw-r--r--src/tools/picc/picc_config.cpp9
-rw-r--r--src/tools/picc/picc_config.h25
-rw-r--r--src/tools/sdcc/Makefile.am9
-rw-r--r--src/tools/sdcc/gui/Makefile.am6
-rw-r--r--src/tools/sdcc/gui/sdcc_ui.cpp29
-rw-r--r--src/tools/sdcc/gui/sdcc_ui.h35
-rw-r--r--src/tools/sdcc/sdcc.cpp115
-rw-r--r--src/tools/sdcc/sdcc.h63
-rw-r--r--src/tools/sdcc/sdcc_compile.cpp103
-rw-r--r--src/tools/sdcc/sdcc_compile.h58
-rw-r--r--src/tools/sdcc/sdcc_config.cpp9
-rw-r--r--src/tools/sdcc/sdcc_config.h25
-rw-r--r--src/tools/sdcc/sdcc_generator.cpp117
-rw-r--r--src/tools/sdcc/sdcc_generator.h45
157 files changed, 8486 insertions, 0 deletions
diff --git a/src/tools/Makefile.am b/src/tools/Makefile.am
new file mode 100644
index 0000000..0b287af
--- /dev/null
+++ b/src/tools/Makefile.am
@@ -0,0 +1,3 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+SUBDIRS = base gui gputils sdcc picc pic30 c18 jal ccsc jalv2 boost mpc cc5x custom list
diff --git a/src/tools/base/Makefile.am b/src/tools/base/Makefile.am
new file mode 100644
index 0000000..2154bf4
--- /dev/null
+++ b/src/tools/base/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libtoolbase.la
+libtoolbase_la_LDFLAGS = $(all_libraries)
+libtoolbase_la_SOURCES = generic_tool.cpp tool_group.cpp
diff --git a/src/tools/base/generic_tool.cpp b/src/tools/base/generic_tool.cpp
new file mode 100644
index 0000000..d595362
--- /dev/null
+++ b/src/tools/base/generic_tool.cpp
@@ -0,0 +1,60 @@
+/***************************************************************************
+ * Copyright (C) 2005-2007 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 "generic_tool.h"
+
+#include "devices/list/device_list.h"
+#include "common/global/process.h"
+#include "tools/list/compile_config.h"
+
+//----------------------------------------------------------------------------
+const Tool::Category::Data Tool::Category::DATA[Nb_Types] = {
+ { "compiler", I18N_NOOP("Compiler:"), I18N_NOOP("Compiler") },
+ { "assembler", I18N_NOOP("Assembler:"), I18N_NOOP("Assembler") },
+ { "linker", I18N_NOOP("Linker:"), I18N_NOOP("Linker") },
+ { "bin_to_hex", I18N_NOOP("Bin to Hex:"), I18N_NOOP("Bin to Hex") },
+ { "librarian", I18N_NOOP("Librarian:"), I18N_NOOP("Librarian") }
+};
+
+const Tool::ExecutableType::Data Tool::ExecutableType::DATA[Nb_Types] = {
+ { "unix", I18N_NOOP("Unix") },
+ { "windows", I18N_NOOP("Windows") }
+};
+
+const Compile::DirectoryType::Data Compile::DirectoryType::DATA[Nb_Types] = {
+ { "executable", I18N_NOOP("Executable directory") },
+ { "include", I18N_NOOP("Header directory") },
+ { "linker_script", I18N_NOOP("Linker Script Directory") },
+ { "library", I18N_NOOP("Library Directory") },
+ { "source", I18N_NOOP("Source Directory") }
+};
+
+const Tool::OutputExecutableType::Data Tool::OutputExecutableType::DATA[Nb_Types] = {
+ { I18N_NOOP("COFF"), "coff", PURL::Coff },
+ { I18N_NOOP("ELF"), "elf", PURL::Elf }
+};
+
+const Tool::OutputType::Data Tool::OutputType::DATA[Nb_Types] = {
+ { "executable", I18N_NOOP("Executable") },
+ { "library", I18N_NOOP("Library") }
+};
+
+//-----------------------------------------------------------------------------
+PURL::Directory Tool::Base::executableDirectory() const
+{
+ return Compile::Config::directory(*_group, Compile::DirectoryType::Executable);
+}
+
+::Process::LineOutput *Tool::Base::checkExecutableProcess(const PURL::Directory &dir, bool withWine, OutputExecutableType type) const
+{
+ ::Process::LineOutput *process = new ::Process::LineOutput;
+ process->setup(dir.path() + baseExecutable(withWine, type), checkExecutableOptions(withWine), withWine);
+ PURL::Directory wdir = checkExecutableWorkingDirectory();
+ if ( !wdir.isEmpty() ) process->setWorkingDirectory(wdir.path());
+ return process;
+}
diff --git a/src/tools/base/generic_tool.h b/src/tools/base/generic_tool.h
new file mode 100644
index 0000000..3b3299d
--- /dev/null
+++ b/src/tools/base/generic_tool.h
@@ -0,0 +1,104 @@
+/***************************************************************************
+ * Copyright (C) 2005-2007 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 GENERIC_TOOL_H
+#define GENERIC_TOOL_H
+
+#include "common/global/purl.h"
+#include "common/common/key_enum.h"
+namespace Device { class Data; class Memory; }
+namespace Process { class LineOutput; }
+class Project;
+
+namespace Tool
+{
+//----------------------------------------------------------------------------
+ struct CategoryData {
+ const char *key, *label, *title;
+ };
+ BEGIN_DECLARE_ENUM(Category)
+ Compiler = 0, Assembler, Linker, BinToHex, Librarian
+ END_DECLARE_ENUM(Category, CategoryData)
+
+ BEGIN_DECLARE_ENUM(ExecutableType)
+ Unix = 0, Windows
+ END_DECLARE_ENUM_STD(ExecutableType)
+} // namespace
+
+namespace Compile
+{
+ enum LinkType { NormalLinking, Icd2Linking };
+ class Process;
+ class Config;
+
+ class TodoItem {
+ public:
+ TodoItem() {}
+ TodoItem(const PURL::Url &_url, bool _generated) : url(_url), generated(_generated) {}
+ PURL::Url url;
+ bool generated;
+ };
+
+ class Data {
+ public:
+ Data() {}
+ Data(Tool::Category c, const QValueList<TodoItem> &i, const QString &d, const Project *p, LinkType lt)
+ : category(c), items(i), device(d), project(p), linkType(lt) {}
+ Tool::Category category;
+ QValueList<TodoItem> items;
+ QString device;
+ const Project *project;
+ LinkType linkType;
+ };
+
+ BEGIN_DECLARE_ENUM(DirectoryType)
+ Executable = 0, Header, LinkerScript, Library, Source
+ END_DECLARE_ENUM_STD(DirectoryType)
+
+} // namespace
+
+namespace Tool
+{
+ class Group;
+
+ struct OutputExecutableTypeData {
+ const char *label, *key;
+ PURL::FileType type;
+ };
+ BEGIN_DECLARE_ENUM(OutputExecutableType)
+ Coff = 0, Elf
+ END_DECLARE_ENUM(OutputExecutableType, OutputExecutableTypeData)
+
+ BEGIN_DECLARE_ENUM(OutputType)
+ Executable = 0, Library
+ END_DECLARE_ENUM_STD(OutputType)
+
+//-----------------------------------------------------------------------------
+class Base
+{
+public:
+ virtual ~Base() {}
+ const Group &group() const { return *_group; }
+ virtual QString baseExecutable(bool withWine, OutputExecutableType type) const = 0;
+ PURL::Directory executableDirectory() const;
+ virtual bool checkExecutable() const { return true; }
+ virtual QStringList checkExecutableOptions(bool withWine) const = 0;
+ virtual PURL::Directory checkExecutableWorkingDirectory() const { return PURL::Directory(); }
+ virtual ::Process::LineOutput *checkExecutableProcess(const PURL::Directory &dir, bool withWine, OutputExecutableType type) const;
+ virtual bool checkExecutableResult(bool withWine, QStringList &lines) const = 0;
+
+protected:
+ Category _category;
+ const Group *_group;
+
+ friend class Group;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/base/tool_group.cpp b/src/tools/base/tool_group.cpp
new file mode 100644
index 0000000..fb347ce
--- /dev/null
+++ b/src/tools/base/tool_group.cpp
@@ -0,0 +1,140 @@
+/***************************************************************************
+ * Copyright (C) 2005-2007 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 "tool_group.h"
+
+#include "devices/list/device_list.h"
+#include "devices/base/device_group.h"
+#include "devices/base/generic_memory.h"
+#include "common/global/process.h"
+#include "tools/list/compile_config.h"
+#include "tools/list/compile_process.h"
+#include "libgui/project.h"
+
+//-----------------------------------------------------------------------------
+const char *Tool::Group::CUSTOM_NAME = "custom";
+
+Tool::Group::Group()
+ : _sourceGenerator(0), _checkDevicesError(true)
+{}
+
+void Tool::Group::init()
+{
+ delete _sourceGenerator;
+ _sourceGenerator = sourceGeneratorFactory();
+ FOR_EACH(Category, i) {
+ delete _bases[i].base;
+ _bases[i] = baseFactory(i);
+ if (_bases[i].base) {
+ _bases[i].base->_category = i;
+ _bases[i].base->_group = this;
+ }
+ }
+ ::Group::Base::init();
+ _version = getToolchainVersion();
+}
+
+Compile::Process *Tool::Group::createCompileProcess(const Compile::Data &data, Compile::Manager *manager) const
+{
+ Compile::Process *p = processFactory(data);
+ if (p) p->init(data, manager);
+ return p;
+}
+
+Compile::Config *Tool::Group::createConfig(::Project *project) const
+{
+ Compile::Config *c = configFactory(project);
+ if (c) c->_group = this;
+ return c;
+}
+
+PURL::Directory Tool::Group::autodetectDirectory(Compile::DirectoryType, const PURL::Directory &, bool) const
+{
+ return PURL::Directory();
+}
+
+QString Tool::Group::defaultLinkerScriptFilename(Compile::LinkType type, const QString &device) const
+{
+ QString basename = device.lower();
+ if ( type==Compile::Icd2Linking ) basename += 'i';
+ return basename + '.' + PURL::extension(PURL::Lkr);
+}
+
+bool Tool::Group::hasCustomLinkerScript(const ::Project *project) const
+{
+ return ( project && !project->customLinkerScript().isEmpty() );
+}
+
+PURL::Url Tool::Group::linkerScript(const ::Project *project, Compile::LinkType type) const
+{
+ if ( hasCustomLinkerScript(project) ) return project->customLinkerScript();
+ QString filename = defaultLinkerScriptFilename(type, Compile::Config::device(project));
+ return PURL::Url(Compile::Config::directory(*this, Compile::DirectoryType::LinkerScript), filename);
+}
+
+::Process::LineOutput *Tool::Group::checkDevicesProcess(uint i, const PURL::Directory &dir, bool withWine) const
+{
+ ::Process::LineOutput *process = new ::Process::LineOutput;
+ Tool::Category cat = checkDevicesCategory();
+ QString exec = base(cat)->baseExecutable(withWine, Compile::Config::outputExecutableType(*this));
+ process->setup(dir.path() + exec, checkDevicesOptions(i), withWine);
+ return process;
+}
+
+bool Tool::Group::checkExecutable(Tool::Category category, QStringList &lines)
+{
+ PURL::Directory dir = Compile::Config::directory(*this, Compile::DirectoryType::Executable);
+ bool withWine = Compile::Config::withWine(*this);
+ Tool::OutputExecutableType outputType = Compile::Config::outputExecutableType(*this);
+ ::Process::LineOutput * process = _bases[category].base->checkExecutableProcess(dir, withWine, outputType);
+ ::Process::State state = ::Process::runSynchronously(*process, ::Process::Start, 10000);
+ if ( state!=::Process::Exited ) return false;
+ lines = process->sout() + process->serr();
+ return _bases[category].base->checkExecutableResult(withWine, lines);
+}
+
+void Tool::Group::initSupported()
+{
+ _checkDevicesError = false;
+ Tool::Category cat = checkDevicesCategory();
+ QValueList<const Device::Data *> list;
+ if ( cat==Tool::Category::Nb_Types ) list = getSupportedDevices(QString::null);
+ else {
+ PURL::Directory dir = Compile::Config::directory(*this, Compile::DirectoryType::Executable);
+ for (uint i=0; i<nbCheckDevices(); i++) {
+ QStringList lines;
+ ::Process::LineOutput *process = checkDevicesProcess(i, dir, Compile::Config::withWine(*this));
+ ::Process::State state = ::Process::runSynchronously(*process, ::Process::Start, 10000);
+ if ( state==::Process::Exited ) {
+ QStringList lines = process->sout() + process->serr();
+ list += getSupportedDevices(lines.join("\n"));
+ } else _checkDevicesError = true;
+ delete process;
+ }
+ }
+ QValueList<const Device::Data *>::const_iterator it;
+ for (it=list.begin(); it!=list.end(); ++it) addDevice((*it)->name(), *it, ::Group::Support::Tested);
+}
+
+bool Tool::Group::check(const QString &device, Log::Generic *log) const
+{
+ const_cast<Tool::Group *>(this)->checkInitSupported();
+ if ( hasCheckDevicesError() )
+ return (log ? log->askContinue(i18n("There were errors detecting supported devices for the selected toolchain (%1). Please check the toolchain configuration. Continue anyway?").arg(label())) : false);
+ if ( !device.isEmpty() && device!=Device::AUTO_DATA.name && !isSupported(device) )
+ return (log ? log->askContinue(i18n("The selected toolchain (%1) does not support device %2. Continue anyway?").arg(label()).arg(device)) : false);
+ return true;
+}
+
+bool Tool::Group::needs(bool withProject, Tool::Category category) const
+{
+ if ( _bases[category].base==0 ) return false;
+ if ( withProject && _bases[category].type==StandaloneOnly ) return false;
+ if ( !withProject && _bases[category].type==ProjectOnly ) return false;
+ return true;
+}
diff --git a/src/tools/base/tool_group.h b/src/tools/base/tool_group.h
new file mode 100644
index 0000000..c4adb84
--- /dev/null
+++ b/src/tools/base/tool_group.h
@@ -0,0 +1,85 @@
+/***************************************************************************
+ * Copyright (C) 2005-2007 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 TOOL_GROUP_H
+#define TOOL_GROUP_H
+
+#include "common/global/purl.h"
+#include "common/common/group.h"
+#include "common/common/version_data.h"
+#include "generic_tool.h"
+#include "coff/base/disassembler.h"
+namespace Compile { class Manager; }
+
+namespace Tool
+{
+enum CompileType { SeparateFiles, AllFiles, SingleFile };
+class SourceGenerator;
+
+//-----------------------------------------------------------------------------
+class Group : public ::Group::Base
+{
+public:
+ static const char *CUSTOM_NAME;
+ Group();
+ bool isCustom() const { return ( name()==CUSTOM_NAME ); }
+ virtual QString comment() const { return QString::null; }
+ virtual void init();
+ virtual const ::Tool::Base *base(Category category) const { return _bases[category].base; }
+ virtual QString informationText() const = 0;
+ virtual ExecutableType preferedExecutableType() const = 0;
+ virtual bool hasDirectory(Compile::DirectoryType) const { return false; }
+ virtual PURL::FileType linkerScriptType() const { return PURL::Nb_FileTypes; }
+ virtual PURL::Directory autodetectDirectory(Compile::DirectoryType type, const PURL::Directory &execDir, bool withWine) const;
+ virtual bool hasOutputExecutableType(Tool::OutputExecutableType type) const { return ( type==Tool::OutputExecutableType::Coff ); }
+ virtual uint nbCheckDevices() const { return 1; }
+ bool hasCheckDevicesError() const { return _checkDevicesError; }
+ virtual Tool::Category checkDevicesCategory() const = 0;
+ virtual QStringList checkDevicesOptions(uint) const { return QStringList(); }
+ ::Process::LineOutput *checkDevicesProcess(uint i, const PURL::Directory &execDir, bool withWine) const;
+ virtual QValueList<const Device::Data *> getSupportedDevices(const QString &s) const = 0;
+ virtual CompileType compileType() const = 0;
+ virtual bool needs(bool withProject, Category category) const;
+ Compile::Process *createCompileProcess(const Compile::Data &data, Compile::Manager *manager) const;
+ Compile::Config *createConfig(::Project *project) const;
+ bool hasCustomLinkerScript(const ::Project *project) const;
+ virtual PURL::Url linkerScript(const ::Project *project, Compile::LinkType type) const;
+ virtual PURL::FileType implementationType(PURL::ToolType type) const = 0;
+ virtual Compile::Process *processFactory(const Compile::Data &data) const = 0;
+ const SourceGenerator *sourceGenerator() const { return _sourceGenerator; }
+ bool check(const QString &device, Log::Generic *log) const;
+ const VersionData &version() const { return _version; }
+ virtual bool generateDebugInformation(const QString &device) const { Q_UNUSED(device); return true; }
+
+protected:
+ enum NeedType { StandaloneOnly, ProjectOnly, Both };
+ class BaseData {
+ public:
+ BaseData() : base(0), type(Both) {}
+ BaseData(::Tool::Base *b, NeedType t) : base(b), type(t) {}
+ ::Tool::Base *base;
+ NeedType type;
+ };
+ virtual void initSupported();
+ virtual BaseData baseFactory(Category category) const = 0;
+ virtual QString defaultLinkerScriptFilename(Compile::LinkType type, const QString &device) const;
+ virtual Compile::Config *configFactory(::Project *project) const = 0;
+ virtual SourceGenerator *sourceGeneratorFactory() const = 0;
+ bool checkExecutable(Tool::Category category, QStringList &lines);
+ virtual VersionData getToolchainVersion() { return VersionData(); }
+
+private:
+ SourceGenerator *_sourceGenerator;
+ QMap<Category, BaseData> _bases;
+ bool _checkDevicesError;
+ VersionData _version;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/boost/Makefile.am b/src/tools/boost/Makefile.am
new file mode 100644
index 0000000..725e078
--- /dev/null
+++ b/src/tools/boost/Makefile.am
@@ -0,0 +1,9 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libboost.la
+libboost_la_SOURCES = boostc.cpp boostc_compile.cpp boost_config.cpp \
+ boost.cpp boostcpp.cpp boostbasic.cpp boost_generator.cpp
+libboost_la_LDFLAGS = $(all_libraries)
+
+SUBDIRS = gui \ No newline at end of file
diff --git a/src/tools/boost/boost.cpp b/src/tools/boost/boost.cpp
new file mode 100644
index 0000000..86e304c
--- /dev/null
+++ b/src/tools/boost/boost.cpp
@@ -0,0 +1,102 @@
+/***************************************************************************
+ * 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 "boost.h"
+
+#include "boostc_compile.h"
+#include "boost_config.h"
+#include "devices/pic/pic/pic_memory.h"
+#include "devices/list/device_list.h"
+#include "devices/base/device_group.h"
+
+//----------------------------------------------------------------------------
+bool Boost::Linker::checkExecutableResult(bool, QStringList &lines) const
+{
+ return ( lines.count()>0 && lines[0].startsWith("BoostLink ") );
+}
+
+PURL::Directory Boost::Linker::checkExecutableWorkingDirectory() const
+{
+ return static_cast<const Group *>(_group)->checkExecutableUrl().directory();
+}
+
+QStringList Boost::Linker16::checkExecutableOptions(bool) const
+{
+ // #### otherwise may stall...
+ QStringList args;
+ args += "-t PIC16F873";
+ args += static_cast<const Group *>(_group)->checkExecutableUrl().toExtension("obj").filename();
+ return args;
+}
+
+QStringList Boost::Linker18::checkExecutableOptions(bool) const
+{
+ // #### otherwise may stall...
+ QStringList args;
+ args += "-t PIC18F452";
+ args += static_cast<const Group *>(_group)->checkExecutableUrl().toExtension("obj").filename();
+ return args;
+}
+
+//----------------------------------------------------------------------------
+QStringList Boost::Compiler::checkExecutableOptions(bool) const
+{
+ // #### otherwise may stall...
+ return static_cast<const Group *>(_group)->checkExecutableUrl().filename();
+}
+
+PURL::Directory Boost::Compiler::checkExecutableWorkingDirectory() const
+{
+ return static_cast<const Group *>(_group)->checkExecutableUrl().directory();
+}
+
+//----------------------------------------------------------------------------
+Boost::Group::Group(const QString &extension, const QString &text)
+ : _checkExecTmp(_sview, extension)
+{
+ if ( _checkExecTmp.openForWrite() ) _checkExecTmp.appendText(text);
+ _checkExecTmp.close();
+}
+
+QString Boost::Group::comment() const
+{
+ return i18n("The Boost toolchain needs to be run by Wine with \"Windows NT 4.0\" compatibility. This can be configured with the Wine configuration utility.");
+}
+
+PURL::Directory Boost::Group::autodetectDirectory(Compile::DirectoryType type, const PURL::Directory &execDir, bool) const
+{
+ if ( type==Compile::DirectoryType::Library ) return execDir.path() + "Lib";
+ return PURL::Directory();
+}
+
+Compile::Process *Boost::Group::processFactory(const Compile::Data &data) const
+{
+ switch (data.category.type()) {
+ case Tool::Category::Compiler: return new Boost::CompileFile;
+ case Tool::Category::Linker: return new Boost::Link;
+ default: break;
+ }
+ Q_ASSERT(false);
+ return 0;
+}
+
+Compile::Config *Boost::Group::configFactory(::Project *project) const
+{
+ return new Boost::Config(project);
+}
+
+QValueList<const Device::Data *> Boost::Group::getSupportedDevices(const QString &) const
+{
+ QValueList<const Device::Data *> list;
+ QValueVector<QString> devices = Device::lister().group("pic")->supportedDevices();
+ for (uint i=0; i<devices.count(); i++) {
+ const Device::Data *data = Device::lister().data(devices[i]);
+ if ( supportedArchitecture(static_cast<const Pic::Data *>(data)->architecture()) ) list.append(data);
+ }
+ return list;
+}
diff --git a/src/tools/boost/boost.h b/src/tools/boost/boost.h
new file mode 100644
index 0000000..d6142c9
--- /dev/null
+++ b/src/tools/boost/boost.h
@@ -0,0 +1,74 @@
+/***************************************************************************
+ * 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 BOOST_H
+#define BOOST_H
+
+#include "tools/base/tool_group.h"
+#include "common/gui/pfile_ext.h"
+#include "devices/pic/base/pic.h"
+
+namespace Boost
+{
+//----------------------------------------------------------------------------
+class Linker : public Tool::Base
+{
+private:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const { return "boostlink.pic.exe"; }
+ virtual bool checkExecutableResult(bool withWine, QStringList &lines) const;
+ virtual PURL::Directory checkExecutableWorkingDirectory() const;
+};
+
+class Linker16 : public Linker
+{
+private:
+ virtual QStringList checkExecutableOptions(bool withWine) const;
+};
+
+class Linker18 : public Linker
+{
+private:
+ virtual QStringList checkExecutableOptions(bool withWine) const;
+};
+
+//----------------------------------------------------------------------------
+class Compiler : public Tool::Base
+{
+private:
+ virtual QStringList checkExecutableOptions(bool withWine) const;
+ virtual PURL::Directory checkExecutableWorkingDirectory() const;
+};
+
+//----------------------------------------------------------------------------
+class Group : public Tool::Group
+{
+public:
+ Group(const QString &extension, const QString &text);
+ PURL::Url checkExecutableUrl() const { return _checkExecTmp.url(); }
+ virtual QString comment() const;
+ virtual Tool::Category checkDevicesCategory() const { return Tool::Category::Nb_Types; }
+ virtual Tool::ExecutableType preferedExecutableType() const { return Tool::ExecutableType::Windows; }
+ virtual Tool::CompileType compileType() const { return Tool::SeparateFiles; }
+ virtual bool hasDirectory(Compile::DirectoryType type) const { return type==Compile::DirectoryType::Library; }
+ virtual PURL::Directory autodetectDirectory(Compile::DirectoryType type, const PURL::Directory &execDir, bool withWine) const;
+
+protected:
+ virtual bool supportedArchitecture(Pic::Architecture architecture) const = 0;
+
+private:
+ Log::StringView _sview;
+ PURL::TempFile _checkExecTmp;
+
+ 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;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/boost/boost_config.cpp b/src/tools/boost/boost_config.cpp
new file mode 100644
index 0000000..b64f0af
--- /dev/null
+++ b/src/tools/boost/boost_config.cpp
@@ -0,0 +1,9 @@
+/***************************************************************************
+ * 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 "boost_config.h"
diff --git a/src/tools/boost/boost_config.h b/src/tools/boost/boost_config.h
new file mode 100644
index 0000000..c8b540e
--- /dev/null
+++ b/src/tools/boost/boost_config.h
@@ -0,0 +1,24 @@
+/***************************************************************************
+ * 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 BOOST_CONFIG_H
+#define BOOST_CONFIG_H
+
+#include "tools/list/compile_config.h"
+
+namespace Boost
+{
+class Config : public Compile::Config
+{
+public:
+ Config(Project *project) : Compile::Config(project) {}
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/boost/boost_generator.cpp b/src/tools/boost/boost_generator.cpp
new file mode 100644
index 0000000..2fa1393
--- /dev/null
+++ b/src/tools/boost/boost_generator.cpp
@@ -0,0 +1,81 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 "boost_generator.h"
+
+#include "devices/pic/pic/pic_memory.h"
+
+//---------------------------------------------------------------------------
+SourceLine::List Boost::CSourceGenerator::configLines(PURL::ToolType, const Device::Memory &memory, bool &ok) const
+{
+ const Pic::Memory &pmemory = static_cast<const Pic::Memory &>(memory);
+ const Pic::Data &data = pmemory.device();
+ const Pic::Config &config = data.config();
+ SourceLine::List lines;
+ Address address = data.range(Pic::MemoryRangeType::Config).start;
+ for (uint i=0; i<data.nbWords(Pic::MemoryRangeType::Config); i++) {
+ const Pic::Config::Word &cword = config._words[i];
+ QStringList cnames = SourceLine::configNames(Pic::ConfigNameType::Default, pmemory, i, ok);
+ if ( cnames.isEmpty() ) continue;
+ QString code = "#pragma DATA ";
+ if ( cword.name.isEmpty() ) code += toHexLabel(address, data.nbCharsAddress());
+ else code += "__" + cword.name;
+ code += cnames.join(" & ") + ";";
+ lines.appendNotIndentedCode(code);
+ address += data.addressIncrement(Pic::MemoryRangeType::Config);
+ }
+ return lines;
+}
+
+SourceLine::List Boost::CSourceGenerator::includeLines(PURL::ToolType, const Device::Data &) const
+{
+ SourceLine::List lines;
+ lines.appendNotIndentedCode("#include <system.h>");
+ return lines;
+}
+
+SourceLine::List Boost::CSourceGenerator::sourceFileContent(PURL::ToolType, const Device::Data &, bool &) const
+{
+ SourceLine::List lines;
+ lines.appendTitle(i18n("interrupt service routine"));
+ lines.appendNotIndentedCode("void interrupt(void) {");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert interrupt code") + " >>");
+ lines.appendNotIndentedCode("}");
+ lines.appendEmpty();
+ lines.appendTitle(i18n("main program"));
+ lines.appendNotIndentedCode("void main() {");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert code") + " >>");
+ lines.appendNotIndentedCode("}");
+ return lines;
+}
+
+//---------------------------------------------------------------------------
+SourceLine::List Boost::BasicSourceGenerator::configLines(PURL::ToolType, const Device::Memory &, bool &ok) const
+{
+ // config bits ?
+ ok = false;
+ return SourceLine::List();
+}
+
+SourceLine::List Boost::BasicSourceGenerator::includeLines(PURL::ToolType, const Device::Data &) const
+{
+ return SourceLine::List();
+}
+
+SourceLine::List Boost::BasicSourceGenerator::sourceFileContent(PURL::ToolType, const Device::Data &, bool &ok) const
+{
+ SourceLine::List lines;
+ ok = true;
+ lines.appendTitle(i18n("main program"));
+ lines.appendNotIndentedCode("Sub main()");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert code") + " >>");
+ lines.appendIndentedCode("Do while 1", i18n("loop forever"));
+ lines.appendIndentedCode("Loop");
+ lines.appendNotIndentedCode("End Sub");
+ return lines;
+}
diff --git a/src/tools/boost/boost_generator.h b/src/tools/boost/boost_generator.h
new file mode 100644
index 0000000..0986ee1
--- /dev/null
+++ b/src/tools/boost/boost_generator.h
@@ -0,0 +1,37 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 BOOST_GENERATOR_H
+#define BOOST_GENERATOR_H
+
+#include "tools/base/tool_group.h"
+
+namespace Boost
+{
+
+//---------------------------------------------------------------------------
+class CSourceGenerator : public Tool::SourceGenerator
+{
+public:
+ virtual SourceLine::List configLines(PURL::ToolType type, const Device::Memory &memory, bool &ok) const;
+ virtual SourceLine::List sourceFileContent(PURL::ToolType type, const Device::Data &data, bool &ok) const;
+ virtual SourceLine::List includeLines(PURL::ToolType type, const Device::Data &data) const;
+};
+
+//---------------------------------------------------------------------------
+class BasicSourceGenerator : public Tool::SourceGenerator
+{
+public:
+ virtual SourceLine::List configLines(PURL::ToolType type, const Device::Memory &memory, bool &ok) const;
+ virtual SourceLine::List sourceFileContent(PURL::ToolType type, const Device::Data &data, bool &ok) const;
+ virtual SourceLine::List includeLines(PURL::ToolType type, const Device::Data &data) const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/boost/boostbasic.cpp b/src/tools/boost/boostbasic.cpp
new file mode 100644
index 0000000..9983874
--- /dev/null
+++ b/src/tools/boost/boostbasic.cpp
@@ -0,0 +1,42 @@
+/***************************************************************************
+ * 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 "boostbasic.h"
+
+#include "boost_generator.h"
+
+//----------------------------------------------------------------------------
+bool Boost::CompilerBasic::checkExecutableResult(bool, QStringList &lines) const
+{
+ return ( lines.count()>0 && lines[0].startsWith("BoostBasic ") );
+}
+
+//----------------------------------------------------------------------------
+QString Boost::GroupBasic::informationText() const
+{
+ return i18n("<a href=\"%1\">BoostBasic Compiler</a> is a Basic compiler distributed by SourceBoost Technologies.").arg("http://www.sourceboost.com/Products/BoostBasic/Overview.html");
+}
+
+Tool::SourceGenerator *Boost::GroupBasic::sourceGeneratorFactory() const
+{
+ return new BasicSourceGenerator;
+}
+
+Tool::Group::BaseData Boost::GroupBasic16::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Compiler ) return BaseData(new Boost::CompilerBasic16, Both);
+ if ( category==Tool::Category::Linker ) return BaseData(new Boost::Linker16, Both);
+ return BaseData();
+}
+
+Tool::Group::BaseData Boost::GroupBasic18::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Linker ) return BaseData(new Boost::Linker18, Both);
+ if ( category==Tool::Category::Compiler ) return BaseData(new Boost::CompilerBasic18, Both);
+ return BaseData();
+}
diff --git a/src/tools/boost/boostbasic.h b/src/tools/boost/boostbasic.h
new file mode 100644
index 0000000..5f3b820
--- /dev/null
+++ b/src/tools/boost/boostbasic.h
@@ -0,0 +1,72 @@
+/***************************************************************************
+ * 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 BOOSTBASIC_H
+#define BOOSTBASIC_H
+
+#include "boost.h"
+
+namespace Boost
+{
+//----------------------------------------------------------------------------
+class CompilerBasic : public Compiler
+{
+private:
+ virtual bool checkExecutableResult(bool withWine, QStringList &lines) const;
+};
+
+class CompilerBasic16 : public CompilerBasic
+{
+public:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const { return "boostbasic.pic16.exe"; }
+};
+
+class CompilerBasic18 : public CompilerBasic
+{
+public:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const { return "boostbasic.pic18.exe"; }
+};
+
+//----------------------------------------------------------------------------
+class GroupBasic : public Group
+{
+public:
+ GroupBasic() : Group(".bas", "Sub main()\nEnd Sub\n") {}
+ virtual QString informationText() const;
+ virtual PURL::FileType implementationType(PURL::ToolType type) const { return (type==PURL::ToolType::Compiler ? PURL::BasicSource : PURL::Nb_FileTypes); }
+
+private:
+ virtual Tool::SourceGenerator *sourceGeneratorFactory() const;
+};
+
+class GroupBasic16 : public GroupBasic
+{
+public:
+ virtual QString name() const { return "boostbasic16"; }
+ virtual QString label() const { return i18n("BoostBasic Compiler for PIC16"); }
+
+private:
+ virtual BaseData baseFactory(Tool::Category) const;
+ virtual bool supportedArchitecture(Pic::Architecture architecture) const { return ( architecture==Pic::Architecture::P16X ); }
+};
+
+class GroupBasic18 : public GroupBasic
+{
+public:
+ virtual QString name() const { return "boostbasic18"; }
+ virtual QString label() const { return i18n("BoostBasic Compiler for PIC18"); }
+
+private:
+ virtual BaseData baseFactory(Tool::Category) const;
+ virtual bool supportedArchitecture(Pic::Architecture architecture) const
+ { return ( architecture==Pic::Architecture::P18C || architecture==Pic::Architecture::P18F || architecture==Pic::Architecture::P18J ); }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/boost/boostc.cpp b/src/tools/boost/boostc.cpp
new file mode 100644
index 0000000..9a6ada9
--- /dev/null
+++ b/src/tools/boost/boostc.cpp
@@ -0,0 +1,42 @@
+/***************************************************************************
+ * 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 "boostc.h"
+
+#include "boost_generator.h"
+
+//----------------------------------------------------------------------------
+bool Boost::CompilerC::checkExecutableResult(bool, QStringList &lines) const
+{
+ return ( lines.count()>0 && lines[0].startsWith("BoostC ") );
+}
+
+//----------------------------------------------------------------------------
+QString Boost::GroupC::informationText() const
+{
+ return i18n("<a href=\"%1\">BoostC Compiler</a> is a C compiler distributed by SourceBoost Technologies.").arg("http://www.sourceboost.com/Products/BoostC/Overview.html");
+}
+
+Tool::SourceGenerator *Boost::GroupC::sourceGeneratorFactory() const
+{
+ return new CSourceGenerator;
+}
+
+Tool::Group::BaseData Boost::GroupC16::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Compiler ) return BaseData(new Boost::CompilerC16, Both);
+ if ( category==Tool::Category::Linker ) return BaseData(new Boost::Linker16, Both);
+ return BaseData();
+}
+
+Tool::Group::BaseData Boost::GroupC18::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Compiler ) return BaseData(new Boost::CompilerC18, Both);
+ if ( category==Tool::Category::Linker ) return BaseData(new Boost::Linker18, Both);
+ return BaseData();
+}
diff --git a/src/tools/boost/boostc.h b/src/tools/boost/boostc.h
new file mode 100644
index 0000000..5191560
--- /dev/null
+++ b/src/tools/boost/boostc.h
@@ -0,0 +1,72 @@
+/***************************************************************************
+ * 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 BOOSTC_H
+#define BOOSTC_H
+
+#include "boost.h"
+
+namespace Boost
+{
+//----------------------------------------------------------------------------
+class CompilerC : public Compiler
+{
+private:
+ virtual bool checkExecutableResult(bool withWine, QStringList &lines) const;
+};
+
+class CompilerC16 : public CompilerC
+{
+public:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const { return "boostc.pic16.exe"; }
+};
+
+class CompilerC18 : public CompilerC
+{
+public:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const { return "boostc.pic18.exe"; }
+};
+
+//----------------------------------------------------------------------------
+class GroupC : public Group
+{
+public:
+ GroupC() : Group(".c", "void main(void) {}\n") {}
+ virtual QString informationText() const;
+ virtual PURL::FileType implementationType(PURL::ToolType type) const { return (type==PURL::ToolType::Compiler ? PURL::CSource : PURL::Nb_FileTypes); }
+
+private:
+ virtual Tool::SourceGenerator *sourceGeneratorFactory() const;
+};
+
+class GroupC16 : public GroupC
+{
+public:
+ virtual QString name() const { return "boostc16"; }
+ virtual QString label() const { return i18n("BoostC Compiler for PIC16"); }
+
+private:
+ virtual BaseData baseFactory(Tool::Category) const;
+ virtual bool supportedArchitecture(Pic::Architecture architecture) const { return ( architecture==Pic::Architecture::P16X ); }
+};
+
+class GroupC18 : public GroupC
+{
+public:
+ virtual QString name() const { return "boostc18"; }
+ virtual QString label() const { return i18n("BoostC Compiler for PIC18"); }
+
+private:
+ virtual BaseData baseFactory(Tool::Category) const;
+ virtual bool supportedArchitecture(Pic::Architecture architecture) const
+ { return ( architecture==Pic::Architecture::P18C || architecture==Pic::Architecture::P18F || architecture==Pic::Architecture::P18J ); }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/boost/boostc_compile.cpp b/src/tools/boost/boostc_compile.cpp
new file mode 100644
index 0000000..2298361
--- /dev/null
+++ b/src/tools/boost/boostc_compile.cpp
@@ -0,0 +1,56 @@
+/***************************************************************************
+ * 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 "boostc_compile.h"
+
+#include "boost_config.h"
+
+//----------------------------------------------------------------------------
+void Boost::Process::logStderrLine(const QString &line)
+{
+ if ( parseErrorLine(line, Compile::ParseErrorData("(.*)\\((\\d+).*\\): (error|warning):(.*)", 1, 2, 4, 3)) ) return;
+ doLog(Log::LineType::Normal, line, QString::null, 0);
+}
+
+//----------------------------------------------------------------------------
+QStringList Boost::CompileFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "-t %DEVICE";
+ args += "-i";
+ args += config.includeDirs(Tool::Category::Compiler, "-I", QString::null, ";");
+ args += config.customOptions(Tool::Category::Compiler);
+ args += "%I";
+ return args;
+}
+
+QString Boost::CompileFile::outputFiles() const
+{
+ return "obj";
+}
+
+//----------------------------------------------------------------------------
+QStringList Boost::Link::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "-t %DEVICE";
+ args += "-p";
+ args += "%PROJECT";
+ args += config.includeDirs(Tool::Category::Linker, "-ld%SEP");
+ PURL::Directory dir = Compile::Config::directory(group(), Compile::DirectoryType::Library);
+ if ( !dir.isEmpty() ) args += "-ld%SEP" + dir.path();
+ args += config.customOptions(Tool::Category::Linker);
+ args += "%OBJS";
+ return args;
+}
+
+QString Boost::Link::outputFiles() const
+{
+ return "PURL::Lst PURL::Hex PURL::Coff PURL::AsmGPAsm stat tree casm";
+}
+
diff --git a/src/tools/boost/boostc_compile.h b/src/tools/boost/boostc_compile.h
new file mode 100644
index 0000000..5c3696a
--- /dev/null
+++ b/src/tools/boost/boostc_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 BOOSTC_COMPILE_H
+#define BOOSTC_COMPILE_H
+
+#include "tools/list/compile_process.h"
+
+namespace Boost
+{
+//----------------------------------------------------------------------------
+class Process : public Compile::Process
+{
+Q_OBJECT
+protected:
+ virtual QString deviceName() const { return "PIC" + _data.device; }
+ virtual void logStderrLine(const QString &line);
+};
+
+//----------------------------------------------------------------------------
+class CompileFile : public Process
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+};
+
+//----------------------------------------------------------------------------
+class Link : public Process
+{
+Q_OBJECT
+protected:
+ virtual QString objectExtension() const { return "obj"; }
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/boost/boostcpp.cpp b/src/tools/boost/boostcpp.cpp
new file mode 100644
index 0000000..8991de7
--- /dev/null
+++ b/src/tools/boost/boostcpp.cpp
@@ -0,0 +1,43 @@
+/***************************************************************************
+ * 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 "boostcpp.h"
+
+#include "boostc.h"
+#include "boost_generator.h"
+
+//----------------------------------------------------------------------------
+bool Boost::CompilerCpp::checkExecutableResult(bool, QStringList &lines) const
+{
+ return ( lines.count()>0 && lines[0].startsWith("BoostC++ ") );
+}
+
+//----------------------------------------------------------------------------
+QString Boost::GroupCpp::informationText() const
+{
+ return i18n("<a href=\"%1\">BoostC++ Compiler</a> is a C compiler distributed by SourceBoost Technologies.").arg("http://www.sourceboost.com/Products/BoostCpp/Overview.html");
+}
+
+Tool::SourceGenerator *Boost::GroupCpp::sourceGeneratorFactory() const
+{
+ return new CSourceGenerator;
+}
+
+Tool::Group::BaseData Boost::GroupCpp16::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Compiler ) return BaseData(new Boost::CompilerCpp16, Both);
+ if ( category==Tool::Category::Linker ) return BaseData(new Boost::Linker16, Both);
+ return BaseData();
+}
+
+Tool::Group::BaseData Boost::GroupCpp18::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Compiler ) return BaseData(new Boost::CompilerCpp18, Both);
+ if ( category==Tool::Category::Linker ) return BaseData(new Boost::Linker18, Both);
+ return BaseData();
+}
diff --git a/src/tools/boost/boostcpp.h b/src/tools/boost/boostcpp.h
new file mode 100644
index 0000000..bf5e2ee
--- /dev/null
+++ b/src/tools/boost/boostcpp.h
@@ -0,0 +1,71 @@
+/***************************************************************************
+ * 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 BOOSTCPP_H
+#define BOOSTCPP_H
+
+#include "boost.h"
+
+namespace Boost
+{
+//----------------------------------------------------------------------------
+class CompilerCpp : public Compiler
+{
+private:
+ virtual bool checkExecutableResult(bool withWine, QStringList &lines) const;
+};
+
+class CompilerCpp16 : public CompilerCpp
+{
+public:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const { return "boostc++.pic16.exe"; }
+};
+
+class CompilerCpp18 : public CompilerCpp
+{
+public:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const { return "boostc++.pic18.exe"; }
+};
+
+//----------------------------------------------------------------------------
+class GroupCpp : public Group
+{
+public:
+ GroupCpp() : Group(".cpp", "void main(void) {}\n") {}
+ virtual QString informationText() const;
+ virtual PURL::FileType implementationType(PURL::ToolType type) const { return (type==PURL::ToolType::Compiler ? PURL::CppSource : PURL::Nb_FileTypes); }
+
+private:
+ virtual Tool::SourceGenerator *sourceGeneratorFactory() const;
+};
+
+class GroupCpp16 : public GroupCpp
+{
+public:
+ virtual QString name() const { return "boostc++16"; }
+ virtual QString label() const { return i18n("BoostC++ Compiler for PIC16"); }
+
+private:
+ virtual BaseData baseFactory(Tool::Category) const;
+ virtual bool supportedArchitecture(Pic::Architecture architecture) const { return ( architecture==Pic::Architecture::P16X ); }
+};
+
+class GroupCpp18 : public GroupCpp
+{
+public:
+ virtual QString name() const { return "boostc++18"; }
+ virtual QString label() const { return i18n("BoostC++ Compiler for PIC18"); }
+
+private:
+ virtual BaseData baseFactory(Tool::Category) const;
+ virtual bool supportedArchitecture(Pic::Architecture architecture) const
+ { return ( architecture==Pic::Architecture::P18C || architecture==Pic::Architecture::P18F || architecture==Pic::Architecture::P18J ); }
+};
+} // namespace
+
+#endif
diff --git a/src/tools/boost/gui/Makefile.am b/src/tools/boost/gui/Makefile.am
new file mode 100644
index 0000000..94fda00
--- /dev/null
+++ b/src/tools/boost/gui/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libboostui.la
+libboostui_la_SOURCES = boost_ui.cpp
+libboostui_la_LDFLAGS = $(all_libraries)
diff --git a/src/tools/boost/gui/boost_ui.cpp b/src/tools/boost/gui/boost_ui.cpp
new file mode 100644
index 0000000..2357165
--- /dev/null
+++ b/src/tools/boost/gui/boost_ui.cpp
@@ -0,0 +1,19 @@
+/***************************************************************************
+ * 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 "boost_ui.h"
+
+//----------------------------------------------------------------------------
+Boost::ConfigWidget::ConfigWidget(Project *project)
+ : ToolConfigWidget(project)
+{}
+
+void Boost::ConfigWidget::initEntries()
+{
+ createIncludeDirectoriesEntry();
+}
diff --git a/src/tools/boost/gui/boost_ui.h b/src/tools/boost/gui/boost_ui.h
new file mode 100644
index 0000000..6cafcf6
--- /dev/null
+++ b/src/tools/boost/gui/boost_ui.h
@@ -0,0 +1,35 @@
+/***************************************************************************
+ * 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 BOOST_UI_H
+#define BOOST_UI_H
+
+#include "tools/gui/tool_config_widget.h"
+#include "tools/gui/tool_group_ui.h"
+
+namespace Boost
+{
+//----------------------------------------------------------------------------
+class ConfigWidget : public ToolConfigWidget
+{
+Q_OBJECT
+public:
+ ConfigWidget(Project *project);
+ virtual void initEntries();
+};
+
+//----------------------------------------------------------------------------
+class GroupUI : public Tool::GroupUI
+{
+public:
+ virtual ToolConfigWidget *configWidgetFactory(Tool::Category, ::Project *project) const { return new ConfigWidget(project); }
+};
+
+} // namespace
+
+#endif
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
diff --git a/src/tools/cc5x/Makefile.am b/src/tools/cc5x/Makefile.am
new file mode 100644
index 0000000..b72d8bb
--- /dev/null
+++ b/src/tools/cc5x/Makefile.am
@@ -0,0 +1,8 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libcc5x.la
+libcc5x_la_SOURCES = cc5x.cpp cc5x_compile.cpp cc5x_config.cpp
+libcc5x_la_LDFLAGS = $(all_libraries)
+
+SUBDIRS = gui \ No newline at end of file
diff --git a/src/tools/cc5x/cc5x.cpp b/src/tools/cc5x/cc5x.cpp
new file mode 100644
index 0000000..5b28397
--- /dev/null
+++ b/src/tools/cc5x/cc5x.cpp
@@ -0,0 +1,62 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 "cc5x.h"
+
+#include <qregexp.h>
+
+#include "cc5x_compile.h"
+#include "cc5x_config.h"
+#include "devices/pic/pic/pic_memory.h"
+#include "devices/list/device_list.h"
+#include "devices/base/device_group.h"
+
+//----------------------------------------------------------------------------
+bool CC5X::Base::checkExecutableResult(bool, QStringList &lines) const
+{
+ return ( lines.count()>0 && lines[0].startsWith("CC5X") );
+}
+
+//----------------------------------------------------------------------------
+QValueList<const Device::Data *> CC5X::Group::getSupportedDevices(const QString &) const
+{
+ QValueList<const Device::Data *> list;
+ QValueVector<QString> devices = Device::lister().group("pic")->supportedDevices();
+ for (uint i=0; i<devices.count(); i++) {
+ const Pic::Data *data = static_cast<const Pic::Data *>(Device::lister().data(devices[i]));
+ if ( data->architecture()!=Pic::Architecture::P10X && data->architecture()!=Pic::Architecture::P16X ) continue;
+ list.append(data);
+ }
+ return list;
+}
+
+Compile::Process *CC5X::Group::processFactory(const Compile::Data &data) const
+{
+ switch (data.category.type()) {
+ case Tool::Category::Compiler: return new CC5X::CompileFile;
+ default: break;
+ }
+ Q_ASSERT(false);
+ return 0;
+}
+
+Compile::Config *CC5X::Group::configFactory(::Project *project) const
+{
+ return new Config(project);
+}
+
+QString CC5X::Group::informationText() const
+{
+ return i18n("<a href=\"%1\">CC5X</a> is a C compiler distributed by B Knudsen Data.").arg("http://www.bknd.com/cc5x/index.shtml");
+}
+
+Tool::Group::BaseData CC5X::Group::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Compiler ) return BaseData(new CC5X::Base, Both);
+ return BaseData();
+}
diff --git a/src/tools/cc5x/cc5x.h b/src/tools/cc5x/cc5x.h
new file mode 100644
index 0000000..054a9ef
--- /dev/null
+++ b/src/tools/cc5x/cc5x.h
@@ -0,0 +1,50 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 CC5X_H
+#define CC5X_H
+
+#include "tools/base/tool_group.h"
+#include "common/global/pfile.h"
+
+namespace CC5X
+{
+//----------------------------------------------------------------------------
+class Base : public Tool::Base
+{
+public:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const { return "cc5x"; }
+
+private:
+ virtual QStringList checkExecutableOptions(bool) const { return QStringList(); }
+ virtual bool checkExecutableResult(bool withWine, QStringList &lines) const;
+};
+
+//----------------------------------------------------------------------------
+class Group : public Tool::Group
+{
+public:
+ virtual QString name() const { return "cc5x"; }
+ virtual QString label() const { return i18n("CC5X Compiler"); }
+ virtual QString informationText() const;
+ virtual Tool::Category checkDevicesCategory() const { return Tool::Category::Nb_Types; }
+ virtual Tool::ExecutableType preferedExecutableType() const { return Tool::ExecutableType::Windows; }
+ virtual Tool::CompileType compileType() const { return Tool::SingleFile; }
+ 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) const;
+ virtual Tool::SourceGenerator *sourceGeneratorFactory() const { /*TODO*/ return 0; }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/cc5x/cc5x_compile.cpp b/src/tools/cc5x/cc5x_compile.cpp
new file mode 100644
index 0000000..6956eb8
--- /dev/null
+++ b/src/tools/cc5x/cc5x_compile.cpp
@@ -0,0 +1,37 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 "cc5x_compile.h"
+
+#include "cc5x_config.h"
+
+QStringList CC5X::CompileFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "-a"; // produce asm file
+ args += "-CC"; // produce cod c file
+ args += "-L"; // produce list file
+ args += "-eL"; // error details
+ //args += "-FM"; // error format for MPLAB
+ args += "-o%O"; // set output file
+ args += config.includeDirs(Tool::Category::Compiler, "-I");
+ args += config.customOptions(Tool::Category::Compiler);
+ args += "%I";
+ return args;
+}
+
+void CC5X::CompileFile::logStderrLine(const QString &line)
+{
+ if ( parseErrorLine(line, Compile::ParseErrorData("(.*):([0-9]+):(.+)\\[([0-9]+)\\](.+)", 1, 2, 5, 3)) ) return;
+ doLog(Log::LineType::Normal, line, QString::null, 0); // unrecognized
+}
+
+QString CC5X::CompileFile::outputFiles() const
+{
+ return "PURL::Lst PURL::AsmGPAsm PURL::Hex PURL::Cod occ";
+}
diff --git a/src/tools/cc5x/cc5x_compile.h b/src/tools/cc5x/cc5x_compile.h
new file mode 100644
index 0000000..f400380
--- /dev/null
+++ b/src/tools/cc5x/cc5x_compile.h
@@ -0,0 +1,29 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 CC5X_COMPILE_H
+#define CC5X_COMPILE_H
+
+#include "tools/list/compile_process.h"
+
+namespace CC5X
+{
+
+class CompileFile : public Compile::Process
+{
+Q_OBJECT
+protected:
+ virtual QString deviceName() const { return QString::null; }
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual void logStderrLine(const QString &line);
+ virtual QString outputFiles() const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/cc5x/cc5x_config.cpp b/src/tools/cc5x/cc5x_config.cpp
new file mode 100644
index 0000000..96def5c
--- /dev/null
+++ b/src/tools/cc5x/cc5x_config.cpp
@@ -0,0 +1,9 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 "cc5x_config.h"
diff --git a/src/tools/cc5x/cc5x_config.h b/src/tools/cc5x/cc5x_config.h
new file mode 100644
index 0000000..da1d1f9
--- /dev/null
+++ b/src/tools/cc5x/cc5x_config.h
@@ -0,0 +1,25 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 CC5X_CONFIG_H
+#define CC5X_CONFIG_H
+
+#include "tools/list/compile_config.h"
+
+namespace CC5X
+{
+//----------------------------------------------------------------------------
+class Config : public Compile::Config
+{
+public:
+ Config(Project *project) : Compile::Config(project) {}
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/cc5x/gui/Makefile.am b/src/tools/cc5x/gui/Makefile.am
new file mode 100644
index 0000000..760aee9
--- /dev/null
+++ b/src/tools/cc5x/gui/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libcc5xui.la
+libcc5xui_la_SOURCES = cc5x_ui.cpp
+libcc5xui_la_LDFLAGS = $(all_libraries) \ No newline at end of file
diff --git a/src/tools/cc5x/gui/cc5x_ui.cpp b/src/tools/cc5x/gui/cc5x_ui.cpp
new file mode 100644
index 0000000..b35e6af
--- /dev/null
+++ b/src/tools/cc5x/gui/cc5x_ui.cpp
@@ -0,0 +1,19 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 "cc5x_ui.h"
+
+//----------------------------------------------------------------------------
+CC5X::ConfigWidget::ConfigWidget(Project *project)
+ : ToolConfigWidget(project)
+{}
+
+void CC5X::ConfigWidget::initEntries()
+{
+ if ( _category!=Tool::Category::Linker ) createIncludeDirectoriesEntry();
+}
diff --git a/src/tools/cc5x/gui/cc5x_ui.h b/src/tools/cc5x/gui/cc5x_ui.h
new file mode 100644
index 0000000..7bf0a37
--- /dev/null
+++ b/src/tools/cc5x/gui/cc5x_ui.h
@@ -0,0 +1,35 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 CC5X_UI_H
+#define CC5X_UI_H
+
+#include "tools/gui/tool_config_widget.h"
+#include "tools/gui/tool_group_ui.h"
+
+namespace CC5X
+{
+//----------------------------------------------------------------------------
+class ConfigWidget : public ToolConfigWidget
+{
+Q_OBJECT
+public:
+ ConfigWidget(Project *project);
+ virtual void initEntries();
+};
+
+//----------------------------------------------------------------------------
+class GroupUI : public Tool::GroupUI
+{
+public:
+ virtual ToolConfigWidget *configWidgetFactory(Tool::Category, ::Project *project) const { return new ConfigWidget(project); }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/ccsc/Makefile.am b/src/tools/ccsc/Makefile.am
new file mode 100644
index 0000000..e0d3844
--- /dev/null
+++ b/src/tools/ccsc/Makefile.am
@@ -0,0 +1,8 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libccsc.la
+libccsc_la_LDFLAGS = $(all_libraries)
+libccsc_la_SOURCES = ccsc.cpp ccsc_compile.cpp ccsc_config.cpp
+
+SUBDIRS = gui \ No newline at end of file
diff --git a/src/tools/ccsc/ccsc.cpp b/src/tools/ccsc/ccsc.cpp
new file mode 100644
index 0000000..b28f29a
--- /dev/null
+++ b/src/tools/ccsc/ccsc.cpp
@@ -0,0 +1,106 @@
+/***************************************************************************
+ * Copyright (C) 2006-2007 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 "ccsc.h"
+
+#include <qregexp.h>
+
+#include "ccsc_compile.h"
+#include "ccsc_config.h"
+#include "devices/pic/pic/pic_memory.h"
+#include "devices/list/device_list.h"
+#include "devices/base/device_group.h"
+
+//----------------------------------------------------------------------------
+QStringList CCSC::Base::checkExecutableOptions(bool withWine) const
+{
+ QStringList args;
+ if (withWine) {
+ args += "+STDOUT";
+ args += "+FM";
+ args += static_cast<const Group *>(_group)->checkExecutableUrl().filename();
+ } else args += "+V";
+ return args;
+}
+
+PURL::Directory CCSC::Base::checkExecutableWorkingDirectory() const
+{
+ return static_cast<const Group *>(_group)->checkExecutableUrl().directory();
+}
+
+bool CCSC::Base::checkExecutableResult(bool withWine, QStringList &lines) const
+{
+ if (withWine) {
+ PURL::Url url = static_cast<const Group *>(_group)->checkExecutableUrl().toExtension("err");
+ Log::StringView sview;
+ PURL::File file(url, sview);
+ if ( !file.openForRead() ) {
+ url = static_cast<const Group *>(_group)->checkExecutableUrl().appendExtension("err");
+ file.setUrl(url);
+ if ( !file.openForRead() ) return false;
+ }
+ lines = file.readLines();
+ }
+ return true;
+}
+
+//----------------------------------------------------------------------------
+CCSC::Group::Group()
+ : _checkExecTmp(_sview, ".c")
+{
+ if ( _checkExecTmp.openForWrite() ) _checkExecTmp.appendText("#include <16f877a.h>\nvoid main(void) {}\n");
+ _checkExecTmp.close();
+}
+
+QValueList<const Device::Data *> CCSC::Group::getSupportedDevices(const QString &) const
+{
+ QValueList<const Device::Data *> list;
+ QValueVector<QString> devices = Device::lister().group("pic")->supportedDevices();
+ for (uint i=0; i<devices.count(); i++) {
+ const Device::Data *data = Device::lister().data(devices[i]);
+ Pic::Architecture arch = static_cast<const Pic::Data *>(data)->architecture();
+ if ( arch==Pic::Architecture::P30F || arch==Pic::Architecture::P33F ) continue;
+ list.append(data);
+ }
+ return list;
+}
+
+Compile::Process *CCSC::Group::processFactory(const Compile::Data &data) const
+{
+ switch (data.category.type()) {
+ case Tool::Category::Compiler: return new CCSC::CompileFile;
+ default: break;
+ }
+ Q_ASSERT(false);
+ return 0;
+}
+
+Compile::Config *CCSC::Group::configFactory(::Project *project) const
+{
+ return new Config(project);
+}
+
+QString CCSC::Group::informationText() const
+{
+ return i18n("<a href=\"%1\">CCS Compiler</a> is a C compiler distributed by CCS.").arg("http://www.ccsinfo.com/content.php?page=compilers");
+}
+
+Tool::Group::BaseData CCSC::Group::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Compiler ) return BaseData(new CCSC::Base, Both);
+ return BaseData();
+}
+
+VersionData CCSC::Group::getToolchainVersion()
+{
+ if ( !Compile::Config::withWine(*this) ) {
+ QStringList lines;
+ if ( checkExecutable(Tool::Category::Compiler, lines) && lines.count()>=1 && lines[0].contains("3.") ) return VersionData(3, 0, 0);
+ }
+ return VersionData(4, 0, 0); // default
+}
diff --git a/src/tools/ccsc/ccsc.h b/src/tools/ccsc/ccsc.h
new file mode 100644
index 0000000..aef2005
--- /dev/null
+++ b/src/tools/ccsc/ccsc.h
@@ -0,0 +1,57 @@
+/***************************************************************************
+ * Copyright (C) 2006-2007 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 CCSC_H
+#define CCSC_H
+
+#include "tools/base/tool_group.h"
+#include "common/gui/pfile_ext.h"
+
+namespace CCSC
+{
+//----------------------------------------------------------------------------
+class Base : public Tool::Base
+{
+public:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const { return "ccsc"; }
+
+private:
+ virtual QStringList checkExecutableOptions(bool withWine) const;
+ virtual bool checkExecutableResult(bool withWine, QStringList &lines) const;
+ virtual PURL::Directory checkExecutableWorkingDirectory() const;
+};
+
+//----------------------------------------------------------------------------
+class Group : public Tool::Group
+{
+public:
+ Group();
+ PURL::Url checkExecutableUrl() const { return _checkExecTmp.url(); }
+ virtual QString name() const { return "ccsc"; }
+ virtual QString label() const { return i18n("CCS Compiler"); }
+ virtual QString informationText() const;
+ virtual Tool::Category checkDevicesCategory() const { return Tool::Category::Nb_Types; }
+ virtual Tool::ExecutableType preferedExecutableType() const { return Tool::ExecutableType::Unix; }
+ virtual Tool::CompileType compileType() const { return Tool::SingleFile; }
+ virtual PURL::FileType implementationType(PURL::ToolType type) const { return (type==PURL::ToolType::Compiler ? PURL::CSource : PURL::Nb_FileTypes); }
+
+private:
+ Log::StringView _sview;
+ PURL::TempFile _checkExecTmp;
+
+ 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) const;
+ virtual Tool::SourceGenerator *sourceGeneratorFactory() const { /*TODO*/ return 0; }
+ virtual VersionData getToolchainVersion();
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/ccsc/ccsc_compile.cpp b/src/tools/ccsc/ccsc_compile.cpp
new file mode 100644
index 0000000..56897e8
--- /dev/null
+++ b/src/tools/ccsc/ccsc_compile.cpp
@@ -0,0 +1,107 @@
+/***************************************************************************
+ * 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 "ccsc_compile.h"
+
+#include "ccsc.h"
+#include "common/global/pfile.h"
+#include "ccsc_config.h"
+#include "devices/list/device_list.h"
+#include "devices/pic/base/pic.h"
+
+QString CCSC::CompileFile::familyName() const
+{
+ const Pic::Data *pdata = static_cast<const Pic::Data *>(Device::lister().data(_data.device));
+ switch (pdata->architecture().type()) {
+ case Pic::Architecture::P10X: return "B";
+ case Pic::Architecture::P16X: return "M";
+ case Pic::Architecture::P17C: return "7";
+ case Pic::Architecture::P18C:
+ case Pic::Architecture::P18F:
+ case Pic::Architecture::P18J: return "H";
+ case Pic::Architecture::P24F:
+ case Pic::Architecture::P24H:
+ case Pic::Architecture::P30F:
+ case Pic::Architecture::P33F: break;
+ case Pic::Architecture::Nb_Types: break;
+ }
+ Q_ASSERT(false);
+ return QString::null;
+}
+
+QStringList CCSC::CompileFile::genericArguments(const Compile::Config &config) const
+{
+ bool isVersion3 = ( static_cast<const Group &>(Main::toolGroup()).version().majorNum()==3 );
+ QStringList args;
+ args += "+STDOUT"; // output messages on stdout
+ if ( !isVersion3 ) args += "+EA"; // show all messages and warnings
+ args += "-P"; // close compile windows after compilation done
+ if ( !isVersion3 ) args += "+DF"; // output COFF file
+ args += "+LSlst"; // normal list file
+ args += "+O8hex"; // produce 8bit Intel file
+ if ( !isVersion3 ) args += "+M"; // generate symbol file
+ args += "-J"; // do not create project file
+ args += "-A"; // do not create stat file
+ args += "+F%FAMILY";
+ if ( isVersion3 ) args += config.includeDirs(Tool::Category::Compiler, "I=\"", "\"");
+ else args += config.includeDirs(Tool::Category::Compiler, "I+=\"", "\"");
+ args += config.customOptions(Tool::Category::Compiler);
+ args += "%I";
+ return args;
+}
+
+void CCSC::CompileFile::logStderrLine(const QString &line)
+{
+ // ignore output for wine
+ if ( !Compile::Config::withWine(group()) ) parseLine(line);
+}
+
+void CCSC::CompileFile::parseLine(const QString &line)
+{
+ Log::LineType type;
+ if ( line.startsWith(">>>") ) type = Log::LineType::Warning;
+ else if ( line.startsWith("***") ) type = Log::LineType::Error;
+ else if ( line.startsWith("---") ) type = Log::LineType::Information;
+ else {
+ doLog(Log::LineType::Normal, line, QString::null, 0); // unrecognized
+ return;
+ }
+ if ( parseErrorLine(line, Compile::ParseErrorData("[*>-]+\\s\\w+\\s\\d+\\s\"([^\"]*)\"\\sLine\\s(\\d+)\\([^)]*\\):(.*)", 1, 2, 3, type)) ) return;
+ if ( parseErrorLine(line, Compile::ParseErrorData("[*>-]+\\s\"([^\"]*)\"\\sLine\\s(\\d+):\\s\\w+\\s#\\d+:(.*)", 1, 2, 3, type)) ) return;
+ doLog(type, line, QString::null, 0);
+}
+
+void CCSC::CompileFile::done(int code)
+{
+ // with wine, rely on error file
+ if ( Compile::Config::withWine(group()) ) {
+ PURL::Url url = PURL::Url(directory(), inputFilepath(0)).toExtension("err");
+ Log::StringView sview;
+ PURL::File file(url, sview);
+ if ( !file.openForRead() ) doLog(Log::LineType::Error, i18n("Could not find error file (%1).").arg(url.pretty()), QString::null, 0);
+ else {
+ QStringList lines = file.readLines();
+ for (uint i=0; i<lines.count(); i++) parseLine(lines[i]);
+ }
+ }
+ Compile::Process::done(code);
+}
+
+PURL::Url CCSC::CompileFile::url(PURL::FileType type, uint i) const
+{
+ PURL::Url url;
+ Q_ASSERT( i<_data.items.count() );
+ url = _data.items[i].url;
+ if ( type==PURL::Nb_FileTypes ) return url;
+ return url.toFileType(type);
+}
+
+QString CCSC::CompileFile::outputFiles() const
+{
+ return "PURL::Lst PURL::Hex PURL::Coff PURL::Cod sym err esym occ";
+}
diff --git a/src/tools/ccsc/ccsc_compile.h b/src/tools/ccsc/ccsc_compile.h
new file mode 100644
index 0000000..ddf8f20
--- /dev/null
+++ b/src/tools/ccsc/ccsc_compile.h
@@ -0,0 +1,37 @@
+/***************************************************************************
+ * 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 CCSC_COMPILE_H
+#define CCSC_COMPILE_H
+
+#include "tools/list/compile_process.h"
+
+namespace CCSC
+{
+
+class CompileFile : public Compile::Process
+{
+Q_OBJECT
+protected:
+ virtual QString deviceName() const { return QString::null; }
+ virtual QString familyName() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual void logStderrLine(const QString &line);
+ virtual QString outputFiles() const;
+ virtual PURL::Url url(PURL::FileType type = PURL::Nb_FileTypes, uint i = 0) const;
+
+protected slots:
+ virtual void done(int code);
+
+private:
+ void parseLine(const QString &line);
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/ccsc/ccsc_config.cpp b/src/tools/ccsc/ccsc_config.cpp
new file mode 100644
index 0000000..333bc14
--- /dev/null
+++ b/src/tools/ccsc/ccsc_config.cpp
@@ -0,0 +1,9 @@
+/***************************************************************************
+ * 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 "ccsc_config.h"
diff --git a/src/tools/ccsc/ccsc_config.h b/src/tools/ccsc/ccsc_config.h
new file mode 100644
index 0000000..f4ddef6
--- /dev/null
+++ b/src/tools/ccsc/ccsc_config.h
@@ -0,0 +1,25 @@
+/***************************************************************************
+ * 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 CCSC_CONFIG_H
+#define CCSC_CONFIG_H
+
+#include "tools/list/compile_config.h"
+
+namespace CCSC
+{
+
+class Config : public Compile::Config
+{
+public:
+ Config(Project *project) : Compile::Config(project) {}
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/ccsc/gui/Makefile.am b/src/tools/ccsc/gui/Makefile.am
new file mode 100644
index 0000000..e3703bb
--- /dev/null
+++ b/src/tools/ccsc/gui/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libccscui.la
+libccscui_la_LDFLAGS = $(all_libraries)
+libccscui_la_SOURCES = ccsc_ui.cpp
diff --git a/src/tools/ccsc/gui/ccsc_ui.cpp b/src/tools/ccsc/gui/ccsc_ui.cpp
new file mode 100644
index 0000000..eb2a900
--- /dev/null
+++ b/src/tools/ccsc/gui/ccsc_ui.cpp
@@ -0,0 +1,19 @@
+/***************************************************************************
+ * 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 "ccsc_ui.h"
+
+//----------------------------------------------------------------------------
+CCSC::ConfigWidget::ConfigWidget(Project *project)
+ : ToolConfigWidget(project)
+{}
+
+void CCSC::ConfigWidget::initEntries()
+{
+ if ( _category!=Tool::Category::Linker ) createIncludeDirectoriesEntry();
+}
diff --git a/src/tools/ccsc/gui/ccsc_ui.h b/src/tools/ccsc/gui/ccsc_ui.h
new file mode 100644
index 0000000..356cf22
--- /dev/null
+++ b/src/tools/ccsc/gui/ccsc_ui.h
@@ -0,0 +1,35 @@
+/***************************************************************************
+ * 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 CCSC_UI_H
+#define CCSC_UI_H
+
+#include "tools/gui/tool_config_widget.h"
+#include "tools/gui/tool_group_ui.h"
+
+namespace CCSC
+{
+//----------------------------------------------------------------------------
+class ConfigWidget : public ToolConfigWidget
+{
+Q_OBJECT
+public:
+ ConfigWidget(Project *project);
+ virtual void initEntries();
+};
+
+//----------------------------------------------------------------------------
+class GroupUI : public Tool::GroupUI
+{
+public:
+ virtual ToolConfigWidget *configWidgetFactory(Tool::Category, ::Project *project) const { return new ConfigWidget(project); }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/custom/Makefile.am b/src/tools/custom/Makefile.am
new file mode 100644
index 0000000..2e45534
--- /dev/null
+++ b/src/tools/custom/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libcustom.la
+libcustom_la_LDFLAGS = $(all_libraries)
+libcustom_la_SOURCES = custom.cpp
diff --git a/src/tools/custom/custom.cpp b/src/tools/custom/custom.cpp
new file mode 100644
index 0000000..3779957
--- /dev/null
+++ b/src/tools/custom/custom.cpp
@@ -0,0 +1,23 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 "custom.h"
+
+#include "devices/list/device_list.h"
+#include "devices/base/device_group.h"
+
+QValueList<const Device::Data *> CustomTool::Group::getSupportedDevices(const QString &) const
+{
+ QValueVector<QString> devices = Device::lister().supportedDevices();
+ QValueList<const Device::Data *> list;
+ for (uint i=0; i<devices.count(); i++) {
+ const Device::Data *data = Device::lister().data(devices[i]);
+ list.append(data);
+ }
+ return list;
+}
diff --git a/src/tools/custom/custom.h b/src/tools/custom/custom.h
new file mode 100644
index 0000000..770515a
--- /dev/null
+++ b/src/tools/custom/custom.h
@@ -0,0 +1,38 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 CUSTOM_TOOL_H
+#define CUSTOM_TOOL_H
+
+#include "tools/base/tool_group.h"
+
+namespace CustomTool
+{
+
+class Group : public Tool::Group
+{
+public:
+ virtual QString name() const { return CUSTOM_NAME; }
+ virtual QString label() const { return i18n("Custom"); }
+ virtual QString informationText() const { return QString::null; }
+ virtual Tool::Category checkDevicesCategory() const { return Tool::Category::Nb_Types; }
+ virtual Tool::ExecutableType preferedExecutableType() const { return Tool::ExecutableType::Unix; }
+ virtual Tool::CompileType compileType() const { return Tool::AllFiles; }
+ virtual PURL::FileType implementationType(PURL::ToolType) const { return PURL::Nb_FileTypes; }
+
+protected:
+ virtual BaseData baseFactory(Tool::Category) const { return BaseData(); }
+ virtual QValueList<const Device::Data *> getSupportedDevices(const QString &s) const;
+ virtual Compile::Process *processFactory(const Compile::Data &) const { return 0; }
+ virtual Compile::Config *configFactory(::Project *) const { return 0; }
+ virtual Tool::SourceGenerator *sourceGeneratorFactory() const { return 0; }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/gputils/Makefile.am b/src/tools/gputils/Makefile.am
new file mode 100644
index 0000000..157784c
--- /dev/null
+++ b/src/tools/gputils/Makefile.am
@@ -0,0 +1,9 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libgputils.la
+libgputils_la_LDFLAGS = $(all_libraries)
+libgputils_la_SOURCES = gputils_compile.cpp gputils_config.cpp gputils.cpp \
+ gputils_generator.cpp
+
+SUBDIRS = gui \ No newline at end of file
diff --git a/src/tools/gputils/gputils.cpp b/src/tools/gputils/gputils.cpp
new file mode 100644
index 0000000..3219598
--- /dev/null
+++ b/src/tools/gputils/gputils.cpp
@@ -0,0 +1,107 @@
+/***************************************************************************
+ * Copyright (C) 2005-2007 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * 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 "gputils.h"
+
+#include <qregexp.h>
+
+#include "gputils_compile.h"
+#include "gputils_config.h"
+#include "devices/pic/pic/pic_memory.h"
+#include "common/global/process.h"
+#include "gputils_generator.h"
+
+//----------------------------------------------------------------------------
+QString GPUtils::Base::baseExecutable(bool, Tool::OutputExecutableType) const
+{
+ switch (_category.type()) {
+ case Tool::Category::Assembler: return "gpasm";
+ case Tool::Category::Linker: return "gplink";
+ case Tool::Category::Librarian: return "gplib";
+ default: break;
+ }
+ return QString::null;
+}
+
+bool GPUtils::Base::checkExecutableResult(bool withWine, QStringList &lines) const
+{
+ return ( lines.count()>0 && lines[0].startsWith(baseExecutable(withWine, Tool::OutputExecutableType::Coff)) );
+}
+
+//----------------------------------------------------------------------------
+QString GPUtils::Group::informationText() const
+{
+ return i18n("<a href=\"%1\">GPUtils</a> is an open-source assembler and linker suite.<br>").arg("http://gputils.sourceforge.net");
+}
+
+Tool::Group::BaseData GPUtils::Group::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Assembler ) return BaseData(new ::GPUtils::Base, Both);
+ if ( category==Tool::Category::Linker || category==Tool::Category::Librarian ) return BaseData(new ::GPUtils::Base, ProjectOnly);
+ return BaseData();
+}
+
+PURL::Directory GPUtils::Group::autodetectDirectory(Compile::DirectoryType type, const PURL::Directory &execDir, bool withWine) const
+{
+ switch (type.type()) {
+ case Compile::DirectoryType::LinkerScript: {
+ QString exec = execDir.path() + base(Tool::Category::Linker)->baseExecutable(withWine, Tool::OutputExecutableType::Coff);
+ ::Process::StringOutput process;
+ process.setup(exec, "-h", withWine);
+ if ( ::Process::runSynchronously(process, ::Process::Start, 1000)!=::Process::Exited ) return PURL::Directory();
+ QString s = process.sout() + process.serr();
+ QRegExp re(".*Default linker script path ([^\\n]*)\\n.*");
+ if ( !re.exactMatch(s) ) return PURL::Directory();
+ return PURL::Directory(re.cap(1));
+ }
+ case Compile::DirectoryType::Header: {
+ QString exec = execDir.path() + base(Tool::Category::Assembler)->baseExecutable(withWine, Tool::OutputExecutableType::Coff);
+ ::Process::StringOutput process;
+ process.setup(exec, "-h", withWine);
+ if ( ::Process::runSynchronously(process, ::Process::Start, 1000)!=::Process::Exited ) return PURL::Directory();
+ QString s = process.sout() + process.serr();
+ QRegExp re(".*Default header file path ([^\\n]*)\\n.*");
+ if ( !re.exactMatch(s) ) return PURL::Directory();
+ return PURL::Directory(re.cap(1));
+ }
+ case Compile::DirectoryType::Executable:
+ case Compile::DirectoryType::Library:
+ case Compile::DirectoryType::Source:
+ case Compile::DirectoryType::Nb_Types: break;
+ }
+ return PURL::Directory();
+}
+
+Compile::Process *GPUtils::Group::processFactory(const Compile::Data &data) const
+{
+ switch (data.category.type()) {
+ case Tool::Category::Assembler:
+ if (data.project) return new GPUtils::AssembleProjectFile;
+ return new GPUtils::AssembleStandaloneFile;
+ case Tool::Category::Linker:
+ Q_ASSERT(data.project);
+ return new GPUtils::LinkProject;
+ case Tool::Category::Librarian:
+ Q_ASSERT(data.project);
+ return new GPUtils::LibraryProject;
+ default: break;
+ }
+ Q_ASSERT(false);
+ return 0;
+}
+
+Compile::Config *GPUtils::Group::configFactory(::Project *project) const
+{
+ return new Config(project);
+}
+
+Tool::SourceGenerator *GPUtils::Group::sourceGeneratorFactory() const
+{
+ return new SourceGenerator;
+}
diff --git a/src/tools/gputils/gputils.h b/src/tools/gputils/gputils.h
new file mode 100644
index 0000000..b8bcded
--- /dev/null
+++ b/src/tools/gputils/gputils.h
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * Copyright (C) 2005-2007 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 GPUTILS_H
+#define GPUTILS_H
+
+#include "tools/base/tool_group.h"
+#include "gputils_generator.h"
+
+namespace GPUtils
+{
+//----------------------------------------------------------------------------
+class Base : public Tool::Base
+{
+public:
+ virtual QString baseExecutable(bool withWine, Tool::OutputExecutableType type) const;
+
+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 "gputils"; }
+ virtual QString label() const { return i18n("GPUtils"); }
+ virtual QString informationText() const;
+ virtual Tool::Category checkDevicesCategory() const { return Tool::Category::Assembler; }
+ virtual QStringList checkDevicesOptions(uint) const { return "-l"; }
+ virtual PURL::Directory autodetectDirectory(Compile::DirectoryType type, const PURL::Directory &execDir, bool withWine) const;
+ virtual bool hasDirectory(Compile::DirectoryType type) const { return type==Compile::DirectoryType::Header || type==Compile::DirectoryType::LinkerScript; }
+ virtual PURL::FileType linkerScriptType() const { return PURL::Lkr; }
+ virtual Tool::ExecutableType preferedExecutableType() const { return Tool::ExecutableType::Unix; }
+ virtual Tool::CompileType compileType() const { return Tool::SeparateFiles; }
+ virtual PURL::FileType implementationType(PURL::ToolType type) const { return (type==PURL::ToolType::Assembler ? PURL::AsmGPAsm : PURL::Nb_FileTypes); }
+
+protected:
+ virtual BaseData baseFactory(Tool::Category c) const;
+ virtual QValueList<const Device::Data *> getSupportedDevices(const QString &s) const { return GPUtils::getSupportedDevices(s); }
+ virtual Compile::Process *processFactory(const Compile::Data &data) const;
+ virtual Compile::Config *configFactory(::Project *project) const;
+ virtual Tool::SourceGenerator *sourceGeneratorFactory() const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/gputils/gputils_compile.cpp b/src/tools/gputils/gputils_compile.cpp
new file mode 100644
index 0000000..c59828c
--- /dev/null
+++ b/src/tools/gputils/gputils_compile.cpp
@@ -0,0 +1,109 @@
+/***************************************************************************
+ * Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * 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 "gputils_compile.h"
+
+#include "gputils.h"
+#include "gputils_config.h"
+#include "devices/list/device_list.h"
+#include "coff/base/disassembler.h"
+
+//-----------------------------------------------------------------------------
+QString GPUtils::Process::deviceName() const
+{
+ return toDeviceName(_data.device);
+}
+
+//-----------------------------------------------------------------------------
+void GPUtils::AssembleFile::logStderrLine(const QString &line)
+{
+ if ( parseErrorLine(line, Compile::ParseErrorData("([^:]*):([0-9]+):(.+)\\[[0-9]+\\](.+)", 1, 2, 4, 3)) ) return;
+ if ( parseErrorLine(line, Compile::ParseErrorData("([^:]*):([^:]+):([0-9]+):(.+)", 2, 3, 4, Log::LineType::Warning)) ) return;
+ doLog(Log::LineType::Normal, line, QString::null, 0); // unrecognized
+}
+
+//-----------------------------------------------------------------------------
+QStringList GPUtils::AssembleStandaloneFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "-L"; // force list
+ args += "-o%O";
+ uint wl = static_cast<const Config &>(config).gpasmWarningLevel();
+ if ( wl!=Config::Nb_WarningLevels ) args += "-w" + QString::number(wl);
+ args += config.includeDirs(Tool::Category::Assembler, "-I");
+ args += "$NO_AUTO_DEVICE(-p%DEVICE)";
+ HexBuffer::Format format = config.hexFormat();
+ if( format!=HexBuffer::Nb_Formats ) args += QString("-a") + HexBuffer::FORMATS[format];
+ args += config.customOptions(Tool::Category::Assembler);
+ args += "%I";
+ return args;
+}
+
+QString GPUtils::AssembleStandaloneFile::outputFiles() const
+{
+ return "PURL::Lst PURL::Cod PURL::Hex";
+}
+
+//-----------------------------------------------------------------------------
+QStringList GPUtils::AssembleProjectFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "-c"; // relocatable code
+ args += config.includeDirs(Tool::Category::Assembler, "-I");
+ if ( !_data.items[0].generated ) args += "-p%DEVICE";
+ uint wl = static_cast<const Config &>(config).gpasmWarningLevel() ;
+ if( wl!=Config::Nb_WarningLevels ) args += "-w" + QString::number(wl);
+ args += config.customOptions(Tool::Category::Assembler);
+ args += "%I";
+ return args;
+}
+
+QString GPUtils::AssembleProjectFile::outputFiles() const
+{
+ return "PURL::Object PURL::Lst";
+}
+
+//-----------------------------------------------------------------------------
+QStringList GPUtils::LinkProject::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "-o%O";
+ args += "-c"; // create coff file
+ HexBuffer::Format f = config.hexFormat();
+ if ( f!=HexBuffer::Nb_Formats ) args += QString("-a") + HexBuffer::FORMATS[f];
+ args += "-m"; // with map
+ args += config.includeDirs(Tool::Category::Linker, "-I");
+ args += "$LKR(-s%LKR)";
+ args += config.customOptions(Tool::Category::Linker);
+ args += "%OBJS";
+ args += "%LIBS";
+ return args;
+}
+
+QString GPUtils::LinkProject::outputFiles() const
+{
+ return "PURL::Lkr PURL::Map PURL::Lst PURL::Cod PURL::Coff PURL::Hex";
+}
+
+//-----------------------------------------------------------------------------
+QStringList GPUtils::LibraryProject::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "-c"; // create archive
+ args += "%O";
+ args += config.customOptions(Tool::Category::Librarian);
+ args += "%OBJS";
+ args += "%LIBS";
+ return args;
+}
+
+QString GPUtils::LibraryProject::outputFiles() const
+{
+ return "PURL::Library";
+}
diff --git a/src/tools/gputils/gputils_compile.h b/src/tools/gputils/gputils_compile.h
new file mode 100644
index 0000000..a6a09c9
--- /dev/null
+++ b/src/tools/gputils/gputils_compile.h
@@ -0,0 +1,73 @@
+/***************************************************************************
+ * Copyright (C) 2005-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 GPUTILS_COMPILE_H
+#define GPUTILS_COMPILE_H
+
+#include "tools/list/compile_process.h"
+
+namespace GPUtils
+{
+//-----------------------------------------------------------------------------
+class Process : public Compile::Process
+{
+Q_OBJECT
+private:
+ virtual QString deviceName() const;
+ virtual bool hasLinkerScript() const { return ( _data.linkType==Compile::Icd2Linking || Compile::Process::hasLinkerScript() ); }
+};
+
+//-----------------------------------------------------------------------------
+class AssembleFile : public Process
+{
+Q_OBJECT
+private:
+ virtual void logStderrLine(const QString &line);
+};
+
+//-----------------------------------------------------------------------------
+class AssembleStandaloneFile : public AssembleFile
+{
+Q_OBJECT
+private:
+ virtual QString outputFiles() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class AssembleProjectFile : public AssembleFile
+{
+Q_OBJECT
+private:
+ virtual QString outputFiles() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class LinkProject : public Process
+{
+Q_OBJECT
+private:
+ virtual QString outputFiles() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual void logStderrLine(const QString &line) { doLog(filterType(line), line, QString::null, 0); }
+};
+
+//-----------------------------------------------------------------------------
+class LibraryProject : public Process
+{
+Q_OBJECT
+private:
+ virtual QString outputFiles() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual void logStderrLine(const QString &line) { doLog(filterType(line), line, QString::null, 0); }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/gputils/gputils_config.cpp b/src/tools/gputils/gputils_config.cpp
new file mode 100644
index 0000000..8f7bca2
--- /dev/null
+++ b/src/tools/gputils/gputils_config.cpp
@@ -0,0 +1,19 @@
+/***************************************************************************
+ * Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * 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 "gputils_config.h"
+
+const char * const GPUtils::Config::WARNING_LEVEL_LABELS[Nb_WarningLevels] = {
+ I18N_NOOP("All messages"), I18N_NOOP("Warning and errors"), I18N_NOOP("Errors only")
+};
+
+uint GPUtils::Config::gpasmWarningLevel() const
+{
+ return QMIN(warningLevel(Tool::Category::Assembler), uint(Nb_WarningLevels));
+}
diff --git a/src/tools/gputils/gputils_config.h b/src/tools/gputils/gputils_config.h
new file mode 100644
index 0000000..cdaa66e
--- /dev/null
+++ b/src/tools/gputils/gputils_config.h
@@ -0,0 +1,30 @@
+/***************************************************************************
+ * Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * 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 GPUTILS_CONFIG_H
+#define GPUTILS_CONFIG_H
+
+#include "tools/list/compile_config.h"
+
+namespace GPUtils
+{
+
+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 gpasmWarningLevel() const;
+ void setGPAsmWarningLevel(uint level) { setWarningLevel(Tool::Category::Assembler, level); }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/gputils/gputils_generator.cpp b/src/tools/gputils/gputils_generator.cpp
new file mode 100644
index 0000000..3bcebac
--- /dev/null
+++ b/src/tools/gputils/gputils_generator.cpp
@@ -0,0 +1,256 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 "gputils_generator.h"
+
+#include "devices/pic/pic/pic_memory.h"
+#include "devices/pic/base/pic_register.h"
+#include "devices/list/device_list.h"
+
+//----------------------------------------------------------------------------
+QValueList<const Device::Data *> GPUtils::getSupportedDevices(const QString &s)
+{
+ QStringList devices = QStringList::split(' ', s.simplifyWhiteSpace().upper());
+ QValueList<const Device::Data *> list;
+ for (uint i=0; i<devices.count(); i++) {
+ QString name = devices[i];
+ if ( devices[i].startsWith("P1") ) name = name.mid(1);
+ const Device::Data *data = Device::lister().data(name);
+ if (data) list.append(data);
+ }
+ return list;
+}
+
+//----------------------------------------------------------------------------
+SourceLine::List GPUtils::SourceGenerator::configLines(PURL::ToolType, const Device::Memory &memory, bool &ok) const
+{
+ return GPUtils::generateConfigLines(static_cast<const Pic::Memory &>(memory), ok);
+}
+
+SourceLine::List GPUtils::SourceGenerator::includeLines(PURL::ToolType, const Device::Data &data) const
+{
+ return GPUtils::includeLines(data);
+}
+
+SourceLine::List GPUtils::SourceGenerator::sourceFileContent(PURL::ToolType, const Device::Data &data, bool &ok) const
+{
+ ok = true;
+ SourceLine::List lines;
+ lines.appendSeparator();
+ const Pic::Data &pdata = static_cast<const Pic::Data &>(data);
+ const Pic::RegistersData &rdata = static_cast<const Pic::RegistersData &>(*data.registersData());
+ switch (pdata.architecture().type()) {
+ case Pic::Architecture::P10X:
+ lines.appendTitle(i18n("relocatable code"));
+ lines.appendNotIndentedCode("PROG CODE");
+ lines.appendNotIndentedCode("start");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert code") + " >>");
+ lines.appendIndentedCode("goto $", i18n("loop forever"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("END");
+ break;
+ case Pic::Architecture::P16X: {
+ lines.appendTitle(i18n("Variables declaration"));
+ bool needPCLATH = ( pdata.nbWords(Pic::MemoryRangeType::Code)>0x400 );
+ uint first;
+ bool allShared;
+ bool hasShared = rdata.hasSharedGprs(first, allShared);
+ if ( hasShared && !allShared ) lines.appendNotIndentedCode("INT_VAR UDATA_SHR");
+ else {
+ first = rdata.firstGprIndex();
+ lines.appendNotIndentedCode("INT_VAR UDATA " + toHexLabel(first, rdata.nbCharsAddress()));
+ }
+ lines.appendNotIndentedCode("w_saved RES 1", i18n("variable used for context saving"));
+ lines.appendNotIndentedCode("status_saved RES 1", i18n("variable used for context saving"));
+ first += 2;
+ if (needPCLATH) {
+ lines.appendNotIndentedCode("pclath_saved RES 1", i18n("variable used for context saving"));
+ first++;
+ }
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("var1 RES 1", i18n("example variable"));
+ if ( !hasShared ) {
+ for (uint i=1; i<rdata.nbBanks; i++) {
+ uint address = first + i*rdata.nbBytesPerBank();
+ lines.appendNotIndentedCode(QString("INT_VAR%1 UDATA ").arg(i) + toHexLabel(address, rdata.nbCharsAddress()), i18n("variables used for context saving"));
+ lines.appendNotIndentedCode(QString("w_saved%1 RES 1").arg(i), i18n("variable used for context saving"));
+ }
+ }
+ lines.appendEmpty();
+ lines.appendSeparator();
+ lines.appendTitle(i18n("reset vector"));
+ lines.appendNotIndentedCode("STARTUP CODE 0x000");
+ lines.appendIndentedCode("nop", i18n("needed for ICD2 debugging"));
+ lines.appendIndentedCode("movlw high start", i18n("load upper byte of 'start' label"));
+ lines.appendIndentedCode("movwf PCLATH", i18n("initialize PCLATH"));
+ lines.appendIndentedCode("goto start", i18n("go to start of main code"));
+ lines.appendEmpty();
+ lines.appendTitle(i18n("interrupt vector"));
+ lines.appendNotIndentedCode("INT_VECTOR CODE 0x004");
+ lines.appendIndentedCode("goto interrupt", i18n("go to start of interrupt code"));
+ lines.appendEmpty();
+ lines.appendTitle(i18n("relocatable code"));
+ lines.appendNotIndentedCode("PROG CODE");
+ lines.appendNotIndentedCode("interrupt");
+ lines.appendIndentedCode("movwf w_saved", i18n("save context"));
+ lines.appendIndentedCode("swapf STATUS,w");
+ if ( !hasShared ) lines.appendIndentedCode("clrf STATUS");
+ lines.appendIndentedCode("movwf status_saved");
+ if (needPCLATH) {
+ lines.appendIndentedCode("movf PCLATH,w", i18n("only required if using more than first page"));
+ lines.appendIndentedCode("movwf pclath_saved");
+ lines.appendIndentedCode("clrf PCLATH");
+ }
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert interrupt code") + " >>");
+ if (needPCLATH) {
+ lines.appendIndentedCode("movf pclath_saved,w", i18n("restore context"));
+ lines.appendIndentedCode("movwf PCLATH");
+ lines.appendIndentedCode("swapf status_saved,w");
+ } else lines.appendIndentedCode("swapf status_saved,w", i18n("restore context"));
+ lines.appendIndentedCode("movwf STATUS");
+ lines.appendIndentedCode("swapf w_saved,f");
+ lines.appendIndentedCode("swapf w_saved,w");
+ lines.appendIndentedCode("retfie");
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("start");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert main code") + " >>");
+ lines.appendIndentedCode("goto $", i18n("loop forever"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("END");
+ break;
+ }
+ case Pic::Architecture::P17C:
+ lines.appendTitle(i18n("Variables declaration"));
+ lines.appendNotIndentedCode("INT_VAR UDATA " + toHexLabel(rdata.accessBankSplit, rdata.nbCharsAddress()));
+ lines.appendNotIndentedCode("wred_saved RES 1", i18n("variable used for context saving (for low-priority interrupts only)"));
+ lines.appendNotIndentedCode("alusta_saved RES 1", i18n("variable used for context saving (for low-priority interrupts only)"));
+ lines.appendNotIndentedCode("bsr_saved RES 1", i18n("variable used for context saving (for low-priority interrupts only)"));
+ lines.appendNotIndentedCode("pclath_saved RES 1", i18n("variable used for context saving (for low-priority interrupts only)"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("var1 RES 1", i18n("example variable"));
+ lines.appendEmpty();
+ lines.appendSeparator();
+ lines.appendTitle(i18n("Macros"));
+ lines.appendNotIndentedCode("PUSH MACRO", i18n("for saving context"));
+ lines.appendIndentedCode("movpf WREG,wred_saved");
+ lines.appendIndentedCode("movpf ALUSTA,alusta_saved");
+ lines.appendIndentedCode("movpf BSR,bsr_saved");
+ lines.appendIndentedCode("movpf PCLATH,pclath_saved");
+ lines.appendIndentedCode("ENDM");
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("POP MACRO", i18n("for restoringing context"));
+ lines.appendIndentedCode("movfp pclath_saved,PCLATH");
+ lines.appendIndentedCode("movfp bsr_saved,BSR");
+ lines.appendIndentedCode("movfp alusta_saved,ALUSTA");
+ lines.appendIndentedCode("movfp wred_saved,WREG");
+ lines.appendIndentedCode("ENDM");
+ lines.appendSeparator();
+ lines.appendTitle(i18n("reset vector"));
+ lines.appendNotIndentedCode("STARTUP CODE 0x0000");
+ lines.appendIndentedCode("nop", i18n("needed for ICD2 debugging"));
+ lines.appendIndentedCode("nop", i18n("needed for ICD2 debugging"));
+ lines.appendIndentedCode("goto start", i18n("go to start of main code"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("INT_PIN_VECTOR CODE 0x0008");
+ lines.appendIndentedCode("PUSH");
+ lines.appendIndentedCode("goto int_pin_isr", i18n("go to start of int pin interrupt code"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("TIMER0_VECTOR CODE 0x0010");
+ lines.appendIndentedCode("PUSH");
+ lines.appendIndentedCode("goto timer0_isr", i18n("go to start of timer0 interrupt code"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("T0CKI_VECTOR CODE 0x00018");
+ lines.appendIndentedCode("PUSH");
+ lines.appendIndentedCode("goto t0cki_isr", i18n("go to start of t0cki interrupt code"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("PERIPHERAL_VECTOR CODE 0x0020");
+ lines.appendIndentedCode("PUSH");
+ lines.appendIndentedCode("goto peripheral_isr", i18n("go to start of peripheral interrupt code"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("start:");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert main code") + " >>");
+ lines.appendIndentedCode("goto $", i18n("loop forever"));
+ lines.appendEmpty();
+ lines.appendTitle(i18n("INT pin interrupt service routine"));
+ lines.appendNotIndentedCode("int_pin_isr:");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert INT pin interrupt code") + " >>");
+ lines.appendIndentedCode("POP");
+ lines.appendIndentedCode("retfie");
+ lines.appendEmpty();
+ lines.appendTitle(i18n("TIMER0 interrupt service routine"));
+ lines.appendNotIndentedCode("timer0_isr:");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert TIMER0 interrupt code") + " >>");
+ lines.appendIndentedCode("POP");
+ lines.appendIndentedCode("retfie");
+ lines.appendEmpty();
+ lines.appendTitle(i18n("T0CKI interrupt service routine"));
+ lines.appendNotIndentedCode("t0cki_isr:");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert T0CKI interrupt code") + " >>");
+ lines.appendIndentedCode("POP");
+ lines.appendIndentedCode("retfie");
+ lines.appendEmpty();
+ lines.appendTitle(i18n("peripheral interrupt service routine"));
+ lines.appendNotIndentedCode("peripheral_isr:");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert peripheral interrupt code") + " >>");
+ lines.appendIndentedCode("POP");
+ lines.appendIndentedCode("retfie");
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("END");
+ break;
+ case Pic::Architecture::P18C:
+ case Pic::Architecture::P18F:
+ case Pic::Architecture::P18J: // ??
+ lines.appendTitle(i18n("Variables declaration"));
+ lines.appendNotIndentedCode("INT_VAR UDATA " + toHexLabel(rdata.accessBankSplit, rdata.nbCharsAddress()));
+ lines.appendNotIndentedCode("w_saved RES 1", i18n("variable used for context saving (for low-priority interrupts only)"));
+ lines.appendNotIndentedCode("status_saved RES 1", i18n("variable used for context saving (for low-priority interrupts only)"));
+ lines.appendNotIndentedCode("bsr_saved RES 1", i18n("variable used for context saving (for low-priority interrupts only)"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("var1 RES 1", i18n("example variable"));
+ lines.appendEmpty();
+ lines.appendSeparator();
+ lines.appendTitle(i18n("reset vector"));
+ lines.appendNotIndentedCode("STARTUP CODE 0x0000");
+ lines.appendIndentedCode("nop", i18n("needed for ICD2 debugging"));
+ lines.appendIndentedCode("nop", i18n("needed for ICD2 debugging"));
+ lines.appendIndentedCode("goto start", i18n("go to start of main code"));
+ lines.appendEmpty();
+ lines.appendTitle(i18n("high priority interrupt vector"));
+ lines.appendNotIndentedCode("HIGH_INT_VECTOR CODE 0x0008");
+ lines.appendIndentedCode("bra high_interrupt", i18n("go to start of high priority interrupt code"));
+ lines.appendEmpty();
+ lines.appendTitle(i18n("low priority interrupt vector"));
+ lines.appendNotIndentedCode("LOW_INT_VECTOR CODE 0x0018");
+ lines.appendIndentedCode("movff STATUS,status_saved", i18n("save context"));
+ lines.appendIndentedCode("movff WREG,w_saved");
+ lines.appendIndentedCode("movff BSR,bsr_saved");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert low priority interrupt code") + " >>");
+ lines.appendIndentedCode("movff bsr_saved,BSR", i18n("restore context"));
+ lines.appendIndentedCode("movff w_saved,WREG");
+ lines.appendIndentedCode("movff status_saved,STATUS");
+ lines.appendIndentedCode("retfie");
+ lines.appendEmpty();
+ lines.appendTitle(i18n("high priority interrupt service routine"));
+ lines.appendNotIndentedCode("high_interrupt:");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert high priority interrupt code") + " >>");
+ lines.appendIndentedCode("retfie FAST");
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("start:");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert main code") + " >>");
+ lines.appendIndentedCode("goto $", i18n("loop forever"));
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("END");
+ break;
+ case Pic::Architecture::P24F:
+ case Pic::Architecture::P24H:
+ case Pic::Architecture::P30F:
+ case Pic::Architecture::P33F: ok = false; break;
+ case Pic::Architecture::Nb_Types: Q_ASSERT(false); break;
+ }
+ return lines;
+}
diff --git a/src/tools/gputils/gputils_generator.h b/src/tools/gputils/gputils_generator.h
new file mode 100644
index 0000000..38da66d
--- /dev/null
+++ b/src/tools/gputils/gputils_generator.h
@@ -0,0 +1,29 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 GPUTILS_GENERATOR_H
+#define GPUTILS_GENERATOR_H
+
+#include "coff/base/disassembler.h"
+
+namespace GPUtils
+{
+
+extern QValueList<const Device::Data *> getSupportedDevices(const QString &s);
+
+class SourceGenerator : public Tool::SourceGenerator
+{
+public:
+ virtual SourceLine::List configLines(PURL::ToolType type, const Device::Memory &memory, bool &ok) const;
+ virtual SourceLine::List sourceFileContent(PURL::ToolType type, const Device::Data &data, bool &ok) const;
+ virtual SourceLine::List includeLines(PURL::ToolType type, const Device::Data &data) const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/gputils/gui/Makefile.am b/src/tools/gputils/gui/Makefile.am
new file mode 100644
index 0000000..0ac81c9
--- /dev/null
+++ b/src/tools/gputils/gui/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libgputilsui.la
+libgputilsui_la_LDFLAGS = $(all_libraries)
+libgputilsui_la_SOURCES = gputils_ui.cpp
diff --git a/src/tools/gputils/gui/gputils_ui.cpp b/src/tools/gputils/gui/gputils_ui.cpp
new file mode 100644
index 0000000..35cdce8
--- /dev/null
+++ b/src/tools/gputils/gui/gputils_ui.cpp
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * 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 "gputils_ui.h"
+
+#include <qlabel.h>
+#include "tools/gputils/gputils_config.h"
+
+//----------------------------------------------------------------------------
+GPUtils::ConfigWidget::ConfigWidget(Project *project)
+ : ToolConfigWidget(project), _gpasmWarning(0)
+{}
+
+void GPUtils::ConfigWidget::initEntries()
+{
+ if ( _category==Tool::Category::Assembler ) {
+ uint row = container()->numRows();
+ QLabel *label = new QLabel(i18n("Warning level:"), container());
+ container()->addWidget(label, row,row, 0,0);
+ _gpasmWarning = new QComboBox(container());
+ connect(_gpasmWarning, SIGNAL(activated(int)), SIGNAL(changed()));
+ for (uint i=0; i<GPUtils::Config::Nb_WarningLevels; i++)
+ _gpasmWarning->insertItem(i18n(GPUtils::Config::WARNING_LEVEL_LABELS[i]));
+ _gpasmWarning->insertItem(i18n("as in LIST directive"));
+ container()->addWidget(_gpasmWarning, row,row, 1,1);
+ createIncludeDirectoriesEntry();
+ if ( _project==0 ) createHexFormatEntry();
+ }
+ if ( _category==Tool::Category::Linker ) {
+ createHexFormatEntry();
+ createIncludeDirectoriesEntry();
+ }
+}
+
+void GPUtils::ConfigWidget::loadConfig(const Compile::Config &config)
+{
+ ToolConfigWidget::loadConfig(config);
+ if ( _category==Tool::Category::Assembler )
+ _gpasmWarning->setCurrentItem(static_cast<const Config &>(config).gpasmWarningLevel());
+}
+
+void GPUtils::ConfigWidget::saveConfig(Compile::Config &config) const
+{
+ ToolConfigWidget::saveConfig(config);
+ if ( _category==Tool::Category::Assembler )
+ static_cast<Config &>(config).setGPAsmWarningLevel(_gpasmWarning->currentItem());
+}
diff --git a/src/tools/gputils/gui/gputils_ui.h b/src/tools/gputils/gui/gputils_ui.h
new file mode 100644
index 0000000..8d6daea
--- /dev/null
+++ b/src/tools/gputils/gui/gputils_ui.h
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * 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 GPUTILS_UI_H
+#define GPUTILS_UI_H
+
+#include "tools/gui/tool_config_widget.h"
+#include "tools/gui/tool_group_ui.h"
+
+namespace GPUtils
+{
+//----------------------------------------------------------------------------
+class ConfigWidget : public ToolConfigWidget
+{
+Q_OBJECT
+public:
+ ConfigWidget(Project *project);
+ virtual void initEntries();
+
+protected:
+ QComboBox *_gpasmWarning;
+ 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
diff --git a/src/tools/gui/Makefile.am b/src/tools/gui/Makefile.am
new file mode 100644
index 0000000..0d582eb
--- /dev/null
+++ b/src/tools/gui/Makefile.am
@@ -0,0 +1,7 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libtoolui.la
+libtoolui_la_LDFLAGS = $(all_libraries)
+libtoolui_la_SOURCES = tool_group_ui.cpp toolchain_config_widget.cpp \
+ tool_config_widget.cpp toolchain_config_center.cpp
diff --git a/src/tools/gui/tool_config_widget.cpp b/src/tools/gui/tool_config_widget.cpp
new file mode 100644
index 0000000..308e61b
--- /dev/null
+++ b/src/tools/gui/tool_config_widget.cpp
@@ -0,0 +1,181 @@
+/***************************************************************************
+ * Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * 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 "tool_config_widget.h"
+
+#include <qtooltip.h>
+#include <qwidgetstack.h>
+#include <qvgroupbox.h>
+#include <klocale.h>
+
+#include "devices/base/hex_buffer.h"
+#include "tools/list/compile_config.h"
+#include "libgui/project.h"
+#include "common/gui/purl_gui.h"
+#include "tools/list/compile_process.h"
+
+const char * const ToolConfigWidget::ARGUMENTS_TYPE_LABELS[Nb_ArgumentsTypes] = {
+ I18N_NOOP("Automatic"), I18N_NOOP("Custom")
+};
+
+ToolConfigWidget::ToolConfigWidget(Project *project)
+ : ::ConfigWidget(0), _group(0), _project(project),
+ _customOptions(0), _customLibraries(0), _includeDirs(0), _hexFormat(0),
+ _config(0), _tmpConfig(0), _process(0), _tmpProject(0)
+{
+
+ Container *container = new Container(this);
+ container->setColStretch(2, 1);
+ addWidget(container, 0,0, 0,0);
+ QLabel *label = new QLabel(i18n("Configuration:"), container);
+ container->addWidget(label, 0,0, 0,0);
+ _argumentsType = new KComboBox(container);
+ for (uint i=0; i<Nb_ArgumentsTypes; i++)
+ _argumentsType->insertItem(i18n(ARGUMENTS_TYPE_LABELS[i]), i);
+ connect(_argumentsType, SIGNAL(activated(int)), SLOT(updateArguments()));
+ container->addWidget(_argumentsType, 0,0, 1,1);
+ label = new QLabel(i18n("Arguments:"), container);
+ container->addWidget(label, 1,1, 0,0);
+ _arguments = new KLineEdit(container);
+ _arguments->setReadOnly(true);
+ container->addWidget(_arguments, 1,1, 1,2);
+ KPushButton *button = new KPushButton(KGuiItem(QString::null, "help"), container);
+ connect(button, SIGNAL(clicked()), SIGNAL(displayHelp()));
+ container->addWidget(button, 1,1, 3,3);
+ _argumentsEditor = new EditListBox(1, container, "arguments_editor", EditListBox::DuplicatesAllowed,
+ EditListBox::Add | EditListBox::Remove | EditListBox::UpDown | EditListBox::RemoveAll | EditListBox::Reset);
+ connect(_argumentsEditor, SIGNAL(changed()), SLOT(updateArguments()));
+ connect(_argumentsEditor, SIGNAL(reset()), SLOT(resetCustomArguments()));
+ container->addWidget(_argumentsEditor, 2,2, 0,3);
+
+ _container = new Container(container);
+ _container->setColStretch(2, 1);
+ container->addWidget(_container, 3,3, 0,3);
+
+ connect(this, SIGNAL(changed()), SLOT(updateArguments()));
+}
+
+void ToolConfigWidget::init(Tool::Category category, const Tool::Group &group)
+{
+ _category = category;
+ _group = &group;
+ _config = _group->createConfig(_project);
+ _tmpProject = new Project(PURL::Url());
+ _tmpConfig = _group->createConfig(_tmpProject);
+ Compile::Data data(_category, QValueList<Compile::TodoItem>(), QString::null, _project, Compile::NormalLinking);
+ _process = _group->createCompileProcess(data, 0);
+
+ initEntries();
+ createCustomOptionsEntry();
+}
+
+ToolConfigWidget::~ToolConfigWidget()
+{
+ delete _process;
+ delete _tmpConfig;
+ delete _tmpProject;
+ delete _config;
+}
+
+PURL::DirectoriesWidget *ToolConfigWidget::createDirectoriesEntry(const QString &text)
+{
+ uint row = container()->numRows();
+ PURL::DirectoriesWidget *sdw = new PURL::DirectoriesWidget(text, _project ? _project->directory().path() : QString::null, container());
+ connect(sdw, SIGNAL(changed()), SIGNAL(changed()));
+ container()->addWidget(sdw, row,row, 0,2);
+ return sdw;
+}
+
+void ToolConfigWidget::createCustomOptionsEntry()
+{
+ uint row = container()->numRows();
+ QLabel *label = new QLabel(i18n("Custom options:"), container());
+ container()->addWidget(label, row,row, 0,0);
+ _customOptions = new QLineEdit(container());
+ connect(_customOptions, SIGNAL(textChanged(const QString &)), SIGNAL(changed()));
+ container()->addWidget(_customOptions, row,row, 1,2);
+}
+
+void ToolConfigWidget::createCustomLibrariesEntry()
+{
+ uint row = container()->numRows();
+ QLabel *label = new QLabel(i18n("Custom libraries:"), container());
+ container()->addWidget(label, row,row, 0,0);
+ _customLibraries = new QLineEdit(container());
+ connect(_customLibraries, SIGNAL(textChanged(const QString &)), SIGNAL(changed()));
+ QToolTip::add(_customLibraries, i18n("<qt>This values will be placed after the linked objects.</qt>")) ;
+ container()->addWidget(_customLibraries, row,row, 1,2);
+}
+
+void ToolConfigWidget::createHexFormatEntry()
+{
+ uint row = container()->numRows();
+ QLabel *label = new QLabel(i18n("Hex file format:"), container());
+ container()->addWidget(label, row,row, 0,0);
+ _hexFormat = new QComboBox(container());
+ connect(_hexFormat, SIGNAL(activated(int)), SIGNAL(changed()));
+ for (uint i=0; i<HexBuffer::Nb_Formats; i++)
+ _hexFormat->insertItem(HexBuffer::FORMATS[i]);
+ _hexFormat->insertItem(i18n("as in LIST directive"));
+ container()->addWidget(_hexFormat, row,row, 1,1);
+}
+
+void ToolConfigWidget::loadConfig()
+{
+ loadConfig(*_config);
+ if ( _config->customArguments(_category).isEmpty() ) resetCustomArguments();
+ else updateArguments();
+}
+
+void ToolConfigWidget::resetCustomArguments()
+{
+ _argumentsEditor->setTexts(arguments(AutomaticArguments));
+ updateArguments();
+}
+
+void ToolConfigWidget::loadConfig(const Compile::Config &config)
+{
+ _argumentsType->setCurrentItem(config.hasCustomArguments(_category) ? CustomArguments : AutomaticArguments);
+ _argumentsEditor->setTexts(config.customArguments(_category));
+ if (_includeDirs) _includeDirs->setDirectories(config.rawIncludeDirs(_category)) ;
+ if (_customOptions) _customOptions->setText(config.rawCustomOptions(_category));
+ if (_customLibraries) _customLibraries->setText(config.rawCustomLibraries(_category));
+ if (_hexFormat) _hexFormat->setCurrentItem(config.hexFormat());
+}
+
+void ToolConfigWidget::saveConfig(Compile::Config &config) const
+{
+ config.setHasCustomArguments(_category, _argumentsType->currentItem()==CustomArguments);
+ config.setCustomArguments(_category, _argumentsEditor->texts());
+ if (_includeDirs) config.setRawIncludeDirs(_category, _includeDirs->directories());
+ if (_customOptions) config.setRawCustomOptions(_category, _customOptions->text());
+ if (_customLibraries) config.setRawCustomLibraries(_category, _customLibraries->text());
+ if (_hexFormat) config.setHexFormat(HexBuffer::Format(_hexFormat->currentItem()));
+}
+
+QStringList ToolConfigWidget::arguments(ArgumentsType type) const
+{
+ if ( _tmpConfig==0 ) return QStringList();
+ saveConfig(*_tmpConfig);
+ if ( type==AutomaticArguments ) return _process->genericArguments(*_tmpConfig);
+ return _argumentsEditor->texts();
+}
+
+void ToolConfigWidget::updateArguments()
+{
+ ArgumentsType type = ArgumentsType(_argumentsType->currentItem());
+ if ( type==AutomaticArguments ) {
+ _argumentsEditor->hide();
+ _container->show();
+ } else {
+ _argumentsEditor->show();
+ _container->hide();
+ }
+ _arguments->setText(arguments(type).join(" "));
+}
diff --git a/src/tools/gui/tool_config_widget.h b/src/tools/gui/tool_config_widget.h
new file mode 100644
index 0000000..5b38753
--- /dev/null
+++ b/src/tools/gui/tool_config_widget.h
@@ -0,0 +1,79 @@
+/***************************************************************************
+ * Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * 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 TOOL_CONFIG_WIDGET_H
+#define TOOL_CONFIG_WIDGET_H
+
+#include <qcombobox.h>
+#include <qlayout.h>
+#include <qtabwidget.h>
+#include <qvaluevector.h>
+#include <kcombobox.h>
+#include <klineedit.h>
+
+#include "common/gui/container.h"
+#include "tools/base/generic_tool.h"
+#include "tools/base/tool_group.h"
+#include "common/gui/config_widget.h"
+#include "common/gui/editlistbox.h"
+namespace PURL { class DirectoriesWidget; }
+
+class ToolConfigWidget : public ::ConfigWidget
+{
+Q_OBJECT
+public:
+ ToolConfigWidget(Project *project);
+ void init(Tool::Category category, const Tool::Group &group);
+ virtual ~ToolConfigWidget();
+
+signals:
+ void changed();
+ void displayHelp();
+
+public slots:
+ virtual void loadConfig();
+ virtual void saveConfig() { saveConfig(*_config); }
+
+private slots:
+ void updateArguments();
+ void resetCustomArguments();
+
+protected:
+ const Tool::Group *_group;
+ Tool::Category _category;
+ Project *_project;
+ QLineEdit *_customOptions, *_customLibraries;
+ PURL::DirectoriesWidget *_includeDirs;
+ QComboBox *_hexFormat;
+
+ Container *container() { return _container; }
+ PURL::DirectoriesWidget * createDirectoriesEntry(const QString &label);
+ void createIncludeDirectoriesEntry() { _includeDirs = createDirectoriesEntry(i18n("Include directories:")); }
+ void createCustomOptionsEntry();
+ void createCustomLibrariesEntry();
+ void createHexFormatEntry();
+ virtual void initEntries() = 0;
+ virtual void loadConfig(const Compile::Config &config);
+ virtual void saveConfig(Compile::Config &config) const;
+
+private:
+ enum ArgumentsType { AutomaticArguments = 0, CustomArguments, Nb_ArgumentsTypes };
+ static const char * const ARGUMENTS_TYPE_LABELS[Nb_ArgumentsTypes];
+ Compile::Config *_config, *_tmpConfig;
+ Compile::Process *_process;
+ Project *_tmpProject;
+ KComboBox *_argumentsType;
+ KLineEdit *_arguments;
+ EditListBox *_argumentsEditor;
+ Container *_container;
+
+ QStringList arguments(ArgumentsType type) const;
+};
+
+#endif
diff --git a/src/tools/gui/tool_group_ui.cpp b/src/tools/gui/tool_group_ui.cpp
new file mode 100644
index 0000000..9bb02dd
--- /dev/null
+++ b/src/tools/gui/tool_group_ui.cpp
@@ -0,0 +1,25 @@
+/***************************************************************************
+ * Copyright (C) 2005-2007 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 "tool_group_ui.h"
+
+#include "tool_config_widget.h"
+#include "toolchain_config_widget.h"
+
+ToolchainConfigWidget *Tool::GroupUI::toolchainConfigWidgetFactory(QWidget *parent) const
+{
+ return new ToolchainConfigWidget(static_cast<const Group &>(group()), parent);
+}
+
+ToolConfigWidget *Tool::GroupUI::createConfigWidget(Category category, ::Project *project) const
+{
+ ToolConfigWidget *cw = configWidgetFactory(category, project);
+ Q_ASSERT(cw);
+ cw->init(category, static_cast<const Group &>(group()));
+ return cw;
+}
diff --git a/src/tools/gui/tool_group_ui.h b/src/tools/gui/tool_group_ui.h
new file mode 100644
index 0000000..4d1f42c
--- /dev/null
+++ b/src/tools/gui/tool_group_ui.h
@@ -0,0 +1,32 @@
+/***************************************************************************
+ * Copyright (C) 2005-2007 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 TOOL_GROUP_UI_H
+#define TOOL_GROUP_UI_H
+
+#include "tools/base/tool_group.h"
+#include "tools/base/generic_tool.h"
+class ToolConfigWidget;
+class ToolchainConfigWidget;
+
+namespace Tool
+{
+
+class GroupUI : public ::Group::BaseGui
+{
+public:
+ ToolConfigWidget *createConfigWidget(Category category, ::Project *project) const;
+ virtual ToolConfigWidget *configWidgetFactory(Category category, ::Project *project) const = 0;
+ virtual ToolchainConfigWidget *toolchainConfigWidgetFactory(QWidget *parent) const;
+};
+
+inline const GroupUI &groupui(const Base &base) { return static_cast<const GroupUI &>(*base.group().gui()); }
+
+} // namespace
+
+#endif
diff --git a/src/tools/gui/toolchain_config_center.cpp b/src/tools/gui/toolchain_config_center.cpp
new file mode 100644
index 0000000..c8b889d
--- /dev/null
+++ b/src/tools/gui/toolchain_config_center.cpp
@@ -0,0 +1,111 @@
+/***************************************************************************
+ * Copyright (C) 2005-2007 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * 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 "toolchain_config_center.h"
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <kiconloader.h>
+
+#include "tools/list/tools_config_widget.h"
+#include "tools/list/compile_config.h"
+#include "tools/list/tool_list.h"
+#include "toolchain_config_widget.h"
+#include "tool_group_ui.h"
+
+ToolchainsConfigCenter::ToolchainsConfigCenter(const Tool::Group &sgroup, QWidget *parent)
+ : TreeListDialog(parent, "configure_toolchains_dialog", true,
+ i18n("Configure Toolchains"), Ok|User1|User2|Cancel, Cancel, false)
+{
+ setButtonGuiItem(User1, KStdGuiItem::reset());
+ setButtonGuiItem(User2, KGuiItem(i18n("Update"), "reload"));
+
+ _titleBox->addStretch(1);
+ _infoButton = new KPushButton(KGuiItem(QString::null, "viewmag"), _frame);
+ connect(_infoButton, SIGNAL(clicked()), SLOT(showInformationDialog()));
+ _titleBox->addWidget(_infoButton);
+
+ QWidget *current = 0;
+ FOR_EACH(PURL::SourceFamily, family) {
+ Tool::Lister::ConstIterator it;
+ for (it=Tool::lister().begin(); it!=Tool::lister().end(); ++it) {
+ PURL::FileType type = it.data()->implementationType(family.data().toolType);
+ if ( type==PURL::Nb_FileTypes || type.data().sourceFamily!=family ) continue;
+ if ( family==PURL::SourceFamily::Asm && it.data()->implementationType(PURL::ToolType::Compiler)!=PURL::Nb_FileTypes ) continue;
+ QStringList names = family.label();
+ names += it.data()->label();
+ QWidget *page = addPage(names);
+ QVBoxLayout *vbox = new QVBoxLayout(page);
+ ToolchainConfigWidget *tcw = static_cast<const ::Tool::GroupUI *>(it.data()->gui())->toolchainConfigWidgetFactory(page);
+ tcw->init();
+ tcw->loadConfig();
+ vbox->addWidget(tcw);
+ _pages[page] = tcw;
+ if ( it.key()==sgroup.name() ) current = page;
+ }
+ }
+ showPage(current);
+ aboutToShowPageSlot(current);
+ connect(this, SIGNAL(aboutToShowPage(QWidget *)), SLOT(aboutToShowPageSlot(QWidget *)));
+}
+
+void ToolchainsConfigCenter::aboutToShowPageSlot(QWidget *page)
+{
+ if ( !_pages.contains(page) ) _infoButton->hide();
+ else {
+ _infoButton->show();
+ QTimer::singleShot(0, _pages[page], SLOT(detect()));
+ }
+}
+
+void ToolchainsConfigCenter::slotApply()
+{
+ QMap<QWidget *, ToolchainConfigWidget *>::iterator it;
+ for (it=_pages.begin(); it!=_pages.end(); ++it) it.data()->saveConfig();
+}
+
+void ToolchainsConfigCenter::slotOk()
+{
+ slotApply();
+ accept();
+}
+
+ToolchainConfigWidget *ToolchainsConfigCenter::current() const
+{
+ int i = activePageIndex();
+ if ( i==-1 ) return 0;
+ QMap<QWidget *, ToolchainConfigWidget *>::const_iterator it;
+ for (it=_pages.begin(); it!=_pages.end(); ++it)
+ if ( pageIndex(it.key())==i ) return it.data();
+ Q_ASSERT(false);
+ return 0;
+}
+
+void ToolchainsConfigCenter::slotUser1()
+{
+ ToolchainConfigWidget *tcw = current();
+ if (tcw) {
+ tcw->loadConfig();
+ tcw->forceDetect();
+ }
+}
+
+void ToolchainsConfigCenter::slotUser2()
+{
+ ToolchainConfigWidget *tcw = current();
+ if (tcw) tcw->forceDetect();
+}
+
+void ToolchainsConfigCenter::showInformationDialog()
+{
+ ToolchainConfigWidget *tcw = current();
+ Q_ASSERT(tcw);
+ TextEditorDialog dialog(tcw->group().informationText(), tcw->group().label(), true, this);
+ dialog.exec();
+}
diff --git a/src/tools/gui/toolchain_config_center.h b/src/tools/gui/toolchain_config_center.h
new file mode 100644
index 0000000..4b2110b
--- /dev/null
+++ b/src/tools/gui/toolchain_config_center.h
@@ -0,0 +1,45 @@
+/***************************************************************************
+ * Copyright (C) 2005 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * 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 TOOLCHAIN_CONFIG_CENTER_H
+#define TOOLCHAIN_CONFIG_CENTER_H
+
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qlineedit.h>
+#include <qwidgetstack.h>
+
+#include "tools/gui/tool_config_widget.h"
+#include "common/gui/dialog.h"
+class ToolchainConfigWidget;
+
+class ToolchainsConfigCenter : public TreeListDialog
+{
+Q_OBJECT
+public:
+ ToolchainsConfigCenter(const Tool::Group &group, QWidget *parent);
+
+public slots:
+ virtual void slotOk();
+ virtual void slotApply();
+ virtual void slotUser1();
+ virtual void slotUser2();
+
+private slots:
+ void aboutToShowPageSlot(QWidget *page);
+ void showInformationDialog();
+
+private:
+ KPushButton *_infoButton;
+ QMap<QWidget *, ToolchainConfigWidget *> _pages;
+
+ ToolchainConfigWidget *current() const;
+};
+
+#endif
diff --git a/src/tools/gui/toolchain_config_widget.cpp b/src/tools/gui/toolchain_config_widget.cpp
new file mode 100644
index 0000000..aede699
--- /dev/null
+++ b/src/tools/gui/toolchain_config_widget.cpp
@@ -0,0 +1,301 @@
+/***************************************************************************
+ * Copyright (C) 2005-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 "toolchain_config_widget.h"
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qgroupbox.h>
+#include <qtabwidget.h>
+#include <kiconloader.h>
+#include <ktextedit.h>
+
+#include "tools/list/compile_config.h"
+#include "common/gui/purl_gui.h"
+#include "common/global/process.h"
+#include "common/gui/container.h"
+
+//----------------------------------------------------------------------------
+ToolchainConfigWidget::ToolchainConfigWidget(const Tool::Group &group, QWidget *parent)
+ : ::ConfigWidget(parent),
+ _group(group), _dirty(false), _outputType(0), _devicesData(group.nbCheckDevices())
+{
+ _config = group.createConfig(0);
+}
+
+ToolchainConfigWidget::~ToolchainConfigWidget()
+{
+ delete _config;
+}
+
+void ToolchainConfigWidget::init()
+{
+ Container *container = new Container(this, Container::Sunken);
+ addWidget(container, 0,0, 0,3);
+ container->setColStretch(3, 1);
+
+ uint row = 0;
+ QLabel *label = new QLabel(Compile::DirectoryType(Compile::DirectoryType::Executable).label() + ":", container);
+ container->addWidget(label, row,row, 0,0);
+ _dirs[Compile::DirectoryType::Executable] = new PURL::DirectoryWidget(container);
+ connect(_dirs[Compile::DirectoryType::Executable], SIGNAL(changed()), SLOT(forceDetect()));
+ container->addWidget(_dirs[Compile::DirectoryType::Executable], row,row, 1,3);
+ row++;
+
+ label = new QLabel(i18n("Executable Type:"), container);
+ container->addWidget(label, row,row, 0,0);
+ _execType = new QComboBox(container);
+ FOR_EACH(Tool::ExecutableType, type) _execType->insertItem(type.label());
+ connect(_execType, SIGNAL(activated(int)), SLOT(forceDetect()));
+ container->addWidget(_execType, row,row, 1,2);
+ row++;
+
+ uint nbOutputTypes = 0;
+ FOR_EACH(Tool::OutputExecutableType, type)
+ if ( _group.hasOutputExecutableType(type) ) nbOutputTypes++;
+ if ( nbOutputTypes>1 ) {
+ label = new QLabel(i18n("Output Executable Type:"), container);
+ container->addWidget(label, row,row, 0,0);
+ _outputType = new KeyComboBox<Tool::OutputExecutableType>(container);
+ FOR_EACH(Tool::OutputExecutableType, type)
+ if ( _group.hasOutputExecutableType(type) ) _outputType->appendItem(type, type.label());
+ connect(_outputType->widget(), SIGNAL(activated(int)), SLOT(forceDetect()));
+ container->addWidget(_outputType->widget(), row,row, 1,1);
+ row++;
+ }
+
+ addCustomExecutableOptions(container);
+
+ FOR_EACH(Tool::Category, k) {
+ const Tool::Base *base = _group.base(k);
+ if ( base==0 ) continue;
+ label = new QLabel(k.label(), container);
+ container->addWidget(label, row,row, 0,0);
+ _data[k].label = new QLabel(container);
+ container->addWidget(_data[k].label, row,row, 1,1);
+ _data[k].button = new KPushButton(KGuiItem(QString::null, "viewmag"), container);
+ connect(_data[k].button, SIGNAL(clicked()), SLOT(showDetails()));
+ container->addWidget(_data[k].button, row,row, 2,2);
+ row++;
+ }
+
+ label = new QLabel(i18n("Device detection:"), container);
+ container->addWidget(label, row,row, 0,0);
+ _devicesLabel = new QLabel(container);
+ container->addWidget(_devicesLabel, row,row, 1,1);
+ KPushButton *button = new KPushButton(KGuiItem(QString::null, "viewmag"), container);
+ connect(button, SIGNAL(clicked()), SLOT(showDeviceDetails()));
+ container->addWidget(button, row,row, 2,2);
+ row++;
+
+ row = numRows();
+ FOR_EACH(Compile::DirectoryType, type) {
+ if ( type==Compile::DirectoryType::Executable ) continue;
+ if ( !_group.hasDirectory(type) ) _dirs[type] = 0;
+ else {
+ label = new QLabel(type.label() + ":", this);
+ addWidget(label, row,row, 0,0);
+ _dirs[type] = new PURL::DirectoryWidget(this);
+ addWidget(_dirs[type], row,row, 1,3);
+ row++;
+ }
+ }
+
+ if ( !_group.comment().isEmpty() ) {
+ KTextEdit *w = new KTextEdit(_group.comment(), QString::null, this);
+ w->setReadOnly(true);
+ w->setWordWrap(QTextEdit::WidgetWidth);
+ addWidget(w, row,row, 0,3);
+ row++;
+ }
+
+ setColStretch(3, 1);
+}
+
+void ToolchainConfigWidget::loadConfig()
+{
+ _execType->blockSignals(true);
+ _execType->setCurrentItem(Compile::Config::withWine(_group) ? Tool::ExecutableType::Windows : Tool::ExecutableType::Unix);
+ _execType->blockSignals(false);
+ if (_outputType) {
+ _outputType->widget()->blockSignals(true);
+ _outputType->setCurrentItem(Compile::Config::outputExecutableType(_group));
+ _outputType->widget()->blockSignals(false);
+ }
+ FOR_EACH(Compile::DirectoryType, type) {
+ if ( _dirs[type]==0 ) continue;
+ _dirs[type]->blockSignals(true);
+ _dirs[type]->setDirectory(Compile::Config::directory(_group, type));
+ _dirs[type]->blockSignals(false);
+ }
+ _dirty = true;
+}
+
+void ToolchainConfigWidget::saveConfig()
+{
+ Compile::Config::setWithWine(_group, withWine());
+ if (_outputType) Compile::Config::setOutputExecutableType(_group, outputType());
+ FOR_EACH(Compile::DirectoryType, type)
+ if ( _dirs[type] ) Compile::Config::setDirectory(_group, type, _dirs[type]->directory());
+}
+
+void ToolchainConfigWidget::forceDetect()
+{
+ _dirty = true;
+ detect();
+}
+
+void ToolchainConfigWidget::checkExecutableDone()
+{
+ FOR_EACH(Tool::Category, i) {
+ if ( _data[i].process!=sender() ) continue;
+ if ( _data[i].process->state()==::Process::Timedout ) {
+ _data[i].label->setText(i18n("Timeout"));
+ return;
+ }
+ _data[i].checkLines = _data[i].process->sout() + _data[i].process->serr();
+ const Tool::Base *base = _group.base(i);
+ QString exec = base->baseExecutable(withWine(), outputType());
+ if ( base->checkExecutableResult(withWine(), _data[i].checkLines) ) _data[i].label->setText(i18n("\"%1\" found").arg(exec));
+ else _data[i].label->setText(i18n("\"%1\" not recognized").arg(exec));
+ break;
+ }
+}
+
+void ToolchainConfigWidget::checkDevicesDone()
+{
+ for(uint i=0; i<_devicesData.count(); i++) {
+ if ( _devicesData[i].process!=sender() ) continue;
+ if ( _devicesData[i].process->state()==::Process::Timedout ) {
+ _devicesLabel->setText(i18n("Timeout"));
+ return;
+ }
+ _devicesData[i].checkLines = _devicesData[i].process->sout() + _devicesData[i].process->serr();
+ _devicesData[i].done = true;
+ break;
+ }
+ QValueList<const Device::Data *> list;
+ for(uint i=0; i<_devicesData.count(); i++) {
+ if ( !_devicesData[i].done ) return;
+ list += _group.getSupportedDevices(_devicesData[i].checkLines.join("\n"));
+ }
+ _devicesLabel->setText(i18n("Detected (%1)").arg(list.count()));
+}
+
+bool ToolchainConfigWidget::withWine() const
+{
+ return ( _execType->currentItem()==Tool::ExecutableType::Windows );
+}
+
+Tool::OutputExecutableType ToolchainConfigWidget::outputType() const
+{
+ return (_outputType==0 ? Compile::Config::outputExecutableType(_group) : _outputType->currentItem());
+}
+
+QString ToolchainConfigWidget::baseExecutable(Tool::Category category) const
+{
+ return _group.base(category)->baseExecutable(withWine(), outputType());
+}
+
+::Process::LineOutput *ToolchainConfigWidget::checkExecutableProcess(Tool::Category category) const
+{
+ PURL::Directory execDir = _dirs[Compile::DirectoryType::Executable]->directory();
+ return _group.base(category)->checkExecutableProcess(execDir, withWine(), outputType());
+}
+
+::Process::LineOutput *ToolchainConfigWidget::checkDevicesProcess(uint i) const
+{
+ PURL::Directory execDir = _dirs[Compile::DirectoryType::Executable]->directory();
+ return _group.checkDevicesProcess(i, execDir, withWine());
+}
+
+void ToolchainConfigWidget::detect()
+{
+ if ( !_dirty ) return;
+ FOR_EACH(Tool::Category, k) {
+ if ( _data[k].label==0 ) continue;
+ if ( !_group.base(k)->checkExecutable() ) _data[k].label->setText(i18n("Unknown"));
+ else {
+ delete _data[k].process;
+ _data[k].checkLines.clear();
+ _data[k].process = checkExecutableProcess(k);
+ _data[k].command = _data[k].process->prettyCommand();
+ connect(_data[k].process, SIGNAL(done(int)), SLOT(checkExecutableDone()));
+ connect(_data[k].process, SIGNAL(timeout()), SLOT(checkExecutableDone()));
+ QString exec = baseExecutable(k);
+ if ( !_data[k].process->start(10000) ) _data[k].label->setText(i18n("\"%1\" not found").arg(exec));
+ else _data[k].label->setText(i18n("Detecting \"%1\"...").arg(exec));
+ }
+ }
+ if ( _group.checkDevicesCategory()==Tool::Category::Nb_Types ) {
+ QValueVector<QString> supported = _group.supportedDevices();
+ _devicesLabel->setText(i18n("Hardcoded (%1)").arg(supported.count()));
+ } else {
+ for (uint i=0; i<_devicesData.count(); i++) {
+ delete _devicesData[i].process;
+ _devicesData[i].process = checkDevicesProcess(i);
+ _devicesData[i].command = _devicesData[i].process->prettyCommand();
+ connect(_devicesData[i].process, SIGNAL(done(int)), SLOT(checkDevicesDone()));
+ connect(_devicesData[i].process, SIGNAL(timeout()), SLOT(checkDevicesDone()));
+ _devicesData[i].done = false;
+ _devicesData[i].checkLines.clear();
+ if ( !_devicesData[i].process->start(10000) ) _devicesLabel->setText(i18n("Failed"));
+ else _devicesLabel->setText(i18n("Detecting ..."));
+ }
+ }
+ FOR_EACH(Compile::DirectoryType, type) {
+ if ( _dirs[type]==0 || type==Compile::DirectoryType::Executable ) continue;
+ PURL::Directory execDir = _dirs[Compile::DirectoryType::Executable]->directory();
+ PURL::Directory dir = _group.autodetectDirectory(type, execDir, withWine());
+ if ( !dir.isEmpty() ) _dirs[type]->setDirectory(dir);
+ }
+ _dirty = false;
+}
+
+void ToolchainConfigWidget::showDetails()
+{
+ FOR_EACH(Tool::Category, k) {
+ if ( sender()!=_data[k].button ) continue;
+ QString s;
+ const Tool::Base *base = _group.base(k);
+ if ( base->checkExecutable() ) {
+ s += i18n("<qt><b>Command for executable detection:</b><br>%1<br>").arg(_data[k].command);
+ s += i18n("<b>Version string:</b><br>%1<br></qt>").arg(_data[k].checkLines.join("<br>"));
+ } else s += i18n("This tool cannot be automatically detected.");
+ MessageBox::text(s, Log::Show);
+ break;
+ }
+}
+
+void ToolchainConfigWidget::showDeviceDetails()
+{
+ QString s;
+ if ( _group.checkDevicesCategory()==Tool::Category::Nb_Types ) {
+ s += "<qt>";
+ QValueVector<QString> supported = _group.supportedDevices();
+ for (uint i=0; i<supported.count(); i++) {
+ if ( i!=0 ) {
+ if ( (i%10)==0 ) s += "<br>";
+ s += " ";
+ }
+ s += supported[i];
+ }
+ s += "</qt>";
+ } else {
+ uint nb = _group.nbCheckDevices();
+ for (uint i=0; i<nb; i++) {
+ if ( nb==1 ) s += i18n("<qt><b>Command for devices detection:</b><br>%1<br>").arg(_devicesData[i].command);
+ else s += i18n("<qt><b>Command #%1 for devices detection:</b><br>%2<br>").arg(i+1).arg(_devicesData[i].command);
+ QString ss = _devicesData[i].checkLines.join("<br>");
+ if ( nb==1 ) s += i18n("<b>Device string:</b><br>%1<br>").arg(ss);
+ else s += i18n("<b>Device string #%1:</b><br>%2<br>").arg(i+1).arg(ss);
+ }
+ }
+ MessageBox::text(s, Log::Show);
+}
diff --git a/src/tools/gui/toolchain_config_widget.h b/src/tools/gui/toolchain_config_widget.h
new file mode 100644
index 0000000..ad7978a
--- /dev/null
+++ b/src/tools/gui/toolchain_config_widget.h
@@ -0,0 +1,85 @@
+/***************************************************************************
+ * Copyright (C) 2005-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 TOOLCHAIN_CONFIG_WIDGET_H
+#define TOOLCHAIN_CONFIG_WIDGET_H
+
+#include <qwidgetstack.h>
+#include <qlabel.h>
+#include <klocale.h>
+#include <kpushbutton.h>
+
+#include "common/gui/key_gui.h"
+#include "common/global/process.h"
+#include "common/gui/config_widget.h"
+#include "tools/list/compile_process.h"
+class Container;
+namespace PURL { class DirectoryWidget; }
+namespace Tool { class Group; }
+
+//----------------------------------------------------------------------------
+class ToolchainConfigWidget : public ::ConfigWidget
+{
+ Q_OBJECT
+public:
+ ToolchainConfigWidget(const Tool::Group &group, QWidget *parent);
+ virtual ~ToolchainConfigWidget();
+ const Tool::Group &group() const { return _group; }
+ void init();
+
+public slots:
+ void detect();
+ void forceDetect();
+ virtual void loadConfig();
+ virtual void saveConfig();
+
+protected:
+ bool withWine() const;
+ Tool::OutputExecutableType outputType() const;
+ virtual void addCustomExecutableOptions(Container *) {}
+ virtual QString baseExecutable(Tool::Category category) const;
+ virtual ::Process::LineOutput *checkExecutableProcess(Tool::Category category) const;
+ virtual ::Process::LineOutput *checkDevicesProcess(uint i) const;
+
+protected slots:
+ void showDetails();
+ void showDeviceDetails();
+ void checkExecutableDone();
+ void checkDevicesDone();
+
+protected:
+ const Tool::Group &_group;
+ Compile::Config *_config;
+ bool _dirty;
+ QComboBox *_execType;
+ KeyComboBox<Tool::OutputExecutableType> *_outputType;
+ QLabel *_devicesLabel;
+ QMap<Compile::DirectoryType, PURL::DirectoryWidget *> _dirs;
+ class ExecData {
+ public:
+ ExecData() : label(0), button(0), process(0) {}
+ ~ExecData() { delete process; }
+ QLabel *label;
+ QString command;
+ QStringList checkLines;
+ KPushButton *button;
+ ::Process::LineOutput *process;
+ };
+ QMap<Tool::Category, ExecData> _data;
+ class DevicesData {
+ public:
+ DevicesData() : process(0) {}
+ bool done;
+ QString command;
+ QStringList checkLines;
+ ::Process::LineOutput *process;
+ };
+ QValueVector<DevicesData> _devicesData;
+};
+
+#endif
diff --git a/src/tools/jal/Makefile.am b/src/tools/jal/Makefile.am
new file mode 100644
index 0000000..b0d8b43
--- /dev/null
+++ b/src/tools/jal/Makefile.am
@@ -0,0 +1,8 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libjal.la
+libjal_la_LDFLAGS = $(all_libraries)
+libjal_la_SOURCES = jal_compile.cpp jal_config.cpp jal.cpp jal_generator.cpp
+
+SUBDIRS = gui \ No newline at end of file
diff --git a/src/tools/jal/gui/Makefile.am b/src/tools/jal/gui/Makefile.am
new file mode 100644
index 0000000..60341d3
--- /dev/null
+++ b/src/tools/jal/gui/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libjalui.la
+libjalui_la_LDFLAGS = $(all_libraries)
+libjalui_la_SOURCES = jal_ui.cpp
diff --git a/src/tools/jal/gui/jal_ui.cpp b/src/tools/jal/gui/jal_ui.cpp
new file mode 100644
index 0000000..4300de0
--- /dev/null
+++ b/src/tools/jal/gui/jal_ui.cpp
@@ -0,0 +1,14 @@
+/***************************************************************************
+ * 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 "jal_ui.h"
+
+//----------------------------------------------------------------------------
+JAL::ConfigWidget::ConfigWidget(Project *project)
+ : ToolConfigWidget(project)
+{}
diff --git a/src/tools/jal/gui/jal_ui.h b/src/tools/jal/gui/jal_ui.h
new file mode 100644
index 0000000..aa6957e
--- /dev/null
+++ b/src/tools/jal/gui/jal_ui.h
@@ -0,0 +1,35 @@
+/***************************************************************************
+ * 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 JAL_UI_H
+#define JAL_UI_H
+
+#include "tools/gui/tool_config_widget.h"
+#include "tools/gui/tool_group_ui.h"
+
+namespace JAL
+{
+//----------------------------------------------------------------------------
+class ConfigWidget : public ToolConfigWidget
+{
+Q_OBJECT
+public:
+ ConfigWidget(Project *project);
+ virtual void initEntries() {}
+};
+
+//----------------------------------------------------------------------------
+class GroupUI : public Tool::GroupUI
+{
+public:
+ virtual ToolConfigWidget *configWidgetFactory(Tool::Category, ::Project *project) const { return new ConfigWidget(project); }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/jal/jal.cpp b/src/tools/jal/jal.cpp
new file mode 100644
index 0000000..009ea21
--- /dev/null
+++ b/src/tools/jal/jal.cpp
@@ -0,0 +1,72 @@
+/***************************************************************************
+ * 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 "jal.h"
+
+#include "jal_compile.h"
+#include "jal_config.h"
+#include "devices/pic/pic/pic_memory.h"
+#include "devices/list/device_list.h"
+#include "common/global/process.h"
+#include "jal_generator.h"
+
+//----------------------------------------------------------------------------
+bool JAL::Base::checkExecutableResult(bool, QStringList &lines) const
+{
+ QStringList tmp;
+ for (uint i=0; i<lines.count(); i++)
+ if ( !lines[i].contains('\r') ) tmp += lines[i]; // ??
+ lines = tmp;
+ return ( lines.count()>0 && lines[0].startsWith("jal") );
+}
+
+//----------------------------------------------------------------------------
+QString JAL::Group::informationText() const
+{
+ return i18n("<a href=\"%1\">JAL</a> is a high-level language for PIC microcontrollers.").arg("http://jal.sourceforge.net");
+}
+
+Tool::Group::BaseData JAL::Group::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Compiler ) return BaseData(new ::JAL::Base, Both);
+ return BaseData();
+}
+
+const char * const SUPPORTED_DEVICES[] = {
+ "12C508", "12C509A", "12CE674", "12F629", "12F675",
+ "16C84", "16F84", "16F88", "16F873", "16F876", "16F877", "16F628",
+ "18F242", "18F252", "18F442", "18F452",
+ 0
+};
+
+QValueList<const Device::Data *> JAL::Group::getSupportedDevices(const QString &) const
+{
+ QValueList<const Device::Data *> list;
+ for (uint i=0; SUPPORTED_DEVICES[i]; i++) {
+ const Device::Data *data = Device::lister().data(SUPPORTED_DEVICES[i]);
+ Q_ASSERT(data);
+ list.append(data);
+ }
+ return list;
+}
+
+Compile::Process *JAL::Group::processFactory(const Compile::Data &data) const
+{
+ Q_ASSERT( data.category==Tool::Category::Compiler );
+ return new CompileFile;
+}
+
+Compile::Config *JAL::Group::configFactory(::Project *project) const
+{
+ return new Config(project);
+}
+
+Tool::SourceGenerator *JAL::Group::sourceGeneratorFactory() const
+{
+ return new SourceGenerator;
+}
diff --git a/src/tools/jal/jal.h b/src/tools/jal/jal.h
new file mode 100644
index 0000000..0c0d790
--- /dev/null
+++ b/src/tools/jal/jal.h
@@ -0,0 +1,49 @@
+/***************************************************************************
+ * 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 JAL_H
+#define JAL_H
+
+#include "tools/base/tool_group.h"
+
+namespace JAL
+{
+//----------------------------------------------------------------------------
+class Base : public Tool::Base
+{
+public:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const { return "jal"; }
+
+private:
+ virtual QStringList checkExecutableOptions(bool) const { return QStringList(); }
+ virtual bool checkExecutableResult(bool withWine, QStringList &lines) const;
+};
+
+//----------------------------------------------------------------------------
+class Group : public Tool::Group
+{
+public:
+ virtual QString name() const { return "jal"; }
+ virtual QString label() const { return i18n("JAL"); }
+ virtual QString informationText() const;
+ virtual Tool::Category checkDevicesCategory() const { return Tool::Category::Nb_Types; }
+ virtual Tool::ExecutableType preferedExecutableType() const { return Tool::ExecutableType::Unix; }
+ virtual Tool::CompileType compileType() const { return Tool::AllFiles; }
+ virtual PURL::FileType implementationType(PURL::ToolType type) const { return (type==PURL::ToolType::Compiler ? PURL::JalSource : PURL::Nb_FileTypes); }
+
+private:
+ virtual BaseData baseFactory(Tool::Category c) const;
+ 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 Tool::SourceGenerator *sourceGeneratorFactory() const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/jal/jal_compile.cpp b/src/tools/jal/jal_compile.cpp
new file mode 100644
index 0000000..4d62e68
--- /dev/null
+++ b/src/tools/jal/jal_compile.cpp
@@ -0,0 +1,26 @@
+/***************************************************************************
+ * 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 "jal_compile.h"
+
+void JAL::CompileFile::logStderrLine(const QString &line)
+{
+ if ( line.contains('\r') ) return; // what are those lines ?
+ // #### TODO
+ doLog(Log::LineType::Normal, line, QString::null, 0); // unrecognized
+}
+
+QStringList JAL::CompileFile::genericArguments(const Compile::Config &) const
+{
+ return "%I";
+}
+
+QString JAL::CompileFile::outputFiles() const
+{
+ return "PURL::AsmGPAsm PURL::Hex";
+}
diff --git a/src/tools/jal/jal_compile.h b/src/tools/jal/jal_compile.h
new file mode 100644
index 0000000..e63f603
--- /dev/null
+++ b/src/tools/jal/jal_compile.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 JAL_COMPILE_H
+#define JAL_COMPILE_H
+
+#include "tools/list/compile_process.h"
+
+namespace JAL
+{
+//-----------------------------------------------------------------------------
+class CompileFile : public Compile::Process
+{
+Q_OBJECT
+protected:
+ virtual QString deviceName() const { return _data.device; }
+ virtual void logStderrLine(const QString &line);
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/jal/jal_config.cpp b/src/tools/jal/jal_config.cpp
new file mode 100644
index 0000000..c51ddf6
--- /dev/null
+++ b/src/tools/jal/jal_config.cpp
@@ -0,0 +1,9 @@
+/***************************************************************************
+ * 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 "jal_config.h"
diff --git a/src/tools/jal/jal_config.h b/src/tools/jal/jal_config.h
new file mode 100644
index 0000000..0d0a513
--- /dev/null
+++ b/src/tools/jal/jal_config.h
@@ -0,0 +1,25 @@
+/***************************************************************************
+ * 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 JAL_CONFIG_H
+#define JAL_CONFIG_H
+
+#include "tools/list/compile_config.h"
+
+namespace JAL
+{
+
+class Config : public Compile::Config
+{
+public:
+ Config(Project *project) : Compile::Config(project) {}
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/jal/jal_generator.cpp b/src/tools/jal/jal_generator.cpp
new file mode 100644
index 0000000..6aa9b08
--- /dev/null
+++ b/src/tools/jal/jal_generator.cpp
@@ -0,0 +1,35 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 "jal_generator.h"
+
+#include "devices/pic/base/pic.h"
+
+SourceLine::List JAL::SourceGenerator::configLines(PURL::ToolType, const Device::Memory &, bool &) const
+{
+ // no config lines (?)
+ return SourceLine::List();
+}
+
+SourceLine::List JAL::SourceGenerator::includeLines(PURL::ToolType, const Device::Data &data) const
+{
+ SourceLine::List lines;
+ lines.appendNotIndentedCode("include " + data.name().lower() + "_10", i18n("10MHz crystal"));
+ lines.appendNotIndentedCode("include jlib", i18n("jal standard library"));
+ return lines;
+}
+
+SourceLine::List JAL::SourceGenerator::sourceFileContent(PURL::ToolType, const Device::Data &, bool &) const
+{
+ SourceLine::List lines;
+ lines.appendTitle(i18n("main code"));
+ lines.appendNotIndentedCode(QString::null, "<< " + i18n("insert code") + " >>");
+ lines.appendNotIndentedCode("forever loop", i18n("loop forever"));
+ lines.appendNotIndentedCode("end loop");
+ return lines;
+}
diff --git a/src/tools/jal/jal_generator.h b/src/tools/jal/jal_generator.h
new file mode 100644
index 0000000..b6beddb
--- /dev/null
+++ b/src/tools/jal/jal_generator.h
@@ -0,0 +1,27 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 JAL_GENERATOR_H
+#define JAL_GENERATOR_H
+
+#include "tools/base/tool_group.h"
+
+namespace JAL
+{
+
+class SourceGenerator : public Tool::SourceGenerator
+{
+public:
+ virtual SourceLine::List configLines(PURL::ToolType type, const Device::Memory &memory, bool &ok) const;
+ virtual SourceLine::List sourceFileContent(PURL::ToolType type, const Device::Data &data, bool &ok) const;
+ virtual SourceLine::List includeLines(PURL::ToolType type, const Device::Data &data) const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/jalv2/Makefile.am b/src/tools/jalv2/Makefile.am
new file mode 100644
index 0000000..3b59ea9
--- /dev/null
+++ b/src/tools/jalv2/Makefile.am
@@ -0,0 +1,8 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libjalv2.la
+libjalv2_la_SOURCES = jalv2_compile.cpp jalv2_config.cpp jalv2.cpp
+libjalv2_la_LDFLAGS = $(all_libraries)
+
+SUBDIRS = gui \ No newline at end of file
diff --git a/src/tools/jalv2/gui/Makefile.am b/src/tools/jalv2/gui/Makefile.am
new file mode 100644
index 0000000..92e338c
--- /dev/null
+++ b/src/tools/jalv2/gui/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libjalv2ui.la
+libjalv2ui_la_SOURCES = jalv2_ui.cpp
+libjalv2ui_la_LDFLAGS = $(all_libraries)
diff --git a/src/tools/jalv2/gui/jalv2_ui.cpp b/src/tools/jalv2/gui/jalv2_ui.cpp
new file mode 100644
index 0000000..0990c6d
--- /dev/null
+++ b/src/tools/jalv2/gui/jalv2_ui.cpp
@@ -0,0 +1,19 @@
+/***************************************************************************
+ * 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 "jalv2_ui.h"
+
+//----------------------------------------------------------------------------
+JALV2::ConfigWidget::ConfigWidget(Project *project)
+ : ToolConfigWidget(project)
+{}
+
+void JALV2::ConfigWidget::initEntries()
+{
+ createIncludeDirectoriesEntry();
+}
diff --git a/src/tools/jalv2/gui/jalv2_ui.h b/src/tools/jalv2/gui/jalv2_ui.h
new file mode 100644
index 0000000..93085c1
--- /dev/null
+++ b/src/tools/jalv2/gui/jalv2_ui.h
@@ -0,0 +1,35 @@
+/***************************************************************************
+ * 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 JALV2_UI_H
+#define JALV2_UI_H
+
+#include "tools/gui/tool_config_widget.h"
+#include "tools/gui/tool_group_ui.h"
+
+namespace JALV2
+{
+//----------------------------------------------------------------------------
+class ConfigWidget : public ToolConfigWidget
+{
+Q_OBJECT
+public:
+ ConfigWidget(Project *project);
+ virtual void initEntries();
+};
+
+//----------------------------------------------------------------------------
+class GroupUI : public Tool::GroupUI
+{
+public:
+ virtual ToolConfigWidget *configWidgetFactory(Tool::Category, ::Project *project) const { return new ConfigWidget(project); }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/jalv2/jalv2.cpp b/src/tools/jalv2/jalv2.cpp
new file mode 100644
index 0000000..1d910b8
--- /dev/null
+++ b/src/tools/jalv2/jalv2.cpp
@@ -0,0 +1,77 @@
+/***************************************************************************
+ * 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 "jalv2.h"
+
+#include "jalv2_compile.h"
+#include "jalv2_config.h"
+#include "devices/pic/pic/pic_memory.h"
+#include "devices/list/device_list.h"
+#include "common/global/process.h"
+#include "tools/jal/jal_generator.h"
+
+//----------------------------------------------------------------------------
+bool JALV2::Base::checkExecutableResult(bool, QStringList &lines) const
+{
+ QStringList tmp;
+ for (uint i=0; i<lines.count(); i++)
+ if ( !lines[i].contains('\r') ) tmp += lines[i]; // ??
+ lines = tmp;
+ return ( lines.count()>0 && lines[0].startsWith("jal") );
+}
+
+//----------------------------------------------------------------------------
+QString JALV2::Group::informationText() const
+{
+ return i18n("<a href=\"%1\">JAL V2</a> is a new compiler for the high-level language JAL.").arg("http://www.casadeyork.com/jalv2");
+}
+
+Tool::Group::BaseData JALV2::Group::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Compiler ) return BaseData(new ::JALV2::Base, Both);
+ return BaseData();
+}
+
+const char * const SUPPORTED_DEVICES[] = {
+ "12C509A", "12F675",
+ "16F628",
+ "16F818", "16F819",
+ "16C84", "16F84",
+ "16F87", "16F88",
+ "16F873", "16F874", "16F876", "16F877",
+ "16F873A", "16F874A", "16F876A", "16F877A",
+ "18F242", "18F252", "18F452",
+ 0
+};
+
+QValueList<const Device::Data *> JALV2::Group::getSupportedDevices(const QString &) const
+{
+ QValueList<const Device::Data *> list;
+ for (uint i=0; SUPPORTED_DEVICES[i]; i++) {
+ const Device::Data *data = Device::lister().data(SUPPORTED_DEVICES[i]);
+ Q_ASSERT(data);
+ list.append(data);
+ }
+ return list;
+}
+
+Compile::Process *JALV2::Group::processFactory(const Compile::Data &data) const
+{
+ Q_ASSERT( data.category==Tool::Category::Compiler );
+ return new CompileFile;
+}
+
+Compile::Config *JALV2::Group::configFactory(::Project *project) const
+{
+ return new Config(project);
+}
+
+Tool::SourceGenerator *JALV2::Group::sourceGeneratorFactory() const
+{
+ return new JAL::SourceGenerator;
+}
diff --git a/src/tools/jalv2/jalv2.h b/src/tools/jalv2/jalv2.h
new file mode 100644
index 0000000..80c3d02
--- /dev/null
+++ b/src/tools/jalv2/jalv2.h
@@ -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. *
+ ***************************************************************************/
+#ifndef JALV2_H
+#define JALV2_H
+
+#include "tools/base/tool_group.h"
+
+namespace JALV2
+{
+//----------------------------------------------------------------------------
+class Base : public Tool::Base
+{
+public:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const { return "jalv2"; }
+
+private:
+ virtual QStringList checkExecutableOptions(bool) const { return QStringList(); }
+ virtual bool checkExecutableResult(bool withWine, QStringList &lines) const;
+};
+
+//----------------------------------------------------------------------------
+class Group : public Tool::Group
+{
+public:
+ virtual QString name() const { return "jalv2"; }
+ virtual QString label() const { return i18n("JAL V2"); }
+ virtual QString informationText() const;
+ virtual bool hasDirectory(Compile::DirectoryType type) const { return type==Compile::DirectoryType::Header; }
+ virtual Tool::Category checkDevicesCategory() const { return Tool::Category::Nb_Types; }
+ virtual Tool::ExecutableType preferedExecutableType() const { return Tool::ExecutableType::Unix; }
+ virtual Tool::CompileType compileType() const { return Tool::AllFiles; }
+ virtual PURL::FileType implementationType(PURL::ToolType type) const { return (type==PURL::ToolType::Compiler ? PURL::JalSource : PURL::Nb_FileTypes); }
+
+private:
+ virtual BaseData baseFactory(Tool::Category c) const;
+ 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 Tool::SourceGenerator *sourceGeneratorFactory() const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/jalv2/jalv2_compile.cpp b/src/tools/jalv2/jalv2_compile.cpp
new file mode 100644
index 0000000..0b1e7f5
--- /dev/null
+++ b/src/tools/jalv2/jalv2_compile.cpp
@@ -0,0 +1,43 @@
+/***************************************************************************
+ * 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 "jalv2_compile.h"
+
+#include "jalv2.h"
+#include "common/common/misc.h"
+#include "tools/list/compile_config.h"
+
+QStringList JALV2::CompileFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ QStringList includes = config.includeDirs(Tool::Category::Compiler, QString::null, QString::null, ";");
+ QString s = (includes.isEmpty() ? QString::null : includes[0]);
+ PURL::Directory dir = Compile::Config::directory(group(), Compile::DirectoryType::Header).path();
+ if ( !dir.isEmpty() ) {
+ if ( !s.isEmpty() ) s += ";";
+ s += dir.path();
+ }
+ if ( !s.isEmpty() ) {
+ args += "-s";
+ args += s;
+ }
+ args += "%I";
+ return args;
+}
+
+void JALV2::CompileFile::logStderrLine(const QString &line)
+{
+ if ( parseErrorLine(line, Compile::ParseErrorData("([^:]*):([0-9]+):\\s*(warning)(.+)", 1, 2, 4, 3)) ) return;
+ if ( parseErrorLine(line, Compile::ParseErrorData("([^:]*):([0-9]+):\\s*(.+)", 1, 2, 3, Log::LineType::Error)) ) return;
+ doLog(Log::LineType::Normal, line, QString::null, 0); // unrecognized
+}
+
+QString JALV2::CompileFile::outputFiles() const
+{
+ return "PURL::AsmGPAsm PURL::Hex";
+}
diff --git a/src/tools/jalv2/jalv2_compile.h b/src/tools/jalv2/jalv2_compile.h
new file mode 100644
index 0000000..de0257d
--- /dev/null
+++ b/src/tools/jalv2/jalv2_compile.h
@@ -0,0 +1,28 @@
+/***************************************************************************
+ * 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 JALV2_COMPILE_H
+#define JALV2_COMPILE_H
+
+#include "tools/list/compile_process.h"
+
+namespace JALV2
+{
+class CompileFile : public Compile::Process
+{
+Q_OBJECT
+protected:
+ virtual QString deviceName() const { return _data.device; }
+ virtual void logStderrLine(const QString &line);
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/jalv2/jalv2_config.cpp b/src/tools/jalv2/jalv2_config.cpp
new file mode 100644
index 0000000..c172c5e
--- /dev/null
+++ b/src/tools/jalv2/jalv2_config.cpp
@@ -0,0 +1,9 @@
+/***************************************************************************
+ * 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 "jalv2_config.h"
diff --git a/src/tools/jalv2/jalv2_config.h b/src/tools/jalv2/jalv2_config.h
new file mode 100644
index 0000000..e2811d3
--- /dev/null
+++ b/src/tools/jalv2/jalv2_config.h
@@ -0,0 +1,25 @@
+/***************************************************************************
+ * 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 JALV2_CONFIG_H
+#define JALV2_CONFIG_H
+
+#include "tools/list/compile_config.h"
+
+namespace JALV2
+{
+
+class Config : public Compile::Config
+{
+public:
+ Config(Project *project) : Compile::Config(project) {}
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/list/Makefile.am b/src/tools/list/Makefile.am
new file mode 100644
index 0000000..9d62533
--- /dev/null
+++ b/src/tools/list/Makefile.am
@@ -0,0 +1,7 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libtoollist.la
+libtoollist_la_LDFLAGS = $(all_libraries)
+libtoollist_la_SOURCES = tool_list.cpp tools_config_widget.cpp \
+ compile_config.cpp device_info.cpp compile_manager.cpp compile_process.cpp
diff --git a/src/tools/list/compile_config.cpp b/src/tools/list/compile_config.cpp
new file mode 100644
index 0000000..5ec8dfc
--- /dev/null
+++ b/src/tools/list/compile_config.cpp
@@ -0,0 +1,189 @@
+/***************************************************************************
+ * 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 "compile_config.h"
+
+#include "common/global/generic_config.h"
+#include "devices/list/device_list.h"
+#include "libgui/project.h"
+#include "tool_list.h"
+
+//----------------------------------------------------------------------------
+PURL::Directory Compile::Config::directory(const Tool::Group &group, DirectoryType type)
+{
+ QString def;
+ if ( type!=DirectoryType::Executable )
+ def = group.autodetectDirectory(type, directory(group, DirectoryType::Executable), withWine(group)).path();
+ return PURL::Directory(value(group.name(), QString::null, type.key() + QString("_path"), def));
+}
+void Compile::Config::setDirectory(const Tool::Group &group, DirectoryType type, const PURL::Directory &dir)
+{
+ setValue(group.name(), QString::null, type.key() + QString("_path"), dir.path());
+ if ( type==DirectoryType::Executable ) const_cast<Tool::Group &>(group).init();
+}
+
+bool Compile::Config::withWine(const Tool::Group &group)
+{
+ QString def = (group.preferedExecutableType()==Tool::ExecutableType::Unix ? "false" : "true");
+ return ( value(group.name(), QString::null, "with_wine", def)=="true" );
+}
+void Compile::Config::setWithWine(const Tool::Group &group, bool withWine)
+{
+ setValue(group.name(), QString::null, "with_wine", withWine ? "true" : "false");
+ const_cast<Tool::Group &>(group).init();
+}
+
+Tool::OutputExecutableType Compile::Config::outputExecutableType(const Tool::Group &group)
+{
+ QString s = value(group.name(), QString::null, "output_type", Tool::OutputExecutableType(Tool::OutputExecutableType::Coff).key());
+ return Tool::OutputExecutableType::fromKey(s);
+}
+void Compile::Config::setOutputExecutableType(const Tool::Group &group, Tool::OutputExecutableType type)
+{
+ setValue(group.name(), QString::null, "output_type", type.key());
+ const_cast<Tool::Group &>(group).init();
+}
+
+QString Compile::Config::value(const QString &group, const QString &subGroup, const QString &key, const QString &defaultValue)
+{
+ QString grp = (subGroup.isEmpty() ? group : group + '-' + subGroup);
+ GenericConfig gc(grp);
+ return gc.readEntry(key, defaultValue);
+}
+void Compile::Config::setValue(const QString &group, const QString &subGroup, const QString &key, const QString &value)
+{
+ QString grp = (subGroup.isEmpty() ? group : group + '-' + subGroup);
+ GenericConfig gc(grp);
+ gc.writeEntry(key, value);
+}
+QStringList Compile::Config::listValues(const QString &group, const QString &subGroup, const QString &key, const QStringList &defaultValues)
+{
+ QString grp = (subGroup.isEmpty() ? group : group + '-' + subGroup);
+ GenericConfig gc(grp);
+ return gc.readListEntry(key, defaultValues);
+}
+void Compile::Config::setListValues(const QString &group, const QString &subGroup, const QString &key, const QStringList &values)
+{
+ QString grp = (subGroup.isEmpty() ? group : group + '-' + subGroup);
+ GenericConfig gc(grp);
+ gc.writeEntry(key, values);
+}
+
+QStringList Compile::Config::includeDirs(Tool::Category category, const QString &prefix, const QString &suffix, const QString &separator) const
+{
+ QStringList list;
+ QStringList raw = rawIncludeDirs(category);
+ for (uint i=0; i<raw.size(); i++) {
+ if ( separator.isEmpty() ) list.append(prefix + raw[i] + suffix);
+ else if ( i==0 ) list.append(prefix + raw[i]);
+ else list[0] += separator + raw[i];
+ }
+ if ( !separator.isEmpty() && list.count()!=0 ) list[0] += suffix;
+ return list;
+}
+
+HexBuffer::Format Compile::Config::hexFormat() const
+{
+ QString s = value(Tool::Category::Linker, "format", HexBuffer::FORMATS[HexBuffer::IHX32]);
+ for (uint i=0; i<HexBuffer::Nb_Formats; i++)
+ if ( s==HexBuffer::FORMATS[i] ) return HexBuffer::Format(i);
+ return HexBuffer::Nb_Formats;
+}
+void Compile::Config::setHexFormat(HexBuffer::Format f)
+{
+ QString s = (f==HexBuffer::Nb_Formats ? 0 : HexBuffer::FORMATS[f]);
+ setValue(Tool::Category::Linker, "format", s);
+}
+
+QString Compile::Config::device(const Project *project)
+{
+ QString device = globalValue(project, "device", QString::null);
+ return Device::lister().checkName(device);
+}
+
+const Tool::Group &Compile::Config::toolGroup(const Project *project)
+{
+ QString s = globalValue(project, "tool", QString::null);
+ const Tool::Group *group = Tool::lister().group(s);
+ if ( group==0 ) return *Tool::lister().begin().data();
+ return *group;
+}
+
+QStringList Compile::Config::customOptions(Tool::Category category) const
+{
+ return QStringList::split(' ', rawCustomOptions(category));
+}
+
+QStringList Compile::Config::customLibraries(Tool::Category category) const
+{
+ return QStringList::split(' ', rawCustomLibraries(category));
+}
+
+void Compile::Config::setValue(Tool::Category category, const QString &key, const QString &value)
+{
+ Q_ASSERT( category!=Tool::Category::Nb_Types );
+ Q_ASSERT( _project || _group );
+ if (_project) _project->setValue(category.key(), key, value);
+ else Config::setValue(_group->name(), category.key(), key, value);
+}
+QString Compile::Config::value(Tool::Category category, const QString &key, const QString &defaultValue) const
+{
+ Q_ASSERT( category!=Tool::Category::Nb_Types );
+ Q_ASSERT( _project || _group );
+ if (_project) return _project->value(category.key(), key, defaultValue);
+ return Config::value(_group->name(), category.key(), key, defaultValue);
+}
+void Compile::Config::setListValues(Tool::Category category, const QString &key, const QStringList &values)
+{
+ Q_ASSERT( category!=Tool::Category::Nb_Types );
+ Q_ASSERT( _project || _group );
+ if (_project) _project->setListValues(category.key(), key, values);
+ else Config::setListValues(_group->name(), category.key(), key, values);
+}
+QStringList Compile::Config::listValues(Tool::Category category, const QString &key, const QStringList &defaultValues) const
+{
+ Q_ASSERT( category!=Tool::Category::Nb_Types );
+ Q_ASSERT( _project || _group );
+ if (_project) return _project->listValues(category.key(), key, defaultValues);
+ return Config::listValues(_group->name(), category.key(), key, defaultValues);
+}
+bool Compile::Config::boolValue(Tool::Category category, const QString &key, bool defaultValue) const
+{
+ QString s = value(category, key, QString::null);
+ if ( s.isNull() ) return defaultValue;
+ return !( s=="false" || s=="0" );
+}
+uint Compile::Config::uintValue(Tool::Category category, const QString &key, uint defaultValue) const
+{
+ bool ok;
+ uint i = value(category, key, QString::null).toUInt(&ok);
+ if ( !ok ) return defaultValue;
+ return i;
+}
+
+QString Compile::Config::globalValue(const Project *project, const QString &key, const QString &defaultValue)
+{
+ if (project) return project->value("general", key, defaultValue);
+ return Config::value("general", QString::null, key, defaultValue);
+}
+void Compile::Config::setGlobalValue(Project *project, const QString &key, const QString &value)
+{
+ if (project) project->setValue("general", key, value);
+ else Config::setValue("general", QString::null, key, value);
+}
+
+QStringList Compile::Config::globalListValues(const Project *project, const QString &key, const QStringList &defaultValues)
+{
+ if (project) return project->listValues("general", key, defaultValues);
+ return Config::listValues("general", QString::null, key, defaultValues);
+}
+void Compile::Config::setGlobalListValues(Project *project, const QString &key, const QStringList &values)
+{
+ if (project) project->setListValues("general", key, values);
+ else Config::setListValues("general", QString::null, key, values);
+}
diff --git a/src/tools/list/compile_config.h b/src/tools/list/compile_config.h
new file mode 100644
index 0000000..13beff4
--- /dev/null
+++ b/src/tools/list/compile_config.h
@@ -0,0 +1,84 @@
+/***************************************************************************
+ * 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 COMPILE_CONFIG_H
+#define COMPILE_CONFIG_H
+
+#include "common/global/purl.h"
+#include "devices/base/hex_buffer.h"
+#include "tools/base/tool_group.h"
+class Project;
+
+//----------------------------------------------------------------------------
+namespace Compile
+{
+class Config
+{
+public:
+ Config(Project *project) : _group(0), _project(project) {}
+
+ bool hasCustomArguments(Tool::Category category) const { return boolValue(category, "has_custom_arguments", false); }
+ void setHasCustomArguments(Tool::Category category, bool custom) { setValue(category, "has_custom_arguments", custom); }
+ QStringList customArguments(Tool::Category category) const { return listValues(category, "custom_arguments", QStringList()); }
+ void setCustomArguments(Tool::Category category, const QStringList &args) { return setListValues(category, "custom_arguments", args); }
+ QStringList rawIncludeDirs(Tool::Category category) const { return listValues(category, "includes", "$(SRCPATH)"); }
+ QStringList includeDirs(Tool::Category category, const QString &prefix, const QString &suffix = QString::null, const QString &separator = QString::null) const;
+ void setRawIncludeDirs(Tool::Category category, const QStringList &dirs) { setListValues(category, "includes", dirs); }
+ QString rawCustomOptions(Tool::Category category) const { return value(category, "custom_options", QString::null); }
+ QStringList customOptions(Tool::Category category) const;
+ void setRawCustomOptions(Tool::Category category, const QString &value) { setValue(category, "custom_options", value); }
+ QString rawCustomLibraries(Tool::Category category) const { return value(category, "custom_libraries", QString::null); }
+ QStringList customLibraries(Tool::Category category) const;
+ void setRawCustomLibraries(Tool::Category category, const QString &value) { setValue(category, "custom_libraries", value); }
+ uint warningLevel(Tool::Category category) const { return uintValue(category, "warning_level", 0); }
+ void setWarningLevel(Tool::Category category, uint level) { setValue(category, "warning_level", QString::number(level)); }
+ HexBuffer::Format hexFormat() const;
+ void setHexFormat(HexBuffer::Format format);
+
+ static const Tool::Group &toolGroup(const Project *project);
+ static void setToolGroup(Project *project, const Tool::Group &group) { setGlobalValue(project, "tool", group.name()); }
+ static QString device(const Project *project);
+ static void setDevice(Project *project, const QString &device) { setGlobalValue(project, "device", device); }
+ static QStringList customCommands(Project *project) { return globalListValues(project, "custom_shell_commands", QStringList()); }
+ static void setCustomCommands(Project *project, const QStringList &commands) { setGlobalListValues(project, "custom_shell_commands", commands); }
+ static QString globalValue(const Project *project, const QString &key, const QString &defaultValue);
+ static void setGlobalValue(Project *project, const QString &key, const QString &value);
+ static QStringList globalListValues(const Project *project, const QString &key, const QStringList &defaultValues);
+ static void setGlobalListValues(Project *project, const QString &key, const QStringList &value);
+
+ static PURL::Directory directory(const Tool::Group &group, DirectoryType type);
+ static void setDirectory(const Tool::Group &group, DirectoryType type, const PURL::Directory &dir);
+ static bool withWine(const Tool::Group &group);
+ static void setWithWine(const Tool::Group &group, bool withWine);
+ static Tool::OutputExecutableType outputExecutableType(const Tool::Group &group);
+ static void setOutputExecutableType(const Tool::Group &group, Tool::OutputExecutableType type);
+
+protected:
+ const Tool::Group *_group;
+ Project *_project;
+
+ void setValue(Tool::Category category, const QString &key, const QString &value);
+ QString value(Tool::Category category, const QString &key, const QString &defaultValue) const;
+ void setListValues(Tool::Category category, const QString &key, const QStringList &values);
+ QStringList listValues(Tool::Category category, const QString &key, const QStringList &defaultValues) const;
+ void setValue(Tool::Category category, const QString &key, bool value) { setValue(category, key, QString(value ? "true" : "false")); }
+ bool boolValue(Tool::Category category, const QString &key, bool defaultValue) const;
+ void setValue(Tool::Category category, const QString &key, uint value) { setValue(category, key, QString::number(value)); }
+ uint uintValue(Tool::Category category, const QString &key, uint defaultValue) const;
+
+ static QString value(const QString &group, const QString &subGroup, const QString &key, const QString &defaultValue);
+ static void setValue(const QString &group, const QString &subGroup, const QString &key, const QString &value);
+ static QStringList listValues(const QString &group, const QString &subGroup, const QString &key, const QStringList &defaultValues);
+ static void setListValues(const QString &group, const QString &subGroup, const QString &key, const QStringList &values);
+
+ friend class Tool::Group;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/list/compile_manager.cpp b/src/tools/list/compile_manager.cpp
new file mode 100644
index 0000000..00a4182
--- /dev/null
+++ b/src/tools/list/compile_manager.cpp
@@ -0,0 +1,292 @@
+/***************************************************************************
+ * Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * 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 "compile_manager.h"
+
+#include <qtimer.h>
+
+#include "libgui/project.h"
+#include "common/gui/misc_gui.h"
+#include "compile_config.h"
+
+Compile::Manager::Manager(QObject *parent)
+ : QObject(parent, "compile_manager"), _base(0)
+{}
+
+void Compile::Manager::cleanFile(const PURL::Url &url)
+{
+ setupFile(Clean, TodoItem(url, false));
+}
+
+bool Compile::Manager::compileFile(const TodoItem &item)
+{
+ _label = i18n("Compiling file...");
+ return setupFile(Clean | (Main::project() ? CompileOnly : Build), item);
+}
+
+bool Compile::Manager::setupFile(Operations op, const TodoItem &item)
+{
+ Log::Base::clear();
+ clearAll();
+ _operations = op;
+ _type = NormalLinking;
+ _todo.append(item);
+ _action = Compiling;
+ _wholeProject = false;
+ QTimer::singleShot(0, this, SLOT(start()));
+ return true;
+}
+
+void Compile::Manager::cleanProject(LinkType type)
+{
+ setupProject(Clean, type);
+}
+
+bool Compile::Manager::buildProject(LinkType type)
+{
+ _label = i18n("Building project...");
+ return setupProject(Clean | Build, type);
+}
+
+bool Compile::Manager::setupProject(Operations op, LinkType type)
+{
+ Log::Base::clear();
+ clearAll();
+ _operations = op;
+ _type = type;
+ PURL::UrlList files = Main::project()->absoluteFiles();
+ if ( files.count()==0 ) {
+ MessageBox::sorry(i18n("Cannot build empty project."), Log::Show);
+ return false;
+ }
+ PURL::UrlList::const_iterator it;
+ for (it=files.begin(); it!=files.end(); ++it)
+ if ( (*it).data().group==PURL::Source ) _todo.append(TodoItem(*it, false));
+ if ( _todo.count()>1 && Main::toolGroup().compileType()==Tool::SingleFile ) {
+ MessageBox::sorry(i18n("The selected toolchain only supports single-file project."), Log::Show);
+ return false;
+ }
+ _action = Compiling;
+ _wholeProject = true;
+ QTimer::singleShot(0, this, SLOT(start()));
+ return true;
+}
+
+void Compile::Manager::kill()
+{
+ if ( clearAll() ) Log::Base::log(Log::LineType::Error, i18n("*** Aborted ***"), Log::Delayed);
+ emit failure();
+}
+
+bool Compile::Manager::clearAll()
+{
+ bool running = ( _base!=0 );
+ delete _base;
+ _base = 0;
+ _todo.clear();
+ return running;
+}
+
+void Compile::Manager::setup(Tool::Category category)
+{
+ delete _base;
+ Compile::Data data(category, _items, Main::device(), Main::project(), _type);
+ _base = Main::toolGroup().createCompileProcess(data, this);
+}
+
+bool Compile::Manager::setupCompile()
+{
+ PURL::FileType type = Main::toolGroup().implementationType(PURL::ToolType::Compiler);
+ for (uint i=0; i<_items.count(); i++) {
+ if ( _items[i].url.fileType()!=type ) {
+ if ( _operations!=Clean ) {
+ QString e = PURL::extensions(type);
+ MessageBox::detailedSorry(i18n("The selected toolchain (%1) cannot compile file. It only supports files with extensions: %2")
+ .arg(Main::toolGroup().label()).arg(e), i18n("File: %1").arg(_items[i].url.pretty()), Log::Show);
+ Log::Base::log(Log::LineType::Error, i18n("*** Aborted ***"), Log::Delayed);
+ processFailed();
+ }
+ return false;
+ }
+ }
+ if ( !compileOnly() && Main::toolGroup().needs(Main::project(), Tool::Category::Assembler) ) {
+ PURL::FileType type = Main::toolGroup().implementationType(PURL::ToolType::Assembler);
+ for (uint i=0; i<_items.count(); i++)
+ _todo.append(TodoItem(_items[i].url.toFileType(type), true));
+ }
+ setup(Tool::Category::Compiler);
+ return true;
+}
+
+bool Compile::Manager::setupAssemble()
+{
+ PURL::FileType type = Main::toolGroup().implementationType(PURL::ToolType::Assembler);
+ for (uint i=0; i<_items.count(); i++) {
+ if ( _items[i].url.fileType()!=type ) {
+ if ( _operations!=Clean ) {
+ if ( type==PURL::Nb_FileTypes ) type = Main::toolGroup().implementationType(PURL::ToolType::Compiler);
+ QString e = PURL::extensions(type);
+ MessageBox::detailedSorry(i18n("The selected toolchain (%1) cannot assemble file. It only supports files with extensions: %2")
+ .arg(Main::toolGroup().label()).arg(e), i18n("File: %1").arg(_items[i].url.pretty()), Log::Show);
+ Log::Base::log(Log::LineType::Error, i18n("*** Aborted ***"), Log::Delayed);
+ processFailed();
+ }
+ return false;
+ }
+ }
+ setup(Tool::Category::Assembler);
+ return true;
+}
+
+bool Compile::Manager::setupLink()
+{
+ _action = Linking;
+ Tool::Category category = (Main::project() && Main::project()->outputType()==Tool::OutputType::Library ? Tool::Category::Librarian : Tool::Category::Linker);
+ if ( !Main::toolGroup().needs(Main::project(), category) ) {
+ start();
+ return false;
+ }
+ setup(category);
+ return true;
+}
+
+bool Compile::Manager::setupBinToHex()
+{
+ _action = BinToHex;
+ if ( !Main::toolGroup().needs(Main::project(), Tool::Category::BinToHex) ) {
+ start();
+ return false;
+ }
+ setup(Tool::Category::BinToHex);
+ return true;
+}
+
+bool Compile::Manager::prepareAction()
+{
+ switch (_action) {
+ case Compiling:
+ if ( _todo.count()!=0 ) {
+ _items.clear();
+ if ( Main::toolGroup().compileType()==Tool::AllFiles ) {
+ _items = _todo;
+ _todo.clear();
+ } else {
+ _items.append(_todo[0]);
+ _todo.remove(_todo.begin());
+ }
+ PURL::SourceFamily family = _items[0].url.data().sourceFamily;
+ if ( family.data().toolType==PURL::ToolType::Compiler && Main::toolGroup().base(Tool::Category::Compiler) )
+ return setupCompile();
+ return setupAssemble();
+ }
+ if ( !compileOnly() ) return setupLink();
+ break;
+ case Linking: return setupBinToHex();
+ case BinToHex: break;
+ }
+ if ( !(_operations & Clean) ) {
+ Log::Base::log(Log::LineType::Information, i18n("*** Success ***"), Log::Delayed);
+ emit success();
+ } else if ( _operations!=Clean ) {
+ _operations &= ~Clean;
+ if (_wholeProject) setupProject(_operations, _type);
+ else setupFile(_operations, _items[0]);
+ }
+ return false;
+}
+
+void Compile::Manager::start()
+{
+ if ( Main::toolGroup().isCustom() ) {
+ executeCustomCommands();
+ return;
+ }
+ delete _base;
+ _base = 0;
+ if ( !prepareAction() ) return;
+ if ( !_base->check() ) {
+ processFailed();
+ return;
+ }
+ if ( _operations & Clean ) {
+ _base->files(0).onlyExistingFiles().cleanGenerated();
+ QTimer::singleShot(0, this, SLOT(start()));
+ return;
+ }
+ if ( !_base->start() ) {
+ Log::Base::log(Log::LineType::Error, i18n("Failed to execute command: check toolchain configuration."), Log::Delayed);
+ processFailed();
+ }
+}
+
+void Compile::Manager::log(Log::LineType type, const QString &message, const QString &filepath, uint line)
+{
+ if ( type==Log::LineType::Error ) setError(message);
+ static_cast<LogWidget *>(view())->appendLine(type, message, filepath, line);
+}
+
+void Compile::Manager::log(Log::DebugLevel level, const QString &message, const QString &filepath, uint line)
+{
+ static_cast<LogWidget *>(view())->appendLine(level, message, filepath, line);
+}
+
+void Compile::Manager::processDone()
+{
+ if ( hasError() ) {
+ processFailed();
+ return;
+ }
+ if ( Main::toolGroup().isCustom() ) {
+ _customCommandIndex++;
+ startCustomCommand();
+ } else {
+ FileData::List list = _base->files(0).onlyExistingFiles();
+ FileData::List::iterator it;
+ for (it=list.begin(); it!=list.end(); ++it) emit updateFile(*it);
+ QTimer::singleShot(0, this, SLOT(start()));
+ }
+}
+
+void Compile::Manager::processFailed()
+{
+ clearAll();
+ emit failure();
+}
+
+void Compile::Manager::startCustomCommand()
+{
+ delete _base;
+ _base = 0;
+ QStringList commands = Compile::Config::customCommands(Main::project());
+ if ( _customCommandIndex==commands.count() ) {
+ Log::Base::log(Log::LineType::Information, i18n("*** Success ***"), Log::Delayed);
+ emit success();
+ return;
+ }
+ QString command = commands[_customCommandIndex];
+ _base = new CustomProcess(command);
+ Compile::Data data(Tool::Category::Nb_Types, _todo, Main::device(), Main::project(), _type);
+ _base->init(data, this);
+ if ( !_base->start() ) {
+ Log::Base::log(Log::LineType::Error, i18n("Failed to execute custom command #%1.").arg(_customCommandIndex+1), Log::Delayed);
+ processFailed();
+ }
+}
+
+void Compile::Manager::executeCustomCommands()
+{
+ _customCommandIndex = 0;
+ if ( Compile::Config::customCommands(Main::project()).isEmpty() ) {
+ MessageBox::sorry(i18n("No custom commands specified."), Log::Show);
+ emit failure();
+ return;
+ }
+ log(Log::LineType::Information, i18n("Executing custom commands..."));
+ startCustomCommand();
+}
diff --git a/src/tools/list/compile_manager.h b/src/tools/list/compile_manager.h
new file mode 100644
index 0000000..6f617b4
--- /dev/null
+++ b/src/tools/list/compile_manager.h
@@ -0,0 +1,74 @@
+/***************************************************************************
+ * Copyright (C) 2005-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 COMPILE_MANAGER_H
+#define COMPILE_MANAGER_H
+
+#include "compile_process.h"
+
+namespace Compile
+{
+
+class Manager : public QObject, public Log::Base
+{
+Q_OBJECT
+public:
+ enum Operation { NoOperation = 0, Clean = 1, CompileOnly = 2, Build = 4 };
+ Q_DECLARE_FLAGS(Operations, Operation)
+
+public:
+ Manager(QObject *parent);
+ QString label() const { return _label; }
+ bool compileFile(const TodoItem &item);
+ void cleanFile(const PURL::Url &url);
+ bool buildProject(LinkType type);
+ void cleanProject(LinkType type);
+ void kill();
+ bool compileOnly() const { return (_operations & CompileOnly); }
+ void processDone();
+ void processFailed();
+ void log(Log::LineType type, const QString &message, const QString &filepath = QString::null, uint line = 0);
+ void log(Log::DebugLevel debug, const QString &message, const QString &filepath = QString::null, uint line = 0);
+
+signals:
+ void success();
+ void failure();
+ void updateFile(const Compile::FileData &fdata);
+
+private slots:
+ void start();
+
+private:
+ Operations _operations;
+ enum Action { Compiling, Linking, BinToHex };
+ Action _action;
+ QValueList<TodoItem> _todo, _items;
+ BaseProcess *_base;
+ QString _label;
+ LinkType _type;
+ bool _wholeProject;
+ uint _customCommandIndex;
+
+ bool startProject();
+ bool clearAll();
+ bool setupFile(Operations operations, const TodoItem &item);
+ bool setupProject(Operations operations, LinkType type);
+ void setup(Tool::Category category);
+ bool setupCompile();
+ bool setupAssemble();
+ bool setupLink();
+ bool setupBinToHex();
+ bool prepareAction();
+ void startCustomCommand();
+ void executeCustomCommands();
+};
+Q_DECLARE_OPERATORS_FOR_FLAGS(Manager::Operations)
+
+} // namespace
+
+#endif
diff --git a/src/tools/list/compile_process.cpp b/src/tools/list/compile_process.cpp
new file mode 100644
index 0000000..4f251bc
--- /dev/null
+++ b/src/tools/list/compile_process.cpp
@@ -0,0 +1,376 @@
+/***************************************************************************
+ * Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * 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 "compile_process.h"
+
+#include <qtimer.h>
+#include <qregexp.h>
+
+#include "devices/list/device_list.h"
+#include "common/global/process.h"
+#include "common/gui/misc_gui.h"
+#include "libgui/text_editor.h"
+#include "libgui/editor_manager.h"
+#include "libgui/project.h"
+#include "compile_config.h"
+#include "compile_manager.h"
+
+//-----------------------------------------------------------------------------
+const Compile::ArgumentData Compile::ARGUMENT_DATA[] = {
+ { "$(SRCPATH)", I18N_NOOP("Replaced by the source directory.") },
+ { "$LKR(xxx)", I18N_NOOP("Replaced by \"xxx\" when there is a custom linker script.") },
+ { "$WINE(xxx)", I18N_NOOP("Replaced by \"xxx\" when \"wine\" is used.") },
+ { "$NO_AUTO_DEVICE(xxx)", I18N_NOOP("Replaced by \"xxx\" when the device name is specified.") },
+ { "%OBJS", I18N_NOOP("Replaced by the list of additionnal objects.") },
+ { "%LIBS", I18N_NOOP("Replaced by the list of additionnal libraries.") },
+ { "%O", I18N_NOOP("Replaced by the output filename.") },
+ { "%PROJECT", I18N_NOOP("Replaced by the project name.") },
+ { "%COFF", I18N_NOOP("Replaced by the COFF filename.") },
+ { "%MAP", I18N_NOOP("Replaced by the map filename.") },
+ { "%SYM", I18N_NOOP("Replaced by the symbol filename.") },
+ { "%LIST", I18N_NOOP("Replaced by the list filename.") },
+ { "%DEVICE", I18N_NOOP("Replaced by the device name.") },
+ { "%FAMILY", I18N_NOOP("Replaced by the device family name (when needed).") },
+ { "%I", I18N_NOOP("Replaced by the relative input filepath(s).") },
+ { "%OBJECT", I18N_NOOP("Replaced by the object file name.") },
+ { "%LKR_PATH", I18N_NOOP("Replaced by the linker script path.") },
+ { "%LKR_NAME", I18N_NOOP("Replaced by the linker script basename.") },
+ { "%LKR", I18N_NOOP("Replaced by the linker script filename.") },
+ { "%SEP", I18N_NOOP("Replaced by a separation into two arguments.") },
+ { 0, 0 }
+};
+
+//-----------------------------------------------------------------------------
+Compile::FileData::List Compile::FileData::List::onlyExistingFiles() const
+{
+ List list;
+ List::const_iterator it;
+ for (it=begin(); it!=end(); ++it) {
+ FileData data = *it;
+ if ( PURL::findExistingUrl(data.url) ) list.append(data);
+ }
+ return list;
+}
+
+void Compile::FileData::List::cleanGenerated() const
+{
+ Log::StringView sview;
+ List::const_iterator it;
+ for (it=begin(); it!=end(); ++it)
+ if ( (*it).actions & Generated ) (*it).url.del(sview);
+}
+
+//-----------------------------------------------------------------------------
+Compile::LogWidget::LogWidget(QWidget *parent)
+ : Log::Widget(parent, "compile_log")
+{
+ connect(this, SIGNAL(clicked(int, int)), SLOT(lineClicked(int)));
+}
+
+void Compile::LogWidget::clear()
+{
+ Log::Widget::clear();
+ _map.clear();
+}
+
+void Compile::LogWidget::appendLine(Log::LineType type, const QString &message, const QString &filepath, uint line)
+{
+ log(type, message, Log::Delayed);
+ if ( !filepath.isEmpty() ) _map[paragraphs()-1] = Data(filepath, line);
+}
+
+void Compile::LogWidget::appendLine(Log::DebugLevel level, const QString &message, const QString &filepath, uint line)
+{
+ log(level, message, Log::Delayed);
+ if ( !filepath.isEmpty() ) _map[paragraphs()-1] = Data(filepath, line);
+}
+
+void Compile::LogWidget::lineClicked(int line)
+{
+ if ( !_map.contains(line) ) return;
+ PURL::Url url = PURL::Url::fromPathOrUrl(_map[line].filepath);
+ TextEditor *e = ::qt_cast<TextEditor *>(Main::editorManager().openEditor(url));
+ if ( e==0 ) return;
+ e->setCursor(_map[line].line, 0);
+}
+
+//-----------------------------------------------------------------------------
+Compile::BaseProcess::BaseProcess()
+ : QObject(0, "compile_process"), _manager(0), _process(0)
+{}
+
+void Compile::BaseProcess::init(const Data &data, Manager *manager)
+{
+ _data = data;
+ _manager = manager;
+}
+
+PURL::Directory Compile::BaseProcess::directory(uint i) const
+{
+ if (_data.project) return _data.project->directory();
+ Q_ASSERT( i<_data.items.count() );
+ return _data.items[i].url.directory();
+}
+
+bool Compile::BaseProcess::start()
+{
+ _stdout = QString::null;
+ _stderr = QString::null;
+ delete _process;
+ _process = new ::Process::LineSignal;
+ connect(_process, SIGNAL(done(int)), SLOT(done(int)));
+ connect(_process, SIGNAL(timeout()), SLOT(timeout()));
+ connect(_process, SIGNAL(logStdoutLine(const QString &)), SLOT(logStdoutLine(const QString &)));
+ connect(_process, SIGNAL(logStderrLine(const QString &)), SLOT(logStderrLine(const QString &)));
+ _process->setWorkingDirectory(directory().path());
+ setupProcess();
+ _manager->log(Log::LineType::Command, _process->arguments().join(" "));
+ return _process->start(0); // no timeout
+}
+
+void Compile::BaseProcess::done(int code)
+{
+ if ( code!=0 ) {
+ _manager->log(Log::LineType::Error, i18n("*** Exited with status: %1 ***").arg(code));
+ _manager->processFailed();
+ } else if ( _manager->hasError() ) {
+ _manager->log(Log::LineType::Error, i18n("*** Error ***"));
+ _manager->processFailed();
+ } else _manager->processDone();
+}
+
+void Compile::BaseProcess::timeout()
+{
+ _manager->log(Log::LineType::Error, i18n("*** Timeout ***"));
+ _manager->processFailed();
+}
+
+//-----------------------------------------------------------------------------
+void Compile::Process::init(const Data &data, Manager *manager)
+{
+ BaseProcess::init(data, manager);
+ _config = group().createConfig(const_cast<Project *>(data.project));
+}
+
+Compile::Process::~Process()
+{
+ delete _config;
+}
+
+bool Compile::Process::check() const
+{
+ return group().check(_data.device, _manager);
+}
+
+PURL::Url Compile::Process::url(PURL::FileType type, uint i) const
+{
+ PURL::Url url;
+ if ( _data.project && (type==PURL::Hex || _data.category==Tool::Category::Linker || _data.category==Tool::Category::BinToHex) )
+ url = _data.project->url();
+ else if ( _data.project && (type==PURL::Library || _data.category==Tool::Category::Librarian) )
+ return _data.project->url().toExtension(libraryExtension());
+ else {
+ Q_ASSERT( i<_data.items.count() );
+ url = _data.items[i].url;
+ }
+ if ( type==PURL::Nb_FileTypes ) return url;
+ return url.toFileType(type);
+}
+
+QString Compile::Process::filepath(PURL::FileType type, uint i) const
+{
+ return url(type, i).relativeTo(directory(), Compile::Config::withWine(group()) ? PURL::WindowsSeparator : PURL::UnixSeparator);
+}
+
+QString Compile::Process::outputFilepath() const
+{
+ if ( _data.category==Tool::Category::Librarian ) return filepath(PURL::Library);
+ return filepath(PURL::Hex);
+}
+
+Compile::FileData Compile::Process::fileData(PURL::FileType type, FileActions actions) const
+{
+ return FileData(url(type, nbFiles()-1), actions);
+}
+
+Compile::FileData::List Compile::Process::files(bool *ok) const
+{
+ if (ok) *ok = true;
+ FileData::List list;
+ QRegExp rexp("PURL::(.*)");
+ QStringList files = QStringList::split(" ", outputFiles());
+ for (uint i=0; i<files.count(); i++) {
+ if ( rexp.exactMatch(files[i]) ) {
+ PURL::FileType type = PURL::FileType::fromKey(rexp.cap(1));
+ if ( type==PURL::Nb_FileTypes ) {
+ if (ok) *ok = false;
+ qWarning("Unknown PURL::FileType in file list for %s", _manager->label().latin1());
+ continue;
+ }
+ if ( type.data().group==PURL::LinkerScript ) {
+ PURL::Url lkr = Main::toolGroup().linkerScript(_data.project, _data.linkType);
+ list += FileData(lkr, Included | InProject);
+ } else {
+ FileActions actions = Generated;
+ if ( type.data().group==PURL::Source || type==PURL::Hex
+ || type==PURL::Map || type==PURL::Coff || type==PURL::Library ) actions |= InProject;
+ if ( type==PURL::Hex && _data.project==0 ) actions |= Show;
+ list += fileData(type, actions);
+ }
+ } else list += FileData(url().toExtension(files[i]), Compile::Generated);
+ }
+ return list;
+}
+
+bool Compile::Process::checkIs(const QString &s, const QString &key)
+{
+ if ( !s.contains(key) ) return false;
+ if ( s!=key ) qWarning("Argument should be only %s, the rest will be ignored...", key.latin1());
+ return true;
+}
+
+QString Compile::Process::replaceIf(const QString &s, const QString &key, bool condition)
+{
+ QRegExp rexp("(.*)\\$" + key + "\\(([^)]*)\\)(.*)");
+ if ( !rexp.exactMatch(s) ) return s;
+ return rexp.cap(1) + (condition ? rexp.cap(2) : QString::null) + rexp.cap(3);
+}
+
+QStringList Compile::Process::arguments() const
+{
+ bool custom = _config->hasCustomArguments(_data.category);
+ bool withWine = Compile::Config::withWine(group());
+ QStringList args = (custom ? _config->customArguments(_data.category) : genericArguments(*_config));
+ PURL::Url lkr = Main::toolGroup().linkerScript(_data.project, _data.linkType);
+ QStringList nargs;
+ for (uint i=0; i<args.count(); i++) {
+ if ( args[i].contains("$(SRCPATH)") ) {
+ args[i].replace("$(SRCPATH)", directory().path());
+ args[i].replace("//", "/");
+ }
+ args[i] = replaceIf(args[i], "WINE", withWine);
+ args[i] = replaceIf(args[i], "LKR", hasLinkerScript());
+ args[i] = replaceIf(args[i], "NO_AUTO_DEVICE", _data.device!=Device::AUTO_DATA.name);
+ if ( checkIs(args[i], "%OBJS") ) { // before %O
+ if (_data.project) nargs += _data.project->objectsForLinker(objectExtension(), withWine);
+ else {
+ PURL::Url tmp = url(PURL::Object);
+ if ( !objectExtension().isEmpty() ) tmp = tmp.toExtension(objectExtension());
+ nargs += tmp.relativeTo(directory(), withWine ? PURL::WindowsSeparator : PURL::UnixSeparator);
+ }
+ continue;
+ }
+ if ( checkIs(args[i], "%LIBS") ) {
+ if (_data.project) nargs += _data.project->librariesForLinker(QString::null, withWine);
+ continue;
+ }
+ args[i].replace("%OBJECT", filepath(PURL::Object)); // before %O
+ args[i].replace("%O", outputFilepath());
+ args[i].replace("%COFF", filepath(PURL::Coff));
+ if (_data.project) args[i].replace("%PROJECT", _data.project->name());
+ else args[i].replace("%PROJECT", url().basename());
+ args[i].replace("%MAP", filepath(PURL::Map));
+ args[i].replace("%SYM", url().toExtension("sym").relativeTo(directory(), withWine ? PURL::WindowsSeparator : PURL::UnixSeparator));
+ args[i].replace("%LIST", filepath(PURL::Lst));
+ args[i].replace("%DEVICE", deviceName());
+ args[i].replace("%FAMILY", familyName());
+ args[i].replace("%LKR_PATH", lkr.path()); // before %LKR
+ args[i].replace("%LKR_NAME", lkr.filename()); // before LKR
+ args[i].replace("%LKR", lkr.filepath());
+ if ( checkIs(args[i], "%I") ) {
+ for (uint k=0; k<nbFiles(); k++) nargs += inputFilepath(k);
+ continue;
+ }
+ if ( !args[i].isEmpty() ) nargs += args[i];
+ }
+ args.clear();
+ for (uint i=0; i<nargs.count(); i++) args += QStringList::split("%SEP", nargs[i]);
+ return args;
+}
+
+void Compile::Process::setupProcess()
+{
+ bool withWine = Compile::Config::withWine(group());
+ QString exec = tool()->baseExecutable(withWine, Compile::Config::outputExecutableType(group()));
+ QString path = tool()->executableDirectory().path();
+ _process->setup(path + exec, arguments(), withWine);
+}
+
+Log::LineType Compile::Process::filterType(const QString &type) const
+{
+ QString s = type.lower();
+ if ( s.startsWith("warning") ) return Log::LineType::Warning;
+ if ( s.startsWith("error") ) return Log::LineType::Error;
+ if ( s.startsWith("message") ) return Log::LineType::Information;
+ return Log::LineType::Normal;
+}
+
+bool Compile::Process::parseErrorLine(const QString &s, const ParseErrorData &data)
+{
+ QRegExp re(data.pattern);
+ if ( !re.exactMatch(s) ) return false;
+ QString file;
+ if ( data.indexFile>=0 ) {
+ file = re.cap(data.indexFile).stripWhiteSpace();
+ if ( file.endsWith(".") ) file = file.mid(0, file.length()-1);
+ if ( file=="-" ) file = QString::null;
+ }
+ bool ok;
+ int line = -1;
+ if ( data.indexLine>=0 ) line = re.cap(data.indexLine).stripWhiteSpace().toUInt(&ok) - 1;
+ if ( !ok ) line = -1;
+ QString message;
+ if ( data.indexMessage>=0 ) message= re.cap(data.indexMessage).stripWhiteSpace();
+ Log::LineType type = data.defaultLineType;
+ if ( data.indexLogType>=0 ) {
+ QString s = re.cap(data.indexLogType).stripWhiteSpace();
+ if ( s.isEmpty() ) type = data.defaultLineType;
+ else type = filterType(s);
+ }
+ doLog(type, message, file, line);
+ return true;
+}
+
+void Compile::Process::doLog(const QString &type, const QString &message, const QString &surl, uint line)
+{
+ doLog(filterType(type), message, surl, line);
+}
+
+void Compile::Process::doLog(Log::LineType type, const QString &message, const QString &surl, uint line)
+{
+ if ( surl.isEmpty() ) {
+ _manager->log(type, message);
+ return;
+ }
+ PURL::Url url = PURL::Url::fromPathOrUrl(surl);
+ QString s;
+ if ( !url.isEmpty() ) {
+ if ( !url.exists() && !url.isInto(directory()) ) url = PURL::Url(directory(), surl);
+ s += url.filename() + ":" + QString::number(line+1) + ": ";
+ }
+ switch (type.type()) {
+ case Log::LineType::Warning: s += i18n("warning: "); break;
+ case Log::LineType::Error: s += i18n("error: "); break;
+ case Log::LineType::Information: s += i18n("message: "); break;
+ default: break;
+ }
+ _manager->log(type, s + message.stripWhiteSpace(), url.filepath(), line);
+}
+
+//-----------------------------------------------------------------------------
+void Compile::CustomProcess::setupProcess()
+{
+ _process->setUseShell(true);
+ _process->setup(_command, QStringList(), false);
+}
+
+void Compile::CustomProcess::logStderrLine(const QString &line)
+{
+ _manager->log(Log::LineType::Normal, line);
+}
diff --git a/src/tools/list/compile_process.h b/src/tools/list/compile_process.h
new file mode 100644
index 0000000..4fe396e
--- /dev/null
+++ b/src/tools/list/compile_process.h
@@ -0,0 +1,179 @@
+/***************************************************************************
+ * Copyright (C) 2005-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 COMPILE_PROCESS_H
+#define COMPILE_PROCESS_H
+
+#include "common/common/qflags.h"
+#include "common/global/purl.h"
+#include "libgui/log_view.h"
+#include "devices/base/hex_buffer.h"
+#include "tools/base/tool_group.h"
+#include "tools/base/generic_tool.h"
+#include "libgui/main_global.h"
+namespace Process { class LineSignal; }
+
+namespace Compile
+{
+ class Manager;
+ enum FileAction { NoAction = 0, Show = 1, InProject = 2, Generated = 8, Included = 16 };
+ Q_DECLARE_FLAGS(FileActions, FileAction)
+ Q_DECLARE_OPERATORS_FOR_FLAGS(FileActions)
+
+ class FileData {
+ public:
+ FileData() {}
+ FileData(const PURL::Url &u, FileActions a) : url(u), actions(a) {}
+ PURL::Url url;
+ FileActions actions;
+ class List : public QValueList<FileData> {
+ public:
+ List() {}
+ List(const FileData &data) { append(data); }
+ List onlyExistingFiles() const;
+ void cleanGenerated() const;
+ };
+ };
+
+ struct ArgumentData {
+ const char *key, *description;
+ };
+ extern const ArgumentData ARGUMENT_DATA[];
+
+ class ParseErrorData {
+ public:
+ ParseErrorData(const QString &p, int iFile, int iLine, int iMessage, Log::LineType dLineType)
+ : pattern(p), indexFile(iFile), indexLine(iLine), indexMessage(iMessage), indexLogType(-1),
+ defaultLineType(dLineType) {}
+ ParseErrorData(const QString &p, int iFile, int iLine, int iMessage, uint iLogType,
+ Log::LineType dLineType = Log::LineType::Error)
+ : pattern(p), indexFile(iFile), indexLine(iLine), indexMessage(iMessage), indexLogType(iLogType),
+ defaultLineType(dLineType) {}
+ QString pattern;
+ int indexFile, indexLine, indexMessage, indexLogType;
+ Log::LineType defaultLineType;
+ };
+
+//-----------------------------------------------------------------------------
+class LogWidget : public Log::Widget
+{
+ Q_OBJECT
+public:
+ LogWidget(QWidget *parent);
+ void appendLine(Log::LineType type, const QString &message, const QString &filepath, uint line);
+ void appendLine(Log::DebugLevel debug, const QString &message, const QString &filepath, uint line);
+ virtual void clear();
+
+private slots:
+ void lineClicked(int line);
+
+private:
+ class Data {
+ public:
+ Data() {}
+ Data(const QString &fp, uint l) : filepath(fp), line(l) {}
+ QString filepath;
+ uint line;
+ };
+ QMap<uint, Data> _map;
+};
+
+//-----------------------------------------------------------------------------
+class BaseProcess : public QObject
+{
+Q_OBJECT
+public:
+ BaseProcess();
+ virtual void init(const Data &data, Manager *manager);
+ virtual bool check() const = 0;
+ virtual FileData::List files(bool *ok) const = 0;
+ bool start();
+
+signals:
+ void success();
+ void failure();
+
+protected:
+ Manager *_manager;
+ Data _data;
+ ::Process::LineSignal *_process;
+ QString _stdout, _stderr;
+
+ const Tool::Group &group() const { return Main::toolGroup(); }
+ PURL::Directory directory(uint i = 0) const;
+ virtual void setupProcess() = 0;
+
+protected slots:
+ virtual void logStdoutLine(const QString &line) { logStderrLine(line); }
+ virtual void logStderrLine(const QString &line) = 0;
+ virtual void done(int code);
+ void timeout();
+};
+
+//-----------------------------------------------------------------------------
+class Process : public BaseProcess
+{
+Q_OBJECT
+public:
+ virtual ~Process();
+ virtual void init(const Data &data, Manager *manager);
+ virtual bool check() const;
+ virtual FileData::List files(bool *ok) const;
+ virtual QStringList genericArguments(const Compile::Config &config) const = 0;
+ void checkArguments() const;
+
+protected:
+ Config *_config;
+
+ virtual PURL::Url url(PURL::FileType type = PURL::Nb_FileTypes, uint i = 0) const;
+ QString filepath(PURL::FileType type, uint i=0) const;
+ virtual QString outputFilepath() const;
+ virtual QString outputFiles() const = 0;
+ uint nbFiles() const { return _data.items.count(); }
+ virtual QString inputFilepath(uint i) const { return filepath(PURL::Nb_FileTypes, i); }
+ virtual QString deviceName() const = 0;
+ virtual QString familyName() const { return QString::null; }
+ virtual QString objectExtension() const { return QString::null; }
+ virtual QString libraryExtension() const { return "lib"; }
+ virtual bool hasLinkerScript() const { return group().hasCustomLinkerScript(_data.project); }
+ FileData fileData(PURL::FileType type, FileActions actions) const;
+ bool parseErrorLine(const QString &s, const ParseErrorData &data);
+ virtual Log::LineType filterType(const QString &type) const;
+ void doLog(const QString &type, const QString &message, const QString &surl, uint line);
+ void doLog(Log::LineType type, const QString &message, const QString &surl, uint line);
+ virtual void setupProcess();
+ QStringList arguments() const;
+ const Tool::Base *tool() const { return group().base(_data.category); }
+
+private:
+ static bool checkIs(const QString &s, const QString &key);
+ static QString replaceIf(const QString &s, const QString &key, bool condition);
+};
+
+//-----------------------------------------------------------------------------
+class CustomProcess : public BaseProcess
+{
+Q_OBJECT
+public:
+ CustomProcess(const QString &command) : _command(command) {}
+ virtual bool check() const { return true; }
+ virtual FileData::List files(bool *ok) const { if (ok) *ok = true; return FileData::List(); }
+
+protected:
+ virtual void setupProcess();
+
+protected slots:
+ virtual void logStderrLine(const QString &line);
+
+private:
+ QString _command;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/list/device_info.cpp b/src/tools/list/device_info.cpp
new file mode 100644
index 0000000..78ca7a7
--- /dev/null
+++ b/src/tools/list/device_info.cpp
@@ -0,0 +1,63 @@
+/***************************************************************************
+ * Copyright (C) 2005-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 "device_info.h"
+
+#include "devices/base/generic_device.h"
+#include "progs/list/prog_list.h"
+#include "tool_list.h"
+
+QString Device::webpageHtml(const Device::Data &data)
+{
+ const Device::Documents &documents = data.documents();
+ QString url = "http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=";
+ if ( documents.webpage.isEmpty() ) url += "2044&amp;AllWords=" + data.name();
+ else url += "1335&amp;dDocName=en" + documents.webpage;
+ return "<a href=\"" + url + "\">" + i18n("Device Page") + "</a> ";
+}
+
+QString documentHtml(const QString &document, const QString &label)
+{
+ if ( document.isEmpty() ) return QString::null;
+ return ", <a href=\"document://" + document + "\">" + label + "</a>";
+}
+
+QString Device::documentHtml(const Device::Data &data)
+{
+ QString s = webpageHtml(data);
+ s += documentHtml(data.documents().datasheet, i18n("Datasheet"));
+ s += documentHtml(data.documents().progsheet, i18n("Programming Specifications"));
+ return htmlTableRow(i18n("Documents"), s);
+}
+
+QString Device::supportedHtmlInfo(const Device::Data &data)
+{
+ QString doc;
+ doc += "<hr />\n";
+ doc += "<table>\n";
+ QString tools;
+ Tool::Lister::ConstIterator tit;
+ for (tit=Tool::lister().begin(); tit!=Tool::lister().end(); ++tit) {
+ if ( !tit.data()->isSupported(data.name()) ) continue;
+ if ( tit.data()->isCustom() ) continue;
+ if ( !tools.isEmpty() ) tools += ", ";
+ tools += tit.data()->label();
+ }
+ doc += htmlTableRow(i18n("Tools"), tools) + "\n";
+ QString progs;
+ Programmer::Lister::ConstIterator pit;
+ for (pit=Programmer::lister().begin(); pit!=Programmer::lister().end(); ++pit) {
+ if ( !pit.data()->isSupported(data.name()) ) continue;
+ if ( !progs.isEmpty() ) progs += ", ";
+ progs += pit.data()->label();
+ }
+ doc += htmlTableRow(i18n("Programmers"), progs) + "\n";
+ doc += "</table>\n";
+
+ return doc;
+}
diff --git a/src/tools/list/device_info.h b/src/tools/list/device_info.h
new file mode 100644
index 0000000..ad69c59
--- /dev/null
+++ b/src/tools/list/device_info.h
@@ -0,0 +1,22 @@
+/***************************************************************************
+ * Copyright (C) 2005-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 DEVICE_INFO_H
+#define DEVICE_INFO_H
+
+#include <qstring.h>
+namespace Device { class Data; }
+
+namespace Device
+{
+ extern QString webpageHtml(const Device::Data &data);
+ extern QString documentHtml(const Device::Data &data);
+ extern QString supportedHtmlInfo(const Device::Data &data);
+} // namespace
+
+#endif
diff --git a/src/tools/list/tool_list.cpp b/src/tools/list/tool_list.cpp
new file mode 100644
index 0000000..da21cd7
--- /dev/null
+++ b/src/tools/list/tool_list.cpp
@@ -0,0 +1,69 @@
+/***************************************************************************
+ * Copyright (C) 2005-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 "tool_list.h"
+
+#include "tools/gputils/gputils.h"
+#include "tools/gputils/gui/gputils_ui.h"
+#include "tools/sdcc/sdcc.h"
+#include "tools/sdcc/gui/sdcc_ui.h"
+#include "tools/pic30/pic30.h"
+#include "tools/pic30/gui/pic30_ui.h"
+#include "tools/picc/picc.h"
+#include "tools/picc/gui/picc_ui.h"
+#include "tools/jal/jal.h"
+#include "tools/jal/gui/jal_ui.h"
+#include "tools/c18/c18.h"
+#include "tools/c18/gui/c18_ui.h"
+#include "tools/ccsc/ccsc.h"
+#include "tools/ccsc/gui/ccsc_ui.h"
+#include "tools/jalv2/jalv2.h"
+#include "tools/jalv2/gui/jalv2_ui.h"
+#include "tools/boost/boostc.h"
+#include "tools/boost/boostcpp.h"
+#include "tools/boost/boostbasic.h"
+#include "tools/boost/gui/boost_ui.h"
+#include "tools/mpc/mpc.h"
+#include "tools/mpc/gui/mpc_ui.h"
+#include "tools/cc5x/cc5x.h"
+#include "tools/cc5x/gui/cc5x_ui.h"
+#include "tools/custom/custom.h"
+
+Tool::Lister::Lister()
+{
+ addGroup(new GPUtils::Group, new GPUtils::GroupUI);
+ addGroup(new SDCC::Group, new SDCC::GroupUI);
+ addGroup(new PIC30::Group, new PIC30::GroupUI);
+ addGroup(new PICC::PICCLiteGroup, new PICC::GroupUI);
+ addGroup(new PICC::PICCGroup, new PICC::GroupUI);
+ addGroup(new PICC::PICC18Group, new PICC::GroupUI);
+ addGroup(new JAL::Group, new JAL::GroupUI);
+ addGroup(new C18::Group, new C18::GroupUI);
+ addGroup(new CCSC::Group, new CCSC::GroupUI);
+ addGroup(new JALV2::Group, new JALV2::GroupUI);
+ addGroup(new Boost::GroupC16, new Boost::GroupUI);
+ addGroup(new Boost::GroupC18, new Boost::GroupUI);
+ addGroup(new Boost::GroupCpp16, new Boost::GroupUI);
+ addGroup(new Boost::GroupCpp18, new Boost::GroupUI);
+ addGroup(new Boost::GroupBasic16, new Boost::GroupUI);
+ addGroup(new Boost::GroupBasic18, new Boost::GroupUI);
+ addGroup(new MPC::Group, new MPC::GroupUI);
+ addGroup(new CC5X::Group, new CC5X::GroupUI);
+ addGroup(new CustomTool::Group, 0);
+}
+
+namespace Tool
+{
+ Lister *_lister = 0;
+}
+
+const Tool::Lister &Tool::lister()
+{
+ if ( _lister==0 ) _lister = new Lister;
+ return *_lister;
+}
diff --git a/src/tools/list/tool_list.h b/src/tools/list/tool_list.h
new file mode 100644
index 0000000..b63aee0
--- /dev/null
+++ b/src/tools/list/tool_list.h
@@ -0,0 +1,28 @@
+/***************************************************************************
+ * Copyright (C) 2005-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 TOOL_LIST_H
+#define TOOL_LIST_H
+
+#include "common/common/lister.h"
+#include "tools/base/tool_group.h"
+
+namespace Tool
+{
+
+class Lister : public ::Group::Lister<Group>
+{
+public:
+ Lister();
+};
+
+extern const Lister &lister();
+
+} // namespace
+
+#endif
diff --git a/src/tools/list/tools_config_widget.cpp b/src/tools/list/tools_config_widget.cpp
new file mode 100644
index 0000000..449183d
--- /dev/null
+++ b/src/tools/list/tools_config_widget.cpp
@@ -0,0 +1,144 @@
+/***************************************************************************
+ * Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * 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 "tools_config_widget.h"
+
+#include <qwidgetstack.h>
+#include <qlabel.h>
+
+#include "tool_list.h"
+#include "tools/gui/tool_config_widget.h"
+#include "tools/gui/tool_group_ui.h"
+#include "compile_config.h"
+#include "compile_process.h"
+#include "libgui/project.h"
+
+//----------------------------------------------------------------------------
+HelpDialog::HelpDialog(QWidget *parent)
+ : Dialog(parent, "help_dialog", false, i18n("Help Dialog"), Close, Close, false)
+{
+ QGridLayout *top = new QGridLayout(mainWidget(), 1, 1, 10, 10);
+ uint k = 0;
+ for (; Compile::ARGUMENT_DATA[k].key; k++) {
+ QLabel *label = new QLabel(Compile::ARGUMENT_DATA[k].key, mainWidget());
+ top->addWidget(label, k, 0);
+ label = new QLabel(i18n(Compile::ARGUMENT_DATA[k].description), mainWidget());
+ top->addWidget(label, k, 1);
+ }
+ top->setColStretch(2, 1);
+ top->setRowStretch(k, 1);
+}
+
+//----------------------------------------------------------------------------
+ToolsConfigWidget::ToolsConfigWidget(Project *project, QWidget *parent)
+ : ::ConfigWidget(parent), _project(project), _helpDialog(0)
+{
+ uint row = 0;
+
+ QLabel *label = new QLabel(i18n("Toolchain:"), this);
+ addWidget(label, row,row, 0,0);
+ _tool = new KeyComboBox<QString>(this);
+ Tool::Lister::ConstIterator it;
+ for (it=Tool::lister().begin(); it!=Tool::lister().end(); ++it)
+ _tool->appendItem(it.key(), it.data()->label());
+ connect(_tool->widget(), SIGNAL(activated(int)), SLOT(toolChanged()));
+ addWidget(_tool->widget(), row,row, 1,1);
+ label = new QLabel(i18n("Output type:"), this);
+ addWidget(label, row,row, 2,2);
+ _output = new KeyComboBox<Tool::OutputType>(this);
+ FOR_EACH(Tool::OutputType, type) _output->appendItem(type, type.label());
+ addWidget(_output->widget(), row,row, 3,3);
+ row++;
+
+ _mainStack = new QWidgetStack(this);
+ addWidget(_mainStack, row,row, 0,4);
+ row++;
+ _tabWidget = new QTabWidget(_mainStack);
+ _mainStack->addWidget(_tabWidget);
+ FOR_EACH(Tool::Category, category) {
+ _stacks[category] = new KeyWidgetStack<QString>(_tabWidget);
+ _stacks[category]->widget()->setMargin(10);
+ Tool::Lister::ConstIterator it;
+ for (it=Tool::lister().begin(); it!=Tool::lister().end(); ++it) {
+ if ( it.data()->isCustom() ) continue;
+ if ( !it.data()->needs(_project, category) ) continue;
+ ToolConfigWidget *cw = static_cast<const Tool::GroupUI *>(it.data()->gui())->createConfigWidget(category, project);
+ Q_ASSERT(cw);
+ _stacks[category]->appendItem(it.key(), cw);
+ connect(cw, SIGNAL(displayHelp()), SLOT(displayHelp()));
+ }
+ }
+ _customWidget = new QWidget(_mainStack);
+ _mainStack->addWidget(_customWidget);
+ QVBoxLayout *vbox = new QVBoxLayout(_customWidget);
+ label = new QLabel(i18n("Custom shell commands:"), _customWidget);
+ vbox->addWidget(label);
+ _commandsEditor = new EditListBox(1, _customWidget, "command_editor", EditListBox::DuplicatesAllowed);
+ vbox->addWidget(_commandsEditor);
+
+ setColStretch(4, 1);
+}
+
+void ToolsConfigWidget::toolChanged()
+{
+ QString name = _tool->currentItem();
+ bool canMakeLibrary = Tool::lister().group(name)->needs(_project, Tool::Category::Librarian);
+ _output->widget()->setEnabled(canMakeLibrary);
+ if ( !canMakeLibrary ) _output->setCurrentItem(Tool::OutputType::Executable);
+ if ( name==Tool::Group::CUSTOM_NAME ) _mainStack->raiseWidget(_customWidget);
+ else {
+ _mainStack->raiseWidget(_tabWidget);
+ FOR_EACH(Tool::Category, k) {
+ _tabWidget->removePage(_stacks[k]->widget());
+ _stacks[k]->widget()->hide();
+ if ( _stacks[k]->contains(name) ) {
+ _stacks[k]->setCurrentItem(name);
+ _stacks[k]->widget()->show();
+ _tabWidget->addTab(_stacks[k]->widget(), i18n(k.data().title));
+ }
+ }
+ _tabWidget->setCurrentPage(0);
+ }
+}
+
+void ToolsConfigWidget::loadConfig()
+{
+ const Tool::Group &group = Compile::Config::toolGroup(_project);
+ _tool->setCurrentItem(group.name());
+ _output->setCurrentItem(_project->outputType());
+ QStringList commands = Compile::Config::customCommands(_project);
+ _commandsEditor->setTexts(commands);
+ toolChanged();
+ FOR_EACH(Tool::Category, k) {
+ KeyWidgetStack<QString>::ConstIterator it;
+ for (it=_stacks[k]->begin(); it!=_stacks[k]->end(); ++it) {
+ if ( it.key()==Tool::Group::CUSTOM_NAME ) continue;
+ static_cast<ToolConfigWidget *>(_stacks[k]->item(it.key()))->loadConfig();
+ }
+ }
+}
+
+void ToolsConfigWidget::saveConfig()
+{
+ QString name = _tool->currentItem();
+ Compile::Config::setToolGroup(_project, *Tool::lister().group(name));
+ _project->setOutputType(_output->currentItem());
+ Compile::Config::setCustomCommands(_project, _commandsEditor->texts());
+ FOR_EACH(Tool::Category, k) {
+ if ( !_stacks[k]->contains(name) ) continue;
+ QWidget *w = _stacks[k]->item(name);
+ static_cast<ToolConfigWidget *>(w)->saveConfig();
+ }
+}
+
+void ToolsConfigWidget::displayHelp()
+{
+ if ( _helpDialog.isNull() ) _helpDialog = new HelpDialog(this);
+ _helpDialog->show();
+}
diff --git a/src/tools/list/tools_config_widget.h b/src/tools/list/tools_config_widget.h
new file mode 100644
index 0000000..0f41b6a
--- /dev/null
+++ b/src/tools/list/tools_config_widget.h
@@ -0,0 +1,60 @@
+/***************************************************************************
+ * Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org> *
+ * Copyright (C) 2004 Alain Gibaud <alain.gibaud@free.fr> *
+ * *
+ * 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 TOOLS_CONFIG_WIDGET_H
+#define TOOLS_CONFIG_WIDGET_H
+
+#include <qcombobox.h>
+#include <qtabwidget.h>
+#include <qvaluevector.h>
+
+#include "common/gui/config_widget.h"
+#include "common/gui/dialog.h"
+#include "common/gui/key_gui.h"
+#include "common/gui/editlistbox.h"
+#include "tools/base/generic_tool.h"
+class Project;
+class ToolConfigWidget;
+
+//----------------------------------------------------------------------------
+class HelpDialog : public Dialog
+{
+Q_OBJECT
+public:
+ HelpDialog(QWidget *parent);
+};
+
+//----------------------------------------------------------------------------
+class ToolsConfigWidget : public ConfigWidget
+{
+Q_OBJECT
+public:
+ ToolsConfigWidget(Project *project, QWidget *parent);
+ virtual void loadConfig();
+
+public slots:
+ virtual void saveConfig();
+ virtual void displayHelp();
+
+private slots:
+ void toolChanged();
+
+private:
+ Project *_project;
+ KeyComboBox<QString> *_tool;
+ KeyComboBox<Tool::OutputType> *_output;
+ QWidgetStack *_mainStack;
+ QWidget *_customWidget;
+ EditListBox *_commandsEditor;
+ QTabWidget *_tabWidget;
+ QMap<Tool::Category, KeyWidgetStack<QString> *> _stacks;
+ QGuardedPtr<Dialog> _helpDialog;
+};
+
+#endif
diff --git a/src/tools/mpc/Makefile.am b/src/tools/mpc/Makefile.am
new file mode 100644
index 0000000..debc478
--- /dev/null
+++ b/src/tools/mpc/Makefile.am
@@ -0,0 +1,8 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libmpc.la
+libmpc_la_SOURCES = mpc.cpp mpc_compile.cpp mpc_config.cpp
+libmpc_la_LDFLAGS = $(all_libraries)
+
+SUBDIRS = gui \ No newline at end of file
diff --git a/src/tools/mpc/gui/Makefile.am b/src/tools/mpc/gui/Makefile.am
new file mode 100644
index 0000000..5d590c6
--- /dev/null
+++ b/src/tools/mpc/gui/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libmpcui.la
+libmpcui_la_SOURCES = mpc_ui.cpp
+libmpcui_la_LDFLAGS = $(all_libraries) \ No newline at end of file
diff --git a/src/tools/mpc/gui/mpc_ui.cpp b/src/tools/mpc/gui/mpc_ui.cpp
new file mode 100644
index 0000000..b3ad4e7
--- /dev/null
+++ b/src/tools/mpc/gui/mpc_ui.cpp
@@ -0,0 +1,14 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 "mpc_ui.h"
+
+//----------------------------------------------------------------------------
+MPC::ConfigWidget::ConfigWidget(Project *project)
+ : ToolConfigWidget(project)
+{}
diff --git a/src/tools/mpc/gui/mpc_ui.h b/src/tools/mpc/gui/mpc_ui.h
new file mode 100644
index 0000000..2fc51f9
--- /dev/null
+++ b/src/tools/mpc/gui/mpc_ui.h
@@ -0,0 +1,35 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 MPC_UI_H
+#define MPC_UI_H
+
+#include "tools/gui/tool_config_widget.h"
+#include "tools/gui/tool_group_ui.h"
+
+namespace MPC
+{
+//----------------------------------------------------------------------------
+class ConfigWidget : public ToolConfigWidget
+{
+Q_OBJECT
+public:
+ ConfigWidget(Project *project);
+ virtual void initEntries() {}
+};
+
+//----------------------------------------------------------------------------
+class GroupUI : public Tool::GroupUI
+{
+public:
+ virtual ToolConfigWidget *configWidgetFactory(Tool::Category, ::Project *project) const { return new ConfigWidget(project); }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/mpc/mpc.cpp b/src/tools/mpc/mpc.cpp
new file mode 100644
index 0000000..88f9ec2
--- /dev/null
+++ b/src/tools/mpc/mpc.cpp
@@ -0,0 +1,57 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 "mpc.h"
+
+#include <qregexp.h>
+
+#include "mpc_compile.h"
+#include "mpc_config.h"
+#include "devices/pic/pic/pic_memory.h"
+#include "devices/list/device_list.h"
+#include "devices/base/device_group.h"
+
+//----------------------------------------------------------------------------
+QValueList<const Device::Data *> MPC::Group::getSupportedDevices(const QString &) const
+{
+ QValueList<const Device::Data *> list;
+ QValueVector<QString> devices = Device::lister().group("pic")->supportedDevices();
+ for (uint i=0; i<devices.count(); i++) {
+ const Device::Data *data = Device::lister().data(devices[i]);
+ Pic::Architecture arch = static_cast<const Pic::Data *>(data)->architecture();
+ if ( arch!=Pic::Architecture::P16X && arch!=Pic::Architecture::P17C ) continue;
+ list.append(data);
+ }
+ return list;
+}
+
+Compile::Process *MPC::Group::processFactory(const Compile::Data &data) const
+{
+ switch (data.category.type()) {
+ case Tool::Category::Compiler: return new MPC::CompileFile;
+ default: break;
+ }
+ Q_ASSERT(false);
+ return 0;
+}
+
+Compile::Config *MPC::Group::configFactory(::Project *project) const
+{
+ return new Config(project);
+}
+
+QString MPC::Group::informationText() const
+{
+ return i18n("<a href=\"%1\">MPC Compiler</a> is a C compiler distributed by Byte Craft.").arg("http://www.bytecraft.com/mpccaps.html");
+}
+
+Tool::Group::BaseData MPC::Group::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Compiler ) return BaseData(new MPC::Base, Both);
+ return BaseData();
+}
diff --git a/src/tools/mpc/mpc.h b/src/tools/mpc/mpc.h
new file mode 100644
index 0000000..a378307
--- /dev/null
+++ b/src/tools/mpc/mpc.h
@@ -0,0 +1,49 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 MPC_H
+#define MPC_H
+
+#include "tools/base/tool_group.h"
+#include "common/global/pfile.h"
+
+namespace MPC
+{
+//----------------------------------------------------------------------------
+class Base : public Tool::Base
+{
+public:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const { return "mpcw"; }
+ virtual bool checkExecutable() const { return false; }
+ virtual QStringList checkExecutableOptions(bool) const { return QStringList(); }
+ virtual bool checkExecutableResult(bool, QStringList &) const { return true; }
+};
+
+//----------------------------------------------------------------------------
+class Group : public Tool::Group
+{
+public:
+ virtual QString name() const { return "mpcw"; }
+ virtual QString label() const { return i18n("MPC Compiler"); }
+ virtual QString informationText() const;
+ virtual Tool::Category checkDevicesCategory() const { return Tool::Category::Nb_Types; }
+ virtual Tool::ExecutableType preferedExecutableType() const { return Tool::ExecutableType::Windows; }
+ virtual Tool::CompileType compileType() const { return Tool::SingleFile; }
+ 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) const;
+ virtual Tool::SourceGenerator *sourceGeneratorFactory() const { /*TODO*/ return 0; }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/mpc/mpc_compile.cpp b/src/tools/mpc/mpc_compile.cpp
new file mode 100644
index 0000000..69ee994
--- /dev/null
+++ b/src/tools/mpc/mpc_compile.cpp
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 "mpc_compile.h"
+
+#include "common/global/pfile.h"
+#include "mpc_config.h"
+#include "devices/list/device_list.h"
+#include "devices/pic/base/pic.h"
+
+QStringList MPC::CompileFile::genericArguments(const Compile::Config &) const
+{
+ QStringList args;
+ args += "%I";
+ return args;
+}
+
+void MPC::CompileFile::logStderrLine(const QString &)
+{
+ // ignore output
+}
+
+void MPC::CompileFile::parseLine(const QString &line)
+{
+ if ( parseErrorLine(line, Compile::ParseErrorData("(\\w+)\\s+(.*)\\s+(\\d+):\\d+:(.*)", 2, 3, 4, 1)) ) return;
+ doLog(Log::LineType::Normal, line, QString::null, 0); // unrecognized
+}
+
+void MPC::CompileFile::done(int code)
+{
+ // rely on error file
+ PURL::Url url = PURL::Url(directory(), inputFilepath(0)).toExtension("err");
+ Log::StringView sview;
+ PURL::File file(url, sview);
+ if ( !file.openForRead() ) doLog(Log::LineType::Error, i18n("Could not find error file (%1).").arg(url.pretty()), QString::null, 0);
+ else {
+ QStringList lines = file.readLines();
+ for (uint i=0; i<lines.count(); i++) parseLine(lines[i]);
+ }
+ Compile::Process::done(code);
+}
+
+QString MPC::CompileFile::outputFiles() const
+{
+ return "PURL::Lst PURL::Hex PURL::Cod err";
+}
diff --git a/src/tools/mpc/mpc_compile.h b/src/tools/mpc/mpc_compile.h
new file mode 100644
index 0000000..a699734
--- /dev/null
+++ b/src/tools/mpc/mpc_compile.h
@@ -0,0 +1,35 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 MPC_COMPILE_H
+#define MPC_COMPILE_H
+
+#include "tools/list/compile_process.h"
+
+namespace MPC
+{
+
+class CompileFile : public Compile::Process
+{
+Q_OBJECT
+protected:
+ virtual QString deviceName() const { return QString::null; }
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual void logStderrLine(const QString &line);
+ virtual QString outputFiles() const;
+
+protected slots:
+ virtual void done(int code);
+
+private:
+ void parseLine(const QString &line);
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/mpc/mpc_config.cpp b/src/tools/mpc/mpc_config.cpp
new file mode 100644
index 0000000..d477e1e
--- /dev/null
+++ b/src/tools/mpc/mpc_config.cpp
@@ -0,0 +1,9 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 "mpc_config.h"
diff --git a/src/tools/mpc/mpc_config.h b/src/tools/mpc/mpc_config.h
new file mode 100644
index 0000000..45ae64c
--- /dev/null
+++ b/src/tools/mpc/mpc_config.h
@@ -0,0 +1,25 @@
+/***************************************************************************
+ * Copyright (C) 2007 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 MPC_CONFIG_H
+#define MPC_CONFIG_H
+
+#include "tools/list/compile_config.h"
+
+namespace MPC
+{
+//----------------------------------------------------------------------------
+class Config : public Compile::Config
+{
+public:
+ Config(Project *project) : Compile::Config(project) {}
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/pic30/Makefile.am b/src/tools/pic30/Makefile.am
new file mode 100644
index 0000000..edf11c8
--- /dev/null
+++ b/src/tools/pic30/Makefile.am
@@ -0,0 +1,9 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libpic30.la
+libpic30_la_LDFLAGS = $(all_libraries)
+libpic30_la_SOURCES = pic30_compile.cpp pic30_config.cpp pic30.cpp \
+ pic30_generator.cpp
+
+SUBDIRS = gui \ No newline at end of file
diff --git a/src/tools/pic30/gui/Makefile.am b/src/tools/pic30/gui/Makefile.am
new file mode 100644
index 0000000..4ee894e
--- /dev/null
+++ b/src/tools/pic30/gui/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libpic30ui.la
+libpic30ui_la_LDFLAGS = $(all_libraries)
+libpic30ui_la_SOURCES = pic30_ui.cpp
diff --git a/src/tools/pic30/gui/pic30_ui.cpp b/src/tools/pic30/gui/pic30_ui.cpp
new file mode 100644
index 0000000..9d1b2c4
--- /dev/null
+++ b/src/tools/pic30/gui/pic30_ui.cpp
@@ -0,0 +1,26 @@
+/***************************************************************************
+ * 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 "pic30_ui.h"
+
+#include <qlabel.h>
+
+#include "common/gui/purl_gui.h"
+#include "tools/pic30/pic30_config.h"
+
+//----------------------------------------------------------------------------
+PIC30::ConfigWidget::ConfigWidget(Project *project)
+ : ToolConfigWidget(project)
+{}
+
+void PIC30::ConfigWidget::initEntries()
+{
+ if ( _category==Tool::Category::Compiler || _category==Tool::Category::Assembler || _category==Tool::Category::Linker )
+ createIncludeDirectoriesEntry();
+ if ( _category==Tool::Category::Linker ) createCustomLibrariesEntry();
+}
diff --git a/src/tools/pic30/gui/pic30_ui.h b/src/tools/pic30/gui/pic30_ui.h
new file mode 100644
index 0000000..d9890e7
--- /dev/null
+++ b/src/tools/pic30/gui/pic30_ui.h
@@ -0,0 +1,36 @@
+/***************************************************************************
+ * 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 PIC30_UI_H
+#define PIC30_UI_H
+
+#include "tools/gui/tool_config_widget.h"
+#include "tools/gui/tool_group_ui.h"
+
+namespace PIC30
+{
+
+//----------------------------------------------------------------------------
+class ConfigWidget : public ToolConfigWidget
+{
+Q_OBJECT
+public:
+ ConfigWidget(Project *project);
+ virtual void initEntries();
+};
+
+//----------------------------------------------------------------------------
+class GroupUI : public Tool::GroupUI
+{
+public:
+ virtual ::ToolConfigWidget *configWidgetFactory(Tool::Category, ::Project *project) const { return new ConfigWidget(project); }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/pic30/pic30.cpp b/src/tools/pic30/pic30.cpp
new file mode 100644
index 0000000..45b9270
--- /dev/null
+++ b/src/tools/pic30/pic30.cpp
@@ -0,0 +1,137 @@
+/***************************************************************************
+ * 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 "pic30.h"
+
+#include "devices/list/device_list.h"
+#include "devices/base/device_group.h"
+#include "pic30_compile.h"
+#include "pic30_config.h"
+#include "devices/pic/pic/pic_memory.h"
+#include "common/global/process.h"
+#include "pic30_generator.h"
+
+//----------------------------------------------------------------------------
+QString PIC30::Base::baseExecutable(bool, Tool::OutputExecutableType type) const
+{
+ QString s = "pic30-";
+ if ( type==Tool::OutputExecutableType::Coff ) s += "coff";
+ else s += "elf";
+ s += "-";
+ switch (_category.type()) {
+ case Tool::Category::Compiler: return s + "gcc";
+ case Tool::Category::Assembler: return s + "as";
+ case Tool::Category::Linker: return s + "ld";
+ case Tool::Category::Librarian: return s + "ar";
+ case Tool::Category::BinToHex: return s + "bin2hex";
+ case Tool::Category::Nb_Types: break;
+ }
+ Q_ASSERT(false);
+ return QString::null;
+}
+
+QStringList PIC30::Base::checkExecutableOptions(bool) const
+{
+ if ( _category!=Tool::Category::BinToHex ) return "--version";
+ return QStringList();
+}
+
+bool PIC30::Base::checkExecutableResult(bool, QStringList &lines) const
+{
+ if ( lines.count()==0 ) return false;
+ lines[0] = lines[0].stripWhiteSpace();
+ switch (_category.type()) {
+ case Tool::Category::Compiler: return lines[0].startsWith("pic30");
+ case Tool::Category::Assembler: return lines[0].startsWith("GNU assembler");
+ case Tool::Category::Linker: return lines[0].startsWith("GNU ld");
+ case Tool::Category::BinToHex: return lines.join(" ").contains("Microchip ");
+ case Tool::Category::Librarian: return lines[0].startsWith("GNU ar");
+ case Tool::Category::Nb_Types: break;
+ }
+ Q_ASSERT(false);
+ return false;
+}
+
+//----------------------------------------------------------------------------
+QString PIC30::Group::informationText() const
+{
+ return i18n("The <a href=\"%1\">PIC30 ToolChain</a> is a toolsuite for 16-bit PICs available from Microchip. Most of it is available under the GNU Public License.").arg("http://microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010065&part=SW006012");
+}
+
+Tool::Group::BaseData PIC30::Group::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Compiler || category==Tool::Category::Assembler
+ || category==Tool::Category::Linker || category==Tool::Category::BinToHex ) return BaseData(new ::PIC30::Base, Both);
+ if ( category==Tool::Category::Librarian ) return BaseData(new ::PIC30::Base, ProjectOnly);
+ return BaseData();
+}
+
+QValueList<const Device::Data *> PIC30::Group::getSupportedDevices(const QString &) const
+{
+ QValueList<const Device::Data *> list;
+ QValueVector<QString> devices = Device::lister().group("pic")->supportedDevices();
+ for (uint i=0; i<devices.count(); i++) {
+ const Device::Data *data = Device::lister().data(devices[i]);
+ if ( static_cast<const Pic::Data *>(data)->is16bitFamily() ) list.append(data);
+ }
+ return list;
+}
+
+Compile::Process *PIC30::Group::processFactory(const Compile::Data &data) const
+{
+ switch (data.category.type()) {
+ case Tool::Category::Compiler:
+ if (data.project) return new PIC30::CompileProjectFile;
+ return new PIC30::CompileStandaloneFile;
+ case Tool::Category::Assembler:
+ if (data.project) return new PIC30::AssembleProjectFile;
+ return new PIC30::AssembleStandaloneFile;
+ case Tool::Category::Linker:
+ if (data.project) return new PIC30::LinkProject;
+ return new PIC30::LinkStandalone;
+ case Tool::Category::Librarian:
+ Q_ASSERT(data.project);
+ return new PIC30::LibraryProject;
+ case Tool::Category::BinToHex: return new PIC30::BinToHex;
+ case Tool::Category::Nb_Types: break;
+ }
+ Q_ASSERT(false);
+ return 0;
+}
+
+Compile::Config *PIC30::Group::configFactory(::Project *project) const
+{
+ return new Config(project);
+}
+
+PURL::FileType PIC30::Group::implementationType(PURL::ToolType type) const
+{
+ if ( type==PURL::ToolType::Assembler ) return PURL::AsmPIC30;
+ if ( type==PURL::ToolType::Compiler ) return PURL::CSource;
+ return PURL::Nb_FileTypes;
+}
+
+Tool::SourceGenerator *PIC30::Group::sourceGeneratorFactory() const
+{
+ return new SourceGenerator;
+}
+
+PURL::Directory PIC30::Group::autodetectDirectory(Compile::DirectoryType type, const PURL::Directory &execDir, bool withWine) const
+{
+ if ( !withWine ) return PURL::Directory();
+ PURL::Directory baseDir = execDir.up();
+ switch (type.type()) {
+ case Compile::DirectoryType::LinkerScript: return baseDir.down("support/gld");
+ case Compile::DirectoryType::Header: return baseDir.down("support/h");
+ case Compile::DirectoryType::Library: return baseDir.down("lib");
+ case Compile::DirectoryType::Executable:
+ case Compile::DirectoryType::Source:
+ case Compile::DirectoryType::Nb_Types: Q_ASSERT(false); break;
+ }
+ return PURL::Directory();
+}
diff --git a/src/tools/pic30/pic30.h b/src/tools/pic30/pic30.h
new file mode 100644
index 0000000..a490ed0
--- /dev/null
+++ b/src/tools/pic30/pic30.h
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * 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 PIC30_H
+#define PIC30_H
+
+#include "tools/base/tool_group.h"
+
+namespace PIC30
+{
+
+//----------------------------------------------------------------------------
+class Base : public Tool::Base
+{
+public:
+ virtual QString baseExecutable(bool withWine, Tool::OutputExecutableType type) const;
+
+private:
+ virtual QStringList checkExecutableOptions(bool withWine) const;
+ virtual bool checkExecutableResult(bool withWine, QStringList &lines) const;
+};
+
+//----------------------------------------------------------------------------
+class Group : public Tool::Group
+{
+public:
+ virtual QString name() const { return "pic30"; }
+ virtual QString label() const { return i18n("PIC30 Toolchain"); }
+ virtual QString informationText() const;
+ virtual bool hasDirectory(Compile::DirectoryType type) const { return type==Compile::DirectoryType::Header || type==Compile::DirectoryType::LinkerScript || type==Compile::DirectoryType::Library; }
+ virtual PURL::Directory autodetectDirectory(Compile::DirectoryType type, const PURL::Directory &execDir, bool withWine) const;
+ virtual bool hasOutputExecutableType(Tool::OutputExecutableType type) const { return ( type==Tool::OutputExecutableType::Coff || type==Tool::OutputExecutableType::Elf ); }
+ virtual Tool::Category checkDevicesCategory() const { return Tool::Category::Nb_Types; }
+ virtual Tool::ExecutableType preferedExecutableType() const { return Tool::ExecutableType::Unix; }
+ virtual Tool::CompileType compileType() const { return Tool::SeparateFiles; }
+ virtual PURL::FileType linkerScriptType() const { return PURL::Gld; }
+ virtual PURL::FileType implementationType(PURL::ToolType type) const;
+
+private:
+ virtual BaseData baseFactory(Tool::Category category) const;
+ 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 Tool::SourceGenerator *sourceGeneratorFactory() const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/pic30/pic30_compile.cpp b/src/tools/pic30/pic30_compile.cpp
new file mode 100644
index 0000000..02cbb35
--- /dev/null
+++ b/src/tools/pic30/pic30_compile.cpp
@@ -0,0 +1,196 @@
+/***************************************************************************
+ * Copyright (C) 2006-2007 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 "pic30_compile.h"
+
+#include "config.h"
+#include "pic30_config.h"
+#include "devices/list/device_list.h"
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::CompileFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "-S"; // compile only
+ args += "$NO_AUTO_DEVICE(-mcpu=%DEVICE)";
+ args += config.includeDirs(Tool::Category::Compiler, "-I");
+ PURL::Directory purl = Compile::Config::directory(group(), Compile::DirectoryType::Header);
+ if ( !purl.isEmpty() ) args += "-I" + purl.path();
+ args += config.customOptions(Tool::Category::Compiler);
+ return args;
+}
+
+QString PIC30::CompileFile::outputFiles() const
+{
+ return "PURL::AsmPIC30";
+}
+
+void PIC30::CompileFile::logStderrLine(const QString &line)
+{
+ // #### TODO
+ doLog(Log::LineType::Normal, line, QString::null, 0); // unrecognized
+}
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::CompileStandaloneFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = CompileFile::genericArguments(config);
+ args += "%I";
+ return args;
+}
+
+QString PIC30::CompileStandaloneFile::outputFiles() const
+{
+ return CompileFile::outputFiles() + " PURL::Object PURL::Elf";
+}
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::CompileProjectFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = CompileFile::genericArguments(config);
+ args += "-g";
+ args += "%I";
+ return args;
+}
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::AssembleFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "-g";
+ args += "-a=%LIST"; // listing
+ args += "-o%O";
+ args += config.includeDirs(Tool::Category::Assembler, "-I");
+ args += config.customOptions(Tool::Category::Assembler);
+ return args;
+}
+
+QString PIC30::AssembleFile::outputFiles() const
+{
+ return "PURL::Object PURL::Lst";
+}
+
+void PIC30::AssembleFile::logStderrLine(const QString &line)
+{
+ // #### TODO
+ doLog(Log::LineType::Normal, line, QString::null, 0); // unrecognized
+}
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::AssembleStandaloneFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = AssembleFile::genericArguments(config);
+ args += "$NO_AUTO_DEVICE(-p%DEVICE)";
+ args += "%I";
+ return args;
+}
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::AssembleProjectFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = AssembleFile::genericArguments(config);
+ if ( !_data.items[0].generated ) args += "-p%DEVICE";
+ args += "%I";
+ return args;
+}
+
+//-----------------------------------------------------------------------------
+QString PIC30::Link::outputFilepath() const
+{
+ PURL::FileType type = Compile::Config::outputExecutableType(group()).data().type;
+ return filepath(type);
+}
+
+QStringList PIC30::Link::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += "-Map";
+ args += "%MAP";
+ args += "-o%O";
+ args += config.includeDirs(Tool::Category::Linker, "-L");
+ PURL::Directory purl = Compile::Config::directory(group(), Compile::DirectoryType::Library);
+ if ( !purl.isEmpty() ) args += "-L" + purl.path();
+ args += "$LKR(-T%LKR)";
+ args += config.customOptions(Tool::Category::Linker);
+ args += "%OBJS";
+ return args;
+}
+
+QString PIC30::Link::outputFiles() const
+{
+ PURL::FileType type = Compile::Config::outputExecutableType(group()).data().type;
+ return QString("PURL::Map PURL::") + type.key();
+}
+
+void PIC30::Link::logStderrLine(const QString &line)
+{
+ // #### TODO
+ doLog(Log::LineType::Normal, line, QString::null, 0); // unrecognized
+}
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::LinkStandalone::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = Link::genericArguments(config);
+ args += config.customLibraries(Tool::Category::Linker);
+ return args;
+}
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::LinkProject::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = Link::genericArguments(config);
+ args += "%LIBS";
+ args += config.customLibraries(Tool::Category::Linker);
+ return args;
+}
+
+//-----------------------------------------------------------------------------
+QStringList PIC30::LibraryProject::genericArguments(const Compile::Config &) const
+{
+ QStringList args;
+ args += "-rc"; // insert new + do not warn if creating library
+ args += "%O";
+ args += "%LIBS";
+ args += "%OBJS";
+ return args;
+}
+
+void PIC30::LibraryProject::logStderrLine(const QString &line)
+{
+ // #### TODO
+ doLog(Log::LineType::Normal, line, QString::null, 0); // unrecognized
+}
+
+QString PIC30::LibraryProject::outputFiles() const
+{
+ return "PURL::Library";
+}
+
+//-----------------------------------------------------------------------------
+QString PIC30::BinToHex::inputFilepath(uint) const
+{
+ PURL::FileType type = Compile::Config::outputExecutableType(group()).data().type;
+ return filepath(type);
+}
+
+QStringList PIC30::BinToHex::genericArguments(const Compile::Config &) const
+{
+ return "%I";
+}
+
+QString PIC30::BinToHex::outputFiles() const
+{
+ return "PURL::Hex";
+}
+
+void PIC30::BinToHex::logStderrLine(const QString &line)
+{
+ // #### TODO
+ doLog(Log::LineType::Normal, line, QString::null, 0); // unrecognized
+}
diff --git a/src/tools/pic30/pic30_compile.h b/src/tools/pic30/pic30_compile.h
new file mode 100644
index 0000000..c298eac
--- /dev/null
+++ b/src/tools/pic30/pic30_compile.h
@@ -0,0 +1,128 @@
+/***************************************************************************
+ * 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 PIC30_COMPILE_H
+#define PIC30_COMPILE_H
+
+#include "tools/list/compile_process.h"
+
+namespace PIC30
+{
+//-----------------------------------------------------------------------------
+class Process : public Compile::Process
+{
+Q_OBJECT
+protected:
+ virtual QString deviceName() const { return _data.device; }
+};
+
+//-----------------------------------------------------------------------------
+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 CompileStandaloneFile : public CompileFile
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+};
+
+//-----------------------------------------------------------------------------
+class CompileProjectFile : public CompileFile
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class AssembleFile : public Process
+{
+Q_OBJECT
+protected:
+ virtual QString outputFilepath() const { return filepath(PURL::Object); }
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+ virtual void logStderrLine(const QString &line);
+};
+
+//-----------------------------------------------------------------------------
+class AssembleStandaloneFile : public AssembleFile
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class AssembleProjectFile : public AssembleFile
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class Link : public Process
+{
+Q_OBJECT
+protected:
+ virtual QString outputFilepath() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+ virtual void logStderrLine(const QString &line);
+};
+
+//-----------------------------------------------------------------------------
+class LinkStandalone : public Link
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class LinkProject : public Link
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class LibraryProject : public Process
+{
+Q_OBJECT
+protected:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+ virtual void logStderrLine(const QString &line);
+};
+
+//-----------------------------------------------------------------------------
+class BinToHex : public Process
+{
+Q_OBJECT
+protected:
+ virtual QString inputFilepath(uint i) const;
+ 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/pic30/pic30_config.cpp b/src/tools/pic30/pic30_config.cpp
new file mode 100644
index 0000000..32ef7e0
--- /dev/null
+++ b/src/tools/pic30/pic30_config.cpp
@@ -0,0 +1,9 @@
+/***************************************************************************
+ * 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 "pic30_config.h"
diff --git a/src/tools/pic30/pic30_config.h b/src/tools/pic30/pic30_config.h
new file mode 100644
index 0000000..f0b1520
--- /dev/null
+++ b/src/tools/pic30/pic30_config.h
@@ -0,0 +1,25 @@
+/***************************************************************************
+ * 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 PIC30_CONFIG_H
+#define PIC30_CONFIG_H
+
+#include "tools/list/compile_config.h"
+
+namespace PIC30
+{
+//----------------------------------------------------------------------------
+class Config : public Compile::Config
+{
+public:
+ Config(Project *project) : Compile::Config(project) {}
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/pic30/pic30_generator.cpp b/src/tools/pic30/pic30_generator.cpp
new file mode 100644
index 0000000..fe874e3
--- /dev/null
+++ b/src/tools/pic30/pic30_generator.cpp
@@ -0,0 +1,111 @@
+/***************************************************************************
+ * Copyright (C) 2006-2007 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 "pic30_generator.h"
+
+#include "devices/pic/pic/pic_memory.h"
+
+SourceLine::List PIC30::SourceGenerator::configLines(PURL::ToolType type, const Device::Memory &memory, bool &ok) const
+{
+ const Pic::Memory &pmemory = static_cast<const Pic::Memory &>(memory);
+ const Pic::Data &data = pmemory.device();
+ const Pic::Config &config = data.config();
+ SourceLine::List lines;
+ for (uint i=0; i<data.nbWords(Pic::MemoryRangeType::Config); i++) {
+ const Pic::Config::Word &cword = config._words[i];
+ QStringList cnames = SourceLine::configNames(Pic::ConfigNameType::Default, pmemory, i, ok);
+ if ( cnames.isEmpty() ) continue;
+ QString code;
+ if ( type==PURL::ToolType::Assembler ) code += "config __" + cword.name + ", ";
+ else code += "_" + cword.name + "(";
+ code += cnames.join(" & ");
+ if ( type==PURL::ToolType::Compiler ) code += ");";
+ lines.appendNotIndentedCode(code);
+ }
+ return lines;
+}
+
+SourceLine::List PIC30::SourceGenerator::includeLines(PURL::ToolType type, const Device::Data &data) const
+{
+ SourceLine::List lines;
+ if ( type==PURL::ToolType::Assembler ) lines.appendIndentedCode(".include \"p" + data.name().lower() + ".inc\"");
+ else lines.appendNotIndentedCode("#include <p" + data.name().lower() + ".h>");
+ return lines;
+}
+
+SourceLine::List PIC30::SourceGenerator::sourceFileContent(PURL::ToolType type, const Device::Data &, bool &ok) const
+{
+ SourceLine::List lines;
+ if ( type==PURL::ToolType::Assembler ) {
+ lines.appendTitle(i18n("Global declarations"));
+ lines.appendIndentedCode(".global _wreg_init");
+ lines.appendIndentedCode(".global __reset", i18n("label for code start"));
+ lines.appendIndentedCode(".global __T1Interrrupt", i18n("declare Timer1 ISR"));
+ lines.appendEmpty();
+ lines.appendSeparator();
+ lines.appendTitle(i18n("Constants in program space"));
+ lines.appendIndentedCode(".section .constbuffer, code");
+ lines.appendIndentedCode(".palign 2");
+ lines.appendNotIndentedCode("const1:");
+ lines.appendIndentedCode(".hword 0x0001, 0x0002, 0X0003");
+ lines.appendEmpty();
+ lines.appendTitle(i18n("Unitialized variables in X-space"));
+ lines.appendIndentedCode(".section .xbss, bss, xmemory");
+ lines.appendNotIndentedCode("x_var1: .space 4", i18n("allocating 4 bytes"));
+ lines.appendEmpty();
+ lines.appendTitle(i18n("Unitialized variables in Y-space"));
+ lines.appendIndentedCode(".section .ybss, bss, ymemory");
+ lines.appendNotIndentedCode("y_var1: .space 2", i18n("allocating 2 bytes"));
+ lines.appendEmpty();
+ lines.appendTitle(i18n("Unitialized variables in near data memory"));
+ lines.appendIndentedCode(".section .nbss, bss, near");
+ lines.appendNotIndentedCode("var1: .space 4", i18n("allocating 4 bytes"));
+ lines.appendEmpty();
+ lines.appendSeparator();
+ lines.appendTitle("Code section");
+ lines.appendNotIndentedCode(".text");
+ lines.appendNotIndentedCode("__reset:");
+ lines.appendIndentedCode("MOV #__SP_init, W15", i18n("initialize stack pointer"));
+ lines.appendIndentedCode("MOV #__SPLIM_init, W0", i18n("initialize stack pointer limit register"));
+ lines.appendIndentedCode("MOV W0, SPLIM");
+ lines.appendIndentedCode("NOP", i18n("nop after SPLIM initialization"));
+ lines.appendIndentedCode("CALL _wreg_init", i18n("call _wreg_init subroutine"));
+ lines.appendEmpty();
+ lines.appendIndentedCode(QString::null, "<<" + i18n("insert code") + ">>");
+ lines.appendEmpty();
+ lines.appendNotIndentedCode("done:");
+ lines.appendIndentedCode("BRA done", i18n("loop forever"));
+ lines.appendEmpty();
+ lines.appendSeparator();
+ lines.appendTitle(i18n("Subroutine to initialize W registers to 0x0000"));
+ lines.appendNotIndentedCode("_wreg_init:");
+ lines.appendIndentedCode("CLR W0");
+ lines.appendIndentedCode("MOV W0, W14");
+ lines.appendIndentedCode("REPEAT #12");
+ lines.appendIndentedCode("MOV W0, [++W14]");
+ lines.appendIndentedCode("CLR W14");
+ lines.appendIndentedCode("RETURN");
+ lines.appendEmpty();
+ lines.appendSeparator();
+ lines.appendTitle(i18n("Timer1 interrupt service routine"));
+ lines.appendNotIndentedCode("__T1Interrupt:");
+ lines.appendIndentedCode("PUSH.D W4", i18n("example of context saving (push W4 and W5)"));
+ lines.appendIndentedCode(QString::null, "<<" + i18n("insert interrupt code") + ">>");
+ lines.appendIndentedCode("BCLR IFS0, #T1IF", i18n("clear Timer1 interrupt flag status bit"));
+ lines.appendIndentedCode("POP.D W4", i18n("restore context from stack"));
+ lines.appendIndentedCode("RETFIE");
+ lines.appendEmpty();
+ lines.appendSeparator();
+ lines.appendTitle(i18n("End of all code sections"));
+ lines.appendNotIndentedCode(".end");
+ } else {
+ // #### TODO
+ ok = false;
+ }
+ return lines;
+}
diff --git a/src/tools/pic30/pic30_generator.h b/src/tools/pic30/pic30_generator.h
new file mode 100644
index 0000000..510a483
--- /dev/null
+++ b/src/tools/pic30/pic30_generator.h
@@ -0,0 +1,27 @@
+/***************************************************************************
+ * Copyright (C) 2006-2007 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 PIC30_GENERATOR_H
+#define PIC30_GENERATOR_H
+
+#include "tools/base/tool_group.h"
+
+namespace PIC30
+{
+
+class SourceGenerator : public Tool::SourceGenerator
+{
+public:
+ virtual SourceLine::List configLines(PURL::ToolType type, const Device::Memory &memory, bool &ok) const;
+ virtual SourceLine::List sourceFileContent(PURL::ToolType type, const Device::Data &data, bool &ok) const;
+ virtual SourceLine::List includeLines(PURL::ToolType type, const Device::Data &data) const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/picc/Makefile.am b/src/tools/picc/Makefile.am
new file mode 100644
index 0000000..9a6d0c2
--- /dev/null
+++ b/src/tools/picc/Makefile.am
@@ -0,0 +1,8 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libpicc.la
+libpicc_la_LDFLAGS = $(all_libraries)
+libpicc_la_SOURCES = picc_compile.cpp picc_config.cpp picc.cpp
+
+SUBDIRS = gui \ No newline at end of file
diff --git a/src/tools/picc/gui/Makefile.am b/src/tools/picc/gui/Makefile.am
new file mode 100644
index 0000000..ddc928d
--- /dev/null
+++ b/src/tools/picc/gui/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libpiccui.la
+libpiccui_la_LDFLAGS = $(all_libraries)
+libpiccui_la_SOURCES = picc_ui.cpp
diff --git a/src/tools/picc/gui/picc_ui.cpp b/src/tools/picc/gui/picc_ui.cpp
new file mode 100644
index 0000000..207a7cb
--- /dev/null
+++ b/src/tools/picc/gui/picc_ui.cpp
@@ -0,0 +1,20 @@
+/***************************************************************************
+ * 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 "picc_ui.h"
+
+//----------------------------------------------------------------------------
+PICC::ConfigWidget::ConfigWidget(Project *project)
+ : ToolConfigWidget(project)
+{}
+
+void PICC::ConfigWidget::initEntries()
+{
+ if ( _category==Tool::Category::Compiler || _category==Tool::Category::Assembler )
+ createIncludeDirectoriesEntry();
+}
diff --git a/src/tools/picc/gui/picc_ui.h b/src/tools/picc/gui/picc_ui.h
new file mode 100644
index 0000000..ec096c2
--- /dev/null
+++ b/src/tools/picc/gui/picc_ui.h
@@ -0,0 +1,35 @@
+/***************************************************************************
+ * 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 PICC_UI_H
+#define PICC_UI_H
+
+#include "tools/gui/tool_config_widget.h"
+#include "tools/gui/tool_group_ui.h"
+
+namespace PICC
+{
+//----------------------------------------------------------------------------
+class ConfigWidget : public ToolConfigWidget
+{
+Q_OBJECT
+public:
+ ConfigWidget(Project *project);
+ virtual void initEntries();
+};
+
+//----------------------------------------------------------------------------
+class GroupUI : public Tool::GroupUI
+{
+public:
+ virtual ToolConfigWidget *configWidgetFactory(Tool::Category, ::Project *project) const { return new ConfigWidget(project); }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/picc/picc.cpp b/src/tools/picc/picc.cpp
new file mode 100644
index 0000000..f0d6e83
--- /dev/null
+++ b/src/tools/picc/picc.cpp
@@ -0,0 +1,127 @@
+/***************************************************************************
+ * 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 "picc.h"
+
+#include <qregexp.h>
+
+#include "picc_compile.h"
+#include "picc_config.h"
+#include "devices/pic/pic/pic_memory.h"
+#include "devices/list/device_list.h"
+#include "common/global/process.h"
+
+//----------------------------------------------------------------------------
+bool PICC::Base::checkExecutableResult(bool, QStringList &lines) const
+{
+ return lines.join(" ").contains("HI-TECH");
+}
+
+QString PICC::BaseLite::baseExecutable(bool, Tool::OutputExecutableType) const
+{
+ if ( _category.type()==Tool::Category::Librarian ) return "libr";
+ return "picl";
+}
+
+QString PICC::BaseNormal::baseExecutable(bool, Tool::OutputExecutableType) const
+{
+ if ( _category.type()==Tool::Category::Librarian ) return "libr";
+ return "picc";
+}
+
+QString PICC::Base18::baseExecutable(bool, Tool::OutputExecutableType) const
+{
+ if ( _category.type()==Tool::Category::Librarian ) return "libr";
+ return "picc18";
+}
+
+//----------------------------------------------------------------------------
+QValueList<const Device::Data *> PICC::Group::getSupportedDevices(const QString &s) const
+{
+ QValueList<const Device::Data *> list;
+ QStringList lines = QStringList::split('\n', s);
+ for (uint i=0; i<lines.count(); i++) {
+ QRegExp re("([A-Za-z0-9]+):.*");
+ if ( !re.exactMatch(lines[i]) ) continue;
+ const Device::Data *data = Device::lister().data(re.cap(1));
+ if (data) list.append(data);
+ }
+ return list;
+}
+
+Compile::Process *PICC::Group::processFactory(const Compile::Data &data) const
+{
+ switch (data.category.type()) {
+ case Tool::Category::Compiler:
+ if (data.project) return new PICC::CompileProjectFile;
+ return new PICC::CompileStandaloneFile;
+ case Tool::Category::Assembler:
+ if (data.project) return new PICC::AssembleProjectFile;
+ return new PICC::AssembleStandaloneFile;
+ case Tool::Category::Linker:
+ Q_ASSERT(data.project);
+ return new PICC::LinkProject;
+ case Tool::Category::Librarian:
+ Q_ASSERT(data.project);
+ return new PICC::LibraryProject;
+ default: break;
+ }
+ Q_ASSERT(false);
+ return 0;
+}
+
+Compile::Config *PICC::Group::configFactory(::Project *project) const
+{
+ return new Config(project);
+}
+
+PURL::FileType PICC::Group::implementationType(PURL::ToolType type) const
+{
+ if ( type==PURL::ToolType::Assembler ) return PURL::AsmPICC;
+ if ( type==PURL::ToolType::Compiler ) return PURL::CSource;
+ return PURL::Nb_FileTypes;
+}
+
+//----------------------------------------------------------------------------
+QString PICC::PICCLiteGroup::informationText() const
+{
+ return i18n("<a href=\"%1\">PICC-Lite</a> is a freeware C compiler distributed by HTSoft.").arg("http://www.htsoft.com");
+}
+
+Tool::Group::BaseData PICC::PICCLiteGroup::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Compiler || category==Tool::Category::Assembler ) return BaseData(new BaseLite, Both);
+ if ( category==Tool::Category::Linker || category==Tool::Category::Librarian ) return BaseData(new BaseLite, ProjectOnly);
+ return BaseData();
+}
+
+//----------------------------------------------------------------------------
+QString PICC::PICCGroup::informationText() const
+{
+ return i18n("<a href=\"%1\">PICC</a> is a C compiler distributed by HTSoft.").arg("http://www.htsoft.com");
+}
+
+Tool::Group::BaseData PICC::PICCGroup::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Compiler || category==Tool::Category::Assembler ) return BaseData(new BaseNormal, Both);
+ if ( category==Tool::Category::Linker || category==Tool::Category::Librarian ) return BaseData(new BaseNormal, ProjectOnly);
+ return BaseData();
+}
+
+//----------------------------------------------------------------------------
+QString PICC::PICC18Group::informationText() const
+{
+ return i18n("<a href=\"%1\">PICC 18</a> is a C compiler distributed by HTSoft.").arg("http://www.htsoft.com");
+}
+
+Tool::Group::BaseData PICC::PICC18Group::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Compiler || category==Tool::Category::Assembler ) return BaseData(new Base18, Both);
+ if ( category==Tool::Category::Linker || category==Tool::Category::Librarian ) return BaseData(new Base18, ProjectOnly);
+ return BaseData();
+}
diff --git a/src/tools/picc/picc.h b/src/tools/picc/picc.h
new file mode 100644
index 0000000..af44d02
--- /dev/null
+++ b/src/tools/picc/picc.h
@@ -0,0 +1,97 @@
+/***************************************************************************
+ * 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 PICC_H
+#define PICC_H
+
+#include "tools/base/tool_group.h"
+
+namespace PICC
+{
+//----------------------------------------------------------------------------
+class Base : public Tool::Base
+{
+private:
+ virtual QStringList checkExecutableOptions(bool) const { return "--ver"; }
+ virtual bool checkExecutableResult(bool withWine, QStringList &lines) const;
+};
+
+class BaseLite : public Base
+{
+public:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const;
+};
+
+class BaseNormal : public Base
+{
+public:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const;
+};
+
+class Base18 : public Base
+{
+public:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const;
+};
+
+//----------------------------------------------------------------------------
+class Group : public Tool::Group
+{
+public:
+ virtual Tool::Category checkDevicesCategory() const { return Tool::Category::Compiler; }
+ virtual QStringList checkDevicesOptions(uint) const { return "--CHIPINFO"; }
+ virtual Tool::ExecutableType preferedExecutableType() const { return Tool::ExecutableType::Unix; }
+ virtual Tool::CompileType compileType() const { return Tool::SeparateFiles; }
+ virtual PURL::FileType implementationType(PURL::ToolType type) const;
+
+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 Tool::SourceGenerator *sourceGeneratorFactory() const { /*TODO*/ return 0; }
+};
+
+//----------------------------------------------------------------------------
+class PICCLiteGroup : public Group
+{
+public:
+ virtual QString name() const { return "picclite"; }
+ virtual QString label() const { return i18n("PICC Lite Compiler"); }
+ virtual QString informationText() const;
+
+private:
+ virtual BaseData baseFactory(Tool::Category) const;
+};
+
+//----------------------------------------------------------------------------
+class PICCGroup : public Group
+{
+public:
+ virtual QString name() const { return "picc"; }
+ virtual QString label() const { return i18n("PICC Compiler"); }
+ virtual QString informationText() const;
+
+private:
+ virtual BaseData baseFactory(Tool::Category) const;
+};
+
+//----------------------------------------------------------------------------
+class PICC18Group : public Group
+{
+public:
+ virtual QString name() const { return "picc18"; }
+ virtual QString label() const { return i18n("PICC-18 Compiler"); }
+ virtual QString informationText() const;
+
+private:
+ virtual BaseData baseFactory(Tool::Category) const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/picc/picc_compile.cpp b/src/tools/picc/picc_compile.cpp
new file mode 100644
index 0000000..63fd127
--- /dev/null
+++ b/src/tools/picc/picc_compile.cpp
@@ -0,0 +1,136 @@
+/***************************************************************************
+ * 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 "picc_compile.h"
+
+#include "picc_config.h"
+
+//-----------------------------------------------------------------------------
+QStringList PICC::Process::genericArguments(const Compile::Config &) const
+{
+ QStringList args;
+ args += "--ERRFORMAT";
+ args += "--WARNFORMAT";
+ args += "--MSGFORMAT";
+ args += "--CHIP=%DEVICE";
+ args += "--IDE=mplab";
+ args += "-Q"; // suppress copyright message
+ return args;
+}
+
+void PICC::Process::logStderrLine(const QString &line)
+{
+ // #### TODO
+ doLog(Log::LineType::Normal, line, QString::null, 0);
+}
+
+//-----------------------------------------------------------------------------
+QStringList PICC::CompileStandaloneFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = Process::genericArguments(config);
+ args += "-M%MAP";
+ args += "-G%SYM";
+ args += "--ASMLIST";
+ args += config.includeDirs(Tool::Category::Compiler, "-I");
+ args += config.customOptions(Tool::Category::Compiler);
+ args += "%I";
+ return args;
+}
+
+QString PICC::CompileStandaloneFile::outputFiles() const
+{
+ return "PURL::Lst PURL::Map obj PURL::Hex PURL::Coff sym sdb hxl rlf";
+}
+
+//-----------------------------------------------------------------------------
+QStringList PICC::CompileProjectFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = Process::genericArguments(config);
+ args += "-S";
+ args += config.includeDirs(Tool::Category::Compiler, "-I");
+ args += config.customOptions(Tool::Category::Compiler);
+ args += "%I";
+ return args;
+}
+
+QString PICC::CompileProjectFile::outputFiles() const
+{
+ return "PURL::AsmPICC";
+}
+
+//-----------------------------------------------------------------------------
+QStringList PICC::AssembleStandaloneFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = Process::genericArguments(config);
+ args += "-M%MAP";
+ args += "-G%SYM";
+ args += "--ASMLIST";
+ args += config.includeDirs(Tool::Category::Assembler, "-I");
+ args += config.customOptions(Tool::Category::Assembler);
+ args += "%I";
+ return args;
+}
+
+QString PICC::AssembleStandaloneFile::outputFiles() const
+{
+ return "PURL::Lst PURL::Map obj PURL::Hex sym sdb hxl rlf";
+}
+
+//-----------------------------------------------------------------------------
+QStringList PICC::AssembleProjectFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = Process::genericArguments(config);
+ args += "-C";
+ args += "--ASMLIST";
+ args += config.includeDirs(Tool::Category::Assembler, "-I");
+ args += config.customOptions(Tool::Category::Assembler);
+ args += "%I";
+ return args;
+}
+
+QString PICC::AssembleProjectFile::outputFiles() const
+{
+ return "obj PURL::Lst rlf";
+}
+
+//-----------------------------------------------------------------------------
+QStringList PICC::LinkProject::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = Process::genericArguments(config);
+ args += "-O%O";
+ args += "-M%MAP";
+ args += "-G%SYM";
+ if ( _data.linkType==Compile::Icd2Linking ) args += "--DEBUGGER=icd2";
+ args += config.customOptions(Tool::Category::Linker);
+ args += "%OBJS";
+ args += "%LIBS";
+ args += config.customLibraries(Tool::Category::Linker);
+ return args;
+}
+
+QString PICC::LinkProject::outputFiles() const
+{
+ return "PURL::Map PURL::Hex PURL::Coff sym sdb hxl";
+}
+
+//-----------------------------------------------------------------------------
+QStringList PICC::LibraryProject::genericArguments(const Compile::Config &config) const
+{
+ QStringList args;
+ args += config.customOptions(Tool::Category::Librarian);
+ args += "r";
+ args += "%O";
+ args += "%OBJS";
+ args += "%LIBS";
+ return args;
+}
+
+QString PICC::LibraryProject::outputFiles() const
+{
+ return "PURL::Library";
+}
diff --git a/src/tools/picc/picc_compile.h b/src/tools/picc/picc_compile.h
new file mode 100644
index 0000000..6db92ca
--- /dev/null
+++ b/src/tools/picc/picc_compile.h
@@ -0,0 +1,83 @@
+/***************************************************************************
+ * 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 PICC_COMPILE_H
+#define PICC_COMPILE_H
+
+#include "tools/list/compile_process.h"
+
+namespace PICC
+{
+//-----------------------------------------------------------------------------
+class Process : public Compile::Process
+{
+Q_OBJECT
+protected:
+ virtual QString deviceName() const { return _data.device; }
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual void logStderrLine(const QString &line);
+ virtual QString objectExtension() const { return "obj"; }
+};
+
+//-----------------------------------------------------------------------------
+class CompileStandaloneFile : public Process
+{
+Q_OBJECT
+protected:
+ virtual QString outputFiles() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class CompileProjectFile : public Process
+{
+Q_OBJECT
+protected:
+ virtual QString outputFiles() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class AssembleStandaloneFile : public Process
+{
+Q_OBJECT
+protected:
+ virtual QString outputFiles() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class AssembleProjectFile : public Process
+{
+Q_OBJECT
+protected:
+ virtual QString outputFiles() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class LinkProject : public Process
+{
+Q_OBJECT
+protected:
+ virtual QString outputFiles() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class LibraryProject : public Process
+{
+Q_OBJECT
+protected:
+ virtual QString outputFiles() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/picc/picc_config.cpp b/src/tools/picc/picc_config.cpp
new file mode 100644
index 0000000..3404bb5
--- /dev/null
+++ b/src/tools/picc/picc_config.cpp
@@ -0,0 +1,9 @@
+/***************************************************************************
+ * 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 "picc_config.h"
diff --git a/src/tools/picc/picc_config.h b/src/tools/picc/picc_config.h
new file mode 100644
index 0000000..c78f186
--- /dev/null
+++ b/src/tools/picc/picc_config.h
@@ -0,0 +1,25 @@
+/***************************************************************************
+ * 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 PICC_CONFIG_H
+#define PICC_CONFIG_H
+
+#include "tools/list/compile_config.h"
+
+namespace PICC
+{
+//----------------------------------------------------------------------------
+class Config : public Compile::Config
+{
+public:
+ Config(Project *project) : Compile::Config(project) {}
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/sdcc/Makefile.am b/src/tools/sdcc/Makefile.am
new file mode 100644
index 0000000..d5fa9da
--- /dev/null
+++ b/src/tools/sdcc/Makefile.am
@@ -0,0 +1,9 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libsdcc.la
+libsdcc_la_LDFLAGS = $(all_libraries)
+libsdcc_la_SOURCES = sdcc_compile.cpp sdcc_config.cpp sdcc.cpp \
+ sdcc_generator.cpp
+
+SUBDIRS = gui
diff --git a/src/tools/sdcc/gui/Makefile.am b/src/tools/sdcc/gui/Makefile.am
new file mode 100644
index 0000000..35ee59a
--- /dev/null
+++ b/src/tools/sdcc/gui/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = -I$(top_srcdir)/src $(all_includes)
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libsdccui.la
+libsdccui_la_LDFLAGS = $(all_libraries)
+libsdccui_la_SOURCES = sdcc_ui.cpp \ No newline at end of file
diff --git a/src/tools/sdcc/gui/sdcc_ui.cpp b/src/tools/sdcc/gui/sdcc_ui.cpp
new file mode 100644
index 0000000..bc14f78
--- /dev/null
+++ b/src/tools/sdcc/gui/sdcc_ui.cpp
@@ -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. *
+ ***************************************************************************/
+#include "sdcc_ui.h"
+
+#include "tools/gputils/gui/gputils_ui.h"
+
+//----------------------------------------------------------------------------
+SDCC::ConfigWidget::ConfigWidget(Project *project)
+ : ToolConfigWidget(project)
+{}
+
+void SDCC::ConfigWidget::initEntries()
+{
+ if ( _category==Tool::Category::Linker ) createHexFormatEntry();
+ createIncludeDirectoriesEntry();
+}
+
+//----------------------------------------------------------------------------
+ToolConfigWidget *SDCC::GroupUI::configWidgetFactory(Tool::Category category, Project *project) const
+{
+ if ( category==Tool::Category::Librarian ) return new GPUtils::ConfigWidget(project);
+ return new ConfigWidget(project);
+}
diff --git a/src/tools/sdcc/gui/sdcc_ui.h b/src/tools/sdcc/gui/sdcc_ui.h
new file mode 100644
index 0000000..a0f0ffc
--- /dev/null
+++ b/src/tools/sdcc/gui/sdcc_ui.h
@@ -0,0 +1,35 @@
+/***************************************************************************
+ * 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 SDCC_UI_H
+#define SDCC_UI_H
+
+#include "tools/gui/tool_config_widget.h"
+#include "tools/gui/tool_group_ui.h"
+
+namespace SDCC
+{
+//----------------------------------------------------------------------------
+class ConfigWidget : public ToolConfigWidget
+{
+Q_OBJECT
+public:
+ ConfigWidget(Project *project);
+ virtual void initEntries();
+};
+
+//----------------------------------------------------------------------------
+class GroupUI : public Tool::GroupUI
+{
+public:
+ virtual ToolConfigWidget *configWidgetFactory(Tool::Category category, ::Project *project) const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/sdcc/sdcc.cpp b/src/tools/sdcc/sdcc.cpp
new file mode 100644
index 0000000..ba86273
--- /dev/null
+++ b/src/tools/sdcc/sdcc.cpp
@@ -0,0 +1,115 @@
+/***************************************************************************
+ * 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 "sdcc.h"
+
+#include "devices/list/device_list.h"
+#include "sdcc_compile.h"
+#include "sdcc_config.h"
+#include "devices/pic/pic/pic_memory.h"
+#include "common/global/pfile.h"
+#include "common/global/process.h"
+#include "sdcc_generator.h"
+
+//----------------------------------------------------------------------------
+bool SDCC::Base::checkExecutableResult(bool, QStringList &lines) const
+{
+ return ( lines.count()>0 && lines[0].startsWith("SDCC") );
+}
+
+//----------------------------------------------------------------------------
+QString SDCC::Group::informationText() const
+{
+ return i18n("The <a href=\"%1\">Small Devices C Compiler</a> is an open-source C compiler for several families of microcontrollers.").arg("http://sdcc.sourceforge.net");
+}
+
+const ::Tool::Base *SDCC::Group::base(Tool::Category category) const
+{
+ if ( category==Tool::Category::Assembler || category==Tool::Category::Librarian )
+ return Tool::lister().group("gputils")->base(category);
+ return Tool::Group::base(category);
+}
+
+Tool::Group::BaseData SDCC::Group::baseFactory(Tool::Category category) const
+{
+ if ( category==Tool::Category::Compiler ) return BaseData(new ::SDCC::Base, Both);
+ if ( category==Tool::Category::Linker) return BaseData(new ::SDCC::Base, ProjectOnly);
+ return BaseData();
+}
+
+SDCC::Group::Group()
+ : _checkDevicesTmp(_sview, ".c")
+{
+ // used to obtain device list
+ if ( _checkDevicesTmp.openForWrite() ) _checkDevicesTmp.appendText("void main(void) {}\n");
+ _checkDevicesTmp.close();
+}
+
+QStringList SDCC::Group::checkDevicesOptions(uint i) const
+{
+ QStringList options;
+ options += QString("-m") + SDCC::FAMILY_DATA[i].name;
+ options += "-phelp";
+ options += _checkDevicesTmp.url().filepath();
+ return options;
+}
+
+PURL::Directory SDCC::Group::autodetectDirectory(Compile::DirectoryType type, const PURL::Directory &dir, bool withWine) const
+{
+ return Tool::lister().group("gputils")->autodetectDirectory(type, dir, withWine);
+}
+
+bool SDCC::Group::needs(bool withProject, Tool::Category category) const
+{
+ if ( category==Tool::Category::Assembler || category==Tool::Category::Librarian ) return Tool::lister().group("gputils")->needs(withProject, category);
+ return Tool::Group::needs(withProject, category);
+}
+
+Compile::Process *SDCC::Group::processFactory(const Compile::Data &data) const
+{
+ switch (data.category.type()) {
+ case Tool::Category::Assembler:
+ case Tool::Category::Librarian:
+ return Tool::lister().group("gputils")->processFactory(data);
+ case Tool::Category::Compiler:
+ if (data.project) return new SDCC::CompileProjectFile;
+ return new SDCC::CompileStandaloneFile;
+ case Tool::Category::Linker:
+ return new SDCC::LinkProjectFile;
+ default: break;
+ }
+ return 0;
+}
+
+Compile::Config *SDCC::Group::configFactory(::Project *project) const
+{
+ return new Config(project);
+}
+
+PURL::FileType SDCC::Group::implementationType(PURL::ToolType type) const
+{
+ if ( type==PURL::ToolType::Assembler ) return PURL::AsmGPAsm;
+ if ( type==PURL::ToolType::Compiler ) return PURL::CSource;
+ return PURL::Nb_FileTypes;
+}
+
+Tool::SourceGenerator *SDCC::Group::sourceGeneratorFactory() const
+{
+ return new SourceGenerator;
+}
+
+bool SDCC::Group::generateDebugInformation(const QString &device) const
+{
+ switch (family(device)) {
+ case P14: return false;
+ case P16: return true;
+ case Nb_Families: break;
+ }
+ Q_ASSERT(false);
+ return false;
+}
diff --git a/src/tools/sdcc/sdcc.h b/src/tools/sdcc/sdcc.h
new file mode 100644
index 0000000..3155273
--- /dev/null
+++ b/src/tools/sdcc/sdcc.h
@@ -0,0 +1,63 @@
+/***************************************************************************
+ * 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 SDCC_H
+#define SDCC_H
+
+#include "tools/list/tool_list.h"
+#include "common/gui/pfile_ext.h"
+#include "sdcc_generator.h"
+
+namespace SDCC
+{
+//----------------------------------------------------------------------------
+class Base : public Tool::Base
+{
+public:
+ virtual QString baseExecutable(bool, Tool::OutputExecutableType) const { return "sdcc"; }
+
+private:
+ virtual QStringList checkExecutableOptions(bool) const { return "-v"; }
+ virtual bool checkExecutableResult(bool withWine, QStringList &lines) const;
+};
+
+//----------------------------------------------------------------------------
+class Group : public Tool::Group
+{
+public:
+ Group();
+ virtual QString name() const { return "sdcc"; }
+ virtual QString label() const { return i18n("Small Device C Compiler"); }
+ virtual QString informationText() const;
+ virtual const ::Tool::Base *base(Tool::Category category) const;
+ virtual uint nbCheckDevices() const { return SDCC::Nb_Families; }
+ virtual bool hasDirectory(Compile::DirectoryType type) const { return type==Compile::DirectoryType::Header || type==Compile::DirectoryType::LinkerScript; }
+ virtual PURL::FileType linkerScriptType() const { return PURL::Lkr; }
+ virtual PURL::Url linkerScript(const ::Project *project, Compile::LinkType type) const { return Tool::lister().group("gputils")->linkerScript(project, type); }
+ virtual PURL::Directory autodetectDirectory(Compile::DirectoryType type, const PURL::Directory &execDir, bool withWine) const;
+ virtual Tool::ExecutableType preferedExecutableType() const { return Tool::ExecutableType::Unix; }
+ virtual Tool::CompileType compileType() const { return Tool::SeparateFiles; }
+ virtual Tool::Category checkDevicesCategory() const { return Tool::Category::Compiler; }
+ virtual QStringList checkDevicesOptions(uint i) const;
+ virtual bool needs(bool withProject, Tool::Category category) const;
+ virtual PURL::FileType implementationType(PURL::ToolType type) const;
+ virtual bool generateDebugInformation(const QString &device) const;
+
+private:
+ Log::StringView _sview;
+ PURL::TempFile _checkDevicesTmp;
+ virtual BaseData baseFactory(Tool::Category category) const;
+ virtual QValueList<const Device::Data *> getSupportedDevices(const QString &s) const { return SDCC::getSupportedDevices(s); }
+ virtual Compile::Process *processFactory(const Compile::Data &data) const;
+ virtual Compile::Config *configFactory(::Project *project) const;
+ virtual Tool::SourceGenerator *sourceGeneratorFactory() const;
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/sdcc/sdcc_compile.cpp b/src/tools/sdcc/sdcc_compile.cpp
new file mode 100644
index 0000000..a3c072f
--- /dev/null
+++ b/src/tools/sdcc/sdcc_compile.cpp
@@ -0,0 +1,103 @@
+/***************************************************************************
+ * 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 "sdcc_compile.h"
+
+#include "sdcc.h"
+#include "sdcc_config.h"
+#include "tools/list/tool_list.h"
+#include "sdcc_generator.h"
+
+//-----------------------------------------------------------------------------
+QString SDCC::Process::familyName() const
+{
+ return FAMILY_DATA[family(_data.device)].name;
+}
+
+QString SDCC::Process::deviceName() const
+{
+ return toDeviceName(_data.device);
+}
+
+QStringList SDCC::Process::genericArguments(const Compile::Config &) const
+{
+ QStringList args;
+ args += "-m%FAMILY";
+ args += "-%DEVICE";
+ args += "-V"; // verbose
+ args += "--debug";
+ return args;
+}
+
+QString SDCC::Process::outputFiles() const
+{
+ return "PURL::Object PURL::AsmGPAsm adb p d PURL::Lst";
+}
+
+void SDCC::Process::logStderrLine(const QString &line)
+{
+ if ( parseErrorLine(line, Compile::ParseErrorData("([^:]*):([0-9]+):(error|warning|message):(.+)", 1, 2, 4, 3)) ) return;
+ if ( parseErrorLine(line, Compile::ParseErrorData("([^:]*):([0-9]+):(\\w+)\\s*\\[[0-9]+\\](.+)", 1, 2, 4, 3)) ) return;
+ if ( parseErrorLine(line, Compile::ParseErrorData("([^:]*)\\s*[0-9]+:(.+)", -1, -1, 2, 1, Log::LineType::Warning)) ) return;
+ if ( parseErrorLine(line, Compile::ParseErrorData("([^:]*):([0-9]+):(.+)", 1, 2, 3, Log::LineType::Warning)) ) return;
+ if ( parseErrorLine(line, Compile::ParseErrorData("([^:]*):([^:]+):([0-9]+):(.+)", 2, 3, 4, Log::LineType::Warning)) ) return;
+ if ( parseErrorLine(line, Compile::ParseErrorData("([^:]+):(.+)", -1, -1, 2, 1, Log::LineType::Warning)) ) return;
+ doLog(filterType(line), line, QString::null, 0);
+}
+
+//-----------------------------------------------------------------------------
+QStringList SDCC::CompileStandaloneFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = Process::genericArguments(config);
+ args += config.includeDirs(Tool::Category::Compiler, "-I");
+ args += config.customOptions(Tool::Category::Compiler);
+ args += "-Wl-o%O";
+ args += "-Wl-m"; // output map file
+ HexBuffer::Format format = config.hexFormat();
+ if( format!=HexBuffer::Nb_Formats )
+ args += QString("-Wl-a") + HexBuffer::FORMATS[format];
+ args += "%I";
+ return args;
+}
+
+QString SDCC::CompileStandaloneFile::outputFiles() const
+{
+ return Process::outputFiles() + " PURL::Map PURL::Hex PURL::Cod rst sym mem lnk";
+}
+
+//-----------------------------------------------------------------------------
+QStringList SDCC::CompileProjectFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = Process::genericArguments(config);
+ args += config.includeDirs(Tool::Category::Compiler, "-I");
+ args += config.customOptions(Tool::Category::Compiler);
+ args += "-c"; // compile only
+ args += "%I";
+ return args;
+}
+
+//-----------------------------------------------------------------------------
+QStringList SDCC::LinkProjectFile::genericArguments(const Compile::Config &config) const
+{
+ QStringList args = Process::genericArguments(config);
+ args += "-Wl-c"; // create coff file
+ args += "-Wl-m"; // output map file
+ args += "$LKR(-Wl-s%LKR)";
+ args += config.includeDirs(Tool::Category::Linker, "-I");
+ args += config.customOptions(Tool::Category::Linker);
+ args += "-o%O";
+ args += "%OBJS";
+ args += "%LIBS";
+ args += config.customLibraries(Tool::Category::Linker);
+ return args;
+}
+
+QString SDCC::LinkProjectFile::outputFiles() const
+{
+ return Process::outputFiles() + " PURL::Lkr PURL::Hex PURL::Cod PURL::Coff PURL::Map";
+}
diff --git a/src/tools/sdcc/sdcc_compile.h b/src/tools/sdcc/sdcc_compile.h
new file mode 100644
index 0000000..8ba4c30
--- /dev/null
+++ b/src/tools/sdcc/sdcc_compile.h
@@ -0,0 +1,58 @@
+/***************************************************************************
+ * 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 SDCC_COMPILE_H
+#define SDCC_COMPILE_H
+
+#include "tools/list/compile_process.h"
+
+namespace SDCC
+{
+//-----------------------------------------------------------------------------
+class Process : public Compile::Process
+{
+Q_OBJECT
+protected:
+ virtual QString deviceName() const;
+ virtual QString familyName() const;
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+ virtual void logStderrLine(const QString &line);
+ virtual bool hasLinkerScript() const { return ( _data.linkType==Compile::Icd2Linking || Main::toolGroup().hasCustomLinkerScript(_data.project) ); }
+};
+
+//-----------------------------------------------------------------------------
+class CompileStandaloneFile : public Process
+{
+Q_OBJECT
+private:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+};
+
+//-----------------------------------------------------------------------------
+class CompileProjectFile : public Process
+{
+Q_OBJECT
+private:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+};
+
+//-----------------------------------------------------------------------------
+class LinkProjectFile : public Process
+{
+Q_OBJECT
+private:
+ virtual QStringList genericArguments(const Compile::Config &config) const;
+ virtual QString outputFiles() const;
+ virtual QString objectExtension() const { return "o"; }
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/sdcc/sdcc_config.cpp b/src/tools/sdcc/sdcc_config.cpp
new file mode 100644
index 0000000..5b44673
--- /dev/null
+++ b/src/tools/sdcc/sdcc_config.cpp
@@ -0,0 +1,9 @@
+/***************************************************************************
+ * 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 "sdcc_config.h"
diff --git a/src/tools/sdcc/sdcc_config.h b/src/tools/sdcc/sdcc_config.h
new file mode 100644
index 0000000..c4bafdd
--- /dev/null
+++ b/src/tools/sdcc/sdcc_config.h
@@ -0,0 +1,25 @@
+/***************************************************************************
+ * 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 SDCC_CONFIG_H
+#define SDCC_CONFIG_H
+
+#include "tools/gputils/gputils_config.h"
+
+namespace SDCC
+{
+//----------------------------------------------------------------------------
+class Config : public GPUtils::Config
+{
+public:
+ Config(Project *project) : GPUtils::Config(project) {}
+};
+
+} // namespace
+
+#endif
diff --git a/src/tools/sdcc/sdcc_generator.cpp b/src/tools/sdcc/sdcc_generator.cpp
new file mode 100644
index 0000000..fb57ab6
--- /dev/null
+++ b/src/tools/sdcc/sdcc_generator.cpp
@@ -0,0 +1,117 @@
+/***************************************************************************
+ * Copyright (C) 2006-2007 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 "sdcc_generator.h"
+
+#include "devices/pic/pic/pic_memory.h"
+#include "devices/list/device_list.h"
+#include "tools/gputils/gputils.h"
+
+//----------------------------------------------------------------------------
+const SDCC::FamilyData SDCC::FAMILY_DATA[Nb_Families] = {
+ { "pic14" },
+ { "pic16" }
+};
+
+SDCC::Family SDCC::family(const QString &device)
+{
+ const Device::Data *data = Device::lister().data(device);
+ switch (static_cast<const Pic::Data *>(data)->architecture().type()) {
+ case Pic::Architecture::P10X:
+ case Pic::Architecture::P16X: return P14;
+ case Pic::Architecture::P17C:
+ case Pic::Architecture::P18C:
+ case Pic::Architecture::P18F:
+ case Pic::Architecture::P18J: return P16;
+ case Pic::Architecture::P24F:
+ case Pic::Architecture::P24H:
+ case Pic::Architecture::P30F:
+ case Pic::Architecture::P33F:
+ case Pic::Architecture::Nb_Types: break;
+ }
+ Q_ASSERT(false);
+ return Nb_Families;
+}
+
+QString SDCC::toDeviceName(const QString &device)
+{
+ return GPUtils::toDeviceName(device);
+}
+
+QValueList<const Device::Data *> SDCC::getSupportedDevices(const QString &s)
+{
+ return GPUtils::getSupportedDevices(s);
+}
+
+SourceLine::List SDCC::SourceGenerator::configLines(PURL::ToolType type, const Device::Memory &memory, bool &ok) const
+{
+ if ( type==PURL::ToolType::Assembler ) {
+ GPUtils::SourceGenerator generator;
+ return generator.configLines(type, memory, ok);
+ }
+ const Pic::Memory &pmemory = static_cast<const Pic::Memory &>(memory);
+ const Pic::Data &data = pmemory.device();
+ const Pic::Config &config = data.config();
+ SourceLine::List lines;
+ if ( !data.is18Family() ) lines.appendNotIndentedCode("typedef unsigned int word;");
+ Address address = data.range(Pic::MemoryRangeType::Config).start;
+ QString prefix = (data.nbWords(Pic::MemoryRangeType::Config)==2 || data.name().startsWith("16F9") ? "_" : "__");
+ for (uint i=0; i<data.nbWords(Pic::MemoryRangeType::Config); i++) {
+ const Pic::Config::Word &cword = config._words[i];
+ QStringList cnames = SourceLine::configNames(Pic::ConfigNameType::SDCC, pmemory, i, ok);
+ if ( cnames.isEmpty() ) continue;
+ QString code;
+ if ( data.is18Family() ) code += "code char at ";
+ else code += "word at ";
+ if ( cword.name.isEmpty() ) code += toHexLabel(address, data.nbCharsAddress()) + " CONFIG";
+ else code += prefix + cword.name + " " + cword.name;
+ code += " = " + cnames.join(" & ") + ";";
+ lines.appendNotIndentedCode(code);
+ address += data.addressIncrement(Pic::MemoryRangeType::Config);
+ }
+ return lines;
+}
+
+//----------------------------------------------------------------------------
+SourceLine::List SDCC::SourceGenerator::includeLines(PURL::ToolType type, const Device::Data &data) const
+{
+ if ( type==PURL::ToolType::Assembler ) {
+ GPUtils::SourceGenerator generator;
+ return generator.includeLines(type, data);
+ }
+ SourceLine::List lines;
+ lines.appendNotIndentedCode("#include <pic" + data.name().lower() + ".h>");
+ return lines;
+}
+
+SourceLine::List SDCC::SourceGenerator::sourceFileContent(PURL::ToolType type, const Device::Data &data, bool &ok) const
+{
+ if ( type==PURL::ToolType::Assembler ) {
+ GPUtils::SourceGenerator generator;
+ return generator.sourceFileContent(type, data, ok);
+ }
+ SourceLine::List lines;
+ switch (static_cast<const Pic::Data &>(data).architecture().type()) {
+ case Pic::Architecture::P16X:
+ lines.appendNotIndentedCode("void isr() interrupt 0 {", i18n("interrupt service routine"));
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert interrupt code") + " >>");
+ lines.appendNotIndentedCode("}");
+ lines.appendEmpty();
+ break;
+ case Pic::Architecture::P18C:
+ case Pic::Architecture::P18F:
+ case Pic::Architecture::P18J:
+ // #### TODO: template interrupt code
+ break;
+ default: Q_ASSERT(false); break;
+ }
+ lines.appendNotIndentedCode("void main() {");
+ lines.appendIndentedCode(QString::null, "<< " + i18n("insert code") + " >>");
+ lines.appendNotIndentedCode("}");
+ return lines;
+}
diff --git a/src/tools/sdcc/sdcc_generator.h b/src/tools/sdcc/sdcc_generator.h
new file mode 100644
index 0000000..e5f0101
--- /dev/null
+++ b/src/tools/sdcc/sdcc_generator.h
@@ -0,0 +1,45 @@
+/***************************************************************************
+ * Copyright (C) 2006-2007 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 SDCC_GENERATOR_H
+#define SDCC_GENERATOR_H
+
+#include "coff/base/disassembler.h"
+
+namespace SDCC
+{
+//----------------------------------------------------------------------------
+enum Family { P14 = 0, P16, Nb_Families };
+struct FamilyData {
+ const char *name;
+};
+extern const FamilyData FAMILY_DATA[Nb_Families];
+extern Family family(const QString &device);
+extern QString toDeviceName(const QString &device);
+extern QValueList<const Device::Data *> getSupportedDevices(const QString &s);
+
+//----------------------------------------------------------------------------
+class SourceGenerator : public Tool::SourceGenerator
+{
+public:
+ virtual SourceLine::List configLines(PURL::ToolType type, const Device::Memory &memory, bool &ok) const;
+ virtual SourceLine::List sourceFileContent(PURL::ToolType type, const Device::Data &data, bool &ok) const;
+ virtual SourceLine::List includeLines(PURL::ToolType type, const Device::Data &data) const;
+
+private:
+ struct P16CNameData {
+ const char *cname, *sdccName;
+ };
+ static const P16CNameData P16_CNAME_DATA[];
+ static void transformCName(QString &cname, const Pic::Data &data);
+
+};
+
+} // namespace
+
+#endif