Home /Modules/operating-system/SLSourceDropper.sleela

SLSourceDropper.sleela

lib/operating-system/os-creator/SLSourceDropper.sleela · 109 line(s) · sleela

<< lib/operating-system/os-creator/SLSourceDropper.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLSourceDropper — the OS Creator(TM) stage that places the
     SLeeLa SOURCE that produced an /os-development tree into that tree, so the
     output is self-reproducing: a reader of /os-development can see both the
     generated C/C++ and the SLeeLa model + creator source that generated it.
     It writes a src/sleela/os-model.sleela recreation of the model's
     construction calls and a src/README.md explaining the provenance and how to
     regenerate.
   
   The dropper does not read the live library files (the VM does not expose the
   repository tree to a running program); instead it reconstructs the minimal,
   runnable SLeeLa that rebuilds the same model, which is the honest, portable
   form of "the source that made this".
   
   Family: operating-system. OS Creator(TM) stage; writes into the dev tree via SLOSDevTree. >>
#sleela 2.5
material;
class SLSourceDropper {
  < ---- 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 = 10940;
  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; }
  < Drop the reconstructable SLeeLa source and a provenance README into the tree. >
  void drop(SLOSModel m, SLOSDevTree tree) {
    tree.writeFile("/src/sleela/os-model.sleela", modelSource(m));
    tree.writeFile("/src/README.md", provenance(m));
  }

  < A minimal, runnable SLeeLa program that reconstructs this model and re-runs >
  < OS Creator(TM) to regenerate the tree. >
  String modelSource(SLOSModel m) {
    String shape = m.osShape().name();
    String preset = "SLLinuxOSModel";
    if (shape == "Windows") { preset = "SLWindowsOSModel"; }
    if (shape == "macOS")   { preset = "SLMacOSModel"; }

    String s = "#sleela 1.5\n";
    s = s + "// os-model.sleela - the SLeeLa source that produced this /os-development.\n";
    s = s + "// Generated by OS Creator(TM); re-running it rebuilds the tree.\n";
    s = s + "class OsModelMain {\n";
    s = s + "  void main() {\n";
    s = s + "    " + preset + " os = new " + preset + "();\n";
    s = s + "    os.build(\"" + m.name() + "\", \"" + m.osVersion() + "\");\n";
    if (m.osEdition() == "Server") { s = s + "    os.asServer();\n"; }
    s = s + "    SLOSCreator creator = new SLOSCreator();\n";
    s = s + "    creator.configure();\n";
    s = s + "    SLOSBuildReport report = creator.create(os, \"/os-development\");\n";
    s = s + "    print(report.summary());\n";
    s = s + "  }\n";
    s = s + "}\n";
    return s;
  }

  String provenance(SLOSModel m) {
    String md = "# /os-development/src - provenance\n\n";
    md = md + "This tree was generated by **OS Creator(TM)** from the SLeeLa model:\n\n";
    md = md + "    " + m.identity() + "\n\n";
    md = md + "## Regenerate\n\n";
    md = md + "Run the SLeeLa source that produced this tree:\n\n";
    md = md + "    SLeeLa src/sleela/os-model.sleela\n\n";
    md = md + "That recomposes the model and re-runs `SLOSCreator.create(model, \"/os-development\")`, "
            + "which rewrites every piece, config, and build file under this root.\n\n";
    md = md + "## What is here\n\n";
    md = md + "- `sleela/os-model.sleela` - the model + creator invocation (SLeeLa).\n";
    md = md + "- the generated C/C++ for every OS piece lives under the sibling directories "
            + "(`firmware/`, `boot/`, `kernel/`, `userspace/`, `desktop/`, `os/`).\n";
    md = md + "- `../Makefile`, `../build.sh`, `../build.ps1` build those sources into the OS and ISO.\n";
    return md;
  }
}