e7738de6d2
CI / Deep Native Runtime Cases (1/6) (push) Has been skipped
CI / Native Preflight (push) Failing after 1s
CI / Native Runtime Cases (1/2) (push) Failing after 0s
CI / Native Runtime Cases (2/2) (push) Failing after 1s
CI / Native Metadata Reports (push) Failing after 0s
CI / Native Direct Backend Artifacts (push) Failing after 0s
CI / Native Sanitizer Smoke (push) Failing after 1s
CI / Command Contract Snapshots (push) Failing after 1s
CI / Deep Conformance Suite (push) Has been skipped
CI / Graph Build Perf (push) Failing after 1s
CI / Deep Native Preflight (push) Has been skipped
CI / Deep Native Runtime Cases (2/6) (push) Has been skipped
CI / Deep Native Runtime Cases (3/6) (push) Has been skipped
CI / Conformance Suite (push) Failing after 1s
CI / Workspace Checks (push) Failing after 0s
CI / Deep Native Runtime Cases (5/6) (push) Has been skipped
CI / Deep Native Runtime Cases (6/6) (push) Has been skipped
CI / Deep Native Runtime Cases (4/6) (push) Has been skipped
CI / Deep Graph Build Perf (push) Has been skipped
59 lines
1.9 KiB
TypeScript
Executable File
59 lines
1.9 KiB
TypeScript
Executable File
#!/usr/bin/env -S node --experimental-strip-types --disable-warning=ExperimentalWarning
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
const outPath = path.join(repoRoot, "native/zero-c/src/embedded_runtime_sources.inc");
|
|
const inputs = [
|
|
["zero_embedded_zero_runtime_h", "native/zero-c/include/zero_runtime.h"],
|
|
["zero_embedded_zero_runtime_c", "native/zero-c/runtime/zero_runtime.c"],
|
|
["zero_embedded_zero_http_curl_c", "native/zero-c/runtime/zero_http_curl.c"],
|
|
];
|
|
|
|
function chunkText(text) {
|
|
const chunks = [];
|
|
let current = "";
|
|
for (const line of text.match(/[^\n]*\n|[^\n]+$/g) || []) {
|
|
if (current && JSON.stringify(current + line).length > 3000) {
|
|
chunks.push(current);
|
|
current = "";
|
|
}
|
|
if (JSON.stringify(line).length <= 3000) {
|
|
current += line;
|
|
continue;
|
|
}
|
|
for (let index = 0; index < line.length; index += 1400) {
|
|
if (current) {
|
|
chunks.push(current);
|
|
current = "";
|
|
}
|
|
chunks.push(line.slice(index, index + 1400));
|
|
}
|
|
}
|
|
if (current) chunks.push(current);
|
|
return chunks;
|
|
}
|
|
|
|
const out = [];
|
|
out.push("/* Generated from Zero runtime sources. Run node --experimental-strip-types --disable-warning=ExperimentalWarning scripts/embed-runtime-sources.mts to refresh. */");
|
|
out.push("#ifndef ZERO_EMBEDDED_RUNTIME_SOURCES_INC");
|
|
out.push("#define ZERO_EMBEDDED_RUNTIME_SOURCES_INC");
|
|
out.push("");
|
|
|
|
for (const [name, relativePath] of inputs) {
|
|
const text = fs.readFileSync(path.join(repoRoot, relativePath), "utf8");
|
|
out.push(`static const char *const ${name}[] = {`);
|
|
for (const chunk of chunkText(text)) {
|
|
out.push(` ${JSON.stringify(chunk)},`);
|
|
}
|
|
out.push(" NULL");
|
|
out.push("};");
|
|
out.push("");
|
|
}
|
|
|
|
out.push("#endif");
|
|
out.push("");
|
|
|
|
fs.writeFileSync(outPath, out.join("\n"));
|