summaryrefslogtreecommitdiffstats
path: root/src/tools/picc/picc.cpp
blob: 060aa4cd2df924f3e94b4e0c4fd8c144fa2a905f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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 <tqregexp.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, TQStringList &lines) const
{
  return lines.join(" ").tqcontains("HI-TECH");
}

TQString PICC::BaseLite::baseExecutable(bool, Tool::OutputExecutableType) const
{
  if ( _category.type()==Tool::Category::Librarian ) return "libr";
  return "picl";
}

TQString PICC::BaseNormal::baseExecutable(bool, Tool::OutputExecutableType) const
{
  if ( _category.type()==Tool::Category::Librarian ) return "libr";
  return "picc";
}

TQString PICC::Base18::baseExecutable(bool, Tool::OutputExecutableType) const
{
  if ( _category.type()==Tool::Category::Librarian ) return "libr";
  return "picc18";
}

//----------------------------------------------------------------------------
TQValueList<const Device::Data *> PICC::Group::getSupportedDevices(const TQString &s) const
{
  TQValueList<const Device::Data *> list;
  TQStringList lines = TQStringList::split('\n', s);
  for (uint i=0; i<lines.count(); i++) {
    TQRegExp 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;
}

//----------------------------------------------------------------------------
TQString PICC::PICCLiteGroup::informationText() const
{
  return i18n("<a href=\"%1\">PICC-Lite</a> is a freeware C compiler distributed by HTSoft.").tqarg("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();
}

//----------------------------------------------------------------------------
TQString PICC::PICCGroup::informationText() const
{
  return i18n("<a href=\"%1\">PICC</a> is a C compiler distributed by HTSoft.").tqarg("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();
}

//----------------------------------------------------------------------------
TQString PICC::PICC18Group::informationText() const
{
  return i18n("<a href=\"%1\">PICC 18</a> is a C compiler distributed by HTSoft.").tqarg("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();
}