-
Notifications
You must be signed in to change notification settings - Fork 0
/
RteGenerator.h
261 lines (221 loc) · 7.77 KB
/
RteGenerator.h
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#ifndef RteGenerator_H
#define RteGenerator_H
/******************************************************************************/
/* RTE - CMSIS Run-Time Environment */
/******************************************************************************/
/** @file RteGenerator.h
* @brief CMSIS RTE Data Model
*/
/******************************************************************************/
/*
* Copyright (c) 2020-2021 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
/******************************************************************************/
#include "RtePackage.h"
#include "RteDevice.h"
class RteFile;
class RteFileContainer;
class RteTarget;
/** RTE Generator
*
* Contains generator properties
*/
/**
* @brief class to support handling of <generator> elements in pdsc file
*/
class RteGenerator : public RteItem
{
public:
/**
* @brief constructor
* @param parent pointer to RteItem parent
*/
RteGenerator(RteItem* parent);
/**
* @brief virtual destructor
*/
~RteGenerator() override;
/**
* @brief get generator commands for all host types without expansion
* @return map with host type ("win", "linux", "mac", "other", or "all") as key and generator command as value
*/
std::map<std::string, std::string> GetCommands() const;
/**
* @brief get generator command without expansion
* @param hostType host type to match, empty to match current host
* @return generator command for specified host type
*/
const std::string GetCommand(const std::string& hostType = EMPTY_STRING ) const;
/**
* @brief get expanded generator executable command
* @param target pointer to RteTarget
* @param hostType host type to match, empty to match current host
* @return generator command for specified host type
*/
std::string GetExecutable(RteTarget* target, const std::string& hostType = EMPTY_STRING) const;
/**
* @brief get item containing command line arguments
* @param type generator type ("exe", "web", etc. ).
* Default is empty for backward compatibility, equals to "exe"
* @return command line arguments (default for "exe")
*/
RteItem* GetArgumentsItem(const std::string& type = EMPTY_STRING) const;
/**
* @brief get files to add to project when using the generator
* @return pointer to RteFileContainer containing file items, nullptr if no files need to be added
*/
RteFileContainer* GetProjectFiles() const { return m_files; }
/**
* @brief get generator device name
* @return device name
*/
const std::string& GetDeviceName() const override { return m_pDeviceAttributes ? m_pDeviceAttributes->GetDeviceName() : EMPTY_STRING; }
/**
* @brief get generator device vendor
* @return device vendor
*/
const std::string& GetDeviceVendor() const override { return m_pDeviceAttributes ? m_pDeviceAttributes->GetDeviceVendor() : EMPTY_STRING; }
/**
* @brief get device variant
* @return device variant name
*/
const std::string& GetDeviceVariantName() const override { return m_pDeviceAttributes ? m_pDeviceAttributes->GetDeviceVariantName() : EMPTY_STRING; }
/**
* @brief get processor name
* @return processor name
*/
const std::string& GetProcessorName() const override { return m_pDeviceAttributes ? m_pDeviceAttributes->GetProcessorName() : EMPTY_STRING; }
/**
* @brief get all device attributes
* @return device attributes as a reference to RteItem
*/
const RteItem& GetDeviceAttributes() const { return m_pDeviceAttributes ? *m_pDeviceAttributes : RteItem::EMPTY_RTE_ITEM; }
/**
* @brief get generator group name to use in project
* @return string in the format ":GetName()::Common Sources"
*/
std::string GetGeneratorGroupName() const;
/**
* @brief get gpdsc file name
* @return gpdsc file name
*/
const std::string& GetGpdsc() const;
/**
* @brief get generator working directory
* @return working directory value
*/
const std::string& GetWorkingDir() const { return GetItemValue("workingDir"); }
/**
* @brief get all arguments as vector for the given host type
* @param target pointer to RteTarget
* @param hostType host type, empty to match current host
* @param dryRun include dry-run arguments
* @return vector of arguments consisting of switch and value in pairs
*/
std::vector<std::pair<std::string, std::string> > GetExpandedArguments(RteTarget* target, const std::string& hostType = EMPTY_STRING, bool dryRun = false) const;
/**
* @brief get full command line with arguments and expanded key sequences for specified target
* @param target pointer to RteTarget
* @param hostType host type, empty to match current host
* @param dryRun include dry-run arguments
* @return expanded command line with arguments, properly quoted
*/
std::string GetExpandedCommandLine(RteTarget* target, const std::string& hostType = EMPTY_STRING, bool dryRun = false) const;
/**
* @brief get absolute path to gpdsc file for specified target
* @param target pointer to RteTarget
* @param optional generator destination directory
* @return absolute gpdsc filename
*/
std::string GetExpandedGpdsc(RteTarget* target, const std::string& genDir = EMPTY_STRING) const;
/**
* @brief get absolute path to working directory for specified target
* @param target pointer to RteTarget
* @param optional generator destination directory
* @return absolute path to working directory
*/
std::string GetExpandedWorkingDir(RteTarget* target, const std::string& genDir = EMPTY_STRING) const;
/**
* @brief get command line for a web application with expanded key sequences
* @param target pointer to RteTarget
* @return expanded command line for web application
*/
std::string GetExpandedWebLine(RteTarget* target) const;
/**
* @brief check if this generator uses as executable
* @return true if uses executable
*/
bool HasExe() const;
/**
* @brief check if this generator uses web application
* @return true if uses web application
*/
bool HasWeb() const;
public:
/**
* @brief get generator name
* @return generator ID
*/
const std::string& GetName() const override { return GetAttribute("id"); }
/**
* @brief get generator name
* @return generator ID
*/
const std::string& GetGeneratorName() const override { return GetName(); }
/**
* @brief clear internal data structures
*/
void Clear() override;
/**
* @brief called to construct the item with attributes and child elements
*/
void Construct() override;
/**
* @brief create a new instance of type RteItem
* @param tag name of tag
* @return pointer to instance of type RteItem
*/
RteItem* CreateItem(const std::string& tag) override;
/**
* @brief check whether the generator can be run in dry-run mode
* @param hostType host type, empty to match current host
* @return true if the generator is dry-run capable, false otherwise
*/
bool IsDryRunCapable(const std::string& hostType = EMPTY_STRING) const;
protected:
/**
* @brief construct generator ID
* @return value of "id" attribute
*/
std::string ConstructID() override { return GetAttribute("id"); }
private:
RteItem* m_pDeviceAttributes;
RteFileContainer* m_files;
};
/**
* @brief class to support <generator> element in *.pdsc files
*/
class RteGeneratorContainer : public RteItem
{
public:
/**
* @brief constructor
* @param parent pointer to RteItem parent
*/
RteGeneratorContainer(RteItem* parent);
/**
* @brief get generator with specified ID
* @param id generator ID
* @return pointer to RteGenerator if found, nullptr otherwise
*/
RteGenerator* GetGenerator(const std::string& id) const;
/**
* @brief create a new instance of type RteItem
* @param tag name of tag
* @return pointer to instance of type RteItem
*/
RteItem* CreateItem(const std::string& tag) override;
};
#endif // RteGenerator_H