-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathobject.c
More file actions
112 lines (96 loc) · 3.51 KB
/
object.c
File metadata and controls
112 lines (96 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <external.h>
#include "buildeka_module.h"
StrVec *BuildCtx_DestFromSrc(BuildCtx *ctx,
StrVec *path, StrVec *src, StrVec *dest){
return NULL;
}
status BuildCtx_LinkObject(BuildCtx *ctx, StrVec *name, DirSel *sel){
DebugStack_Push(NULL, ZERO);
DebugStack_SetRef(ctx->current.dest, ctx->current.dest->type.of);
MemCh *m = ctx->m;
ctx->cli.fields.current[BUILIDER_CLI_ACTION] = K(m, "Link Object");
ctx->cli.fields.current[BUILIDER_CLI_SOURCE] = ctx->current.source;
ctx->cli.fields.current[BUILIDER_CLI_DEST] = ctx->current.dest;
BuildCtx_Log(ctx);
ProcDets pd;
ProcDets_Init(&pd);
Span *cmd = Span_Make(m);
Span_Add(cmd, ctx->tools.ar);
Span_Add(cmd, Str_CstrRef(m, "-rc"));
Span_Add(cmd, StrVec_Str(m, ctx->current.target));
Span_Add(cmd, StrVec_Str(m, ctx->current.dest));
ProcDets_Init(&pd);
status re = SubProcess(m, cmd, &pd);
if(re & ERROR){
DebugStack_SetRef(cmd, cmd->type.of);
Fatal(FUNCNAME, FILENAME, LINENUMBER,
"Build error for adding object to lib", NULL);
DebugStack_Pop();
return ERROR;
}
DebugStack_Pop();
return ZERO;
}
status BuildCtx_BuildObject(BuildCtx *ctx, StrVec *name, DirSel *sel){
DebugStack_Push(NULL, ZERO);
void *args[8];
status r = READY;
MemCh *m = ctx->m;
if(ctx->type.state & DEBUG){
args[0] = name;
args[1] = ctx->current.source;
args[2] = ctx->current.dest;
args[3] = sel;
args[4] = NULL;
Out("^y.BuildObject name:@\n source:@ ->\n dest:@ sel:@^0\n", args);
}
DebugStack_SetRef(ctx->current.source, ctx->current.source->type.of);
if(ctx->current.binDest){
ctx->cli.fields.current[BUILIDER_CLI_ACTION] = K(m, "Build Exec");
ctx->cli.fields.current[BUILIDER_CLI_SOURCE] = ctx->current.source;
ctx->cli.fields.current[BUILIDER_CLI_DEST] = ctx->current.binDest;
}else{
ctx->cli.fields.current[BUILIDER_CLI_ACTION] = K(m, "Build Object");
ctx->cli.fields.current[BUILIDER_CLI_SOURCE] = ctx->current.source;
ctx->cli.fields.current[BUILIDER_CLI_DEST] = ctx->current.dest;
}
BuildCtx_Log(ctx);
Span *cmd = Span_Make(m);
Span_Add(cmd, ctx->tools.cc);
Span_AddSpan(cmd, ctx->input.cflags);
Span_AddSpan(cmd, ctx->current.inc);
Span_AddSpan(cmd, ctx->current.flags);
if(ctx->current.binDest){
Span_Add(cmd, Str_CstrRef(m, "-o"));
Span_Add(cmd, StrVec_Str(m, ctx->current.binDest));
Span_Add(cmd, StrVec_Str(m, ctx->current.source));
if(ctx->current.target != NULL){
Span_Add(cmd, StrVec_Str(m, ctx->current.target));
}
if(ctx->current.liblist != NULL && ctx->current.liblist->nvalues > 0){
Span_AddSpan(cmd, ctx->current.liblist);
}
Span_AddSpanRev(cmd, ctx->current.staticlibs);
Span_AddSpan(cmd, ctx->input.libs);
}else{
Span_Add(cmd, Str_CstrRef(m, "-g"));
Span_Add(cmd, Str_CstrRef(m, "-c"));
Span_Add(cmd, Str_CstrRef(m, "-o"));
Span_Add(cmd, StrVec_Str(m, ctx->current.dest));
Span_Add(cmd, StrVec_Str(m, ctx->current.source));
Span_AddSpan(cmd, ctx->input.libs);
}
ProcDets pd;
ProcDets_Init(&pd);
r |= SubProcess(m, cmd, &pd);
if(r & ERROR){
void *args[] = {
cmd,
NULL
};
Fatal(FUNCNAME, FILENAME, LINENUMBER, "Build error for source file: @", args);
return ERROR;
}
DebugStack_Pop();
return r;
}