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/picc | |
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/picc')
-rw-r--r-- | src/tools/picc/Makefile.am | 8 | ||||
-rw-r--r-- | src/tools/picc/gui/Makefile.am | 6 | ||||
-rw-r--r-- | src/tools/picc/gui/picc_ui.cpp | 20 | ||||
-rw-r--r-- | src/tools/picc/gui/picc_ui.h | 35 | ||||
-rw-r--r-- | src/tools/picc/picc.cpp | 127 | ||||
-rw-r--r-- | src/tools/picc/picc.h | 97 | ||||
-rw-r--r-- | src/tools/picc/picc_compile.cpp | 136 | ||||
-rw-r--r-- | src/tools/picc/picc_compile.h | 83 | ||||
-rw-r--r-- | src/tools/picc/picc_config.cpp | 9 | ||||
-rw-r--r-- | src/tools/picc/picc_config.h | 25 |
10 files changed, 546 insertions, 0 deletions
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 |