Refactor the boot library to be a bit simpler.
This commit is contained in:
29
lib/boot.ks
29
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.
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user