tcbuilder 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tcbuild.d.ts +21 -1
- package/dist/tcbuild.js +31 -25
- package/package.json +1 -1
package/dist/tcbuild.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ declare global {
|
|
|
6
6
|
var build_dir: string;
|
|
7
7
|
}
|
|
8
8
|
declare global {
|
|
9
|
+
var groups: Record<string, Group>;
|
|
9
10
|
var build: typeof _build;
|
|
10
11
|
var extExecutable: typeof _extExecutable;
|
|
11
12
|
var extFlags: typeof _extFlags;
|
|
@@ -28,11 +29,30 @@ declare global {
|
|
|
28
29
|
var relGroupFile: typeof groupFile;
|
|
29
30
|
}
|
|
30
31
|
declare function _build(name?: string): Promise<void>;
|
|
32
|
+
type StringKeyValue = Record<string, string>;
|
|
33
|
+
type Group = {
|
|
34
|
+
name: string;
|
|
35
|
+
files: Record<string, {
|
|
36
|
+
flags: string;
|
|
37
|
+
executable: string;
|
|
38
|
+
toBeRemoved: string[];
|
|
39
|
+
includeInFinalOutput: boolean;
|
|
40
|
+
}>;
|
|
41
|
+
extFlags: StringKeyValue;
|
|
42
|
+
extExecutable: StringKeyValue;
|
|
43
|
+
finalFlags: string;
|
|
44
|
+
finalFlagsToBeRemoved: string[];
|
|
45
|
+
finalExe: string;
|
|
46
|
+
finalExeSuffix: string;
|
|
47
|
+
};
|
|
31
48
|
declare function _extExecutable(ext: string, exec?: string): string;
|
|
32
49
|
declare function _extFlags(ext: string, flags?: string): string;
|
|
33
50
|
declare function _groupFinalFlags(flags: string, toBeRemoved: string): string | undefined;
|
|
34
51
|
declare function _groupFinalExecutable(exe: string): string | undefined;
|
|
35
52
|
declare function _groupFinalExecutableSuffix(suffix: string): string | undefined;
|
|
36
|
-
declare function _groupFile(fileName: string, flags?: string,
|
|
53
|
+
declare function _groupFile(fileName: string, flags?: string, options?: {
|
|
54
|
+
toBeRemoved?: string;
|
|
55
|
+
includeInFinalOutput?: boolean;
|
|
56
|
+
}): void;
|
|
37
57
|
declare function _group(name: string | null, fn: () => void): Promise<void>;
|
|
38
58
|
export {};
|
package/dist/tcbuild.js
CHANGED
|
@@ -46,57 +46,57 @@ async function _build(name = '') {
|
|
|
46
46
|
global.build = _build;
|
|
47
47
|
const globalExtExecutable = {};
|
|
48
48
|
const globalExtFlags = {};
|
|
49
|
-
|
|
49
|
+
global.groups = {};
|
|
50
50
|
let currentGroup = null;
|
|
51
51
|
global.debExtExecutable = (...args) => {
|
|
52
52
|
if (is_debug)
|
|
53
53
|
return extExecutable(...args);
|
|
54
|
-
return
|
|
54
|
+
return '';
|
|
55
55
|
};
|
|
56
56
|
global.relExtExecutable = (...args) => {
|
|
57
57
|
if (!is_debug)
|
|
58
58
|
return extExecutable(...args);
|
|
59
|
-
return
|
|
59
|
+
return '';
|
|
60
60
|
};
|
|
61
61
|
global.debExtFlags = (...args) => {
|
|
62
62
|
if (is_debug)
|
|
63
63
|
return extFlags(...args);
|
|
64
|
-
return
|
|
64
|
+
return '';
|
|
65
65
|
};
|
|
66
66
|
global.relExtFlags = (...args) => {
|
|
67
67
|
if (!is_debug)
|
|
68
68
|
return extFlags(...args);
|
|
69
|
-
return
|
|
69
|
+
return '';
|
|
70
70
|
};
|
|
71
71
|
global.debGroupFinalFlags = (...args) => {
|
|
72
72
|
if (is_debug)
|
|
73
73
|
return groupFinalFlags(...args);
|
|
74
|
-
return
|
|
74
|
+
return '';
|
|
75
75
|
};
|
|
76
76
|
global.relGroupFinalFlags = (...args) => {
|
|
77
77
|
if (!is_debug)
|
|
78
78
|
return groupFinalFlags(...args);
|
|
79
|
-
return
|
|
79
|
+
return '';
|
|
80
80
|
};
|
|
81
81
|
global.debGroupFinalExecutable = (...args) => {
|
|
82
82
|
if (is_debug)
|
|
83
83
|
return groupFinalExecutable(...args);
|
|
84
|
-
return
|
|
84
|
+
return '';
|
|
85
85
|
};
|
|
86
86
|
global.relGroupFinalExecutable = (...args) => {
|
|
87
87
|
if (!is_debug)
|
|
88
88
|
return groupFinalExecutable(...args);
|
|
89
|
-
return
|
|
89
|
+
return '';
|
|
90
90
|
};
|
|
91
91
|
global.debGroupFinalExecutableSuffix = (...args) => {
|
|
92
92
|
if (is_debug)
|
|
93
93
|
return groupFinalExecutableSuffix(...args);
|
|
94
|
-
return
|
|
94
|
+
return '';
|
|
95
95
|
};
|
|
96
96
|
global.relGroupFinalExecutableSuffix = (...args) => {
|
|
97
97
|
if (!is_debug)
|
|
98
98
|
return groupFinalExecutableSuffix(...args);
|
|
99
|
-
return
|
|
99
|
+
return '';
|
|
100
100
|
};
|
|
101
101
|
global.debGroupFile = (...args) => {
|
|
102
102
|
if (is_debug)
|
|
@@ -112,15 +112,15 @@ function _extExecutable(ext, exec) {
|
|
|
112
112
|
if (exec)
|
|
113
113
|
globalExtExecutable[ext] = exec;
|
|
114
114
|
else
|
|
115
|
-
return globalExtExecutable[ext] ??
|
|
115
|
+
return globalExtExecutable[ext] ?? '';
|
|
116
116
|
}
|
|
117
117
|
else {
|
|
118
118
|
if (exec)
|
|
119
119
|
currentGroup.extExecutable[ext] = exec;
|
|
120
120
|
else
|
|
121
|
-
return currentGroup.extExecutable[ext] ??
|
|
121
|
+
return currentGroup.extExecutable[ext] ?? '';
|
|
122
122
|
}
|
|
123
|
-
return
|
|
123
|
+
return '';
|
|
124
124
|
}
|
|
125
125
|
global.extExecutable = _extExecutable;
|
|
126
126
|
function _extFlags(ext, flags) {
|
|
@@ -130,7 +130,7 @@ function _extFlags(ext, flags) {
|
|
|
130
130
|
if (flags)
|
|
131
131
|
globalExtFlags[ext] += ` ${flags}`;
|
|
132
132
|
else
|
|
133
|
-
return globalExtFlags[ext] ??
|
|
133
|
+
return globalExtFlags[ext] ?? '';
|
|
134
134
|
}
|
|
135
135
|
else {
|
|
136
136
|
if (!currentGroup.extFlags[ext])
|
|
@@ -138,9 +138,9 @@ function _extFlags(ext, flags) {
|
|
|
138
138
|
if (flags)
|
|
139
139
|
currentGroup.extFlags[ext] += ` ${flags}`;
|
|
140
140
|
else
|
|
141
|
-
return currentGroup.extFlags[ext] ??
|
|
141
|
+
return currentGroup.extFlags[ext] ?? '';
|
|
142
142
|
}
|
|
143
|
-
return
|
|
143
|
+
return '';
|
|
144
144
|
}
|
|
145
145
|
global.extFlags = _extFlags;
|
|
146
146
|
function _groupFinalFlags(flags, toBeRemoved) {
|
|
@@ -173,7 +173,7 @@ function _groupFinalExecutableSuffix(suffix) {
|
|
|
173
173
|
return currentGroup.finalExeSuffix;
|
|
174
174
|
}
|
|
175
175
|
global.groupFinalExecutableSuffix = _groupFinalExecutableSuffix;
|
|
176
|
-
function _groupFile(fileName, flags,
|
|
176
|
+
function _groupFile(fileName, flags, options) {
|
|
177
177
|
if (!currentGroup)
|
|
178
178
|
throw 'any group function called outside of group';
|
|
179
179
|
const file = contextStack.join('/') + (contextStack.length > 0 ? '/' : '') + fileName;
|
|
@@ -181,17 +181,22 @@ function _groupFile(fileName, flags, toBeRemoved) {
|
|
|
181
181
|
if (existisFile) {
|
|
182
182
|
if (flags)
|
|
183
183
|
existisFile.flags += ` ${flags}`;
|
|
184
|
-
if (toBeRemoved)
|
|
185
|
-
existisFile.toBeRemoved.push(toBeRemoved);
|
|
184
|
+
if (options?.toBeRemoved)
|
|
185
|
+
existisFile.toBeRemoved.push(options.toBeRemoved);
|
|
186
|
+
if (options?.includeInFinalOutput)
|
|
187
|
+
existisFile.includeInFinalOutput = options.includeInFinalOutput;
|
|
186
188
|
}
|
|
187
189
|
else {
|
|
188
190
|
currentGroup.files[file] = {
|
|
189
191
|
flags: flags ?? '',
|
|
190
192
|
executable: '',
|
|
191
|
-
toBeRemoved: []
|
|
193
|
+
toBeRemoved: [],
|
|
194
|
+
includeInFinalOutput: true
|
|
192
195
|
};
|
|
193
|
-
if (toBeRemoved)
|
|
194
|
-
currentGroup.files[file].toBeRemoved.push(toBeRemoved);
|
|
196
|
+
if (options?.toBeRemoved)
|
|
197
|
+
currentGroup.files[file].toBeRemoved.push(options.toBeRemoved);
|
|
198
|
+
if (options?.includeInFinalOutput)
|
|
199
|
+
currentGroup.files[file].includeInFinalOutput = options.includeInFinalOutput;
|
|
195
200
|
}
|
|
196
201
|
}
|
|
197
202
|
global.groupFile = _groupFile;
|
|
@@ -205,7 +210,7 @@ async function _group(name, fn) {
|
|
|
205
210
|
finalFlags: '',
|
|
206
211
|
finalFlagsToBeRemoved: [],
|
|
207
212
|
finalExe: '',
|
|
208
|
-
finalExeSuffix: ''
|
|
213
|
+
finalExeSuffix: ''
|
|
209
214
|
};
|
|
210
215
|
if (!name) {
|
|
211
216
|
currentGroup = null;
|
|
@@ -238,7 +243,8 @@ process.once('beforeExit', async () => {
|
|
|
238
243
|
const file = group.files[fileName];
|
|
239
244
|
const fileLastExt = fileName.split('.').pop();
|
|
240
245
|
let obj_out = `${build_dir}/${fileName}.o`;
|
|
241
|
-
|
|
246
|
+
if (file.includeInFinalOutput)
|
|
247
|
+
objects += ` ${obj_out}`;
|
|
242
248
|
let final_flags = `${ /* globalSrcFileFlags */''} ${file.flags ?? ''}`;
|
|
243
249
|
for (const ext of fileName.split('.').slice(1)) {
|
|
244
250
|
if (ext.length <= 0)
|