@microtronics/studio-cli 0.6.1 → 0.8.0
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/CHANGELOG.md +18 -0
- package/dist/studio-cli.d.ts +139 -0
- package/out/FS.d.ts.map +1 -1
- package/out/FS.js +0 -17
- package/out/api.d.ts.map +1 -1
- package/out/api.js +3 -1
- package/out/cliFS.d.ts.map +1 -1
- package/out/cliFS.js +16 -2
- package/out/dde/dde.d.ts.map +1 -1
- package/out/dde/dde.js +4 -3
- package/out/dde/fileGenerators/dlo.d.ts.map +1 -1
- package/out/dde/fileGenerators/dlo.js +0 -1
- package/out/defaultFiles.d.ts.map +1 -1
- package/out/defaultFiles.js +5 -2
- package/out/dlo/compiler.d.ts.map +1 -0
- package/out/dlo/compiler.js +312 -0
- package/out/dlo/dlo.d.ts.map +1 -0
- package/out/dlo/dlo.js +31 -0
- package/out/dlo/dlocc.d.ts.map +1 -0
- package/out/dlo/dlocc.js +3849 -0
- package/out/dlo/fileSequencer.d.ts.map +1 -0
- package/out/dlo/fileSequencer.js +40 -0
- package/out/dlo/preCompiler.d.ts.map +1 -0
- package/out/dlo/preCompiler.js +321 -0
- package/out/globals.d.ts.map +1 -1
- package/out/globals.js +3 -2
- package/out/helper.d.ts.map +1 -1
- package/out/helper.js +31 -0
- package/out/main.js +20 -3
- package/out/manifest.d.ts.map +1 -1
- package/out/manifest.js +3 -2
- package/out/scriptRunner.d.ts.map +1 -0
- package/out/scriptRunner.js +101 -0
- package/package.json +4 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileSequencer.d.ts","sourceRoot":"","sources":["../../src/dlo/fileSequencer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAMjC,qBAAa,gBAAgB;IAC5B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;IAC7C,OAAO,CAAC,OAAO,CAAsB;;IAGrC,IAAI,aAAa,CAAC,aAAa,EAAE,GAAG,EAEnC;IAEM,kBAAkB,CAAC,QAAQ,EAAE,MAAM;IAcnC,sBAAsB,CAAC,UAAU,EAAE,MAAM;CAWhD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DloFileSequencer = void 0;
|
|
4
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
5
|
+
const helper_1 = require("../helper");
|
|
6
|
+
class DloFileSequencer {
|
|
7
|
+
dloFileMap = {};
|
|
8
|
+
rootUri = vscode_uri_1.URI.parse('');
|
|
9
|
+
constructor() { }
|
|
10
|
+
set workspacePath(workspacePath) {
|
|
11
|
+
this.rootUri = workspacePath;
|
|
12
|
+
}
|
|
13
|
+
getSequenceForFile(filePath) {
|
|
14
|
+
let relativePath = filePath.substring(this.rootUri.path.length || 0);
|
|
15
|
+
if (this.rootUri.scheme !== 'file') {
|
|
16
|
+
const workspaceRoot = this.rootUri.toString();
|
|
17
|
+
relativePath = filePath.substring(workspaceRoot.length + 1);
|
|
18
|
+
}
|
|
19
|
+
if (Object.hasOwn(this.dloFileMap, relativePath)) {
|
|
20
|
+
return this.dloFileMap[relativePath];
|
|
21
|
+
}
|
|
22
|
+
const filePathCrc = helper_1.Helper.generateHashForFilePath(relativePath);
|
|
23
|
+
this.dloFileMap[relativePath] = filePathCrc;
|
|
24
|
+
return filePathCrc;
|
|
25
|
+
}
|
|
26
|
+
getFilePathForSequence(sequenceId) {
|
|
27
|
+
const sequenceMap = Object.entries(this.dloFileMap).find(([, /*filePath*/ fileId]) => {
|
|
28
|
+
return fileId === sequenceId;
|
|
29
|
+
});
|
|
30
|
+
if (sequenceMap) {
|
|
31
|
+
const extendedPath = vscode_uri_1.URI.parse(`${this.rootUri.path}${sequenceMap[0]}`);
|
|
32
|
+
return extendedPath.path;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.DloFileSequencer = DloFileSequencer;
|
|
40
|
+
//# sourceMappingURL=fileSequencer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preCompiler.d.ts","sourceRoot":"","sources":["../../src/dlo/preCompiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,GAAG,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AA6F7C,qBAAa,cAAc;IAC1B,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,gBAAgB,CAA0B;;IAGlD,IAAI,iBAAiB,IAAI,MAAM,GAAG,IAAI,CAMrC;IAGK,iBAAiB,CACtB,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAC3B,OAAO,EAAE,GAAG,EACZ,QAAQ,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC;QACV,WAAW,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;QAChC,IAAI,EAAE,MAAM,CAAC;KACb,CAAC;CAqPF"}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DloPreCompiler = void 0;
|
|
4
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
5
|
+
const fileSequencer_1 = require("./fileSequencer");
|
|
6
|
+
const manifest_1 = require("../manifest");
|
|
7
|
+
const defaultFiles_1 = require("../defaultFiles");
|
|
8
|
+
const helper_1 = require("../helper");
|
|
9
|
+
// #options "..." - line starts with "#options "
|
|
10
|
+
const rxpOptions = /^(?:\s*#options\s+)(.*)(?:\s*)$/;
|
|
11
|
+
// #preinclude "..." - line starts with "#preinclude "
|
|
12
|
+
const rxpPreinclude = /^(?:\s*#preinclude\s+)(.*)(?:\s*)$/;
|
|
13
|
+
// #ifdef ... - line starts with "#ifdef "
|
|
14
|
+
const rxpIfdef = /^(?:\s*#ifdef\s+)(.*)$/;
|
|
15
|
+
// #ifndef ... - line starts with "#ifndef "
|
|
16
|
+
const rxpIfndef = /^(?:\s*#ifndef\s+)(.*)$/;
|
|
17
|
+
// #elseifdef ... - line starts with "#elseifdef "
|
|
18
|
+
const rxpElseifdef = /^(?:\s*#elseifdef\s+)(.*)$/;
|
|
19
|
+
// #elseifndef ... - line starts with "#elseifndef "
|
|
20
|
+
const rxpElseifndef = /^(?:\s*#elseifndef\s+)(.*)$/;
|
|
21
|
+
// #callback( params...) {... - line starts with "#callback(" and ends with ")" or "){"
|
|
22
|
+
const rxpCallback = /^(\s*)(?:#callback\s+)(\w*)(?:\s*\(\s*)(.*?)(?:\s*\)\s*)(\{*){1}(?:\s*)$/;
|
|
23
|
+
// assert( cond, params...); - line contains "assert ( cond," and ends with ")" or ");"
|
|
24
|
+
const rxpAssert = /^(.*)(^|\s+)(?:assert\s*\(\s*)(.*?)(?:\s*,\s*)(.*?)(?:\s*\)\s*;*\s*)$/;
|
|
25
|
+
// assert( cond); - line contains "assert ( cond" and ends with ")" or ");"
|
|
26
|
+
const rxpAssert0 = /^(.*)(^|\s+)(?:assert\s*\(\s*)(.*?)(?:\s*\)\s*;*\s*)$/;
|
|
27
|
+
// assert(); - line ends with "assert ( )" or "assert ( );"
|
|
28
|
+
const rxpAssertF = /^(.*)(^|\s+)(?:assert\s*\(\s*\);*\s*)$/;
|
|
29
|
+
// catch( params...); - line contains "catch (" and ends with ")" or ");"
|
|
30
|
+
const rxpCatch = /^(.*)(^|\s+)(?:catch\s*\(\s*)(.*?)(?:\s*\)\s*;*\s*)$/;
|
|
31
|
+
// line starts with "#include <"
|
|
32
|
+
const rxpIncludesClib = /^\s*#include\s*</;
|
|
33
|
+
// line starts with "#endinput "
|
|
34
|
+
const rxpEndinputClib = /^\s*#endinput\s*/;
|
|
35
|
+
// #pragma dynamic - line contains "#pragma dynamic
|
|
36
|
+
const rxpPragmaDynamic = /^\s*#pragma\s+dynamic\s+(\S+)\s*(\/\/.*|\/\*.*|)$/;
|
|
37
|
+
/*applog( prio_code, format, params...); - line contains "applog ( prio_code," and ends with ")" or ");"
|
|
38
|
+
applog_<level>( prio_code, format, params...); - line contains "applog_<level> ( prio_code," and ends with ")" or ");"*/
|
|
39
|
+
const rxpApplog = /^(.*)(^|\s+)(?:applog(|_ok|_warning|_alarm|_debug|_fatal)\s*\(\s*)(.*?)(?:\s*,\s*)(.*?)(?:\s*\)\s*;*\s*)$/;
|
|
40
|
+
// applog( prio_code); - line contains "applog ( prio_code" and ends with ")" or ");"
|
|
41
|
+
// applog_<level>( prio_code); - line contains "aspplog_<level> ( prio_code" and ends with ")" or ");"
|
|
42
|
+
const rxpApplog0 = /^(.*)(^|\s*)(?:applog(|_ok|_warning|_alarm|_debug|_fatal)\s*\(\s*)(.*?)(?:\s*\)\s*;*\s*)$/;
|
|
43
|
+
//function to parse the log prio (if any) from the prio_code string or match the given level to the correct prio
|
|
44
|
+
function parseApplogPriority(priorityCode, level = '') {
|
|
45
|
+
let priority = ' '; //default prio is space!
|
|
46
|
+
let code = priorityCode;
|
|
47
|
+
if (level.length) {
|
|
48
|
+
priority =
|
|
49
|
+
{
|
|
50
|
+
fatal: '§',
|
|
51
|
+
alarm: '!',
|
|
52
|
+
warning: '?',
|
|
53
|
+
debug: '~',
|
|
54
|
+
ok: '$'
|
|
55
|
+
}[level] || null;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
if (['!', '?', '~', '$', '§'].includes(priorityCode.substring(1, 1))) {
|
|
59
|
+
priority = priorityCode.substring(1, 1);
|
|
60
|
+
code = `"${priorityCode.substring(2, priorityCode.length - 1)}"`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return { priority: `'${priority}'`, code };
|
|
64
|
+
}
|
|
65
|
+
const rxpLogBackend = /^(.*)(^|\s+)(?:log(|_debug|_info|_warn|_error)\s*\(\s*)(.*?)(?:\s*\)\s*;*\s*)$/;
|
|
66
|
+
var LogLevel;
|
|
67
|
+
(function (LogLevel) {
|
|
68
|
+
LogLevel[LogLevel["debug"] = 0] = "debug";
|
|
69
|
+
LogLevel[LogLevel["info"] = 1] = "info";
|
|
70
|
+
LogLevel[LogLevel["warn"] = 2] = "warn";
|
|
71
|
+
LogLevel[LogLevel["error"] = 3] = "error";
|
|
72
|
+
})(LogLevel || (LogLevel = {}));
|
|
73
|
+
// const rxpDDE =/^(.*)(^|\s+)DDE_(up|down)_(state|control)_(persist|update)\(\)/;
|
|
74
|
+
const rxpDDE = /^(.*)(^|\s*)DDE_(state|result|aloha|volatile|setting|command)_/;
|
|
75
|
+
const rxpUplinkRestore = /^(.*)(^|\s*)onUplink(Restore|Apply)_(state|result|aloha|volatile|setting|command)/;
|
|
76
|
+
const rxpUplinkEvent = /^(.*)(^|\s*)onUplinkEvent/;
|
|
77
|
+
class DloPreCompiler {
|
|
78
|
+
pragmaDynamic = null;
|
|
79
|
+
dloFileSequencer = new fileSequencer_1.DloFileSequencer();
|
|
80
|
+
constructor() { }
|
|
81
|
+
get pragmaDynamicFlag() {
|
|
82
|
+
if (!this.pragmaDynamic) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
return `-S${this.pragmaDynamic}`;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
90
|
+
async preCompileDloFile(cwd, manifest, fileUri, fileBlob) {
|
|
91
|
+
this.dloFileSequencer.workspacePath = cwd;
|
|
92
|
+
const fileDiagnostics = [];
|
|
93
|
+
const filePath = fileUri.path;
|
|
94
|
+
let mangleDDEFunctions = false;
|
|
95
|
+
const baseName = vscode_uri_1.Utils.basename(fileUri);
|
|
96
|
+
// look for autogenerated xxx-dde.inc files
|
|
97
|
+
if (filePath.includes(defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.path) && baseName.endsWith('-dde.inc')) {
|
|
98
|
+
const ddeIncSource = baseName.substring(0, baseName.length - 8);
|
|
99
|
+
if (!['app', 'main'].includes(ddeIncSource)) {
|
|
100
|
+
// this is a library specific file!
|
|
101
|
+
mangleDDEFunctions = helper_1.Helper.generateHashForLibraryName(ddeIncSource);
|
|
102
|
+
// console.log('MANGLED LIB DDE', baseName, ddeIncSource, mangleDDEFunctions);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// look for library source files:
|
|
106
|
+
if (filePath.includes(defaultFiles_1.DefaultFiles.filePaths.studio.libdeps)) {
|
|
107
|
+
const libPath = filePath.split('libdeps/')[1];
|
|
108
|
+
const [libName] = libPath.split('/');
|
|
109
|
+
if (!['dlo-core'].includes(libName)) {
|
|
110
|
+
mangleDDEFunctions = helper_1.Helper.generateHashForLibraryName(libName);
|
|
111
|
+
// console.log('MANGLED LIB', baseName, mangleDDEFunctions);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if (manifest_1.Manifest.isLibraryProject(manifest) && baseName === `${manifest.name}.inc`) {
|
|
115
|
+
mangleDDEFunctions = helper_1.Helper.generateHashForLibraryName(manifest.name);
|
|
116
|
+
// console.log('MANGLED PROJECT LIB', baseName, mangleDDEFunctions);
|
|
117
|
+
}
|
|
118
|
+
if (filePath.endsWith('.auto/default.inc')) {
|
|
119
|
+
return {
|
|
120
|
+
data: fileBlob.join(`\n`),
|
|
121
|
+
diagnostics: fileDiagnostics
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const precompiledData = [];
|
|
125
|
+
const fileSequence = this.dloFileSequencer.getSequenceForFile(filePath);
|
|
126
|
+
precompiledData.push(`stock static __file{} = "${fileSequence}";`);
|
|
127
|
+
precompiledData.push(`stock static __refid{} = "${fileSequence}";`);
|
|
128
|
+
const appLogSrcId = `A\\0\\0\\0\\0\\0\\0\\0`;
|
|
129
|
+
precompiledData.push(`stock static __applog_src_id{} = "${appLogSrcId}";`);
|
|
130
|
+
precompiledData.push('#line 0'); // manually reset pawns line counter to ignore header lines injected above
|
|
131
|
+
let outLineNumber = 0;
|
|
132
|
+
// !!!
|
|
133
|
+
// !!! output is always single-line to keep line numbers equal to original source!
|
|
134
|
+
// !!!
|
|
135
|
+
for (let lineNumber = 0; lineNumber < fileBlob.length; lineNumber++) {
|
|
136
|
+
let newLine = fileBlob[lineNumber];
|
|
137
|
+
const currentLine = newLine.split('//', 1)[0]; // todo dirty solution! strip-off "end of line" comments
|
|
138
|
+
let h = null;
|
|
139
|
+
// #options
|
|
140
|
+
if ((h = rxpOptions.exec(currentLine))) {
|
|
141
|
+
newLine = '// ' + newLine;
|
|
142
|
+
fileDiagnostics.push({
|
|
143
|
+
file: fileUri,
|
|
144
|
+
level: 'error',
|
|
145
|
+
line: lineNumber,
|
|
146
|
+
message: `#options is not supported here. Use the DLO settings instead.`
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
// #preinclude
|
|
150
|
+
else if ((h = rxpPreinclude.exec(currentLine))) {
|
|
151
|
+
newLine = '// ' + newLine;
|
|
152
|
+
fileDiagnostics.push({
|
|
153
|
+
file: fileUri,
|
|
154
|
+
level: 'error',
|
|
155
|
+
line: lineNumber,
|
|
156
|
+
message: `#preinclude is not supported here. Use the DLO settings instead.`
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
// #pragma dynamic
|
|
160
|
+
else if ((h = rxpPragmaDynamic.exec(currentLine))) {
|
|
161
|
+
const pragmaDynamic = Number(h[1].startsWith('(') ? h[1].substring(1, h[1].length - 1) : h[1]);
|
|
162
|
+
if (!Number.isInteger(pragmaDynamic) || pragmaDynamic < 64) {
|
|
163
|
+
fileDiagnostics.push({
|
|
164
|
+
file: fileUri,
|
|
165
|
+
level: 'error',
|
|
166
|
+
line: lineNumber,
|
|
167
|
+
message: `#pragma dynamic only supports integer values and must be greater than 63`
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
else if (!this.pragmaDynamic || pragmaDynamic > this.pragmaDynamic) {
|
|
171
|
+
this.pragmaDynamic = pragmaDynamic;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// #ifdef
|
|
175
|
+
else if ((h = rxpIfdef.exec(currentLine))) {
|
|
176
|
+
newLine = newLine.replace('#ifdef ', '#if defined ');
|
|
177
|
+
}
|
|
178
|
+
// #ifndef
|
|
179
|
+
else if ((h = rxpIfndef.exec(currentLine))) {
|
|
180
|
+
newLine = newLine.replace('#ifndef ', '#if !defined ');
|
|
181
|
+
}
|
|
182
|
+
// #elseifdef
|
|
183
|
+
else if ((h = rxpElseifdef.exec(currentLine))) {
|
|
184
|
+
newLine = newLine.replace('#elseifdef ', '#elseif defined ');
|
|
185
|
+
}
|
|
186
|
+
// #elseifndef
|
|
187
|
+
else if ((h = rxpElseifndef.exec(currentLine))) {
|
|
188
|
+
newLine = newLine.replace('#elseifndef ', '#elseif !defined ');
|
|
189
|
+
}
|
|
190
|
+
// #callback
|
|
191
|
+
else if ((h = rxpCallback.exec(currentLine))) {
|
|
192
|
+
const [, indent, name, params, curly] = h;
|
|
193
|
+
newLine =
|
|
194
|
+
`${indent}` +
|
|
195
|
+
`#define ${name} _catch_funcidx( "___${name}")\n` +
|
|
196
|
+
`forward ___${name}( ${params});\n` +
|
|
197
|
+
`#line\n${outLineNumber}\n` + // re-adjust line numbering to hide inserted #define line
|
|
198
|
+
// ^-- workaround for pawncc bug: extra \n to avoid error 58 when #line is inside #if
|
|
199
|
+
`public ___${name}( ${params})${curly}`;
|
|
200
|
+
}
|
|
201
|
+
// assert()
|
|
202
|
+
else if ((h = rxpAssertF.exec(currentLine))) {
|
|
203
|
+
const [, prefix, spaces] = h;
|
|
204
|
+
newLine = `${prefix}${spaces}{_log_string="";_assert(__refid,__line);}`;
|
|
205
|
+
}
|
|
206
|
+
// assert(cond,param) - incl. workaround printf%%
|
|
207
|
+
else if ((h = rxpAssert.exec(currentLine))) {
|
|
208
|
+
const [, prefix, spaces, cond, params] = h;
|
|
209
|
+
newLine =
|
|
210
|
+
`${prefix}${spaces}{ ` +
|
|
211
|
+
`if (!(${cond})) { ` +
|
|
212
|
+
`sprintf(_log_string,_,${params.replace(/%%/g, '\xff')});` +
|
|
213
|
+
`_assert(__refid,__line);` +
|
|
214
|
+
` }}`;
|
|
215
|
+
}
|
|
216
|
+
// assert(cond)
|
|
217
|
+
else if ((h = rxpAssert0.exec(currentLine))) {
|
|
218
|
+
const [, prefix, spaces, cond] = h;
|
|
219
|
+
newLine =
|
|
220
|
+
`${prefix}${spaces}{ ` + `if (!(${cond})) { ` + `_log_string="";` + `_assert(__refid,__line);` + ` }}`;
|
|
221
|
+
}
|
|
222
|
+
// catch(cond[,xe[,xs]])
|
|
223
|
+
else if ((h = rxpCatch.exec(currentLine))) {
|
|
224
|
+
const [, prefix, spaces, params] = h;
|
|
225
|
+
newLine = `${prefix}${spaces}_catch(__refid,__line,${params});`;
|
|
226
|
+
}
|
|
227
|
+
// applog(prio_code, params)
|
|
228
|
+
else if ((h = rxpApplog.exec(currentLine))) {
|
|
229
|
+
const [, prefix, spaces, level, priorityCode, formatParams] = h;
|
|
230
|
+
const { priority, code } = parseApplogPriority(priorityCode, level.substring(1));
|
|
231
|
+
if (priority !== null) {
|
|
232
|
+
newLine =
|
|
233
|
+
`${prefix}${spaces}{` +
|
|
234
|
+
`new params_str{DDE_APPLOG_SIZE_PARAMS};` +
|
|
235
|
+
`sprintf(params_str,_,${formatParams});` +
|
|
236
|
+
`DDE_applog_write(${priority}, ${code}, params_str, __applog_src_id);` +
|
|
237
|
+
`}`;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// applog(prio_code)
|
|
241
|
+
else if ((h = rxpApplog0.exec(currentLine))) {
|
|
242
|
+
const [, prefix, spaces, level, priorityCode] = h;
|
|
243
|
+
const { priority, code } = parseApplogPriority(priorityCode, level.substring(1));
|
|
244
|
+
if (priority !== null) {
|
|
245
|
+
newLine = `${prefix}${spaces}DDE_applog_write(${priority}, ${code}, "", __applog_src_id);`;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// log_xxx
|
|
249
|
+
else if ((h = rxpLogBackend.exec(currentLine))) {
|
|
250
|
+
const [, prefix, spaces, level, params] = h;
|
|
251
|
+
const logLevel = level.substring(1);
|
|
252
|
+
const levelNumber = LogLevel[logLevel];
|
|
253
|
+
newLine =
|
|
254
|
+
`${prefix}${spaces}{ ` +
|
|
255
|
+
`if(_log_level <= ${levelNumber}){ ` +
|
|
256
|
+
`sprintf(_log_string,_,${params.replace(/%%/g, '\xff')}); ` +
|
|
257
|
+
`_log${level}(__refid,__line); ` +
|
|
258
|
+
`}` +
|
|
259
|
+
`}`;
|
|
260
|
+
}
|
|
261
|
+
// #include <
|
|
262
|
+
else if ((h = rxpIncludesClib.exec(currentLine)) && !filePath.includes(defaultFiles_1.DefaultFiles.filePaths.studio.auto.path)) {
|
|
263
|
+
//silently ignore this warning if this is a library dependency
|
|
264
|
+
if (!filePath.includes(defaultFiles_1.DefaultFiles.filePaths.studio.libdeps)) {
|
|
265
|
+
fileDiagnostics.push({
|
|
266
|
+
file: fileUri,
|
|
267
|
+
level: 'warning',
|
|
268
|
+
line: lineNumber,
|
|
269
|
+
message: `Libraries are included automatically - remove this #include line`
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
newLine = '// Libraries are included automatically! - ' + currentLine;
|
|
273
|
+
}
|
|
274
|
+
// #endinput
|
|
275
|
+
else if ((h = rxpEndinputClib.exec(currentLine))) {
|
|
276
|
+
fileDiagnostics.push({
|
|
277
|
+
file: fileUri,
|
|
278
|
+
level: 'error',
|
|
279
|
+
line: lineNumber,
|
|
280
|
+
message: `#endinput is not supported - use #if/#endif instead`
|
|
281
|
+
});
|
|
282
|
+
newLine = currentLine;
|
|
283
|
+
}
|
|
284
|
+
if (mangleDDEFunctions && !manifest.legacyProject) {
|
|
285
|
+
// DDE_(up|down)_(state|control)_(persist|update)
|
|
286
|
+
if (rxpDDE.exec(currentLine)) {
|
|
287
|
+
newLine = newLine.replaceAll('DDE_', `_${mangleDDEFunctions}`);
|
|
288
|
+
}
|
|
289
|
+
// onUplink(Restore|Apply)_(up|down)_(state|control)
|
|
290
|
+
if (rxpUplinkRestore.exec(currentLine)) {
|
|
291
|
+
newLine = newLine.replace('onUplink', `_${mangleDDEFunctions}`);
|
|
292
|
+
}
|
|
293
|
+
// onUplinkEvent
|
|
294
|
+
if (rxpUplinkEvent.exec(currentLine)) {
|
|
295
|
+
newLine = newLine.replace('onUplink', `_${mangleDDEFunctions}Uplink`);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
precompiledData.push(newLine);
|
|
299
|
+
outLineNumber++;
|
|
300
|
+
}
|
|
301
|
+
// add undef of file include
|
|
302
|
+
if (baseName !== 'main.dlo') {
|
|
303
|
+
const undefFileName = baseName.split('.')[0].replace(/[^a-zA-Z0-9]/g, '_');
|
|
304
|
+
const incName = `_inc_${undefFileName}`.substring(0, 31);
|
|
305
|
+
const incNameInc = `_inc_${undefFileName}_inc`.substring(0, 31);
|
|
306
|
+
//add special handling for defines with .inc and without
|
|
307
|
+
precompiledData.push(`#if defined ${incName}`);
|
|
308
|
+
precompiledData.push(`#undef ${incName}`);
|
|
309
|
+
precompiledData.push(`#endif`);
|
|
310
|
+
precompiledData.push(`#if defined ${incNameInc}`);
|
|
311
|
+
precompiledData.push(`#undef ${incNameInc}`);
|
|
312
|
+
precompiledData.push(`#endif`);
|
|
313
|
+
}
|
|
314
|
+
return {
|
|
315
|
+
data: precompiledData.join('\n'),
|
|
316
|
+
diagnostics: fileDiagnostics
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
exports.DloPreCompiler = DloPreCompiler;
|
|
321
|
+
//# sourceMappingURL=preCompiler.js.map
|
package/out/globals.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../src/globals.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../src/globals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAS,MAAM,YAAY,CAAC;AAUxC,yBAAiB,OAAO,CAAC;IACxB,UAAiB,OAAO;QACvB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACtB;IAED;;;;OAIG;IACH,SAAsB,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAkClE;CACD"}
|
package/out/globals.js
CHANGED
|
@@ -24,12 +24,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.Globals = void 0;
|
|
27
|
-
const FS_1 = require("./FS");
|
|
28
27
|
const vscode_uri_1 = require("vscode-uri");
|
|
29
28
|
const dependencies_1 = require("./dependencies");
|
|
30
29
|
const manifest_1 = require("./manifest");
|
|
31
30
|
const defaultFiles_1 = require("./defaultFiles");
|
|
32
31
|
const ini = __importStar(require("ini"));
|
|
32
|
+
const helper_1 = require("./helper");
|
|
33
|
+
var convertBlobToString = helper_1.Helper.convertBlobToString;
|
|
33
34
|
const DLO_PATH = defaultFiles_1.DefaultFiles.filePaths.dlo.path;
|
|
34
35
|
var Globals;
|
|
35
36
|
(function (Globals) {
|
|
@@ -77,6 +78,6 @@ var Globals;
|
|
|
77
78
|
*/
|
|
78
79
|
async function readIniFile(fs, filePath) {
|
|
79
80
|
const iniContent = await fs.readFile(filePath);
|
|
80
|
-
return ini.parse(
|
|
81
|
+
return ini.parse(convertBlobToString(iniContent));
|
|
81
82
|
}
|
|
82
83
|
//# sourceMappingURL=globals.js.map
|
package/out/helper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAG1C,yBAAiB,MAAM,CAAC;IACvB;;;;OAIG;IACH,SAAgB,0BAA0B,CACzC,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,KAAK,GACf;QACF,IAAI,EAAE,MAAM,CAAC;QACb,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;KACrB,CAQA;IAID;;;OAGG;IACH,SAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,UAE7D;IAED,SAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,UAEvD;IAED;;;OAGG;IACH,SAAgB,2BAA2B,CAAC,OAAO,EAAE,UAAU,UAE9D;CACD"}
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAG1C,yBAAiB,MAAM,CAAC;IACvB;;;;OAIG;IACH,SAAgB,0BAA0B,CACzC,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,KAAK,GACf;QACF,IAAI,EAAE,MAAM,CAAC;QACb,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;KACrB,CAQA;IAID;;;OAGG;IACH,SAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,UAE7D;IAED,SAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,UAEvD;IAED;;;OAGG;IACH,SAAgB,2BAA2B,CAAC,OAAO,EAAE,UAAU,UAE9D;IAED,SAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,GAAG,GAAG,UAazD;IACD,SAAgB,WAAW,CAAC,iBAAiB,GAAE,MAAW,UAEzD;IAED,SAAgB,wBAAwB,CAAC,IAAI,EAAE,UAAU,GAAG,GAAG,GAAG,MAAM,EAAE,CAOzE;CACD"}
|
package/out/helper.js
CHANGED
|
@@ -40,5 +40,36 @@ var Helper;
|
|
|
40
40
|
return (0, crc_1.crc32_ethernet)(content).toString(16).toUpperCase().padStart(8, '0');
|
|
41
41
|
}
|
|
42
42
|
Helper.generateCRC32ForFileContent = generateCRC32ForFileContent;
|
|
43
|
+
function convertBlobToString(blob) {
|
|
44
|
+
try {
|
|
45
|
+
let binaryData = null;
|
|
46
|
+
// if vscode runs in desktop mode, the blob is a serialized buffer
|
|
47
|
+
if (blob?.type === 'Buffer') {
|
|
48
|
+
binaryData = Uint8Array.from(blob.data);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
binaryData = blob;
|
|
52
|
+
}
|
|
53
|
+
return new TextDecoder('utf8').decode(binaryData);
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
Helper.convertBlobToString = convertBlobToString;
|
|
60
|
+
function normalizeLF(stringToNormalize = '') {
|
|
61
|
+
return stringToNormalize.replace(/\r\n|\n\r|\r/g, '\n');
|
|
62
|
+
}
|
|
63
|
+
Helper.normalizeLF = normalizeLF;
|
|
64
|
+
function convertBlobToStringArray(blob) {
|
|
65
|
+
try {
|
|
66
|
+
const textData = convertBlobToString(blob).trim();
|
|
67
|
+
return normalizeLF(textData).split('\n');
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
Helper.convertBlobToStringArray = convertBlobToStringArray;
|
|
43
74
|
})(Helper || (exports.Helper = Helper = {}));
|
|
44
75
|
//# sourceMappingURL=helper.js.map
|
package/out/main.js
CHANGED
|
@@ -11,6 +11,9 @@ const dependencies_1 = require("./dependencies");
|
|
|
11
11
|
var installDependencies = dependencies_1.Dependencies.installDependencies;
|
|
12
12
|
var installDependency = dependencies_1.Dependencies.installDependency;
|
|
13
13
|
const dde_1 = require("./dde/dde");
|
|
14
|
+
const compiler_1 = require("./dlo/compiler");
|
|
15
|
+
const dlo_1 = require("./dlo/dlo");
|
|
16
|
+
const scriptRunner_1 = require("./scriptRunner");
|
|
14
17
|
const program = new commander_1.Command();
|
|
15
18
|
// dummy cwd
|
|
16
19
|
const devPath = process.env.NODE_ENV === 'local-dev' ? './dev' : '';
|
|
@@ -53,9 +56,10 @@ program
|
|
|
53
56
|
});
|
|
54
57
|
program
|
|
55
58
|
.command('build')
|
|
56
|
-
.arguments('[dde]
|
|
59
|
+
.arguments('[dde] [dlo] [pov] [blo]')
|
|
60
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
57
61
|
.action(async (apmPart) => {
|
|
58
|
-
if (apmPart === 'dde') {
|
|
62
|
+
if (!apmPart || apmPart === 'dde') {
|
|
59
63
|
const result = await dde_1.DDE.compileDDE(cwd, cliFS_1.cliFS);
|
|
60
64
|
result.diagnostics.forEach(diagnostic => {
|
|
61
65
|
const message = `${diagnostic.file.path}: ${diagnostic.message}`;
|
|
@@ -74,11 +78,24 @@ program
|
|
|
74
78
|
await dde_1.DDE.exportHistoryJson(cwd, cliFS_1.cliFS, result.ddeJSON);
|
|
75
79
|
await dde_1.DDE.exportOpenApi(cwd, cliFS_1.cliFS, result.ddeJSON);
|
|
76
80
|
await dde_1.DDE.exportAutoDloFiles(cwd, cliFS_1.cliFS, result.ddeJSON);
|
|
81
|
+
await dlo_1.DLO.exportDloConfig(cwd, cliFS_1.cliFS);
|
|
77
82
|
}
|
|
78
83
|
else {
|
|
79
|
-
|
|
84
|
+
throw new Error('Project has errors!');
|
|
80
85
|
}
|
|
81
86
|
}
|
|
87
|
+
if (!apmPart || apmPart === 'dlo') {
|
|
88
|
+
//todo skip if manifest.dlo not set!
|
|
89
|
+
const compiler = new compiler_1.DloCompiler();
|
|
90
|
+
await compiler.compile(cwd, cliFS_1.cliFS);
|
|
91
|
+
}
|
|
92
|
+
if (!apmPart || apmPart === 'pov') {
|
|
93
|
+
await scriptRunner_1.Shell.tryBuildPov(cwd, cliFS_1.cliFS);
|
|
94
|
+
}
|
|
95
|
+
if (!apmPart || apmPart === 'blo') {
|
|
96
|
+
await scriptRunner_1.Shell.tryBuildBlo(cwd, cliFS_1.cliFS);
|
|
97
|
+
}
|
|
98
|
+
console.log('DONE');
|
|
82
99
|
});
|
|
83
100
|
module.exports = function (argv) {
|
|
84
101
|
program.parse(argv);
|
package/out/manifest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAS,MAAM,YAAY,CAAC;AACxC,OAAO,
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAS,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAG/B,yBAAiB,QAAQ,CAAC;IAEzB,KAAY,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,GAAG,WAAW,CAAC;IAE9F,UAAiB,QAAQ;QACxB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,cAAc,CAAC;QACrB,OAAO,CAAC,EAAE;YACT,OAAO,CAAC,EAAE,MAAM,CAAC;YACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;YAChB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;SACrB,CAAC;QACF,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,mBAAmB,CAAC,EAAE,YAAY,CAAC;QACnC,sBAAsB,CAAC,EAAE,YAAY,CAAC;QACtC;;WAEG;QACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,GAAG,CAAC,EAAE;YACL,QAAQ,EAAE,MAAM,CAAC;YACjB,cAAc,EAAE,MAAM,EAAE,CAAC;SACzB,CAAC;QACF,QAAQ,CAAC,EAAE;YACV,EAAE,CAAC,EAAE,MAAM,CAAC;YACZ,eAAe,CAAC,EAAE,IAAI,GAAG,GAAG,GAAG,MAAM,EAAE,CAAC;YACxC,MAAM,CAAC,EAAE,WAAW,GAAG,KAAK,GAAG,OAAO,CAAC;SACvC,CAAC;QACF;;WAEG;QACH,MAAM,CAAC,EAAE,WAAW,GAAG,KAAK,GAAG,OAAO,CAAC;QACvC,GAAG,CAAC,EAAE;YACL,OAAO,CAAC,EAAE,cAAc,CAAC;SACzB,CAAC;QACF,GAAG,CAAC,EAAE,cAAc,CAAC;KACrB;IAED,UAAiB,YAAY;QAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACtB;IAED,UAAiB,cAAc;QAC9B,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;KACpB;IAED;;;;OAIG;IACH,SAAsB,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAInE;IAED;;;;;OAKG;IACH,SAAsB,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAExF;IAED;;OAEG;IACH,SAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,GAAG,OAAO,CAErE;CACD"}
|
package/out/manifest.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Manifest = void 0;
|
|
4
4
|
const vscode_uri_1 = require("vscode-uri");
|
|
5
|
-
const
|
|
5
|
+
const helper_1 = require("./helper");
|
|
6
6
|
var Manifest;
|
|
7
7
|
(function (Manifest) {
|
|
8
|
+
var convertBlobToString = helper_1.Helper.convertBlobToString;
|
|
8
9
|
/**
|
|
9
10
|
* Read the studio.json manifest and parse it
|
|
10
11
|
* @param cwd
|
|
@@ -12,7 +13,7 @@ var Manifest;
|
|
|
12
13
|
*/
|
|
13
14
|
async function read(cwd, fs) {
|
|
14
15
|
const localManifest = await fs.readFile(vscode_uri_1.Utils.joinPath(cwd, 'studio.json'));
|
|
15
|
-
const manifestString =
|
|
16
|
+
const manifestString = convertBlobToString(localManifest);
|
|
16
17
|
return JSON.parse(manifestString);
|
|
17
18
|
}
|
|
18
19
|
Manifest.read = read;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scriptRunner.d.ts","sourceRoot":"","sources":["../src/scriptRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAS,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAI/B,yBAAiB,KAAK,CAAC;IACtB;;;;OAIG;IACH,SAAsB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,iBAgBtD;IAED;;;;OAIG;IACH,SAAsB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,iBAgBtD;CACD"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Shell = void 0;
|
|
27
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
28
|
+
const manifest_1 = require("./manifest");
|
|
29
|
+
const child_process = __importStar(require("node:child_process"));
|
|
30
|
+
var Shell;
|
|
31
|
+
(function (Shell) {
|
|
32
|
+
/**
|
|
33
|
+
* Calls the POV build command defined within the manifest
|
|
34
|
+
* @param cwd
|
|
35
|
+
* @param fs
|
|
36
|
+
*/
|
|
37
|
+
async function tryBuildPov(cwd, fs) {
|
|
38
|
+
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
39
|
+
if (manifest.pov?.details?.buildCommand && manifest.pov.details.workingPath) {
|
|
40
|
+
console.log('Executing POV build script', manifest.pov?.details.buildCommand);
|
|
41
|
+
const { buildCommand, workingPath } = manifest.pov.details;
|
|
42
|
+
const povDir = vscode_uri_1.Utils.joinPath(cwd, workingPath);
|
|
43
|
+
try {
|
|
44
|
+
await execShell(povDir, buildCommand);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
if (e.code) {
|
|
48
|
+
throw new Error('Build POV failed');
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
throw e;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
Shell.tryBuildPov = tryBuildPov;
|
|
57
|
+
/**
|
|
58
|
+
* Calls the BLO build command defined within the manifest
|
|
59
|
+
* @param cwd
|
|
60
|
+
* @param fs
|
|
61
|
+
*/
|
|
62
|
+
async function tryBuildBlo(cwd, fs) {
|
|
63
|
+
const manifest = await manifest_1.Manifest.read(cwd, fs);
|
|
64
|
+
if (manifest.blo?.buildCommand && manifest.blo?.workingPath) {
|
|
65
|
+
console.log('Executing BLO build script', manifest.blo?.buildCommand);
|
|
66
|
+
const { buildCommand, workingPath } = manifest.blo;
|
|
67
|
+
const bloDir = vscode_uri_1.Utils.joinPath(cwd, workingPath);
|
|
68
|
+
try {
|
|
69
|
+
await execShell(bloDir, buildCommand);
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
if (e.code) {
|
|
73
|
+
throw new Error('Build BLO failed');
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
throw e;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
Shell.tryBuildBlo = tryBuildBlo;
|
|
82
|
+
})(Shell || (exports.Shell = Shell = {}));
|
|
83
|
+
/**
|
|
84
|
+
* Generic shell executor
|
|
85
|
+
* @param cwd - working dir where the command should be executed in
|
|
86
|
+
* @param cmd - the shell command
|
|
87
|
+
*/
|
|
88
|
+
async function execShell(cwd, cmd) {
|
|
89
|
+
return new Promise((resolve, reject) => {
|
|
90
|
+
// todo use spawn instead of exec to allow streaming to the console
|
|
91
|
+
child_process.exec(cmd, { cwd: cwd.fsPath, env: process.env }, (error, stdout, stderr) => {
|
|
92
|
+
console.log(stdout);
|
|
93
|
+
console.error(stderr);
|
|
94
|
+
if (error) {
|
|
95
|
+
reject(error);
|
|
96
|
+
}
|
|
97
|
+
resolve(null);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=scriptRunner.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microtronics/studio-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Microtronics Studio CLI Tool",
|
|
5
5
|
"main": "./out/api.js",
|
|
6
6
|
"typings": "./dist/studio-cli.d.ts",
|
|
@@ -30,6 +30,8 @@
|
|
|
30
30
|
"ajv-keywords": "^5.1.0",
|
|
31
31
|
"commander": "^12.1.0",
|
|
32
32
|
"cross-fetch": "^4.0.0",
|
|
33
|
+
"glob": "^11.0.0",
|
|
34
|
+
"iconv-lite": "^0.6.3",
|
|
33
35
|
"ini": "^5.0.0",
|
|
34
36
|
"openapi-fetch": "^0.13.0",
|
|
35
37
|
"pako": "^2.1.0",
|
|
@@ -43,10 +45,10 @@
|
|
|
43
45
|
"node": ">= 20"
|
|
44
46
|
},
|
|
45
47
|
"devDependencies": {
|
|
46
|
-
"@types/ini": "^4.1.1",
|
|
47
48
|
"@microsoft/api-extractor": "^7.47.11",
|
|
48
49
|
"@types/chai": "^4.3.6",
|
|
49
50
|
"@types/chai-as-promised": "^7.1.5",
|
|
51
|
+
"@types/ini": "^4.1.1",
|
|
50
52
|
"@types/mocha": "^10.0.9",
|
|
51
53
|
"@types/node": "^22.9.1",
|
|
52
54
|
"@types/semver": "^7.5.6",
|