MWCC/command_line/CmdLine/Src/CLTarg.c

56 lines
1.5 KiB
C

#include "cmdline.h"
Target *Target_New(const char *name, OSType cpu, OSType os, OSType lang) {
Target *targ;
targ = xcalloc("target", sizeof(Target));
strncpy(targ->targetName, name, sizeof(targ->targetName));
targ->targetinfo = xcalloc("target info", sizeof(CWTargetInfo));
targ->cpu = cpu;
targ->os = os;
targ->lang = lang;
OS_GetCWD(&targ->outputDirectory);
#line 25
OPTION_ASSERT(Segments_Initialize(&targ->linkage.segs));
#line 28
OPTION_ASSERT(Overlays_Initialize(&targ->linkage.overlays));
#line 35
OPTION_ASSERT(Files_Initialize(&targ->files) && Files_Initialize(&targ->pchs) && VFiles_Initialize(&targ->virtualFiles) &&
Paths_Initialize(&targ->sysPaths) && Paths_Initialize(&targ->userPaths) && Incls_Initialize(&targ->incls, targ));
return targ;
}
void Target_Free(Target *targ) {
Segments_Terminate(&targ->linkage.segs);
Overlays_Terminate(&targ->linkage.overlays);
Paths_Terminate(&targ->sysPaths);
Paths_Terminate(&targ->userPaths);
Files_Terminate(&targ->files);
Files_Terminate(&targ->pchs);
VFiles_Terminate(&targ->virtualFiles);
Incls_Terminate(&targ->incls);
xfree(targ);
}
void Targets_Term(Target *list) {
Target *scan;
Target *next;
for (scan = list; scan; scan = next) {
next = scan->next;
Target_Free(scan);
}
}
void Target_Add(Target **list, Target *targ) {
Target **scan;
for (scan = list; *scan; scan = &(*scan)->next) {}
*scan = targ;
}