make usb.vhd if missing, fix clear behavior
This commit is contained in:
1 parent
467a58c9c6
commit
ee55de0534
3 files changed
+34
-2
No files matched your search
Binary file not shown.
+30
-1
@@ -71,16 +71,45 @@ Nob_Proc run_async(const char *cmd_str) {
|
||||
return proc;
|
||||
}
|
||||
|
||||
// Creates an empty USB image the first time the build sees a missing usb.vhd.
|
||||
// The image is intentionally left unmounted and unpopulated after formatting so
|
||||
// callers can use it as removable FAT32 storage without the build overwriting it.
|
||||
bool create_usb_vhd_if_missing(void) {
|
||||
if (nob_file_exists("usb.vhd")) return true;
|
||||
|
||||
char vhd_path[MAX_PATH];
|
||||
GetFullPathNameA("usb.vhd", MAX_PATH, vhd_path, NULL);
|
||||
|
||||
const char *diskpart_script = nob_temp_sprintf(
|
||||
"create vdisk file=\"%s\" maximum=256 type=fixed\n"
|
||||
"select vdisk file=\"%s\"\n"
|
||||
"attach vdisk\n"
|
||||
"convert gpt\n"
|
||||
"create partition primary\n"
|
||||
"format fs=fat32 quick\n"
|
||||
"detach vdisk\n"
|
||||
"exit\n",
|
||||
vhd_path, vhd_path
|
||||
);
|
||||
|
||||
nob_log(NOB_INFO, "usb.vhd missing, creating empty 256 MB FAT32 GPT image...");
|
||||
nob_write_entire_file("usb_mkimage.txt", diskpart_script, strlen(diskpart_script));
|
||||
bool ok = run_sync("diskpart /s usb_mkimage.txt");
|
||||
remove("usb_mkimage.txt");
|
||||
return ok;
|
||||
}
|
||||
|
||||
// Runs the requested operation.
|
||||
int main(int argc, char **argv) {
|
||||
// The build tool rebuilds itself before doing any real work so the graph below matches the source.
|
||||
NOB_GO_REBUILD_URSELF(argc, argv);
|
||||
|
||||
// The disk image must exist before the build can copy fresh binaries into it.
|
||||
// The boot image must exist before the build can copy fresh binaries into it.
|
||||
if (!nob_file_exists("disk.vhd")) {
|
||||
nob_log(NOB_INFO, "disk.vhd missing, calling mkimage.bat...");
|
||||
if (!run_sync("mkimage.bat")) return 1;
|
||||
}
|
||||
if (!create_usb_vhd_if_missing()) return 1;
|
||||
create_layout();
|
||||
|
||||
// Core images build sequentially because later images link against earlier import libraries.
|
||||
|
||||
@@ -677,8 +677,11 @@ static KSTATUS KiDisplayClearLocked(uint32_t color) {
|
||||
return s;
|
||||
KiDisplayBeginDraw();
|
||||
s = KiDisplayFillRectNoCursor(0, 0, (int)mode.Width, (int)mode.Height, color);
|
||||
if (KSUCCESS(s))
|
||||
if (KSUCCESS(s)) {
|
||||
KiDisplayConsoleResetCellsLocked();
|
||||
gConsoleX = 0;
|
||||
gConsoleY = 0;
|
||||
}
|
||||
KSTATUS ps = KiDisplayEndDraw();
|
||||
return KSUCCESS(s) ? ps : s;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user