mkf18a takes nucleus=SYSDIR, assembles the nucleus as the ROM does and looks NAME up by its dictionary name; a word in line there, or one with no fixed effect, is refused (plan section 12, rulings 3 and 4). test_mkf18a: 5 new checks failed first, 93 pass at both widths. Its build now has the host node's size, as the tool's has: the nucleus did not fit a mesh node's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
54 lines
1.8 KiB
C
54 lines
1.8 KiB
C
/* SPDX-License-Identifier: LicenseRef-Starship-1.0
|
|
* Copyright (c) 2023-2026 Robert A. James
|
|
*/
|
|
/* mkf18a.c -- build a train's engine, its F18 artifact, off the node (f18a.h).
|
|
*
|
|
* mkf18a OUT.f18a MAP.f18 ROM DIR [TRAIN=PATH.f18a ...] [nucleus=SYSDIR]
|
|
*
|
|
* docs/v4.0.0/plans/2026-11-19-f18-artifact-build.md section 2. Built as mkrom is, one per cell width,
|
|
* with the node's size. DIR holds the train's .f18; each TRAIN=PATH is a train it may import from;
|
|
* nucleus=SYSDIR is the nucleus's source, for `import nucleus NAME` (plan section 12).
|
|
*/
|
|
#include "f18a.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#ifndef V4_ROOT
|
|
#error "V4_ROOT must name the v4 directory"
|
|
#endif
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
f18a_args a;
|
|
f18a_train trains[64];
|
|
unsigned char *out = NULL;
|
|
size_t len = 0;
|
|
char err[512];
|
|
int i;
|
|
FILE *f;
|
|
|
|
if (argc < 5) { fprintf(stderr, "usage: mkf18a OUT.f18a MAP.f18 ROM DIR [TRAIN=PATH.f18a ...] [nucleus=SYSDIR]\n"); return 2; }
|
|
a.map = argv[2];
|
|
a.rom = argv[3];
|
|
a.dir = argv[4];
|
|
a.ntrains = 0;
|
|
a.nucleus = NULL;
|
|
for (i = 5; i < argc; i++) {
|
|
char *eq = strchr(argv[i], '=');
|
|
if (!eq || a.ntrains == 64) { fprintf(stderr, "mkf18a: not TRAIN=PATH: %s\n", argv[i]); return 2; }
|
|
*eq = 0;
|
|
if (strcmp(argv[i], "nucleus") == 0) { a.nucleus = eq + 1; continue; }
|
|
trains[a.ntrains].name = argv[i];
|
|
trains[a.ntrains].path = eq + 1;
|
|
a.ntrains++;
|
|
}
|
|
a.trains = trains;
|
|
a.tool_root = V4_ROOT;
|
|
if (!f18a_build(&a, &out, &len, err, sizeof err)) { fprintf(stderr, "mkf18a: %s: %s\n", a.dir, err); return 1; }
|
|
f = fopen(argv[1], "wb");
|
|
if (!f || fwrite(out, 1, len, f) != len || fclose(f) != 0) { fprintf(stderr, "mkf18a: cannot write %s\n", argv[1]); return 1; }
|
|
free(out);
|
|
return 0;
|
|
}
|