@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 CHANGED
@@ -1,5 +1,15 @@
1
1
 
2
2
 
3
+ ## 0.7.0 (2024-12-16)
4
+
5
+
6
+ ### Features
7
+
8
+ * **studio-cli:** dlo compiler returns errors as diagnostic information ([eb14ac9](https://bitbucket.org/microtronics-core/vscode-studio/commits/eb14ac9460d3dfd3be9221adde0a87e15eb13cd9))
9
+ * **studio-cli:** first working version of dlo compiler ([158e85f](https://bitbucket.org/microtronics-core/vscode-studio/commits/158e85f3e51a9288835017b928e8306896f5655e))
10
+ * **studio-cli:** implement `findFiles` function ([984ab83](https://bitbucket.org/microtronics-core/vscode-studio/commits/984ab83aacb1fbbd06b8b4ce7a88095a346470a1))
11
+ * **studio-cli:** moved dlo precompiler to the cli ([3087cbc](https://bitbucket.org/microtronics-core/vscode-studio/commits/3087cbcbe9fb494bf368ee50f6774be80c80987d))
12
+
3
13
  ## 0.6.1 (2024-12-12)
4
14
 
5
15
 
@@ -1344,6 +1344,7 @@ export declare namespace DefaultFiles {
1344
1344
  legacyAutoDdeInc: string;
1345
1345
  legacyAutoUplinkInc: string;
1346
1346
  reportTemplate: string;
1347
+ dloCfg: string;
1347
1348
  };
1348
1349
  const filePaths: {
1349
1350
  studio: {
@@ -1360,12 +1361,14 @@ export declare namespace DefaultFiles {
1360
1361
  legacyAutoInc: string;
1361
1362
  legacyAutoDdeInc: string;
1362
1363
  legacyAutoUplinkInc: string;
1364
+ cfg: string;
1363
1365
  };
1364
1366
  };
1365
1367
  libdeps: string;
1366
1368
  };
1367
1369
  dist: {
1368
1370
  path: string;
1371
+ dloPath: string;
1369
1372
  mainAmxPath: string;
1370
1373
  mainAmxReportPath: string;
1371
1374
  ddeXmlPath: string;
@@ -1521,6 +1524,73 @@ export declare namespace Diagnostics {
1521
1524
  }
1522
1525
  }
1523
1526
 
1527
+ export declare namespace DLO {
1528
+ const FileSequencer: typeof DloFileSequencer;
1529
+ export type FileSequencer = DloFileSequencer;
1530
+ const PreCompiler: typeof DloPreCompiler;
1531
+ export type PreCompiler = DloPreCompiler;
1532
+ /**
1533
+ * The DLO Compiler
1534
+ */
1535
+ const Compiler: typeof DloCompiler;
1536
+ export type Compiler = DloCompiler;
1537
+ /**
1538
+ * Generate the dlo.cfg file and write it to the .studio/auto/dlo directory
1539
+ * @param cwd
1540
+ * @param fs
1541
+ */
1542
+ export function exportDloConfig(cwd: URI, fs: LocalFS): Promise<void>;
1543
+ }
1544
+
1545
+ declare class DloCompiler {
1546
+ private preCompiler;
1547
+ private pawnCC;
1548
+ private stdout;
1549
+ private stderr;
1550
+ constructor();
1551
+ private initPawnCC;
1552
+ private get MEMFS();
1553
+ compile(cwd: URI, fs: LocalFS): Promise<{
1554
+ code: number;
1555
+ stdout: string[];
1556
+ stderr: string[];
1557
+ diagnostics: Diagnostics.File[];
1558
+ }>;
1559
+ private persistGeneratedFiles;
1560
+ private readConfigFile;
1561
+ /**
1562
+ * Precompile the given file and pass it to the MEMFS
1563
+ * @param cwd
1564
+ * @param fs
1565
+ * @param manifest
1566
+ * @private
1567
+ */
1568
+ private memFSwriteFile;
1569
+ private memFSmkdir;
1570
+ private memFSstat;
1571
+ private parseWarningsAndErrors;
1572
+ }
1573
+
1574
+ declare class DloFileSequencer {
1575
+ private readonly dloFileMap;
1576
+ private rootUri;
1577
+ constructor();
1578
+ set workspacePath(workspacePath: URI);
1579
+ getSequenceForFile(filePath: string): string;
1580
+ getFilePathForSequence(sequenceId: string): string | null;
1581
+ }
1582
+
1583
+ declare class DloPreCompiler {
1584
+ private pragmaDynamic;
1585
+ private dloFileSequencer;
1586
+ constructor();
1587
+ get pragmaDynamicFlag(): string | null;
1588
+ preCompileDloFile(cwd: URI, manifest: Manifest.Manifest, fileUri: URI, fileBlob: string[]): Promise<{
1589
+ diagnostics: Diagnostics.File[];
1590
+ data: string;
1591
+ }>;
1592
+ }
1593
+
1524
1594
  /**
1525
1595
  * Permissions of a file.
1526
1596
  */
@@ -1611,6 +1681,24 @@ export declare namespace Globals {
1611
1681
  export function read(cwd: URI, fs: LocalFS): Promise<Defines>;
1612
1682
  }
1613
1683
 
1684
+ /**
1685
+ * A file glob pattern to match file paths against. This can either be a glob pattern string
1686
+ *
1687
+ * Glob patterns can have the following syntax:
1688
+ * * `*` to match zero or more characters in a path segment
1689
+ * * `?` to match on one character in a path segment
1690
+ * * `**` to match any number of path segments, including none
1691
+ * * `{}` to group conditions matches all TypeScript and JavaScript files)
1692
+ * * `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)
1693
+ * * `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)
1694
+ *
1695
+ * Note: a backslash (`\`) is not valid within a glob pattern. If you have an existing file
1696
+ * path to match against, consider to use the {@link RelativePattern relative pattern} support
1697
+ * that takes care of converting any backslash into slash. Otherwise, make sure to convert
1698
+ * any backslash to slash when creating the glob pattern.
1699
+ */
1700
+ declare type GlobPattern = string;
1701
+
1614
1702
  export declare namespace Helper {
1615
1703
  /**
1616
1704
  * Convert yaml range to an valid vscode line information
@@ -1653,6 +1741,22 @@ declare interface LocalFS {
1653
1741
  */
1654
1742
  readFile: (path: URI) => Promise<Uint8Array>;
1655
1743
  stat: (path: URI) => Promise<FileStat | null>;
1744
+ /**
1745
+ * Find files across all folders
1746
+ *
1747
+ *
1748
+ * @param include A {@link GlobPattern glob pattern} that defines the files to search for. The glob pattern
1749
+ * will be matched against the file paths of resulting matches relative to their workspace. Use a {@link RelativePattern relative pattern}
1750
+ * to restrict the search results to a {@link WorkspaceFolder workspace folder}.
1751
+ * @param exclude A {@link GlobPattern glob pattern} that defines files and folders to exclude. The glob pattern
1752
+ * will be matched against the file paths of resulting matches relative to their workspace. When `undefined`, default file-excludes (e.g. the `files.exclude`-setting
1753
+ * but not `search.exclude`) will apply. When `null`, no excludes will apply.
1754
+ * @param maxResults An upper-bound for the result.
1755
+ * @param token A token that can be used to signal cancellation to the underlying search engine.
1756
+ * @return A thenable that resolves to an array of resource identifiers. Will return no results if no
1757
+ * {@link workspace.workspaceFolders workspace folders} are opened.
1758
+ */
1759
+ findFiles: (cwd: URI, include: GlobPattern, exclude?: GlobPattern) => Promise<URI[]>;
1656
1760
  }
1657
1761
 
1658
1762
  export declare namespace Manifest {
package/out/FS.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"FS.d.ts","sourceRoot":"","sources":["../src/FS.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,MAAM,WAAW,OAAO;IACvB;;;OAGG;IACH,EAAE,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAChC;;;;OAIG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,UAAU,GAAG,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACrE;;;OAGG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7C,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;CAC9C;AACD;;;;GAIG;AACH,oBAAY,QAAQ;IACnB;;OAEG;IACH,OAAO,IAAI;IACX;;OAEG;IACH,IAAI,IAAI;IACR;;OAEG;IACH,SAAS,IAAI;IACb;;OAEG;IACH,YAAY,KAAK;CACjB;AAED;;GAEG;AACH,oBAAY,cAAc;IACzB;;;;;;;OAOG;IACH,QAAQ,IAAI;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB;;;;;OAKG;IACH,IAAI,EAAE,QAAQ,CAAC;IACf;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;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,CAAC;IACf;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,GAAG,GAAG,UAazD;AACD,wBAAgB,WAAW,CAAC,iBAAiB,GAAE,MAAW,UAEzD;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,UAAU,GAAG,GAAG,GAAG,MAAM,EAAE,CAOzE"}
package/out/FS.js CHANGED
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FilePermission = exports.FileType = void 0;
4
4
  exports.convertBlobToString = convertBlobToString;
5
+ exports.normalizeLF = normalizeLF;
6
+ exports.convertBlobToStringArray = convertBlobToStringArray;
5
7
  /**
6
8
  * Enumeration of file types. The types `File` and `Directory` can also be
7
9
  * a symbolic links, in that case use `FileType.File | FileType.SymbolicLink` and
@@ -57,4 +59,16 @@ function convertBlobToString(blob) {
57
59
  return '';
58
60
  }
59
61
  }
62
+ function normalizeLF(stringToNormalize = '') {
63
+ return stringToNormalize.replace(/\r\n|\n\r|\r/g, '\n');
64
+ }
65
+ function convertBlobToStringArray(blob) {
66
+ try {
67
+ const textData = convertBlobToString(blob).trim();
68
+ return normalizeLF(textData).split('\n');
69
+ }
70
+ catch (e) {
71
+ return [];
72
+ }
73
+ }
60
74
  //# sourceMappingURL=FS.js.map
package/out/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QA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AAQ,EACR,QAAQ,EACR,GAAG,EACH,MAAM,EACN,WAAW,EACX,YAAY,EACZ,cAAc,EACd,OAAO,EACP,GAAG,EACH,CAAC"}
package/out/api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Globals = exports.DeviceProfiles = exports.DefaultFiles = exports.Diagnostics = exports.Helper = exports.DDE = exports.DDE_Core = exports.Registry = exports.Manifest = exports.Dependencies = void 0;
3
+ exports.DLO = exports.Globals = exports.DeviceProfiles = exports.DefaultFiles = exports.Diagnostics = exports.Helper = exports.DDE = exports.DDE_Core = exports.Registry = exports.Manifest = exports.Dependencies = void 0;
4
4
  const dependencies_1 = require("./dependencies");
5
5
  Object.defineProperty(exports, "Dependencies", { enumerable: true, get: function () { return dependencies_1.Dependencies; } });
6
6
  const manifest_1 = require("./manifest");
@@ -21,4 +21,6 @@ const DeviceProfiles_1 = require("./DeviceProfiles");
21
21
  Object.defineProperty(exports, "DeviceProfiles", { enumerable: true, get: function () { return DeviceProfiles_1.DeviceProfiles; } });
22
22
  const globals_1 = require("./globals");
23
23
  Object.defineProperty(exports, "Globals", { enumerable: true, get: function () { return globals_1.Globals; } });
24
+ const dlo_1 = require("./dlo/dlo");
25
+ Object.defineProperty(exports, "DLO", { enumerable: true, get: function () { return dlo_1.DLO; } });
24
26
  //# sourceMappingURL=api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cliFS.d.ts","sourceRoot":"","sources":["../src/cliFS.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,OAAO,EAAE,MAAM,MAAM,CAAC;AAInD,eAAO,MAAM,KAAK,EAAE,OAmCnB,CAAC"}
1
+ {"version":3,"file":"cliFS.d.ts","sourceRoot":"","sources":["../src/cliFS.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,OAAO,EAAE,MAAM,MAAM,CAAC;AAIhE,eAAO,MAAM,KAAK,EAAE,OAkDnB,CAAC"}
package/out/cliFS.js CHANGED
@@ -7,7 +7,7 @@ exports.cliFS = void 0;
7
7
  const promises_1 = __importDefault(require("node:fs/promises"));
8
8
  const FS_1 = require("./FS");
9
9
  const vscode_uri_1 = require("vscode-uri");
10
- var dirname = vscode_uri_1.Utils.dirname;
10
+ const glob_1 = require("glob");
11
11
  exports.cliFS = {
12
12
  readFile(path) {
13
13
  return promises_1.default.readFile(path.fsPath);
@@ -39,9 +39,23 @@ exports.cliFS = {
39
39
  if (typeof content === 'string') {
40
40
  content = new TextEncoder().encode(content);
41
41
  }
42
- const dirPath = dirname(path);
42
+ const dirPath = vscode_uri_1.Utils.dirname(path);
43
43
  await promises_1.default.mkdir(dirPath.fsPath, { recursive: true });
44
44
  return promises_1.default.writeFile(path.fsPath, content, { flag: 'w' });
45
+ },
46
+ async findFiles(cwd, include, exclude) {
47
+ const options = {
48
+ ignore: exclude,
49
+ nodir: true,
50
+ absolute: true,
51
+ dot: true,
52
+ cwd: vscode_uri_1.Utils.dirname(cwd).fsPath
53
+ };
54
+ const files = await (0, glob_1.glob)(include, options);
55
+ return files.map(file => {
56
+ const posix = file.replace(/\\/g, '/');
57
+ return vscode_uri_1.URI.parse(`file:///${posix}`);
58
+ });
45
59
  }
46
60
  };
47
61
  //# sourceMappingURL=cliFS.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dlo.d.ts","sourceRoot":"","sources":["../../../src/dde/fileGenerators/dlo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,OAAO,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;AAUlC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,GAAG,EAAS,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAuBnC,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OA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AAC,gBAAgB;IAwBxB,OAAO,CAAC,8BAA8B;IAoEtC,OAAO,CAAC,uBAAuB;IAY/B,OAAO,CAAC,yBAAyB;IAgBjC,OAAO,CAAC,uBAAuB;IA8D/B,OAAO,CAAC,6BAA6B;IASrC,OAAO,CAAC,2BAA2B;IAmBnC;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,0BAA0B;IA8BlC,OAAO,CAAC,mBAAmB;IAiD3B;;;;;;OAMG;IACH,OAAO,CAAC,4BAA4B;IAIpC,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,sBAAsB;IAmC9B,OAAO,CAAC,iBAAiB;IAoDzB;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;CA6B7B;AAGD,wBAAgB,4BAA4B,CAC3C,MAAM,EAAE,OAAO;AACf;;GAEG;AACH,gBAAgB,EAAE,MAAM,EAAE,UAsI1B;AAID,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,OAAO,UAqExD;AAqBD;;GAEG;AAEH;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,mBAmB1D"}
@@ -891,7 +891,6 @@ function generateMainDDEFunctionBody(pawnSource, containerDefinition, readWrite)
891
891
  * Generate the default.inc file
892
892
  * @param cwd
893
893
  * @param fs
894
- * @param dependencies
895
894
  */
896
895
  async function buildDefaultInc(cwd, fs) {
897
896
  const fileContent = [];
@@ -1 +1 @@
1
- {"version":3,"file":"defaultFiles.d.ts","sourceRoot":"","sources":["../src/defaultFiles.ts"],"names":[],"mappings":"AAMA,yBAAiB,YAAY,CAAC;IACtB,MAAM,SAAS;;;;;;;;;;;;;;;;;KAkBrB,CAAC;IAIK,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkDrB,CAAC;CACF"}
1
+ {"version":3,"file":"defaultFiles.d.ts","sourceRoot":"","sources":["../src/defaultFiles.ts"],"names":[],"mappings":"AAMA,yBAAiB,YAAY,CAAC;IACtB,MAAM,SAAS;;;;;;;;;;;;;;;;;;KAmBrB,CAAC;IAIK,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoDrB,CAAC;CACF"}
@@ -25,7 +25,8 @@ var DefaultFiles;
25
25
  legacyAutoInc: 'legacy-auto.inc',
26
26
  legacyAutoDdeInc: 'legacy-auto-dde.inc',
27
27
  legacyAutoUplinkInc: 'legacy-auto-uplink.inc',
28
- reportTemplate: 'mdn_report_template.json'
28
+ reportTemplate: 'mdn_report_template.json',
29
+ dloCfg: 'dlo.cfg'
29
30
  };
30
31
  const studioAutoPath = `${studioDirectoryName}auto/`;
31
32
  const studioAutoDloPath = `${studioAutoPath}dlo/`;
@@ -45,13 +46,15 @@ var DefaultFiles;
45
46
  mainDdeInc: `${studioAutoDloPath}${DefaultFiles.fileNames.mainDdeInc}`,
46
47
  legacyAutoInc: `${studioAutoDloPath}${DefaultFiles.fileNames.legacyAutoInc}`,
47
48
  legacyAutoDdeInc: `${studioAutoDloPath}${DefaultFiles.fileNames.legacyAutoDdeInc}`,
48
- legacyAutoUplinkInc: `${studioAutoDloPath}${DefaultFiles.fileNames.legacyAutoUplinkInc}`
49
+ legacyAutoUplinkInc: `${studioAutoDloPath}${DefaultFiles.fileNames.legacyAutoUplinkInc}`,
50
+ cfg: `${studioAutoDloPath}${DefaultFiles.fileNames.dloCfg}`
49
51
  }
50
52
  },
51
53
  libdeps: `${studioDirectoryName}libdeps/`
52
54
  },
53
55
  dist: {
54
56
  path: deployDirectoryName,
57
+ dloPath: `${deployDirectoryName}dlo/`,
55
58
  mainAmxPath: `${deployDirectoryName}dlo/${DefaultFiles.fileNames.mainAmx}`,
56
59
  mainAmxReportPath: `${deployDirectoryName}dlo/${DefaultFiles.fileNames.mainAmxReport}`,
57
60
  ddeXmlPath: `${deployDirectoryName}dde/${DefaultFiles.fileNames.ddeXml}`,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../src/dlo/compiler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAS,MAAM,YAAY,CAAC;AACxC,OAAO,EAA4B,OAAO,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAO7C,qBAAa,WAAW;IACvB,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAgB;;YAKhB,UAAU;IAiBxB,OAAO,KAAK,KAAK,GAEhB;IAEY,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO;;;;;;YAkC5B,qBAAqB;YAarB,cAAc;IAS5B;;;;;;OAMG;YACW,cAAc;IAkB5B,OAAO,CAAC,UAAU;IAiBlB,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,sBAAsB;CA+C9B;AAMD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ;;;GAwB1F"}
@@ -0,0 +1,237 @@
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.DloCompiler = void 0;
27
+ exports.generateConfigFile = generateConfigFile;
28
+ const preCompiler_1 = require("./preCompiler");
29
+ const vscode_uri_1 = require("vscode-uri");
30
+ const FS_1 = require("../FS");
31
+ const manifest_1 = require("../manifest");
32
+ const defaultFiles_1 = require("../defaultFiles");
33
+ const dependencies_1 = require("../dependencies");
34
+ const iconv = __importStar(require("iconv-lite"));
35
+ const PAWN_MODULE = require('./dlocc.js');
36
+ class DloCompiler {
37
+ preCompiler = new preCompiler_1.DloPreCompiler();
38
+ pawnCC;
39
+ stdout = [];
40
+ stderr = [];
41
+ constructor() {
42
+ this.pawnCC = null;
43
+ }
44
+ async initPawnCC() {
45
+ this.stdout.length = 0;
46
+ this.stderr.length = 0;
47
+ this.pawnCC = await PAWN_MODULE({
48
+ noExitRuntime: true,
49
+ print: (data) => {
50
+ console.log(data);
51
+ this.stdout.push(data);
52
+ },
53
+ printErr: (err) => {
54
+ console.error(err);
55
+ this.stderr.push(err);
56
+ this.stdout.push(err);
57
+ }
58
+ });
59
+ }
60
+ get MEMFS() {
61
+ return this.pawnCC.FS;
62
+ }
63
+ async compile(cwd, fs) {
64
+ const manifest = await manifest_1.Manifest.read(cwd, fs);
65
+ await this.initPawnCC();
66
+ const precompilerDiagnostics = await this.memFSwriteFile(cwd, fs, manifest);
67
+ const mainFile = vscode_uri_1.Utils.joinPath(cwd, manifest.dlo?.mainFile || defaultFiles_1.DefaultFiles.filePaths.dlo.mainDLO);
68
+ const options = [];
69
+ // todo only add cfg file to options if not already set!
70
+ const configFilePath = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.cfg);
71
+ options.push(...(await this.readConfigFile(fs, configFilePath)));
72
+ if (this.preCompiler.pragmaDynamicFlag) {
73
+ options.push(this.preCompiler.pragmaDynamicFlag);
74
+ }
75
+ let exitCode = 0;
76
+ try {
77
+ exitCode = await this.pawnCC.callMain([uriToMemFsPath(mainFile), ...options]);
78
+ // compiler doesn't have any errors
79
+ if (exitCode === 0) {
80
+ await this.persistGeneratedFiles(cwd, fs, mainFile);
81
+ }
82
+ }
83
+ catch (e) {
84
+ console.error(e);
85
+ }
86
+ return {
87
+ code: exitCode,
88
+ stdout: this.stdout,
89
+ stderr: this.stderr,
90
+ diagnostics: [...precompilerDiagnostics, ...this.parseWarningsAndErrors(this.stderr, mainFile)]
91
+ };
92
+ }
93
+ async persistGeneratedFiles(cwd, fs, mainFile) {
94
+ const baseName = vscode_uri_1.Utils.basename(mainFile).split('.')[0];
95
+ const possibleFiles = this.MEMFS.readdir('/');
96
+ for (const fileName of possibleFiles) {
97
+ if (fileName.startsWith(baseName)) {
98
+ const blob = this.MEMFS.readFile(fileName);
99
+ const distPath = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.dist.dloPath, fileName);
100
+ await fs.writeFile(distPath, blob);
101
+ }
102
+ }
103
+ }
104
+ async readConfigFile(fs, configPath) {
105
+ if (await fs.stat(configPath)) {
106
+ const content = await fs.readFile(configPath);
107
+ return (0, FS_1.convertBlobToStringArray)(content);
108
+ }
109
+ else {
110
+ return [];
111
+ }
112
+ }
113
+ /**
114
+ * Precompile the given file and pass it to the MEMFS
115
+ * @param cwd
116
+ * @param fs
117
+ * @param manifest
118
+ * @private
119
+ */
120
+ async memFSwriteFile(cwd, fs, manifest) {
121
+ const files = await fs.findFiles(cwd, '**/*.{dlo,inc}');
122
+ const precompilerDiagnostics = [];
123
+ // add dlo.cfg file to the file list
124
+ for (const file of files) {
125
+ if (await fs.stat(file)) {
126
+ const content = await fs.readFile(file);
127
+ const stringBlob = (0, FS_1.convertBlobToStringArray)(content);
128
+ const preCompiled = await this.preCompiler.preCompileDloFile(cwd, manifest, file, stringBlob);
129
+ precompilerDiagnostics.push(...preCompiled.diagnostics);
130
+ this.memFSmkdir(file);
131
+ this.MEMFS.writeFile(uriToMemFsPath(file), iconv.encode(preCompiled.data, 'cp1252'));
132
+ }
133
+ }
134
+ return precompilerDiagnostics;
135
+ }
136
+ memFSmkdir(uri) {
137
+ const split = uriToMemFsPath(vscode_uri_1.Utils.dirname(uri)).split('/');
138
+ let dirname = '';
139
+ split.forEach(folder => {
140
+ if (!folder) {
141
+ return;
142
+ }
143
+ try {
144
+ dirname += `${folder}/`;
145
+ if (!this.memFSstat(dirname)) {
146
+ this.MEMFS.mkdir(dirname);
147
+ }
148
+ }
149
+ catch (e) {
150
+ console.error('ensureDir', e);
151
+ }
152
+ });
153
+ }
154
+ memFSstat(dirname) {
155
+ try {
156
+ this.MEMFS.stat(dirname);
157
+ return true;
158
+ }
159
+ catch (e) {
160
+ return false;
161
+ }
162
+ }
163
+ parseWarningsAndErrors(stderr, relatedFile) {
164
+ const compilerDiagnostics = [];
165
+ const messages = stderr.filter(line => !!line.trim());
166
+ for (const message of messages) {
167
+ if ((message.includes('Assertion failed:') || message.includes('Compilation aborted.')) && relatedFile) {
168
+ compilerDiagnostics.push({
169
+ file: relatedFile,
170
+ level: 'error',
171
+ line: 0,
172
+ message: message
173
+ });
174
+ continue;
175
+ }
176
+ // regular error/warning - such as:
177
+ // C:\Users\aai\rmstudio\apmparts\dlo-pawn\stdlib\rm-dde.inc(392) : error 036: empty statement
178
+ // main.p(138) : warning 203: symbol is never used: "log_str"
179
+ // main.p(6) : fatal error 100: cannot read from file: "oTests/module_t"
180
+ const i0 = message.indexOf(' : ');
181
+ const i1 = message.indexOf(': ', i0 + 3);
182
+ const fileNameAndLineNumber = message.substring(0, i0).trim();
183
+ const levelAndCode = message.substring(i0 + 3, i1).trim();
184
+ const msg = message.substring(i1 + 2).trim();
185
+ // ignore lines which do not contain err/warn msg (or are empty)
186
+ if (!fileNameAndLineNumber || !levelAndCode || !msg) {
187
+ continue;
188
+ }
189
+ const [fileName, lineNumber] = fileNameAndLineNumber.split(/[()(-)]/);
190
+ const decodeLevelAndCode = levelAndCode.split(' ');
191
+ const level = decodeLevelAndCode[decodeLevelAndCode.length - 2]; //lvl is always the second last
192
+ let posix = fileName.replace(/\\/g, '/');
193
+ if (posix.startsWith('/')) {
194
+ posix = posix.substring(1);
195
+ }
196
+ compilerDiagnostics.push({
197
+ file: vscode_uri_1.URI.parse(`file:///${posix}`),
198
+ level,
199
+ line: Number(lineNumber) - 1,
200
+ message: msg
201
+ });
202
+ }
203
+ return compilerDiagnostics;
204
+ }
205
+ }
206
+ exports.DloCompiler = DloCompiler;
207
+ function uriToMemFsPath(path) {
208
+ return path.fsPath.replace(/\\/g, '/');
209
+ }
210
+ /**
211
+ * Generates the DLO .cfg file for the dlo compiler
212
+ * @param cwd
213
+ * @param fs
214
+ * @param manifest
215
+ */
216
+ async function generateConfigFile(cwd, fs, manifest) {
217
+ const compileOptions = [
218
+ '-M', //map output for pawndbg to generate link map
219
+ '-v2' // verbosity of stdout -> 0=quiet, 1=normal, 2=code/data/stack usage report
220
+ ];
221
+ const defaultIncPath = vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.defaultInc);
222
+ compileOptions.push(`-p${uriToMemFsPath(defaultIncPath)}`);
223
+ const dloLibs = await dependencies_1.Dependencies.getDloDependencies(cwd, fs);
224
+ for (const dloLib of dloLibs) {
225
+ const dirName = vscode_uri_1.Utils.dirname(dloLib.path);
226
+ compileOptions.push(`-i${uriToMemFsPath(dirName)}`);
227
+ }
228
+ const dloConfiguration = manifest.dlo;
229
+ if (dloConfiguration) {
230
+ compileOptions.push(...dloConfiguration.compileOptions);
231
+ }
232
+ return {
233
+ path: vscode_uri_1.Utils.joinPath(cwd, defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.cfg),
234
+ data: compileOptions.join('\n')
235
+ };
236
+ }
237
+ //# sourceMappingURL=compiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dlo.d.ts","sourceRoot":"","sources":["../../src/dlo/dlo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,WAAW,EAAsB,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAGjC,yBAAiB,GAAG,CAAC;IACb,MAAM,aAAa,yBAAmB,CAAC;IAC9C,KAAY,aAAa,GAAG,gBAAgB,CAAC;IAEtC,MAAM,WAAW,uBAAiB,CAAC;IAC1C,KAAY,WAAW,GAAG,cAAc,CAAC;IAEzC;;OAEG;IACI,MAAM,QAAQ,oBAAc,CAAC;IACpC,KAAY,QAAQ,GAAG,WAAW,CAAC;IAEnC;;;;OAIG;IACH,SAAsB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,OAAO,iBAK1D;CACD"}
package/out/dlo/dlo.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DLO = void 0;
4
+ const fileSequencer_1 = require("./fileSequencer");
5
+ const preCompiler_1 = require("./preCompiler");
6
+ const manifest_1 = require("../manifest");
7
+ const compiler_1 = require("./compiler");
8
+ const defaultFiles_1 = require("../defaultFiles");
9
+ var DLO;
10
+ (function (DLO) {
11
+ DLO.FileSequencer = fileSequencer_1.DloFileSequencer;
12
+ DLO.PreCompiler = preCompiler_1.DloPreCompiler;
13
+ /**
14
+ * The DLO Compiler
15
+ */
16
+ DLO.Compiler = compiler_1.DloCompiler;
17
+ /**
18
+ * Generate the dlo.cfg file and write it to the .studio/auto/dlo directory
19
+ * @param cwd
20
+ * @param fs
21
+ */
22
+ async function exportDloConfig(cwd, fs) {
23
+ const manifest = await manifest_1.Manifest.read(cwd, fs);
24
+ const cfgData = await (0, compiler_1.generateConfigFile)(cwd, fs, manifest);
25
+ await fs.writeFile(cfgData.path, cfgData.data);
26
+ console.log('Generated', defaultFiles_1.DefaultFiles.filePaths.studio.auto.dlo.cfg);
27
+ }
28
+ DLO.exportDloConfig = exportDloConfig;
29
+ })(DLO || (exports.DLO = DLO = {}));
30
+ //# sourceMappingURL=dlo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dlocc.d.ts","sourceRoot":"","sources":["../../src/dlo/dlocc.js"],"names":[],"mappings":";AAGQ,6CA8kHN"}