From 9b034aaa1a27ee16bea9263ca991c658f2d3f1df Mon Sep 17 00:00:00 2001 From: annabunches Date: Wed, 1 Sep 2021 01:46:03 -0400 Subject: [PATCH] Refactor the boot library to be a bit simpler. --- boot/aircraft.ks | 3 +-- boot/helicopter.ks | 3 +-- boot/launchpad.ks | 3 +-- boot/rocket.ks | 3 +-- boot/satellite.ks | 4 ++-- boot/science.ks | 4 ++-- lib/boot.ks | 29 ++++++++++++++--------------- 7 files changed, 22 insertions(+), 27 deletions(-) diff --git a/boot/aircraft.ks b/boot/aircraft.ks index 6a04de6..2665c78 100644 --- a/boot/aircraft.ks +++ b/boot/aircraft.ks @@ -4,7 +4,6 @@ parameter debug is false. Bootstrap( "/boot/aircraft", -"/prog/aircraft", -List(), // no additional program files +List("/prog/aircraft"), debug ). diff --git a/boot/helicopter.ks b/boot/helicopter.ks index fe5c1ac..8ad21a0 100644 --- a/boot/helicopter.ks +++ b/boot/helicopter.ks @@ -4,7 +4,6 @@ parameter debug is false. Bootstrap( "/boot/helicopter", -"/prog/helicopter", -List(), // no additional program files +List("/prog/helicopter"), debug ). diff --git a/boot/launchpad.ks b/boot/launchpad.ks index c252859..9808296 100644 --- a/boot/launchpad.ks +++ b/boot/launchpad.ks @@ -4,7 +4,6 @@ parameter debug is false. Bootstrap( "/boot/launchpad", - "/prog/launchpad", - List(), + List("/prog/launchpad"), debug ). diff --git a/boot/rocket.ks b/boot/rocket.ks index 4bb32e1..8c4c13d 100644 --- a/boot/rocket.ks +++ b/boot/rocket.ks @@ -4,7 +4,6 @@ parameter debug is false. Bootstrap( "/boot/rocket", - "/prog/rocket", - List(), + List("/prog/rocket"), debug ). diff --git a/boot/satellite.ks b/boot/satellite.ks index 6023cf3..a5caf86 100644 --- a/boot/satellite.ks +++ b/boot/satellite.ks @@ -4,12 +4,12 @@ parameter debug is false. Bootstrap( "/boot/satellite", - "", List( "/prog/execnode", "/prog/circ", "/prog/satdeploy", "/prog/nodestats" ), - debug + debug, + false ). diff --git a/boot/science.ks b/boot/science.ks index eef0300..dd55435 100644 --- a/boot/science.ks +++ b/boot/science.ks @@ -4,12 +4,12 @@ parameter debug is false. Bootstrap( "/boot/science", - "", List( "/prog/circ", "/prog/execnode", "/prog/nodestats", "/prog/reentry" ), - debug + debug, + false ). diff --git a/lib/boot.ks b/lib/boot.ks index 3211f7e..664b471 100644 --- a/lib/boot.ks +++ b/lib/boot.ks @@ -1,20 +1,24 @@ +// "bootfile" should be the path to the bootfile, so it can be deleted. +// "programs" is a List() of programs to install in the CPU root. +// "debug" will skip compiling if enabled, and only copy files. +// if "init" is true, the first program in the programs List will become the new boot file. +// pass false in here if you want CPU control from the terminal. function Bootstrap { - parameter bootFile, init, programs, debug. + parameter bootFile, programs, debug, init is true. + + local initProgram is "". + if init { + set initProgram to programs[0]:Replace("/prog", ""). + } // create a list of libraries that we need to compile local libs is UniqueSet(). - if init <> "" { - addLibs(libs, init). - } for program in programs { addLibs(libs, program). } // compile the main program files - if init <> "" { - compileFile(init, "/init", debug). - } for program in programs { compileFile(program, program:Replace("/prog", ""), debug). } @@ -29,18 +33,13 @@ function Bootstrap { // Open a terminal and run init. CORE:PART:GETMODULE("kOSProcessor"):DOEVENT("Open Terminal"). if init <> "" { - run "/init". + RunPath(initProgram). } - // ... or delete the bootstrapping file, set init to the bootfile, + // ... or delete the bootstrapping file, configure to boot from the init program, // and reboot. } else { DeletePath("1:" + bootfile). - // Set OS to boot and restart. - if init = "" { - set CORE:BOOTFILENAME to "". - } else { - set CORE:BOOTFILENAME to "/init". - } + set CORE:BOOTFILENAME to initProgram. reboot. } }