gwenhywfar 5.12.0
gwenbuild.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
15#include "gwenbuild/types/gwenbuild_p.h"
18
19#include <gwenhywfar/debug.h>
20#include <gwenhywfar/directory.h>
21#include <gwenhywfar/text.h>
22#include <gwenhywfar/stringlist.h>
23
24/* for stat */
25#include <sys/types.h>
26#include <sys/stat.h>
27#include <unistd.h>
28
29/* for strerror */
30#include <errno.h>
31#include <string.h>
32
33
34
35
36/* Changes these two functions for new target types or new source types */
37static GWB_BUILDER *_genBuilderForSourceFile(GWENBUILD *gwenbuild, GWB_CONTEXT *context, GWB_FILE *file);
39
40static GWB_BUILDER *_getBuilderByName(GWENBUILD *gwenbuild, GWB_CONTEXT *context, const char *builderName);
41
42static int _addOrBuildTargetSources(GWB_PROJECT *project, GWB_TARGET *target);
44 GWB_TARGET *target,
45 GWB_FILE_LIST2 *sourceFileList,
46 GWB_FILE_LIST2 *newOutputList);
47static int _addSubTargets(GWB_PROJECT *project);
48static int _addSubTargetsForTarget(GWB_PROJECT *project, GWB_TARGET *target, GWEN_STRINGLIST *usedTargetList);
49static int _addOneSubTargetForTarget(GWB_TARGET *target, GWB_TARGET *subTarget);
50
51static int _addBuildCommandsFromBuilder(GWB_PROJECT *project, GWB_BUILD_CONTEXT *buildCtx);
53static void _addBuildCommands(GWB_BUILD_CONTEXT *buildCtx, const GWB_BUILD_CMD_LIST *buildCmdList);
54static void _addFilesToBuildCtx(GWB_BUILD_CONTEXT *buildCtx, GWB_FILE_LIST2 *fileList);
55
56
57
58
59
61{
62 GWENBUILD *gwenbuild;
63
64 GWEN_NEW_OBJECT(GWENBUILD, gwenbuild);
65 gwenbuild->buildFilenameList=GWEN_StringList_new();
66
67 return gwenbuild;
68}
69
70
71
72void GWBUILD_free(GWENBUILD *gwenbuild)
73{
74 if (gwenbuild) {
75 GWEN_StringList_free(gwenbuild->buildFilenameList);
76 GWB_GBuilderDescr_List_free(gwenbuild->builderDescrList);
77
78 GWEN_FREE_OBJECT(gwenbuild);
79 }
80}
81
82
83
84uint32_t GWBUILD_GetFlags(const GWENBUILD *gwenbuild)
85{
86 return gwenbuild->flags;
87}
88
89
90
91void GWBUILD_SetFlags(GWENBUILD *gwenbuild, uint32_t f)
92{
93 gwenbuild->flags=f;
94}
95
96
97
98void GWBUILD_AddFlags(GWENBUILD *gwenbuild, uint32_t f)
99{
100 gwenbuild->flags|=f;
101}
102
103
104
105void GWBUILD_DelFlags(GWENBUILD *gwenbuild, uint32_t f)
106{
107 gwenbuild->flags&=~f;
108}
109
110
111
112const char *GWBUILD_GetTargetSystem(const GWENBUILD *gwenbuild)
113{
114 return gwenbuild->targetSystem;
115}
116
117
118
119void GWBUILD_SetTargetSystem(GWENBUILD *gwenbuild, const char *s)
120{
121 free(gwenbuild->targetSystem);
122 gwenbuild->targetSystem=s?strdup(s):NULL;
123}
124
125
127{
128 return gwenbuild->targetIsWindows;
129}
130
131
132
134{
135 gwenbuild->targetIsWindows=i;
136}
137
138
139
141{
142 return gwenbuild->buildFilenameList;
143}
144
145
146
147void GWBUILD_AddBuildFilename(GWENBUILD *gwenbuild, const char *s)
148{
149 GWEN_StringList_AppendString(gwenbuild->buildFilenameList, s, 0, 1);
150}
151
152
153
155{
156 const char *s;
157
158 s=getenv("PATH");
159 if (s && *s)
160 return GWEN_StringList_fromString2(s, ":;", 1,
165 return NULL;
166}
167
168
169
170
171
172
173
174
175
177{
178 /* TODO: Create from builder files */
179 if (s && *s) {
180 if (strcasecmp(s, "InstallLibrary")==0)
182 else if (strcasecmp(s, "ConvenienceLibrary")==0 ||
183 strcasecmp(s, "TempLibrary")==0)
185 else if (strcasecmp(s, "Program")==0)
187 else if (strcasecmp(s, "CxxProgram")==0)
189 else if (strcasecmp(s, "Objects")==0)
191 else if (strcasecmp(s, "Module")==0)
193 else if (strcasecmp(s, "I18nCatalog")==0)
195 else if (strcasecmp(s, "AvrHexFile")==0)
197 else {
198 DBG_ERROR(NULL, "Invalid target type \"%s\"", s);
199 }
200 }
201 else {
202 DBG_ERROR(NULL, "Empty target type");
203 }
204
206}
207
208
209
211{
212 switch(tt) {
213 case GWBUILD_TargetType_Invalid: return "invalid";
214 case GWBUILD_TargetType_None: return "none";
215 case GWBUILD_TargetType_InstallLibrary: return "InstallLibrary";
216 case GWBUILD_TargetType_ConvenienceLibrary: return "ConvenienceLibrary";
217 case GWBUILD_TargetType_Program: return "program";
218 case GWBUILD_TargetType_CxxProgram: return "CxxProgram";
219 case GWBUILD_TargetType_Objects: return "objects";
220 case GWBUILD_TargetType_Module: return "module";
221 case GWBUILD_TargetType_I18nCatalog: return "I18nCatalog";
222 case GWBUILD_TargetType_AvrHexFile: return "AvrHexFile";
223 }
224
225 return "invalid";
226}
227
228
229void GWBUILD_Debug_PrintValue(const char *sName, const char *sValue, int indent)
230{
231 int i;
232
233 for(i=0; i<indent; i++)
234 fprintf(stderr, " ");
235 fprintf(stderr, "%s = %s\n", sName, sValue?sValue:"<empty>");
236}
237
238
239
240void GWBUILD_Debug_PrintIntValue(const char *sName, int value, int indent)
241{
242 int i;
243
244 for(i=0; i<indent; i++)
245 fprintf(stderr, " ");
246 fprintf(stderr, "%s = %d\n", sName, value);
247}
248
249
250
251void GWBUILD_Debug_PrintKvpList(const char *sName, const GWB_KEYVALUEPAIR_LIST *kvpList, int indent)
252{
253 int i;
254
255 for(i=0; i<indent; i++)
256 fprintf(stderr, " ");
257 fprintf(stderr, "%s:\n", sName);
258
259 if (kvpList) {
260 const GWB_KEYVALUEPAIR *kvp;
261
262 kvp=GWB_KeyValuePair_List_First(kvpList);
263 while(kvp) {
264 const char *sKey;
265 const char *sValue;
266
267 sKey=GWB_KeyValuePair_GetKey(kvp);
268 sValue=GWB_KeyValuePair_GetValue(kvp);
269 GWBUILD_Debug_PrintValue(sKey, sValue, indent+2);
270 kvp=GWB_KeyValuePair_List_Next(kvp);
271 }
272 }
273}
274
275
276
277void GWBUILD_Debug_PrintDb(const char *sName, GWEN_DB_NODE *db, int indent)
278{
279 int i;
280
281 for(i=0; i<indent; i++)
282 fprintf(stderr, " ");
283 fprintf(stderr, "%s:\n", sName);
284
285 if (db)
286 GWEN_DB_Dump(db, indent+2);
287}
288
289
290
291void GWBUILD_Debug_PrintFile(const char *sName, const GWB_FILE *file, int indent)
292{
293 int i;
294
295 for(i=0; i<indent; i++)
296 fprintf(stderr, " ");
297
298 if (sName)
299 fprintf(stderr, "%s = ", sName);
300
301 if (file) {
302 uint32_t id;
303 const char *sFolder;
304 const char *sName;
305 const char *sInstallPath;
306 const char *sFileType;
307 uint32_t flags;
308
309 id=GWB_File_GetId(file);
310 sFolder=GWB_File_GetFolder(file);
311 sName=GWB_File_GetName(file);
312 flags=GWB_File_GetFlags(file);
313 sFileType=GWB_File_GetFileType(file);
314 sInstallPath=GWB_File_GetInstallPath(file);
315
316 fprintf(stderr, "[%5d] ", (int) id);
317 if (sFolder && *sFolder)
318 fprintf(stderr, "%s/", sFolder);
319 fprintf(stderr, "%s", sName?sName:"<no name>");
320 fprintf(stderr, " (%s)", sFileType?sFileType:"no type");
321
322 if (flags & GWB_FILE_FLAGS_DIST)
323 fprintf(stderr, " DIST");
324 if (flags & GWB_FILE_FLAGS_INSTALL)
325 fprintf(stderr, " INSTALL");
326 if (flags & GWB_FILE_FLAGS_GENERATED)
327 fprintf(stderr, " GENERATED");
328 fprintf(stderr, " %s", sInstallPath?sInstallPath:"<no install path>");
329 if (GWB_File_GetBuildCmd(file))
330 fprintf(stderr, " BUILDCMD");
331
332 fprintf(stderr, "\n");
333 }
334 else
335 fprintf(stderr, "<empty>\n");
336}
337
338
339
340void GWBUILD_Debug_PrintFileList2(const char *sName, const GWB_FILE_LIST2 *fileList2, int indent)
341{
342 int i;
343
344 for(i=0; i<indent; i++)
345 fprintf(stderr, " ");
346 fprintf(stderr, "%s:\n", sName);
347
348 if (fileList2) {
349 GWB_FILE_LIST2_ITERATOR *it;
350
351 it=GWB_File_List2_First(fileList2);
352 if (it) {
353 GWB_FILE *file;
354
355 file=GWB_File_List2Iterator_Data(it);
356 while(file) {
357 GWBUILD_Debug_PrintFile(NULL, file, indent+2);
358 file=GWB_File_List2Iterator_Next(it);
359 }
360 GWB_File_List2Iterator_free(it);
361 }
362 }
363}
364
365
366
367void GWBUILD_Debug_PrintTargetList2(const char *sName, const GWB_TARGET_LIST2 *targetList2, int indent, int fullDump)
368{
369 int i;
370
371 for(i=0; i<indent; i++)
372 fprintf(stderr, " ");
373 fprintf(stderr, "%s:\n", sName);
374
375 if (targetList2) {
376 GWB_TARGET_LIST2_ITERATOR *it;
377
378 it=GWB_Target_List2_First(targetList2);
379 if (it) {
380 GWB_TARGET *target;
381
382 target=GWB_Target_List2Iterator_Data(it);
383 while(target) {
384 GWB_Target_Dump(target, indent+2, fullDump);
385 target=GWB_Target_List2Iterator_Next(it);
386 }
387 GWB_Target_List2Iterator_free(it);
388 }
389 }
390}
391
392
393
394void GWBUILD_Debug_PrintOptionList(const char *sName, const GWB_OPTION_LIST *optionList, int indent)
395{
396 int i;
397
398 for(i=0; i<indent; i++)
399 fprintf(stderr, " ");
400 fprintf(stderr, "%s:\n", sName);
401
402 if (optionList) {
403 const GWB_OPTION *option;
404
405 option=GWB_Option_List_First(optionList);
406 while(option) {
407 GWB_Option_Dump(option, indent+2);
408 option=GWB_Option_List_Next(option);
409 }
410 }
411}
412
413
414
415void GWBUILD_Debug_PrintBuilderList2(const char *sName, const GWB_BUILDER_LIST2 *builderList2, int indent, int fullDump)
416{
417 int i;
418
419 for(i=0; i<indent; i++)
420 fprintf(stderr, " ");
421 fprintf(stderr, "%s:\n", sName);
422
423 if (builderList2) {
424 GWB_BUILDER_LIST2_ITERATOR *it;
425
426 it=GWB_Builder_List2_First(builderList2);
427 if (it) {
428 GWB_BUILDER *builder;
429
430 builder=GWB_Builder_List2Iterator_Data(it);
431 while(builder) {
432 GWB_Builder_Dump(builder, indent+2, fullDump);
433 builder=GWB_Builder_List2Iterator_Next(it);
434 }
435 GWB_Builder_List2Iterator_free(it);
436 }
437 }
438}
439
440
441
442void GWBUILD_Debug_PrintBuildCmdList2(const char *sName, const GWB_BUILD_CMD_LIST2 *buildCmdList2, int indent)
443{
444 int i;
445
446 for(i=0; i<indent; i++)
447 fprintf(stderr, " ");
448 fprintf(stderr, "%s:\n", sName);
449
450 if (buildCmdList2) {
451 GWB_BUILD_CMD_LIST2_ITERATOR *it;
452
453 it=GWB_BuildCmd_List2_First(buildCmdList2);
454 if (it) {
455 GWB_BUILD_CMD *builder;
456
457 builder=GWB_BuildCmd_List2Iterator_Data(it);
458 while(builder) {
459 GWB_BuildCmd_Dump(builder, indent+2);
460 builder=GWB_BuildCmd_List2Iterator_Next(it);
461 }
462 GWB_BuildCmd_List2Iterator_free(it);
463 }
464 }
465}
466
467
468
469void GWBUILD_Debug_PrintStringList(const char *sName, const GWEN_STRINGLIST *sl, int indent)
470{
471 if (sl) {
472 int i;
473 const GWEN_STRINGLISTENTRY *se;
474
475 for(i=0; i<indent; i++)
476 fprintf(stderr, " ");
477 fprintf(stderr, "%s:\n", sName);
478
480 while(se) {
481 const char *s;
482
484 for(i=0; i<indent+2; i++)
485 fprintf(stderr, " ");
486 fprintf(stderr, "[%s]\n", (s && *s)?s:"<empty>");
487
489 }
490 }
491}
492
493
494
496{
497 GWB_TARGET_LIST2 *targetList;
498
499 targetList=GWB_Project_GetTargetList(project);
500 if (targetList) {
501 GWB_TARGET_LIST2_ITERATOR *it;
502 int rv;
503
504 it=GWB_Target_List2_First(targetList);
505 if (it) {
506 GWB_TARGET *target;
507
508 target=GWB_Target_List2Iterator_Data(it);
509 while(target) {
510 GWB_BUILDER *builder;
511
512 builder=_genBuilderForTarget(project, target);
513 if (builder==NULL) {
514 DBG_INFO(NULL, "here)");
515 GWB_Target_List2Iterator_free(it);
516 return GWEN_ERROR_GENERIC;
517 }
518 GWB_Target_SetBuilder(target, builder);
519 GWB_Project_AddBuilder(project, builder);
520
521 rv=_addOrBuildTargetSources(project, target);
522 if (rv<0) {
523 DBG_INFO(NULL, "here (%d)", rv);
524 return rv;
525 }
526
527 target=GWB_Target_List2Iterator_Next(it);
528 }
529 GWB_Target_List2Iterator_free(it);
530 }
531
532 rv=_addSubTargets(project);
533 if (rv<0) {
534 DBG_INFO(NULL, "here (%d)", rv);
535 return rv;
536 }
537 }
538 return 0;
539}
540
541
542
544{
545 GWB_FILE_LIST2 *fileList1;
546 GWB_CONTEXT *context;
547
548 context=GWB_Target_GetContext(target);
549 fileList1=GWB_Context_GetSourceFileList2(context);
550 if (!(fileList1 && GWB_File_List2_GetSize(fileList1)>0)) {
551 DBG_ERROR(NULL, "Empty source file list in context of target \"%s\"", GWB_Target_GetId(target));
552 GWB_Target_Dump(target, 2, 1);
553 return GWEN_ERROR_GENERIC;
554 }
555
556 fileList1=GWB_File_List2_dup(fileList1);
557 while(GWB_File_List2_GetSize(fileList1)>0) {
558 GWB_FILE_LIST2 *fileList2;
559 int rv;
560
561 fileList2=GWB_File_List2_new();
562 rv=_addSourcesOrMkBuildersAndGetTheirOutputs(project, target, fileList1, fileList2);
563 if (rv<0) {
564 DBG_INFO(NULL, "here (%d)", rv);
565 GWB_File_List2_free(fileList1);
566 GWB_File_List2_free(fileList1);
567 return rv;
568 }
569 GWB_File_List2_free(fileList1);
570 fileList1=fileList2;
571 }
572 GWB_File_List2_free(fileList1);
573 return 0;
574}
575
576
577
579 GWB_TARGET *target,
580 GWB_FILE_LIST2 *sourceFileList,
581 GWB_FILE_LIST2 *newOutputList)
582{
583 GWENBUILD *gwenbuild;
584 GWB_BUILDER *targetBuilder;
585 GWB_FILE_LIST2_ITERATOR *it;
586 GWB_CONTEXT *context;
587
588 gwenbuild=GWB_Project_GetGwbuild(project);
589 context=GWB_Target_GetContext(target);
590 targetBuilder=GWB_Target_GetBuilder(target);
591
592 it=GWB_File_List2_First(sourceFileList);
593 if (it) {
594 GWB_FILE *file;
595
596 file=GWB_File_List2Iterator_Data(it);
597 while(file) {
598 DBG_DEBUG(NULL, "Checking target \"%s\": file \"%s\"",
599 GWB_Target_GetId(target),
600 GWB_File_GetName(file));
601 if (GWB_Builder_IsAcceptableInput(targetBuilder, file)) {
602 DBG_DEBUG(NULL, "- adding file \"%s\" as input for target \"%s\"",
603 GWB_File_GetName(file),
604 GWB_Target_GetId(target));
605 GWB_Builder_AddSourceFile(targetBuilder, file);
606 }
607 else {
608 GWB_BUILDER *sourceBuilder;
609
610 sourceBuilder=_genBuilderForSourceFile(gwenbuild, context, file);
611 if (sourceBuilder) {
612 GWB_FILE_LIST2 *buildersOutputFileList;
613
614 buildersOutputFileList=GWB_Builder_GetOutputFileList2(sourceBuilder);
615 GWB_Project_AddBuilder(project, sourceBuilder);
616 GWB_File_AddFileList2ToFileList2(buildersOutputFileList, newOutputList, ".c");
617 GWB_File_AddFileList2ToFileList2(buildersOutputFileList, newOutputList, ".cpp");
618 GWB_File_AddFileList2ToFileList2(buildersOutputFileList, newOutputList, ".o");
619 }
620 }
621 file=GWB_File_List2Iterator_Next(it);
622 }
623
624 GWB_File_List2Iterator_free(it);
625 }
626
627 return 0;
628}
629
630
631
633{
634 GWB_TARGET_LIST2 *targetList;
635
636 targetList=GWB_Project_GetTargetList(project);
637 if (targetList) {
638 GWB_TARGET_LIST2_ITERATOR *it;
639
640 it=GWB_Target_List2_First(targetList);
641 if (it) {
642 GWB_TARGET *target;
643
644 target=GWB_Target_List2Iterator_Data(it);
645 while(target) {
646 GWEN_STRINGLIST *usedTargetList;
647
648 usedTargetList=GWB_Target_GetUsedTargetNameList(target);
649 if (usedTargetList && GWEN_StringList_Count(usedTargetList)>0) {
650 int rv;
651
652 rv=_addSubTargetsForTarget(project, target, usedTargetList);
653 if (rv<0) {
654 DBG_INFO(NULL, "here (%d)", rv);
655 GWB_Target_List2Iterator_free(it);
656 return rv;
657 }
658 }
659
660 target=GWB_Target_List2Iterator_Next(it);
661 }
662 GWB_Target_List2Iterator_free(it);
663 }
664 }
665 return 0;
666}
667
668
669
670int _addSubTargetsForTarget(GWB_PROJECT *project, GWB_TARGET *target, GWEN_STRINGLIST *usedTargetList)
671{
673
674 se=GWEN_StringList_FirstEntry(usedTargetList);
675 while(se) {
676 const char *s;
677
679 if (s && *s) {
680 GWB_TARGET *subTarget;
681
682 subTarget=GWB_Project_GetTargetById(project, s);
683 if (subTarget) {
684 int rv;
685
686 rv=_addOneSubTargetForTarget(target, subTarget);
687 if (rv<0) {
688 DBG_INFO(NULL, "here (%d)", rv);
689 return rv;
690 }
691 }
692 }
694 }
695
696 return 0;
697}
698
699
700
702{
703 GWB_CONTEXT *context;
704 GWB_BUILDER *targetBuilder;
705 GWB_BUILDER *subTargetBuilder;
706 GWB_FILE_LIST2 *subTargetOutputFileList;
707 GWB_FILE *subTargetFile;
708 const char *s;
709
710 context=GWB_Target_GetContext(target);
711
712 targetBuilder=GWB_Target_GetBuilder(target);
713 if (targetBuilder==NULL) {
714 DBG_ERROR(NULL, "No builder for target \"%s\"", GWB_Target_GetId(target));
715 return GWEN_ERROR_GENERIC;
716 }
717 subTargetBuilder=GWB_Target_GetBuilder(subTarget);
718 if (subTargetBuilder==NULL) {
719 DBG_ERROR(NULL, "No builder for sub-target \"%s\"", GWB_Target_GetId(subTarget));
720 return GWEN_ERROR_GENERIC;
721 }
722
723 subTargetOutputFileList=GWB_Builder_GetOutputFileList2(subTargetBuilder);
724 if (subTargetOutputFileList==NULL) {
725 DBG_ERROR(NULL, "No output file list in target \"%s\"", GWB_Target_GetId(subTarget));
726 return GWEN_ERROR_GENERIC;
727 }
728 subTargetFile=GWB_File_List2_GetFront(subTargetOutputFileList);
729 if (subTargetFile==NULL) {
730 DBG_ERROR(NULL, "No output file in target \"%s\"", GWB_Target_GetId(subTarget));
731 return GWEN_ERROR_GENERIC;
732 }
733 GWB_Builder_AddInputFile(targetBuilder, subTargetFile);
734
735 s=GWB_Builder_GetTargetLinkSpec(subTargetBuilder);
736 if (s && *s) {
737 const char *folder;
738 GWEN_BUFFER *linkSpecBuffer;
739
740 /* determine path */
741 folder=GWB_File_GetFolder(subTargetFile);
742
743 linkSpecBuffer=GWEN_Buffer_new(0, 256, 0, 1);
744 GWEN_Buffer_AppendString(linkSpecBuffer, "-L");
745 GWB_Builder_AddRelativeFolderToBuffer(context, folder, 1, linkSpecBuffer); /* useBuildDir=1 */
746 GWEN_Buffer_AppendString(linkSpecBuffer, " ");
747 GWEN_Buffer_AppendString(linkSpecBuffer, s);
749 GWEN_Buffer_free(linkSpecBuffer);
750 }
751 return 0;
752}
753
754
755
757{
758 int rv;
759 GWB_BUILD_CONTEXT *buildCtx;
760 GWB_CONTEXT *rootContext;
761
762 rootContext=GWB_Project_GetRootContext(project);
763 buildCtx=GWB_BuildCtx_new();
765
766 rv=_addBuildCommandsFromBuilder(project, buildCtx);
767 if (rv<0) {
768 DBG_INFO(NULL, "here (%d)", rv);
769 GWB_BuildCtx_free(buildCtx);
770 return NULL;
771 }
772 _addExplicitBuildCommandsFromTargets(project, buildCtx);
773
774 return buildCtx;
775}
776
777
778
780{
781 GWB_BUILDER_LIST2 *builderList;
782
783 builderList=GWB_Project_GetBuilderList(project);
784 if (builderList) {
785 GWB_BUILDER_LIST2_ITERATOR *it;
786
787 it=GWB_Builder_List2_First(builderList);
788 if (it) {
789 GWB_BUILDER *builder;
790
791 builder=GWB_Builder_List2Iterator_Data(it);
792 while(builder) {
793 int rv;
794
795 rv=GWB_Builder_AddBuildCmd(builder, buildCtx);
796 if (rv<0) {
797 DBG_INFO(NULL, "here (%d)", rv);
798 GWB_Builder_List2Iterator_free(it);
799 return rv;
800 }
801 builder=GWB_Builder_List2Iterator_Next(it);
802 }
803
804 GWB_Builder_List2Iterator_free(it);
805 return 0;
806 }
807 }
808
809 DBG_ERROR(NULL, "No targets in 0BUILD files");
810 return GWEN_ERROR_NO_DATA;
811}
812
813
814
816{
817 GWB_TARGET_LIST2 *targetList;
818 GWB_BUILD_CMD_LIST *explicitBuildCmdList;
819
820 /* add explicit build commands from project */
821 explicitBuildCmdList=GWB_Project_GetExplicitBuildList(project);
822 if (explicitBuildCmdList)
823 _addBuildCommands(buildCtx, explicitBuildCmdList);
824
825 /* add explicit build commands from targets */
826 targetList=GWB_Project_GetTargetList(project);
827 if (targetList) {
828 GWB_TARGET_LIST2_ITERATOR *it;
829
830 it=GWB_Target_List2_First(targetList);
831 if (it) {
832 GWB_TARGET *target;
833
834 target=GWB_Target_List2Iterator_Data(it);
835 while(target) {
836 explicitBuildCmdList=GWB_Target_GetExplicitBuildList(target);
837 if (explicitBuildCmdList)
838 _addBuildCommands(buildCtx, explicitBuildCmdList);
839 target=GWB_Target_List2Iterator_Next(it);
840 }
841 GWB_Target_List2Iterator_free(it);
842 }
843 }
844}
845
846
847
848void _addBuildCommands(GWB_BUILD_CONTEXT *buildCtx, const GWB_BUILD_CMD_LIST *buildCmdList)
849{
850 if (buildCmdList) {
851 GWB_BUILD_CMD *cmd;
852
853 cmd=GWB_BuildCmd_List_First(buildCmdList);
854 while(cmd) {
855 _addFilesToBuildCtx(buildCtx, GWB_BuildCmd_GetInFileList2(cmd)); /* assigns ids etc */
858 cmd=GWB_BuildCmd_List_Next(cmd);
859 }
860 }
861}
862
863
864
865void _addFilesToBuildCtx(GWB_BUILD_CONTEXT *buildCtx, GWB_FILE_LIST2 *fileList)
866{
867 if (fileList) {
868 GWB_FILE_LIST2_ITERATOR *it;
869
870 it=GWB_File_List2_First(fileList);
871 if (it) {
872 GWB_FILE *file;
873
874 file=GWB_File_List2Iterator_Data(it);
875 while(file) {
876 GWB_FILE *copyOfFile;
877
878 copyOfFile=GWB_File_dup(file);
879 GWB_BuildCtx_AddFile(buildCtx, copyOfFile);
880 GWB_File_SetId(file, GWB_File_GetId(copyOfFile));
881 file=GWB_File_List2Iterator_Next(it);
882 }
883
884 GWB_File_List2Iterator_free(it);
885 }
886 }
887}
888
889
890
891time_t GWBUILD_GetModificationTimeOfFile(const char *filename)
892{
893 struct stat st;
894 int rv;
895
896#if _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
897 rv=lstat(filename, &st);
898#else
899 rv=stat(filename, &st);
900#endif
901 if (rv == -1) {
902 DBG_INFO(NULL, "Error on stat(%s): %s", filename, strerror(errno));
903 return (time_t) 0;
904 }
905
906 return st.st_mtime;
907}
908
909
910/* code from https://stackoverflow.com/questions/152016/detecting-cpu-architecture-compile-time
911 */
912const char *GWBUILD_GetHostArch() { //Get current architecture, detectx nearly every architecture. Coded by Freak
913#if defined(__x86_64__) || defined(_M_X64)
914 return "x86_64";
915#elif defined(i386) || defined(__i386__) || defined(__i386) || defined(_M_IX86)
916 return "x86_32";
917#elif defined(__ARM_ARCH_2__)
918 return "ARM2";
919#elif defined(__ARM_ARCH_3__) || defined(__ARM_ARCH_3M__)
920 return "ARM3";
921#elif defined(__ARM_ARCH_4T__) || defined(__TARGET_ARM_4T)
922 return "ARM4T";
923#elif defined(__ARM_ARCH_5_) || defined(__ARM_ARCH_5E_)
924 return "ARM5"
925#elif defined(__ARM_ARCH_6T2_) || defined(__ARM_ARCH_6T2_)
926 return "ARM6T2";
927#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__)
928 return "ARM6";
929#elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
930 return "ARM7";
931#elif defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
932 return "ARM7A";
933#elif defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
934 return "ARM7R";
935#elif defined(__ARM_ARCH_7M__)
936 return "ARM7M";
937#elif defined(__ARM_ARCH_7S__)
938 return "ARM7S";
939#elif defined(__aarch64__) || defined(_M_ARM64)
940 return "ARM64";
941#elif defined(mips) || defined(__mips__) || defined(__mips)
942 return "MIPS";
943#elif defined(__sh__)
944 return "SUPERH";
945#elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) || defined(__POWERPC__) || defined(__ppc__) || defined(__PPC__) || defined(_ARCH_PPC)
946 return "POWERPC";
947#elif defined(__PPC64__) || defined(__ppc64__) || defined(_ARCH_PPC64)
948 return "POWERPC64";
949#elif defined(__sparc__) || defined(__sparc)
950 return "SPARC";
951#elif defined(__m68k__)
952 return "M68K";
953#else
954 return "UNKNOWN";
955#endif
956}
957
958
959
961#if defined(__linux__)
962 return "linux";
963#elif defined(__sun)
964 return "solaris";
965#elif defined(__FreeBSD__)
966 return "freebsd";
967#elif defined(__NetBSD__)
968 return "netbsd";
969#elif defined(__OpenBSD__)
970 return "openbsd";
971#elif defined(__APPLE__)
972 return "osx";
973#elif defined(__hpux)
974 return "hpux";
975
976#elif defined(__osf__)
977 return "tru64";
978#elif defined(__sgi)
979 return "irix";
980#elif defined(_AIX)
981 return "aix";
982#elif defined(_WIN32)
983 return "windows";
984#else
985 return "unknown";
986#endif
987}
988
989
990
991const char *GWBUILD_GetArchFromTriplet(const char *sTriplet)
992{
993 if (-1!=GWEN_Text_ComparePattern(sTriplet, "*x86_64*", 0))
994 return "x86_64";
995 else if (-1!=GWEN_Text_ComparePattern(sTriplet, "*i?86*", 0))
996 return "x86_32";
997 else
998 return "unknown";
999}
1000
1001
1002
1003const char *GWBUILD_GetSystemFromTriplet(const char *sTriplet)
1004{
1005 if (-1!=GWEN_Text_ComparePattern(sTriplet, "*mingw*", 0))
1006 return "windows";
1007 else if (-1!=GWEN_Text_ComparePattern(sTriplet, "*linux*", 0))
1008 return "linux";
1009 else
1010 return "unknown";
1011}
1012
1013
1014
1015void GWBUILD_AddFilesFromStringList(GWB_FILE_LIST2 *mainFileList,
1016 const char *sFolder,
1017 const GWEN_STRINGLIST *fileNameList,
1018 GWB_FILE_LIST2 *outFileList,
1019 uint32_t flagsToAdd,
1020 int copyFileForOutList)
1021{
1022 if (fileNameList) {
1024
1025 se=GWEN_StringList_FirstEntry(fileNameList);
1026 while(se) {
1027 const char *s;
1028
1030 if (s && *s) {
1031 GWB_FILE *file;
1032
1033 file=GWB_File_List2_GetOrCreateFile(mainFileList, sFolder, s);
1034 GWB_File_AddFlags(file, flagsToAdd);
1035 if (outFileList) {
1036 if (copyFileForOutList)
1037 GWB_File_List2_PushBack(outFileList, GWB_File_dup(file));
1038 else
1039 GWB_File_List2_PushBack(outFileList, file);
1040 }
1041 }
1042
1044 }
1045 }
1046}
1047
1048
1049
1051{
1052 GWEN_BUFFER *nameBuf;
1053
1054 nameBuf=GWEN_Buffer_new(0, 256, 0, 1);
1055 GWEN_Buffer_AppendString(nameBuf, BUILDERDATADIR GWEN_DIR_SEPARATOR_S);
1056 if (GWBUILD_GetTargetIsWindows(gwenbuild))
1057 GWEN_Buffer_AppendString(nameBuf, "windows");
1058 else
1059 GWEN_Buffer_AppendString(nameBuf, "posix");
1060
1061 gwenbuild->builderDescrList=GWB_GBuilderDescr_ReadAll(GWEN_Buffer_GetStart(nameBuf));
1062 GWEN_Buffer_free(nameBuf);
1063}
1064
1065
1066
1067GWB_BUILDER *_getBuilderByName(GWENBUILD *gwenbuild, GWB_CONTEXT *context, const char *builderName)
1068{
1069 GWB_GBUILDER_DESCR *descr;
1070 GWEN_XMLNODE *xmlDescr;
1071 GWB_BUILDER *builder;
1072
1073 if (gwenbuild->builderDescrList==NULL)
1074 _readBuilderDescrList(gwenbuild);
1075
1076 descr=GWB_GBuilderDescr_List_GetByName(gwenbuild->builderDescrList, builderName);
1077 if (descr==NULL) {
1078 DBG_ERROR(NULL, "Builder \"%s\" not found", builderName);
1079 return NULL;
1080 }
1081
1083 builder=GWB_GenericBuilder_new(gwenbuild, context, xmlDescr);
1084 if (builder==NULL) {
1085 DBG_ERROR(NULL, "Error instantiating builder \"%s\"", builderName);
1086 return NULL;
1087 }
1088
1089 return builder;
1090}
1091
1092
1093
1094/*
1095 * --------------------------------------------------------------------------------------------
1096 * Add new targets or known source types below.
1097 * --------------------------------------------------------------------------------------------
1098 */
1099
1100
1102{
1103 const char *builderName;
1104 const char *name;
1105 const char *ext;
1106 GWB_BUILDER *builder;
1107
1108 name=GWB_File_GetName(file);
1109 if (!(name && *name)) {
1110 DBG_ERROR(NULL, "No file name.");
1111 return NULL;
1112 }
1113 ext=GWB_File_GetExt(file);
1114 if (ext==NULL) {
1115 DBG_DEBUG(NULL, "Unable to determine builder for source file \"%s\"", name);
1116 return NULL;
1117 }
1118
1119 builderName=GWB_File_GetBuilder(file);
1120 if (!(builderName && *builderName)) {
1121 DBG_INFO(NULL, "Determining builder type for file \%s\"", name);
1122 if (strcasecmp(ext, ".c")==0)
1123 builderName="cbuilder";
1124 else if (strcasecmp(ext, ".cpp")==0)
1125 builderName="cxxbuilder";
1126 else if (strcasecmp(ext, ".t2d")==0 || strcasecmp(ext, ".xml")==0)
1127 builderName="tm2builder";
1128 /* add more here */
1129 else {
1130 DBG_DEBUG(NULL, "Unable to determine builder for source file \"%s\" (unhandled ext)", name);
1131 return NULL;
1132 }
1133 GWB_File_SetBuilder(file, builderName);
1134 }
1135
1136 DBG_INFO(NULL, "Selected builder type is for file \%s\" is \"%s\"", name, builderName);
1137 builder=_getBuilderByName(gwenbuild, context, builderName);
1138 if (builder==NULL) {
1139 DBG_ERROR(NULL, "Could not create builder for type \"%s\"", ext);
1140 return NULL;
1141 }
1142
1143 GWB_Builder_AddSourceFile(builder, file);
1144
1145 return builder;
1146}
1147
1148
1149
1151{
1152 GWB_BUILDER *builder=NULL;
1153 GWENBUILD *gwenbuild;
1154
1155 gwenbuild=GWB_Project_GetGwbuild(project);
1156
1157 switch(GWB_Target_GetTargetType(target)) {
1160 break;
1163 builder=_getBuilderByName(gwenbuild, GWB_Target_GetContext(target), "staticlib");
1164 else
1165 builder=_getBuilderByName(gwenbuild, GWB_Target_GetContext(target), "sharedlib");
1166 break;
1168 //builder=GWEN_TmpLibBuilder_new(gwenbuild, GWB_Target_GetContext(target));
1169 builder=_getBuilderByName(gwenbuild, GWB_Target_GetContext(target), "tmplib");
1170 break;
1172 builder=_getBuilderByName(gwenbuild, GWB_Target_GetContext(target), "app");
1173 break;
1175 builder=_getBuilderByName(gwenbuild, GWB_Target_GetContext(target), "cxxapp");
1176 break;
1178 break;
1180 builder=_getBuilderByName(gwenbuild, GWB_Target_GetContext(target), "module");
1181 break;
1183 builder=_getBuilderByName(gwenbuild, GWB_Target_GetContext(target), "msgfmt");
1184 break;
1186 builder=_getBuilderByName(gwenbuild, GWB_Target_GetContext(target), "avrhexfile");
1187 break;
1188
1189 }
1190 if (builder==NULL) {
1192 "Could not create builder for type \"%s\"",
1194 return NULL;
1195 }
1196
1197 return builder;
1198}
1199
1200
1201
1202
#define NULL
Definition binreloc.c:300
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
Definition buffer.c:42
void GWEN_Buffer_free(GWEN_BUFFER *bf)
Definition buffer.c:89
int GWEN_Buffer_AppendString(GWEN_BUFFER *bf, const char *buffer)
Definition buffer.c:992
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
Definition buffer.c:235
GWB_BUILD_CMD * GWB_BuildCmd_dup(GWB_BUILD_CMD *origCmd)
Definition buildcmd.c:60
GWB_FILE_LIST2 * GWB_BuildCmd_GetOutFileList2(const GWB_BUILD_CMD *bcmd)
Definition buildcmd.c:270
void GWB_BuildCmd_Dump(const GWB_BUILD_CMD *bcmd, int indent)
Definition buildcmd.c:571
GWB_FILE_LIST2 * GWB_BuildCmd_GetInFileList2(const GWB_BUILD_CMD *bcmd)
Definition buildcmd.c:255
struct GWB_BUILD_CMD GWB_BUILD_CMD
Definition buildcmd.h:20
void GWB_BuildCtx_free(GWB_BUILD_CONTEXT *bctx)
Definition buildctx.c:47
void GWB_BuildCtx_SetInitialSourceDir(GWB_BUILD_CONTEXT *bctx, const char *s)
Definition buildctx.c:87
void GWB_BuildCtx_AddCommand(GWB_BUILD_CONTEXT *bctx, GWB_BUILD_CMD *cmd)
Definition buildctx.c:102
void GWB_BuildCtx_AddFile(GWB_BUILD_CONTEXT *bctx, GWB_FILE *file)
Definition buildctx.c:116
GWB_BUILD_CONTEXT * GWB_BuildCtx_new()
Definition buildctx.c:34
struct GWB_BUILD_CONTEXT GWB_BUILD_CONTEXT
Definition buildctx.h:16
int GWB_Builder_AddBuildCmd(GWB_BUILDER *builder, GWB_BUILD_CONTEXT *bctx)
Definition builder.c:166
GWB_FILE_LIST2 * GWB_Builder_GetOutputFileList2(const GWB_BUILDER *builder)
Definition builder.c:116
int GWB_Builder_IsAcceptableInput(GWB_BUILDER *builder, const GWB_FILE *file)
Definition builder.c:156
void GWB_Builder_AddInputFile(GWB_BUILDER *builder, GWB_FILE *f)
Definition builder.c:107
void GWB_Builder_AddSourceFile(GWB_BUILDER *builder, GWB_FILE *f)
Definition builder.c:176
void GWB_Builder_Dump(const GWB_BUILDER *builder, int indent, int fullDump)
Definition builder.c:346
const char * GWB_Builder_GetTargetLinkSpec(const GWB_BUILDER *builder)
Definition builder.c:78
void GWB_Builder_AddRelativeFolderToBuffer(const GWB_CONTEXT *context, const char *folder, int useBuildDir, GWEN_BUFFER *argBuffer)
Definition builder.c:276
struct GWB_BUILDER GWB_BUILDER
Definition builder.h:17
GWB_FILE_LIST2 * GWB_Context_GetSourceFileList2(const GWB_CONTEXT *ctx)
Definition context.c:434
const char * GWB_Context_GetInitialSourceDir(const GWB_CONTEXT *ctx)
Definition context.c:285
struct GWB_CONTEXT GWB_CONTEXT
Definition context.h:17
void GWEN_DB_Dump(GWEN_DB_NODE *n, int insert)
Definition db.c:1420
struct GWEN_DB_NODE GWEN_DB_NODE
Definition db.h:228
#define DBG_INFO(dbg_logger, format,...)
Definition debug.h:181
#define DBG_ERROR(dbg_logger, format,...)
Definition debug.h:97
#define DBG_DEBUG(dbg_logger, format,...)
Definition debug.h:214
#define GWEN_ERROR_GENERIC
Definition error.h:62
#define GWEN_ERROR_NO_DATA
Definition error.h:94
void GWB_File_SetId(GWB_FILE *f, uint32_t i)
Definition file.c:92
void GWB_File_AddFileList2ToFileList2(GWB_FILE_LIST2 *sourceList, GWB_FILE_LIST2 *destList, const char *ext)
Definition file.c:446
const char * GWB_File_GetFolder(const GWB_FILE *f)
Definition file.c:127
const char * GWB_File_GetName(const GWB_FILE *f)
Definition file.c:146
void GWB_File_SetBuilder(GWB_FILE *f, const char *s)
Definition file.c:200
GWB_FILE * GWB_File_List2_GetOrCreateFile(GWB_FILE_LIST2 *fileList, const char *folder, const char *fname)
Definition file.c:386
uint32_t GWB_File_GetFlags(const GWB_FILE *f)
Definition file.c:99
const char * GWB_File_GetInstallPath(const GWB_FILE *f)
Definition file.c:208
GWB_FILE * GWB_File_dup(const GWB_FILE *oldFile)
Definition file.c:50
uint32_t GWB_File_GetId(const GWB_FILE *f)
Definition file.c:85
const char * GWB_File_GetBuilder(const GWB_FILE *f)
Definition file.c:193
GWB_BUILD_CMD * GWB_File_GetBuildCmd(const GWB_FILE *f)
Definition file.c:270
const char * GWB_File_GetFileType(const GWB_FILE *f)
Definition file.c:227
void GWB_File_AddFlags(GWB_FILE *f, uint32_t i)
Definition file.c:113
const char * GWB_File_GetExt(const GWB_FILE *f)
Definition file.c:184
struct GWB_FILE GWB_FILE
Definition file.h:18
#define GWB_FILE_FLAGS_GENERATED
Definition file.h:23
#define GWB_FILE_FLAGS_DIST
Definition file.h:21
#define GWB_FILE_FLAGS_INSTALL
Definition file.h:22
GWB_GBUILDER_DESCR * GWB_GBuilderDescr_List_GetByName(const GWB_GBUILDER_DESCR_LIST *descrList, const char *name)
GWB_GBUILDER_DESCR_LIST * GWB_GBuilderDescr_ReadAll(const char *folder)
GWEN_XMLNODE * GWB_GBuilderDescr_GetXmlDescr(const GWB_GBUILDER_DESCR *descr)
struct GWB_GBUILDER_DESCR GWB_GBUILDER_DESCR
GWB_BUILDER * GWB_GenericBuilder_new(GWENBUILD *gwenbuild, GWB_CONTEXT *context, GWEN_XMLNODE *xmlDescr)
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
Definition buffer.h:38
static void _addBuildCommands(GWB_BUILD_CONTEXT *buildCtx, const GWB_BUILD_CMD_LIST *buildCmdList)
Definition gwenbuild.c:848
const char * GWBUILD_GetHostSystem()
Definition gwenbuild.c:960
void GWBUILD_Debug_PrintKvpList(const char *sName, const GWB_KEYVALUEPAIR_LIST *kvpList, int indent)
Definition gwenbuild.c:251
uint32_t GWBUILD_GetFlags(const GWENBUILD *gwenbuild)
Definition gwenbuild.c:84
void GWBUILD_Debug_PrintStringList(const char *sName, const GWEN_STRINGLIST *sl, int indent)
Definition gwenbuild.c:469
static int _addSubTargets(GWB_PROJECT *project)
Definition gwenbuild.c:632
static void _addExplicitBuildCommandsFromTargets(GWB_PROJECT *project, GWB_BUILD_CONTEXT *buildCtx)
Definition gwenbuild.c:815
int GWBUILD_GetTargetIsWindows(const GWENBUILD *gwenbuild)
Definition gwenbuild.c:126
int GWBUILD_MakeBuildersForTargets(GWB_PROJECT *project)
Definition gwenbuild.c:495
GWEN_STRINGLIST * GWBUILD_GetBuildFilenameList(const GWENBUILD *gwenbuild)
Definition gwenbuild.c:140
void GWBUILD_Debug_PrintIntValue(const char *sName, int value, int indent)
Definition gwenbuild.c:240
GWEN_STRINGLIST * GWBUILD_GetPathFromEnvironment()
Definition gwenbuild.c:154
void GWBUILD_AddFilesFromStringList(GWB_FILE_LIST2 *mainFileList, const char *sFolder, const GWEN_STRINGLIST *fileNameList, GWB_FILE_LIST2 *outFileList, uint32_t flagsToAdd, int copyFileForOutList)
Definition gwenbuild.c:1015
static int _addBuildCommandsFromBuilder(GWB_PROJECT *project, GWB_BUILD_CONTEXT *buildCtx)
Definition gwenbuild.c:779
void _readBuilderDescrList(GWENBUILD *gwenbuild)
Definition gwenbuild.c:1050
const char * GWBUILD_TargetType_toString(GWBUILD_TARGETTYPE tt)
Definition gwenbuild.c:210
static GWB_BUILDER * _genBuilderForTarget(GWB_PROJECT *project, GWB_TARGET *target)
Definition gwenbuild.c:1150
static int _addOrBuildTargetSources(GWB_PROJECT *project, GWB_TARGET *target)
Definition gwenbuild.c:543
void GWBUILD_Debug_PrintOptionList(const char *sName, const GWB_OPTION_LIST *optionList, int indent)
Definition gwenbuild.c:394
void GWBUILD_Debug_PrintFile(const char *sName, const GWB_FILE *file, int indent)
Definition gwenbuild.c:291
void GWBUILD_Debug_PrintBuildCmdList2(const char *sName, const GWB_BUILD_CMD_LIST2 *buildCmdList2, int indent)
Definition gwenbuild.c:442
const char * GWBUILD_GetSystemFromTriplet(const char *sTriplet)
Definition gwenbuild.c:1003
void GWBUILD_Debug_PrintFileList2(const char *sName, const GWB_FILE_LIST2 *fileList2, int indent)
Definition gwenbuild.c:340
static void _addFilesToBuildCtx(GWB_BUILD_CONTEXT *buildCtx, GWB_FILE_LIST2 *fileList)
Definition gwenbuild.c:865
static GWB_BUILDER * _getBuilderByName(GWENBUILD *gwenbuild, GWB_CONTEXT *context, const char *builderName)
Definition gwenbuild.c:1067
GWB_BUILD_CONTEXT * GWBUILD_MakeBuildCommands(GWB_PROJECT *project)
Definition gwenbuild.c:756
GWENBUILD * GWBUILD_new(void)
Definition gwenbuild.c:60
time_t GWBUILD_GetModificationTimeOfFile(const char *filename)
Definition gwenbuild.c:891
static GWB_BUILDER * _genBuilderForSourceFile(GWENBUILD *gwenbuild, GWB_CONTEXT *context, GWB_FILE *file)
Definition gwenbuild.c:1101
GWBUILD_TARGETTYPE GWBUILD_TargetType_fromString(const char *s)
Definition gwenbuild.c:176
void GWBUILD_Debug_PrintBuilderList2(const char *sName, const GWB_BUILDER_LIST2 *builderList2, int indent, int fullDump)
Definition gwenbuild.c:415
void GWBUILD_SetTargetIsWindows(GWENBUILD *gwenbuild, int i)
Definition gwenbuild.c:133
void GWBUILD_Debug_PrintDb(const char *sName, GWEN_DB_NODE *db, int indent)
Definition gwenbuild.c:277
const char * GWBUILD_GetArchFromTriplet(const char *sTriplet)
Definition gwenbuild.c:991
void GWBUILD_SetTargetSystem(GWENBUILD *gwenbuild, const char *s)
Definition gwenbuild.c:119
const char * GWBUILD_GetTargetSystem(const GWENBUILD *gwenbuild)
Definition gwenbuild.c:112
void GWBUILD_Debug_PrintTargetList2(const char *sName, const GWB_TARGET_LIST2 *targetList2, int indent, int fullDump)
Definition gwenbuild.c:367
void GWBUILD_AddBuildFilename(GWENBUILD *gwenbuild, const char *s)
Definition gwenbuild.c:147
void GWBUILD_SetFlags(GWENBUILD *gwenbuild, uint32_t f)
Definition gwenbuild.c:91
static int _addOneSubTargetForTarget(GWB_TARGET *target, GWB_TARGET *subTarget)
Definition gwenbuild.c:701
const char * GWBUILD_GetHostArch()
Definition gwenbuild.c:912
static int _addSubTargetsForTarget(GWB_PROJECT *project, GWB_TARGET *target, GWEN_STRINGLIST *usedTargetList)
Definition gwenbuild.c:670
void GWBUILD_DelFlags(GWENBUILD *gwenbuild, uint32_t f)
Definition gwenbuild.c:105
void GWBUILD_AddFlags(GWENBUILD *gwenbuild, uint32_t f)
Definition gwenbuild.c:98
static int _addSourcesOrMkBuildersAndGetTheirOutputs(GWB_PROJECT *project, GWB_TARGET *target, GWB_FILE_LIST2 *sourceFileList, GWB_FILE_LIST2 *newOutputList)
Definition gwenbuild.c:578
void GWBUILD_free(GWENBUILD *gwenbuild)
Definition gwenbuild.c:72
void GWBUILD_Debug_PrintValue(const char *sName, const char *sValue, int indent)
Definition gwenbuild.c:229
GWBUILD_TARGETTYPE
Definition gwenbuild.h:18
@ GWBUILD_TargetType_Objects
Definition gwenbuild.h:25
@ GWBUILD_TargetType_AvrHexFile
Definition gwenbuild.h:28
@ GWBUILD_TargetType_Program
Definition gwenbuild.h:23
@ GWBUILD_TargetType_None
Definition gwenbuild.h:20
@ GWBUILD_TargetType_ConvenienceLibrary
Definition gwenbuild.h:22
@ GWBUILD_TargetType_Module
Definition gwenbuild.h:26
@ GWBUILD_TargetType_Invalid
Definition gwenbuild.h:19
@ GWBUILD_TargetType_CxxProgram
Definition gwenbuild.h:24
@ GWBUILD_TargetType_InstallLibrary
Definition gwenbuild.h:21
@ GWBUILD_TargetType_I18nCatalog
Definition gwenbuild.h:27
struct GWENBUILD GWENBUILD
Definition gwenbuild.h:15
#define GWENBUILD_FLAGS_STATIC
Definition gwenbuild.h:33
#define GWEN_DIR_SEPARATOR_S
const char * GWB_KeyValuePair_GetValue(const GWB_KEYVALUEPAIR *kvp)
const char * GWB_KeyValuePair_GetKey(const GWB_KEYVALUEPAIR *kvp)
struct GWB_KEYVALUEPAIR GWB_KEYVALUEPAIR
#define GWEN_FREE_OBJECT(varname)
Definition memory.h:61
#define GWEN_NEW_OBJECT(typ, varname)
Definition memory.h:55
void GWB_Option_Dump(const GWB_OPTION *option, int indent)
Definition option.c:172
struct GWB_OPTION GWB_OPTION
Definition option.h:17
GWB_BUILDER_LIST2 * GWB_Project_GetBuilderList(const GWB_PROJECT *project)
Definition project.c:277
GWB_TARGET * GWB_Project_GetTargetById(const GWB_PROJECT *project, const char *id)
Definition project.c:248
GWENBUILD * GWB_Project_GetGwbuild(const GWB_PROJECT *project)
Definition project.c:70
GWB_BUILD_CMD_LIST * GWB_Project_GetExplicitBuildList(const GWB_PROJECT *project)
Definition project.c:406
GWB_CONTEXT * GWB_Project_GetRootContext(const GWB_PROJECT *project)
Definition project.c:226
void GWB_Project_AddBuilder(GWB_PROJECT *project, GWB_BUILDER *builder)
Definition project.c:284
GWB_TARGET_LIST2 * GWB_Project_GetTargetList(const GWB_PROJECT *project)
Definition project.c:234
struct GWB_PROJECT GWB_PROJECT
Definition project.h:14
void GWEN_StringList_free(GWEN_STRINGLIST *sl)
Definition stringlist.c:62
GWEN_STRINGLIST * GWEN_StringList_fromString2(const char *str, const char *delimiters, int checkDouble, uint32_t flags)
Definition stringlist.c:818
const char * GWEN_StringListEntry_Data(const GWEN_STRINGLISTENTRY *se)
Definition stringlist.c:406
GWEN_STRINGLISTENTRY * GWEN_StringListEntry_Next(const GWEN_STRINGLISTENTRY *se)
Definition stringlist.c:398
unsigned int GWEN_StringList_Count(const GWEN_STRINGLIST *sl)
Definition stringlist.c:427
int GWEN_StringList_AppendString(GWEN_STRINGLIST *sl, const char *s, int take, int checkDouble)
Definition stringlist.c:245
GWEN_STRINGLISTENTRY * GWEN_StringList_FirstEntry(const GWEN_STRINGLIST *sl)
Definition stringlist.c:390
GWEN_STRINGLIST * GWEN_StringList_new(void)
Definition stringlist.c:50
struct GWEN_STRINGLISTENTRYSTRUCT GWEN_STRINGLISTENTRY
Definition stringlist.h:53
struct GWEN_STRINGLISTSTRUCT GWEN_STRINGLIST
Definition stringlist.h:56
GWB_BUILDER * GWB_Target_GetBuilder(const GWB_TARGET *target)
Definition target.c:265
void GWB_Target_AddUsedTargetLinkSpec(GWB_TARGET *target, const char *s)
Definition target.c:255
void GWB_Target_Dump(const GWB_TARGET *target, int indent, int fullDump)
Definition target.c:332
GWB_CONTEXT * GWB_Target_GetContext(const GWB_TARGET *target)
Definition target.c:187
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
GWEN_STRINGLIST * GWB_Target_GetUsedTargetNameList(const GWB_TARGET *target)
Definition target.c:216
GWBUILD_TARGETTYPE GWB_Target_GetTargetType(const GWB_TARGET *target)
Definition target.c:128
struct GWB_TARGET GWB_TARGET
Definition target.h:17
int GWEN_Text_ComparePattern(const char *w, const char *p, int sensecase)
Definition text.c:1208
#define GWEN_TEXT_FLAGS_DEL_LEADING_BLANKS
Definition text.h:44
#define GWEN_TEXT_FLAGS_DEL_QUOTES
Definition text.h:49
#define GWEN_TEXT_FLAGS_CHECK_BACKSLASH
Definition text.h:50
#define GWEN_TEXT_FLAGS_DEL_TRAILING_BLANKS
Definition text.h:45
GWEN_XMLNODE * GWEN_XMLNode_dup(const GWEN_XMLNODE *n)
Definition xml.c:187
struct GWEN__XMLNODE GWEN_XMLNODE
Definition xml.h:156