blob: 0b817a3cc554637c2bdf67f81ecc9600f16e6926 (
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
|
/***************************************************************************
* 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 <tqregexp.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"
//----------------------------------------------------------------------------
TQStringList CCSC::Base::checkExecutableOptions(bool withWine) const
{
TQStringList 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, TQStringList &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();
}
TQValueList<const Device::Data *> CCSC::Group::getSupportedDevices(const TQString &) const
{
TQValueList<const Device::Data *> list;
TQValueVector<TQString> 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);
}
TQString CCSC::Group::informationText() const
{
return i18n("<a href=\"%1\">CCS Compiler</a> is a C compiler distributed by CCS.").tqarg("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) ) {
TQStringList 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
}
|