2022-05-22 20:35:28 +02:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
const process = require("process");
|
|
|
|
const fs = require("fs");
|
|
|
|
const path = require("path");
|
|
|
|
|
|
|
|
const infn = process.argv[2];
|
|
|
|
const outfn = process.argv[3];
|
|
|
|
|
2022-11-12 13:48:46 +01:00
|
|
|
const name = path
|
|
|
|
.basename(outfn)
|
|
|
|
.split(".")
|
|
|
|
.slice(0, -1)
|
|
|
|
.join(".")
|
|
|
|
.replace(/-/g, "_");
|
2022-05-22 20:35:28 +02:00
|
|
|
const inf = fs.readFileSync(infn);
|
|
|
|
const bs = [];
|
|
|
|
for (const b of inf) {
|
|
|
|
bs.push(`0x${b.toString(16)}`);
|
|
|
|
}
|
2022-11-11 19:11:19 +01:00
|
|
|
const out = `static unsigned char ${name}[] = { ${bs.join(", ")} };\n`;
|
2022-05-22 20:35:28 +02:00
|
|
|
fs.writeFileSync(outfn, out);
|