gwenhywfar  5.7.2
target.c
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Mon Feb 08 2021
3  copyright : (C) 2021 by Martin Preuss
4  email : martin@libchipcard.de
5 
6  ***************************************************************************
7  * Please see toplevel file COPYING for license details *
8  ***************************************************************************/
9 
10 #ifdef HAVE_CONFIG_H
11 # include <config.h>
12 #endif
13 
14 #include "gwenbuild/types/target_p.h"
15 
16 
17 #include <gwenhywfar/debug.h>
18 #include <gwenhywfar/memory.h>
19 
20 
21 
23 
24 
25 
27 {
28  GWB_TARGET *target;
29 
30  GWEN_NEW_OBJECT(GWB_TARGET, target);
31 
32  target->sourceFileList=GWB_File_List2_new();
33  target->usedTargetNameList=GWEN_StringList_new();
34  target->usedLibraryList=GWEN_StringList_new();
35  target->usedTargetLinkSpecList=GWEN_StringList_new();
36  target->project=project;
37  target->explicitBuildList=GWB_BuildCmd_List_new();
38 
39 
40  return target;
41 }
42 
43 
44 
46 {
47  if (target) {
48  free(target->installPath);
49  free(target->name);
50  free(target->id);
51  GWB_File_List2_free(target->sourceFileList);
52  GWEN_StringList_free(target->usedTargetNameList);
53  GWEN_StringList_free(target->usedTargetLinkSpecList);
54  GWEN_StringList_free(target->usedLibraryList);
55  GWB_BuildCmd_List_free(target->explicitBuildList);
56 
57  GWEN_FREE_OBJECT(target);
58  }
59 }
60 
61 
62 
64 {
65  return target->project;
66 }
67 
68 
69 
70 const char *GWB_Target_GetName(const GWB_TARGET *target)
71 {
72  return target->name;
73 }
74 
75 
76 
77 void GWB_Target_SetName(GWB_TARGET *target, const char *s)
78 {
79  if (target->name)
80  free(target->name);
81  if (s)
82  target->name=strdup(s);
83  else
84  target->name=NULL;
85 }
86 
87 
88 
89 const char *GWB_Target_GetId(const GWB_TARGET *target)
90 {
91  return target->id;
92 }
93 
94 
95 
96 void GWB_Target_SetId(GWB_TARGET *target, const char *s)
97 {
98  if (target->id)
99  free(target->id);
100  if (s)
101  target->id=strdup(s);
102  else
103  target->id=NULL;
104 }
105 
106 
107 
109 {
110  return target->targetType;
111 }
112 
113 
114 
116 {
117  target->targetType=t;
118 }
119 
120 
121 
122 const char *GWB_Target_GetInstallPath(const GWB_TARGET *target)
123 {
124  return target->installPath;
125 }
126 
127 
128 
129 void GWB_Target_SetInstallPath(GWB_TARGET *target, const char *s)
130 {
131  free(target->installPath);
132  target->installPath=s?strdup(s):NULL;
133 }
134 
135 
136 
137 void GWB_Target_SetSoVersion(GWB_TARGET *target, int vCurrent, int vAge, int vRevision)
138 {
139  target->soVersionCurrent=vCurrent;
140  target->soVersionAge=vAge;
141  target->soVersionRevision=vRevision;
142 }
143 
144 
145 
147 {
148  return target->soVersionCurrent;
149 }
150 
151 
152 
154 {
155  return target->soVersionAge;
156 }
157 
158 
159 
161 {
162  return target->soVersionRevision;
163 }
164 
165 
166 
168 {
169  return target->context;
170 }
171 
172 
173 
175 {
176  target->context=ctx;
177 }
178 
179 
180 
181 GWB_FILE_LIST2 *GWB_Target_GetSourceFileList(const GWB_TARGET *target)
182 {
183  return target->sourceFileList;
184 }
185 
186 
187 
189 {
190  GWB_File_List2_PushBack(target->sourceFileList, file);
191 }
192 
193 
194 
195 
197 {
198  return target->usedTargetNameList;
199 }
200 
201 
202 
203 void GWB_Target_AddUsedTargetName(GWB_TARGET *target, const char *s)
204 {
205  if (target->usedTargetNameList==NULL)
206  target->usedTargetNameList=GWEN_StringList_new();
207  GWEN_StringList_AppendString(target->usedTargetNameList, s, 0, 1);
208 }
209 
210 
211 
213 {
214  return target->usedLibraryList;
215 }
216 
217 
218 
219 void GWB_Target_AddUsedLibraryName(GWB_TARGET *target, const char *s)
220 {
221  if (target->usedLibraryList==NULL)
222  target->usedLibraryList=GWEN_StringList_new();
223  GWEN_StringList_AppendString(target->usedLibraryList, s, 0, 1);
224 }
225 
226 
227 
229 {
230  return target->usedTargetLinkSpecList;
231 }
232 
233 
234 
235 void GWB_Target_AddUsedTargetLinkSpec(GWB_TARGET *target, const char *s)
236 {
237  if (target->usedTargetLinkSpecList==NULL)
238  target->usedTargetLinkSpecList=GWEN_StringList_new();
239  GWEN_StringList_AppendString(target->usedTargetLinkSpecList, s, 0, 1);
240 }
241 
242 
243 
244 
246 {
247  return target->builder;
248 }
249 
250 
251 
253 {
254  target->builder=builder;
255 }
256 
257 
258 
260 {
261  return target->outputFile;
262 }
263 
264 
265 
267 {
268  target->outputFile=f;
269 }
270 
271 
272 
273 GWB_BUILD_CMD_LIST *GWB_Target_GetExplicitBuildList(const GWB_TARGET *target)
274 {
275  return target->explicitBuildList;
276 }
277 
278 
279 
281 {
282  GWB_BuildCmd_List_Add(bcmd, target->explicitBuildList);
283 }
284 
285 
286 
287 void GWB_Target_toXml(const GWB_TARGET *target, GWEN_XMLNODE *xmlNode)
288 {
289  if (target->id)
290  GWEN_XMLNode_SetCharValue(xmlNode, "id", target->id);
291  if (target->name)
292  GWEN_XMLNode_SetCharValue(xmlNode, "name", target->name);
293  GWEN_XMLNode_SetIntValue(xmlNode, "soVersionCurrent", target->soVersionCurrent);
294  GWEN_XMLNode_SetIntValue(xmlNode, "soVersionAge", target->soVersionAge);
295  GWEN_XMLNode_SetIntValue(xmlNode, "soVersionRevision", target->soVersionRevision);
296 
297  if (target->sourceFileList) {
298  GWEN_XMLNODE *n;
299 
300  n=GWEN_XMLNode_new(GWEN_XMLNodeTypeTag, "SourceFileList");
301  GWB_File_List2_WriteXml(target->sourceFileList, n, "File");
302  GWEN_XMLNode_AddChild(xmlNode, n);
303  }
304 }
305 
306 
307 
308 
309 
310 void GWB_Target_Dump(const GWB_TARGET *target, int indent, int fullDump)
311 {
312  int i;
313 
314  for(i=0; i<indent; i++)
315  fprintf(stderr, " ");
316  fprintf(stderr, "Target:\n");
317 
318  GWBUILD_Debug_PrintValue( "id....................", target->id, indent+2);
319  GWBUILD_Debug_PrintValue( "name..................", target->name, indent+2);
320  GWBUILD_Debug_PrintValue( "type..................", GWBUILD_TargetType_toString(target->targetType), indent+2);
321  GWBUILD_Debug_PrintIntValue( "soVersionCurrent......", target->soVersionCurrent, indent+2);
322  GWBUILD_Debug_PrintIntValue( "soVersionAge..........", target->soVersionAge, indent+2);
323  GWBUILD_Debug_PrintIntValue( "soVersionRevision.....", target->soVersionRevision, indent+2);
324  GWBUILD_Debug_PrintFileList2( "sourceFileList........", target->sourceFileList, indent+2);
325  GWBUILD_Debug_PrintStringList("usedTargetNameList....", target->usedTargetNameList, indent+2);
326  GWBUILD_Debug_PrintStringList("usedTargetLinkSpecList", target->usedTargetLinkSpecList, indent+2);
327  GWBUILD_Debug_PrintStringList("usedLibraryList.......", target->usedLibraryList, indent+2);
328  GWBUILD_Debug_PrintFile( "outputFile............", target->outputFile, indent+2);
329  if (fullDump)
330  GWB_Context_Dump(target->context, indent+2);
331 
332 
333 }
334 
335 
336 
void GWB_Target_SetName(GWB_TARGET *target, const char *s)
Definition: target.c:77
void GWB_Target_SetTargetType(GWB_TARGET *target, GWBUILD_TARGETTYPE t)
Definition: target.c:115
void GWBUILD_Debug_PrintIntValue(const char *sName, int value, int indent)
Definition: gwenbuild.c:233
struct GWB_CONTEXT GWB_CONTEXT
Definition: context.h:17
const char * GWB_Target_GetName(const GWB_TARGET *target)
Definition: target.c:70
#define GWEN_LIST2_FUNCTIONS(t, pr)
Definition: list2.h:99
int GWB_Target_GetSoVersionRevision(const GWB_TARGET *target)
Definition: target.c:160
void GWB_Target_Dump(const GWB_TARGET *target, int indent, int fullDump)
Definition: target.c:310
struct GWB_FILE GWB_FILE
Definition: file.h:18
#define GWEN_FREE_OBJECT(varname)
Definition: memory.h:61
#define NULL
Definition: binreloc.c:300
GWB_FILE_LIST2 * GWB_Target_GetSourceFileList(const GWB_TARGET *target)
Definition: target.c:181
void GWB_Target_AddSourceFile(GWB_TARGET *target, GWB_FILE *file)
Definition: target.c:188
struct GWB_PROJECT GWB_PROJECT
Definition: project.h:14
void GWB_Target_SetOutputFile(GWB_TARGET *target, GWB_FILE *f)
Definition: target.c:266
void GWEN_XMLNode_SetCharValue(GWEN_XMLNODE *n, const char *name, const char *value)
Definition: xml.c:897
GWBUILD_TARGETTYPE
Definition: gwenbuild.h:18
GWEN_XMLNODE * GWEN_XMLNode_new(GWEN_XMLNODE_TYPE t, const char *data)
Definition: xml.c:144
GWEN_STRINGLIST * GWB_Target_GetUsedLibraryNameList(const GWB_TARGET *target)
Definition: target.c:212
void GWB_Target_SetSoVersion(GWB_TARGET *target, int vCurrent, int vAge, int vRevision)
Definition: target.c:137
void GWB_Target_SetContext(GWB_TARGET *target, GWB_CONTEXT *ctx)
Definition: target.c:174
void GWB_Target_SetId(GWB_TARGET *target, const char *s)
Definition: target.c:96
void GWBUILD_Debug_PrintValue(const char *sName, const char *sValue, int indent)
Definition: gwenbuild.c:222
void GWEN_StringList_free(GWEN_STRINGLIST *sl)
Definition: stringlist.c:62
GWEN_STRINGLIST * GWB_Target_GetUsedTargetNameList(const GWB_TARGET *target)
Definition: target.c:196
GWEN_STRINGLIST * GWB_Target_GetUsedTargetLinkSpecList(const GWB_TARGET *target)
Definition: target.c:228
#define GWEN_NEW_OBJECT(typ, varname)
Definition: memory.h:55
void GWBUILD_Debug_PrintFile(const char *sName, const GWB_FILE *file, int indent)
Definition: gwenbuild.c:284
struct GWB_TARGET GWB_TARGET
Definition: target.h:17
int GWEN_StringList_AppendString(GWEN_STRINGLIST *sl, const char *s, int take, int checkDouble)
Definition: stringlist.c:245
GWB_TARGET * GWB_Target_new(GWB_PROJECT *project)
Definition: target.c:26
void GWB_Target_SetInstallPath(GWB_TARGET *target, const char *s)
Definition: target.c:129
GWB_BUILD_CMD_LIST * GWB_Target_GetExplicitBuildList(const GWB_TARGET *target)
Definition: target.c:273
const char * GWB_Target_GetInstallPath(const GWB_TARGET *target)
Definition: target.c:122
void GWB_Target_AddExplicitBuild(GWB_TARGET *target, GWB_BUILD_CMD *bcmd)
Definition: target.c:280
void GWB_Target_AddUsedTargetName(GWB_TARGET *target, const char *s)
Definition: target.c:203
struct GWEN_STRINGLISTSTRUCT GWEN_STRINGLIST
Definition: stringlist.h:56
void GWBUILD_Debug_PrintStringList(const char *sName, const GWEN_STRINGLIST *sl, int indent)
Definition: gwenbuild.c:460
int GWB_Target_GetSoVersionCurrent(const GWB_TARGET *target)
Definition: target.c:146
void GWBUILD_Debug_PrintFileList2(const char *sName, const GWB_FILE_LIST2 *fileList2, int indent)
Definition: gwenbuild.c:331
const char * GWBUILD_TargetType_toString(GWBUILD_TARGETTYPE tt)
Definition: gwenbuild.c:205
const char * GWB_Target_GetId(const GWB_TARGET *target)
Definition: target.c:89
GWB_BUILDER * GWB_Target_GetBuilder(const GWB_TARGET *target)
Definition: target.c:245
void GWB_File_List2_WriteXml(const GWB_FILE_LIST2 *fileList, GWEN_XMLNODE *xmlNode, const char *groupName)
Definition: file.c:646
struct GWB_BUILD_CMD GWB_BUILD_CMD
Definition: buildcmd.h:20
struct GWB_BUILDER GWB_BUILDER
Definition: builder.h:17
void GWB_Context_Dump(const GWB_CONTEXT *ctx, int indent)
Definition: context.c:598
void GWB_Target_AddUsedTargetLinkSpec(GWB_TARGET *target, const char *s)
Definition: target.c:235
void GWB_Target_AddUsedLibraryName(GWB_TARGET *target, const char *s)
Definition: target.c:219
void GWB_Target_free(GWB_TARGET *target)
Definition: target.c:45
GWBUILD_TARGETTYPE GWB_Target_GetTargetType(const GWB_TARGET *target)
Definition: target.c:108
GWB_CONTEXT * GWB_Target_GetContext(const GWB_TARGET *target)
Definition: target.c:167
int GWB_Target_GetSoVersionAge(const GWB_TARGET *target)
Definition: target.c:153
GWEN_STRINGLIST * GWEN_StringList_new(void)
Definition: stringlist.c:50
struct GWEN__XMLNODE GWEN_XMLNODE
Definition: xml.h:156
GWB_PROJECT * GWB_Target_GetProject(const GWB_TARGET *target)
Definition: target.c:63
void GWB_Target_toXml(const GWB_TARGET *target, GWEN_XMLNODE *xmlNode)
Definition: target.c:287
void GWEN_XMLNode_AddChild(GWEN_XMLNODE *n, GWEN_XMLNODE *child)
Definition: xml.c:423
GWB_FILE * GWB_Target_GetOutputFile(const GWB_TARGET *target)
Definition: target.c:259
void GWEN_XMLNode_SetIntValue(GWEN_XMLNODE *n, const char *name, int value)
Definition: xml.c:940
void GWB_Target_SetBuilder(GWB_TARGET *target, GWB_BUILDER *builder)
Definition: target.c:252