@tsplc/build 0.2.6 → 0.2.8
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/cli.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/python/build.py +160 -291
- package/python/codesys_online.py +18 -40
- package/python/hardware.py +261 -0
- package/python/test_build.py +105 -17
- package/python/test_codesys_online.py +31 -12
- package/src/controller-session.ts +9 -5
- package/src/host/codesys-worker.ts +8 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
-
import {
|
|
2
|
+
import { cp, mkdir, readdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import type { ResolvedConfig } from "./config";
|
|
@@ -123,12 +123,11 @@ export const runControllerSession = async (
|
|
|
123
123
|
const candidate = resolve(root, "generations", generation);
|
|
124
124
|
const project = resolve(candidate, "project", "Application.project");
|
|
125
125
|
await mkdir(resolve(candidate, "project"), { recursive: true });
|
|
126
|
+
// A download saves the template here, with its controller and device tree.
|
|
126
127
|
if (previous) {
|
|
127
128
|
await cp(previous.project, resolve(candidate, "project"), {
|
|
128
129
|
recursive: true,
|
|
129
130
|
});
|
|
130
|
-
} else {
|
|
131
|
-
await copyFile(config.template, project);
|
|
132
131
|
}
|
|
133
132
|
const jobConfig = {
|
|
134
133
|
...config,
|
|
@@ -140,11 +139,16 @@ export const runControllerSession = async (
|
|
|
140
139
|
const request = {
|
|
141
140
|
libraryReferences: config.libraryReferences,
|
|
142
141
|
// A download starts from the template; an online change keeps the downloaded project's tree.
|
|
143
|
-
...(
|
|
144
|
-
|
|
142
|
+
...(operation === "download" && {
|
|
143
|
+
template: await toWindowsPath(config.template, config.codesys.wine),
|
|
144
|
+
templateHash,
|
|
145
|
+
// Kept across jobs: generating a device tree takes minutes, and the same inputs make the same one.
|
|
146
|
+
caches: await toWindowsPath(root, config.codesys.wine),
|
|
147
|
+
...(config.deviceTree && {
|
|
145
148
|
deviceTree: await writeDeviceTree(config.deviceTree, requestDirectory),
|
|
146
149
|
devices: await toWindowsPath(requestDirectory, config.codesys.wine),
|
|
147
150
|
}),
|
|
151
|
+
}),
|
|
148
152
|
libraries: await Promise.all(
|
|
149
153
|
(config.libraries ?? []).map(async (library) => ({
|
|
150
154
|
...library,
|
|
@@ -218,6 +218,7 @@ export const createCodesysWorker = (config: ResolvedConfig) => {
|
|
|
218
218
|
.update(
|
|
219
219
|
JSON.stringify({
|
|
220
220
|
builder: await readFile(resolve(pythonDirectory, "build.py"), "utf8"),
|
|
221
|
+
hardware: await readFile(resolve(pythonDirectory, "hardware.py"), "utf8"),
|
|
221
222
|
online: await readFile(resolve(pythonDirectory, "codesys_online.py"), "utf8"),
|
|
222
223
|
login: await readFile(resolve(pythonDirectory, "codesys_login.py"), "utf8"),
|
|
223
224
|
command: codesysCommand,
|
|
@@ -244,9 +245,13 @@ export const createCodesysWorker = (config: ResolvedConfig) => {
|
|
|
244
245
|
const directory = resolve(config.outDir, ".codesys/worker");
|
|
245
246
|
await rm(directory, { recursive: true, force: true });
|
|
246
247
|
await mkdir(directory, { recursive: true });
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
for (const script of [
|
|
249
|
+
"build.py",
|
|
250
|
+
"hardware.py",
|
|
251
|
+
"worker.py",
|
|
252
|
+
"codesys_online.py",
|
|
253
|
+
"codesys_login.py",
|
|
254
|
+
]) {
|
|
250
255
|
await copyFile(resolve(pythonDirectory, script), resolve(directory, script));
|
|
251
256
|
}
|
|
252
257
|
console.log(`Starting CODESYS. Log: ${directory}/codesys.log`);
|