tcbuilder 1.1.4 → 1.1.6

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 CHANGED
@@ -10,23 +10,12 @@ declare global {
10
10
  var build: typeof _build;
11
11
  var extExecutable: typeof _extExecutable;
12
12
  var extFlags: typeof _extFlags;
13
+ var extSuffix: typeof _extSuffix;
13
14
  var groupFinalExecutable: typeof _groupFinalExecutable;
14
15
  var groupFinalExecutableSuffix: typeof _groupFinalExecutableSuffix;
15
16
  var groupFinalFlags: typeof _groupFinalFlags;
16
17
  var groupFile: typeof _groupFile;
17
18
  var group: typeof _group;
18
- var debExtExecutable: typeof extExecutable;
19
- var relExtExecutable: typeof extExecutable;
20
- var debExtFlags: typeof extFlags;
21
- var relExtFlags: typeof extFlags;
22
- var debGroupFinalFlags: typeof groupFinalFlags;
23
- var relGroupFinalFlags: typeof groupFinalFlags;
24
- var debGroupFinalExecutable: typeof groupFinalExecutable;
25
- var relGroupFinalExecutable: typeof groupFinalExecutable;
26
- var debGroupFinalExecutableSuffix: typeof groupFinalExecutableSuffix;
27
- var relGroupFinalExecutableSuffix: typeof groupFinalExecutableSuffix;
28
- var debGroupFile: typeof groupFile;
29
- var relGroupFile: typeof groupFile;
30
19
  }
31
20
  declare function _build(name?: string): Promise<void>;
32
21
  type StringKeyValue = Record<string, string>;
@@ -47,6 +36,7 @@ type Group = {
47
36
  };
48
37
  declare function _extExecutable(ext: string, exec?: string): string;
49
38
  declare function _extFlags(ext: string, flags?: string): string;
39
+ declare function _extSuffix(ext: string, suffix?: string): string;
50
40
  declare function _groupFinalFlags(flags: string, toBeRemoved: string): string | undefined;
51
41
  declare function _groupFinalExecutable(exe: string): string | undefined;
52
42
  declare function _groupFinalExecutableSuffix(suffix: string): string | undefined;
package/dist/tcbuild.js CHANGED
@@ -46,66 +46,9 @@ async function _build(name = '') {
46
46
  global.build = _build;
47
47
  const globalExtExecutable = {};
48
48
  const globalExtFlags = {};
49
+ const globalExtSuffix = {};
49
50
  global.groups = {};
50
51
  let currentGroup = null;
51
- global.debExtExecutable = (...args) => {
52
- if (is_debug)
53
- return extExecutable(...args);
54
- return '';
55
- };
56
- global.relExtExecutable = (...args) => {
57
- if (!is_debug)
58
- return extExecutable(...args);
59
- return '';
60
- };
61
- global.debExtFlags = (...args) => {
62
- if (is_debug)
63
- return extFlags(...args);
64
- return '';
65
- };
66
- global.relExtFlags = (...args) => {
67
- if (!is_debug)
68
- return extFlags(...args);
69
- return '';
70
- };
71
- global.debGroupFinalFlags = (...args) => {
72
- if (is_debug)
73
- return groupFinalFlags(...args);
74
- return '';
75
- };
76
- global.relGroupFinalFlags = (...args) => {
77
- if (!is_debug)
78
- return groupFinalFlags(...args);
79
- return '';
80
- };
81
- global.debGroupFinalExecutable = (...args) => {
82
- if (is_debug)
83
- return groupFinalExecutable(...args);
84
- return '';
85
- };
86
- global.relGroupFinalExecutable = (...args) => {
87
- if (!is_debug)
88
- return groupFinalExecutable(...args);
89
- return '';
90
- };
91
- global.debGroupFinalExecutableSuffix = (...args) => {
92
- if (is_debug)
93
- return groupFinalExecutableSuffix(...args);
94
- return '';
95
- };
96
- global.relGroupFinalExecutableSuffix = (...args) => {
97
- if (!is_debug)
98
- return groupFinalExecutableSuffix(...args);
99
- return '';
100
- };
101
- global.debGroupFile = (...args) => {
102
- if (is_debug)
103
- return groupFile(...args);
104
- };
105
- global.relGroupFile = (...args) => {
106
- if (!is_debug)
107
- return groupFile(...args);
108
- };
109
52
  //
110
53
  function _extExecutable(ext, exec) {
111
54
  if (currentGroup === null) {
@@ -143,6 +86,17 @@ function _extFlags(ext, flags) {
143
86
  return '';
144
87
  }
145
88
  global.extFlags = _extFlags;
89
+ function _extSuffix(ext, suffix) {
90
+ if (!globalExtSuffix[ext])
91
+ globalExtSuffix[ext] = '';
92
+ if (suffix) {
93
+ globalExtSuffix[ext] = suffix;
94
+ return suffix;
95
+ }
96
+ else
97
+ return globalExtSuffix[ext];
98
+ }
99
+ global.extSuffix = _extSuffix;
146
100
  function _groupFinalFlags(flags, toBeRemoved) {
147
101
  if (!currentGroup)
148
102
  throw 'any group function called outside of group';
@@ -183,7 +137,7 @@ function _groupFile(fileName, flags, options) {
183
137
  existisFile.flags += ` ${flags}`;
184
138
  if (options?.toBeRemoved)
185
139
  existisFile.toBeRemoved.push(options.toBeRemoved);
186
- if (options?.includeInFinalOutput)
140
+ if (options?.includeInFinalOutput !== undefined)
187
141
  existisFile.includeInFinalOutput = options.includeInFinalOutput;
188
142
  }
189
143
  else {
@@ -195,7 +149,7 @@ function _groupFile(fileName, flags, options) {
195
149
  };
196
150
  if (options?.toBeRemoved)
197
151
  currentGroup.files[file].toBeRemoved.push(options.toBeRemoved);
198
- if (options?.includeInFinalOutput)
152
+ if (options?.includeInFinalOutput !== undefined)
199
153
  currentGroup.files[file].includeInFinalOutput = options.includeInFinalOutput;
200
154
  }
201
155
  }
@@ -237,14 +191,17 @@ process.once('beforeExit', async () => {
237
191
  targets += `${out_name}${group.finalExeSuffix} `;
238
192
  let recipe = '';
239
193
  let objects = '';
194
+ let non_objects = '';
240
195
  for (const fileName in group.files) {
241
196
  if (!Object.hasOwn(group.files, fileName))
242
197
  continue;
243
198
  const file = group.files[fileName];
244
199
  const fileLastExt = fileName.split('.').pop();
245
- let obj_out = `${build_dir}/${fileName}.o`;
200
+ let obj_out = `${build_dir}/${fileName}${globalExtSuffix[fileLastExt] ? `.${globalExtSuffix[fileLastExt]}` : ""}`;
246
201
  if (file.includeInFinalOutput)
247
202
  objects += ` ${obj_out}`;
203
+ else
204
+ non_objects += ` ${obj_out}`;
248
205
  let final_flags = `${ /* globalSrcFileFlags */''} ${file.flags ?? ''}`;
249
206
  for (const ext of fileName.split('.').slice(1)) {
250
207
  if (ext.length <= 0)
@@ -260,7 +217,7 @@ process.once('beforeExit', async () => {
260
217
  if (group.finalFlagsToBeRemoved.length > 0)
261
218
  for (const remove of group.finalFlagsToBeRemoved)
262
219
  group_final_flags = group_final_flags.replaceAll(remove, '');
263
- make_out += `OBJ_${name}=${objects}\n${out_name}${group.finalExeSuffix}:$(OBJ_${name})\n\t${group.finalExe} ${group_final_flags}\n${recipe}-include $(OBJ_${name}:=.d)\n`;
220
+ make_out += `OBJ_${name}=${objects}\n${out_name}${group.finalExeSuffix}:$(OBJ_${name}) ${non_objects}\n\t${group.finalExe} ${group_final_flags}\n${recipe}-include $(OBJ_${name}:=.d)\n`;
264
221
  }
265
222
  await fs.promises.writeFile('./Makefile', `all: ${targets}\n${make_out}`);
266
223
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tcbuilder",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "Build System",
5
5
  "homepage": "https://github.com/umutfahriozkan/tcbuild#readme",
6
6
  "bugs": {