diff --git a/build.py b/build.py index b084a7c..8eb9e71 100644 --- a/build.py +++ b/build.py @@ -9,6 +9,7 @@ import threading clean = '--noclean' not in sys.argv kernel_only = '--kernel-only' in sys.argv noapp = '--noapp' in sys.argv +bootloader = '--bootloader' in sys.argv # 编译内核 @@ -97,6 +98,20 @@ else: shutil.copy(vpui_path, "./disk/libs/vpui64.so") +# 编译 bootloader(GNU-EFI:MSYS make → WSL Ubuntu); +# bootx64.efi 不由 viperc 产出,容易忘记重编而一直用旧引导器(改了 boot.c / 内核预留逻辑 +# 却仍在用旧件)。显式传 --bootloader 才重编;未传时若 boot.c 比产物新则给出提醒。 +boot_src = "boot/boot.c" +boot_out = "disk/EFI/BOOT/bootx64.efi" +if bootloader: + print("[build] building bootloader (make -C boot)...") + boot_rc = os.system('make -C boot') + if boot_rc != 0: + print("[build] 警告: bootloader 构建失败(需 MSYS make + WSL Ubuntu + _UNCADK/tools/gnu-efi)") +elif os.path.exists(boot_src) and os.path.exists(boot_out) and os.path.getmtime(boot_src) > os.path.getmtime(boot_out): + print("[build] 警告: boot/boot.c 比 disk/EFI/BOOT/bootx64.efi 新 → bootloader 已过期,请用 --bootloader 重编") + + os.system('powershell -ExecutionPolicy Bypass -File ./Scripts/disk.ps1')