diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 18:42:24 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-24 18:42:24 +0000 |
commit | f508189682b6fba62e08feeb1596f682bad5fff9 (patch) | |
tree | 28aeb0e6c19386c385c1ce5edf8a92c1bca15281 /src/tools/sdcc | |
download | piklab-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/sdcc')
-rw-r--r-- | src/tools/sdcc/Makefile.am | 9 | ||||
-rw-r--r-- | src/tools/sdcc/gui/Makefile.am | 6 | ||||
-rw-r--r-- | src/tools/sdcc/gui/sdcc_ui.cpp | 29 | ||||
-rw-r--r-- | src/tools/sdcc/gui/sdcc_ui.h | 35 | ||||
-rw-r--r-- | src/tools/sdcc/sdcc.cpp | 115 | ||||
-rw-r--r-- | src/tools/sdcc/sdcc.h | 63 | ||||
-rw-r--r-- | src/tools/sdcc/sdcc_compile.cpp | 103 | ||||
-rw-r--r-- | src/tools/sdcc/sdcc_compile.h | 58 | ||||
-rw-r--r-- | src/tools/sdcc/sdcc_config.cpp | 9 | ||||
-rw-r--r-- | src/tools/sdcc/sdcc_config.h | 25 | ||||
-rw-r--r-- | src/tools/sdcc/sdcc_generator.cpp | 117 | ||||
-rw-r--r-- | src/tools/sdcc/sdcc_generator.h | 45 |
12 files changed, 614 insertions, 0 deletions
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 |