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