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