SLOSDevTree.sleela
lib/operating-system/os-creator/SLOSDevTree.sleela · 143 line(s) · sleela
<< lib/operating-system/os-creator/SLOSDevTree.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLOSDevTree — the on-disk /os-development directory that
OS Creator(TM) materialises. It owns the real filesystem side of the
provider: it creates the directory layout with the osMakeDir bridge and
writes every file (piece source, config, README, toolchain, manifest)
through the openFile/write/close content built-ins. It also accumulates a
MANIFEST.md index of everything written so the result is self-describing.
Every write is a GENUINE host filesystem write across the explicit VM/OS
bridge; nothing is in-memory only. A fresh SLOSDevTree is rooted at a caller-
chosen path (conventionally "/os-development"), creates the standard subtree,
and then accepts files relative to that root.
Family: operating-system. Writes via the os*/file I/O bridge; records a manifest. >>
*/
#sleela 2.5
material;
class SLOSDevTree {
< ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
<< Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
or catalog can read and (where appropriate) override this record.
Values are faithful to the subject's real origin where publicly known. >>
String metaVersion = "1.0.0";
int metaId = 10928;
String metaAuthor = "Kiro Agent";
String metaDate = "2026-10-16";
String metaCopyright = "SLeeLa project";
String metaTrademark = "none";
String metaCorporation = "none";
< metaOrigin: National | <nation> | International | Galactic >
String metaOrigin = "International";
String metaBirthDate = "2026-10-10";
< metaScienceRating: maturity/robustness on a 1..10 scale >
int metaScienceRating = 9;
< metaNationalSchedule: a real, citable instrument or "none" >
String metaNationalSchedule = "none";
String getMetaVersion() { return metaVersion; }
void setMetaVersion(String v) { metaVersion = v; }
int getMetaId() { return metaId; }
void setMetaId(int v) { metaId = v; }
String getAuthor() { return metaAuthor; }
void setAuthor(String v) { metaAuthor = v; }
String getDate() { return metaDate; }
void setDate(String v) { metaDate = v; }
String getCopyright() { return metaCopyright; }
void setCopyright(String v) { metaCopyright = v; }
String getTrademark() { return metaTrademark; }
void setTrademark(String v) { metaTrademark = v; }
String getCorporation() { return metaCorporation; }
void setCorporation(String v) { metaCorporation = v; }
String getOrigin() { return metaOrigin; }
void setOrigin(String v) { metaOrigin = v; }
String getBirthDate() { return metaBirthDate; }
void setBirthDate(String v) { metaBirthDate = v; }
int getScienceRating() { return metaScienceRating; }
void setScienceRating(int v) { metaScienceRating = v; }
String getNationalSchedule() { return metaNationalSchedule; }
void setNationalSchedule(String v) { metaNationalSchedule = v; }
< absolute output root, e.g. "/os-development" >
String root;
< newline-separated "bytes path" index >
String manifest;
int fileCount;
int configured;
void configure(String outputRoot) {
root = outputRoot; manifest = ""; fileCount = 0; configured = 1;
}
< Create the standard /os-development subtree. Returns 1 on success. Existing >
< directories are tolerated (osMakeDir is idempotent-friendly in the bridge). >
int layout(boolean withDesktop) {
makeDir("");
makeDir("/config");
makeDir("/firmware");
makeDir("/firmware/uefi");
makeDir("/firmware/bios");
makeDir("/boot");
makeDir("/boot/loader");
makeDir("/boot/kernel-loader");
makeDir("/kernel");
makeDir("/kernel/driver-loader");
makeDir("/userspace");
makeDir("/userspace/os-loader");
if (withDesktop) {
makeDir("/desktop");
makeDir("/desktop/gui-loader");
}
makeDir("/os");
makeDir("/src");
makeDir("/src/sleela");
makeDir("/tools");
return 1;
}
< Make one directory relative to the root (relative "" makes the root itself). >
int makeDir(String rel) { return osMakeDir(root + rel); }
< Write one file relative to the root, creating/truncating it. Records the >
< write in the manifest. Returns the byte count written (-1 on failure). >
int writeFile(String rel, String contents) {
String path = root + rel;
< "w": create/truncate for writing >
int fd = openFile(path, "w");
if (fd < 0) { return -1; }
int n = write(fd, contents);
close(fd);
recordFile(rel, n);
return n;
}
< Write every file an SLOSPiece carries into the piece's subtree. >
void writePiece(SLOSPiece p) {
makeDir("/" + p.dir());
writeFile("/" + p.cPath(), p.c());
writeFile("/" + p.cppPath(), p.cpp());
if (p.hasConfig()) { writeFile("/" + p.configPath(), p.config()); }
if (p.hasReadme()) { writeFile("/" + p.readmePath(), p.readmeText()); }
}
void recordFile(String rel, int bytes) {
String line = intToStr(bytes) + " " + rel;
if (manifest == "") { manifest = line; } else { manifest = manifest + "\n" + line; }
fileCount = fileCount + 1;
}
< Finalise the tree: write MANIFEST.md listing everything produced. >
int writeManifest(String identityLine) {
String md = "# /os-development - generated by OS Creator(TM)\n\n";
md = md + "Model: " + identityLine + "\n\n";
md = md + "Files written: " + intToStr(fileCount) + "\n\n";
md = md + "## Index (bytes path)\n\n" + manifest + "\n";
return writeFile("/MANIFEST.md", md);
}
String outputRoot() { return root; }
int filesWritten() { return fileCount; }
String fileIndex() { return manifest; }
String intToStr(int v) { return "" + v; }
}