Skip to content

Commit

Permalink
Add dependencies to run and generation targets
Browse files Browse the repository at this point in the history
The CMake targets that run QEMU now depend on the targets
that generate the corresponding boot media, if it exists.

The targets that generate boot media now rely on their dependencies, as well.
  • Loading branch information
LensPlaysGames committed Apr 20, 2022
1 parent 8f40669 commit 7c9053c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ Here is a list of the current build targets relating to boot media
generation, as well as their dependencies listed underneath each.
- `image_raw` --
Combine built executables and resources to generate UEFI-compatible FAT32 boot media.
- `Kernel` build target (creates `kernel/bin/kernel.elf`).
- The built bootloader EFI application at `gnu-efi/x86_64/bootloader/main.efi`.
- dd -- Native command on Unix
- On Windows, use one of the following options:
- [MinGW installer to get MSYS coreutils ext package](https://osdn.net/projects/mingw/)
Expand All @@ -234,11 +236,16 @@ Here is a list of the current build targets relating to boot media
- Debian distros: `sudo apt install xorriso`
- [Pre-built binaries for Windows](https://github.com/PeyTy/xorriso-exe-for-windows)

The generated targets can be chained together for easy, quick development. \
To build the LensorOS kernel, generate new boot media, and then
launch into LensorOS, it takes just one command.
```bash
cmake --build kernel/bld && cmake --build kernel/bld -t image_raw runimg_qemu
As an example, a FAT32 formatted UEFI-compatible boot
image may be generated using the following command:
```sh
cmake --build kernel/bld --target image_raw
```

It takes just one command to build the LensorOS kernel, generate new
boot media, and then launch the QEMU virtual machine into LensorOS.
```sh
cmake --build kernel/bld --target runimg_qemu
```

---
Expand Down
30 changes: 29 additions & 1 deletion kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,14 @@ if( CMAKE_HOST_UNIX AND BASH_PROGRAM )
image_raw
COMMAND bash mkimg.sh
WORKING_DIRECTORY ${SCRIPTS_DIR}
DEPENDS
${REPO_DIR}/gnu-efi/x86_64/bootloader/main.efi
${SCRIPTS_DIR}/startup.nsh
COMMENT "Generating UEFI-compatible FAT32 boot media"
USES_TERMINAL
VERBATIM
)
add_dependencies( image_raw Kernel )
endif()
# Boot media generation: GPT partitioned hard drive.
if( FDISK_PROGRAM )
Expand Down Expand Up @@ -203,6 +207,9 @@ if( CMAKE_HOST_UNIX AND BASH_PROGRAM )
" Install mkgpt using ${SCRIPTS_DIR}/install_mkgpt.sh"
)
endif()
if( TARGET image_gpt AND TARGET image_raw )
add_dependencies( image_gpt image_raw )
endif()
# Boot media generation: ISO-9660 CD-ROM.
if( XORRISO_PROGRAM )
message(
Expand All @@ -217,6 +224,9 @@ if( CMAKE_HOST_UNIX AND BASH_PROGRAM )
USES_TERMINAL
VERBATIM
)
if( TARGET image_raw )
add_dependencies( image_iso image_raw )
endif()
else()
message( "-- xorriso was not found on your system, skipping image_iso target generation." )
endif()
Expand All @@ -235,9 +245,14 @@ if( CMAKE_HOST_WIN32 )
image_raw
COMMAND cmd /c ${SCRIPTS_DIR}/mkimg.bat
COMMENT "Generating UEFI-compatible FAT32 boot media"
DEPENDS
${REPO_DIR}/gnu-efi/x86_64/bootloader/main.efi
${SCRIPTS_DIR}/startup.nsh
USES_TERMINAL
VERBATIM
)
# Image generation relies on kernel.elf
add_dependencies( image_raw Kernel )
endif()
# Boot media generation: ISO-9660 CD-ROM.
if( XORRISO_PROGRAM )
Expand All @@ -252,6 +267,9 @@ if( CMAKE_HOST_WIN32 )
USES_TERMINAL
VERBATIM
)
if( TARGET image_raw )
add_dependencies( image_iso image_raw )
endif()
else()
message( "-- xorriso was not found on your system, skipping image_iso target generation." )
endif()
Expand Down Expand Up @@ -344,4 +362,14 @@ if ( QEMU_PROGRAM )
WORKING_DIRECTORY ${REPO_DIR}
VERBATIM
)
endif ()
# Dependencies
if( TARGET image_raw )
add_dependencies( runimg_qemu image_raw )
endif()
if( TARGET image_gpt )
add_dependencies( runhda_qemu image_gpt )
endif()
if( TARGET image_iso )
add_dependencies( runiso_qemu image_iso )
endif()
endif()

0 comments on commit 7c9053c

Please sign in to comment.