@microtronics/studio-cli 0.6.1 → 0.7.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 +10 -0
- package/dist/studio-cli.d.ts +104 -0
- package/out/FS.d.ts.map +1 -1
- package/out/FS.js +14 -0
- 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/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 +237 -0
- package/out/dlo/dlo.d.ts.map +1 -0
- package/out/dlo/dlo.js +30 -0
- package/out/dlo/dlocc.d.ts.map +1 -0
- package/out/dlo/dlocc.js +3904 -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/main.js +10 -2
- package/package.json +73 -71
|
@@ -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/main.js
CHANGED
|
@@ -11,6 +11,8 @@ 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");
|
|
14
16
|
const program = new commander_1.Command();
|
|
15
17
|
// dummy cwd
|
|
16
18
|
const devPath = process.env.NODE_ENV === 'local-dev' ? './dev' : '';
|
|
@@ -53,9 +55,9 @@ program
|
|
|
53
55
|
});
|
|
54
56
|
program
|
|
55
57
|
.command('build')
|
|
56
|
-
.arguments('[dde]
|
|
58
|
+
.arguments('[dde] [dlo]') // [pov] ....
|
|
57
59
|
.action(async (apmPart) => {
|
|
58
|
-
if (apmPart === 'dde') {
|
|
60
|
+
if (!apmPart || apmPart === 'dde') {
|
|
59
61
|
const result = await dde_1.DDE.compileDDE(cwd, cliFS_1.cliFS);
|
|
60
62
|
result.diagnostics.forEach(diagnostic => {
|
|
61
63
|
const message = `${diagnostic.file.path}: ${diagnostic.message}`;
|
|
@@ -74,11 +76,17 @@ program
|
|
|
74
76
|
await dde_1.DDE.exportHistoryJson(cwd, cliFS_1.cliFS, result.ddeJSON);
|
|
75
77
|
await dde_1.DDE.exportOpenApi(cwd, cliFS_1.cliFS, result.ddeJSON);
|
|
76
78
|
await dde_1.DDE.exportAutoDloFiles(cwd, cliFS_1.cliFS, result.ddeJSON);
|
|
79
|
+
await dlo_1.DLO.exportDloConfig(cwd, cliFS_1.cliFS);
|
|
77
80
|
}
|
|
78
81
|
else {
|
|
79
82
|
console.error('Project has errors!');
|
|
80
83
|
}
|
|
81
84
|
}
|
|
85
|
+
if (!apmPart || apmPart === 'dlo') {
|
|
86
|
+
//todo skip if manifest.dlo not set!
|
|
87
|
+
const compiler = new compiler_1.DloCompiler();
|
|
88
|
+
await compiler.compile(cwd, cliFS_1.cliFS);
|
|
89
|
+
}
|
|
82
90
|
});
|
|
83
91
|
module.exports = function (argv) {
|
|
84
92
|
program.parse(argv);
|
package/package.json
CHANGED
|
@@ -1,71 +1,73 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@microtronics/studio-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Microtronics Studio CLI Tool",
|
|
5
|
-
"main": "./out/api.js",
|
|
6
|
-
"typings": "./dist/studio-cli.d.ts",
|
|
7
|
-
"bin": {
|
|
8
|
-
"studio-cli": "studio-cli"
|
|
9
|
-
},
|
|
10
|
-
"publishConfig": {
|
|
11
|
-
"access": "public"
|
|
12
|
-
},
|
|
13
|
-
"scripts": {
|
|
14
|
-
"release": "release-it --ci",
|
|
15
|
-
"compile": "npm run build:registryApiTypings && tsc",
|
|
16
|
-
"api": "api-extractor run --local --verbose",
|
|
17
|
-
"build": "npm run compile && npm run api",
|
|
18
|
-
"watch:build": "npm run compile -- --watch",
|
|
19
|
-
"test": "cross-env STUDIO_ENV=lucky mocha",
|
|
20
|
-
"test-ci": "cross-env STUDIO_ENV=lucky mocha --reporter mocha-junit-reporter",
|
|
21
|
-
"watch:test": "npm run test -- --watch",
|
|
22
|
-
"prepublishOnly": "npm run build",
|
|
23
|
-
"build:registryApiTypings": "npx openapi-typescript https://api.registry.stage.microtronics.com/v1/openapi.yaml -o ./src/typings/registry.ts"
|
|
24
|
-
},
|
|
25
|
-
"author": "Microtronics",
|
|
26
|
-
"license": "ISC",
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"ajv": "^8.17.1",
|
|
29
|
-
"ajv-formats": "^3.0.1",
|
|
30
|
-
"ajv-keywords": "^5.1.0",
|
|
31
|
-
"commander": "^12.1.0",
|
|
32
|
-
"cross-fetch": "^4.0.0",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"@
|
|
49
|
-
"@types/chai
|
|
50
|
-
"@types/
|
|
51
|
-
"@types/
|
|
52
|
-
"@types/
|
|
53
|
-
"@types/
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"typescript": "^
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@microtronics/studio-cli",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Microtronics Studio CLI Tool",
|
|
5
|
+
"main": "./out/api.js",
|
|
6
|
+
"typings": "./dist/studio-cli.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"studio-cli": "studio-cli"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"release": "release-it --ci",
|
|
15
|
+
"compile": "npm run build:registryApiTypings && tsc",
|
|
16
|
+
"api": "api-extractor run --local --verbose",
|
|
17
|
+
"build": "npm run compile && npm run api",
|
|
18
|
+
"watch:build": "npm run compile -- --watch",
|
|
19
|
+
"test": "cross-env STUDIO_ENV=lucky mocha",
|
|
20
|
+
"test-ci": "cross-env STUDIO_ENV=lucky mocha --reporter mocha-junit-reporter",
|
|
21
|
+
"watch:test": "npm run test -- --watch",
|
|
22
|
+
"prepublishOnly": "npm run build",
|
|
23
|
+
"build:registryApiTypings": "npx openapi-typescript https://api.registry.stage.microtronics.com/v1/openapi.yaml -o ./src/typings/registry.ts"
|
|
24
|
+
},
|
|
25
|
+
"author": "Microtronics",
|
|
26
|
+
"license": "ISC",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"ajv": "^8.17.1",
|
|
29
|
+
"ajv-formats": "^3.0.1",
|
|
30
|
+
"ajv-keywords": "^5.1.0",
|
|
31
|
+
"commander": "^12.1.0",
|
|
32
|
+
"cross-fetch": "^4.0.0",
|
|
33
|
+
"glob": "^11.0.0",
|
|
34
|
+
"iconv-lite": "^0.6.3",
|
|
35
|
+
"ini": "^5.0.0",
|
|
36
|
+
"openapi-fetch": "^0.13.0",
|
|
37
|
+
"pako": "^2.1.0",
|
|
38
|
+
"semver": "^7.6.3",
|
|
39
|
+
"tarballjs": "github:ankitrohatgi/tarballjs",
|
|
40
|
+
"tinytar-fix": "^0.1.1",
|
|
41
|
+
"vscode-uri": "^3.0.8",
|
|
42
|
+
"yaml": "^2.6.1"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">= 20"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@microsoft/api-extractor": "^7.47.11",
|
|
49
|
+
"@types/chai": "^4.3.6",
|
|
50
|
+
"@types/chai-as-promised": "^7.1.5",
|
|
51
|
+
"@types/ini": "^4.1.1",
|
|
52
|
+
"@types/mocha": "^10.0.9",
|
|
53
|
+
"@types/node": "^22.9.1",
|
|
54
|
+
"@types/semver": "^7.5.6",
|
|
55
|
+
"@types/vscode": "^1.86.2",
|
|
56
|
+
"chai": "^4.3.8",
|
|
57
|
+
"chai-as-promised": "^7.1.2",
|
|
58
|
+
"cross-env": "^7.0.3",
|
|
59
|
+
"mocha": "^10.8.2",
|
|
60
|
+
"mocha-junit-reporter": "^2.2.1",
|
|
61
|
+
"openapi-typescript": "^7.4.3",
|
|
62
|
+
"ts-node": "^10.9.2",
|
|
63
|
+
"typescript": "^5.6.3"
|
|
64
|
+
},
|
|
65
|
+
"mocha": {
|
|
66
|
+
"require": [
|
|
67
|
+
"ts-node/register"
|
|
68
|
+
],
|
|
69
|
+
"watch-files": "src/**",
|
|
70
|
+
"spec": "./test/**/*.spec.ts",
|
|
71
|
+
"recursive": true
|
|
72
|
+
}
|
|
73
|
+
}
|