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