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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
/***************************************************************************
* 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 };
TQ_DECLARE_FLAGS(FileActions, FileAction)
TQ_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 TQValueList<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 TQString &p, int iFile, int iLine, int iMessage, Log::LineType dLineType)
: pattern(p), indexFile(iFile), indexLine(iLine), indexMessage(iMessage), indexLogType(-1),
defaultLineType(dLineType) {}
ParseErrorData(const TQString &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) {}
TQString pattern;
int indexFile, indexLine, indexMessage, indexLogType;
Log::LineType defaultLineType;
};
//-----------------------------------------------------------------------------
class LogWidget : public Log::Widget
{
Q_OBJECT
TQ_OBJECT
public:
LogWidget(TQWidget *tqparent);
void appendLine(Log::LineType type, const TQString &message, const TQString &filepath, uint line);
void appendLine(Log::DebugLevel debug, const TQString &message, const TQString &filepath, uint line);
virtual void clear();
private slots:
void lineClicked(int line);
private:
class Data {
public:
Data() {}
Data(const TQString &fp, uint l) : filepath(fp), line(l) {}
TQString filepath;
uint line;
};
TQMap<uint, Data> _map;
};
//-----------------------------------------------------------------------------
class BaseProcess : public TQObject
{
Q_OBJECT
TQ_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;
TQString _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 TQString &line) { logStderrLine(line); }
virtual void logStderrLine(const TQString &line) = 0;
virtual void done(int code);
void timeout();
};
//-----------------------------------------------------------------------------
class Process : public BaseProcess
{
Q_OBJECT
TQ_OBJECT
public:
virtual ~Process();
virtual void init(const Data &data, Manager *manager);
virtual bool check() const;
virtual FileData::List files(bool *ok) const;
virtual TQStringList 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;
TQString filepath(PURL::FileType type, uint i=0) const;
virtual TQString outputFilepath() const;
virtual TQString outputFiles() const = 0;
uint nbFiles() const { return _data.items.count(); }
virtual TQString inputFilepath(uint i) const { return filepath(PURL::Nb_FileTypes, i); }
virtual TQString deviceName() const = 0;
virtual TQString familyName() const { return TQString(); }
virtual TQString objectExtension() const { return TQString(); }
virtual TQString libraryExtension() const { return "lib"; }
virtual bool hasLinkerScript() const { return group().hasCustomLinkerScript(_data.project); }
FileData fileData(PURL::FileType type, FileActions actions) const;
bool parseErrorLine(const TQString &s, const ParseErrorData &data);
virtual Log::LineType filterType(const TQString &type) const;
void doLog(const TQString &type, const TQString &message, const TQString &surl, uint line);
void doLog(Log::LineType type, const TQString &message, const TQString &surl, uint line);
virtual void setupProcess();
TQStringList arguments() const;
const Tool::Base *tool() const { return group().base(_data.category); }
private:
static bool checkIs(const TQString &s, const TQString &key);
static TQString replaceIf(const TQString &s, const TQString &key, bool condition);
};
//-----------------------------------------------------------------------------
class CustomProcess : public BaseProcess
{
Q_OBJECT
TQ_OBJECT
public:
CustomProcess(const TQString &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 TQString &line);
private:
TQString _command;
};
} // namespace
#endif
|