### Install bootimage CLI Source: https://github.com/rust-osdev/bootimage/blob/master/Readme.md Install the bootimage command-line tool using Cargo. ```bash cargo install bootimage ``` -------------------------------- ### Configure Run Command in Cargo.toml Source: https://github.com/rust-osdev/bootimage/blob/master/src/help/runner_help.txt Define the command used to launch the bootable disk image in `Cargo.toml`. The `{}` placeholder will be replaced with the path to the generated image. This example uses QEMU. ```toml [package.metadata.bootimage] run-command = ["qemu-system-x86_64", "-drive", "format=raw,file={}"] ``` -------------------------------- ### Build bootable disk image Source: https://github.com/rust-osdev/bootimage/blob/master/Readme.md Build the kernel and create a bootable disk image using the `cargo bootimage` command. Forward any build arguments as needed. ```bash cargo bootimage --target your_custom_target.json [other_args] ``` -------------------------------- ### Basic Usage of cargo-bootimage Source: https://github.com/rust-osdev/bootimage/blob/master/src/help/cargo_bootimage_help.txt Creates a bootable disk image from a Rust kernel. Any options are directly passed to `cargo build`. ```bash cargo bootimage [BUILD_OPTS] ``` -------------------------------- ### Run kernel in QEMU Source: https://github.com/rust-osdev/bootimage/blob/master/Readme.md Run your kernel in QEMU using `cargo xrun` after configuring a custom runner. Arguments after `--` are passed to QEMU. ```bash cargo xrun --target your_custom_target.json [other_args] -- [qemu args] ``` -------------------------------- ### Configure bootimage metadata Source: https://github.com/rust-osdev/bootimage/blob/master/Readme.md Configure build, run, and test behavior for `bootimage` within the `[package.metadata.bootimage]` section of `Cargo.toml`. ```toml [package.metadata.bootimage] # The cargo subcommand that will be used for building the kernel. # # For building using the `cargo-xbuild` crate, set this to `xbuild`. build-command = ["build"] # The command invoked with the created bootimage (the "{}" will be replaced # with the path to the bootable disk image) # Applies to `bootimage run` and `bootimage runner` run-command = ["qemu-system-x86_64", "-drive", "format=raw,file={}"] # Additional arguments passed to the run command for non-test executables # Applies to `bootimage run` and `bootimage runner` run-args = [] # Additional arguments passed to the run command for test executables # Applies to `bootimage runner` test-args = [] # An exit code that should be considered as success for test executables test-success-exit-code = {integer} # The timeout for running a test through `bootimage test` or `bootimage runner` (in seconds) test-timeout = 300 # Whether the `-no-reboot` flag should be passed to test executables test-no-reboot = true ``` -------------------------------- ### Configure Additional Run Arguments in Cargo.toml Source: https://github.com/rust-osdev/bootimage/blob/master/src/help/runner_help.txt Specify additional arguments to be passed to the run command for non-test executables. This can be used to customize QEMU or other runners. ```toml [package.metadata.bootimage] run-args = [] ``` -------------------------------- ### Cargo.toml Configuration for build-command Source: https://github.com/rust-osdev/bootimage/blob/master/src/help/cargo_bootimage_help.txt Configures the cargo subcommand used for building the kernel. Set to `xbuild` when using the `cargo-xbuild` crate. ```toml [package.metadata.bootimage] # The cargo subcommand that will be used for building the kernel. # # For building using the `cargo-xbuild` crate, set this to `xbuild`. build-command = ["build"] ``` -------------------------------- ### Add bootloader dependency Source: https://github.com/rust-osdev/bootimage/blob/master/Readme.md Add the bootloader crate as a dependency in your Cargo.toml file. Ensure you use a compatible version. ```toml # in your Cargo.toml [dependencies] bootloader = "0.9.8" ``` -------------------------------- ### Configure Runner in .cargo/config Source: https://github.com/rust-osdev/bootimage/blob/master/src/help/runner_help.txt Specify `bootimage runner` as the default runner for the 'none' target in your `.cargo/config` file. This allows Cargo to automatically use `bootimage` to run your kernel. ```toml [target.'cfg(target_os = "none")'] runner = "bootimage runner" ``` -------------------------------- ### Configure Test Arguments in Cargo.toml Source: https://github.com/rust-osdev/bootimage/blob/master/src/help/runner_help.txt Define additional arguments for running test executables. This allows for specific configurations when running tests. ```toml [package.metadata.bootimage] test-args = [] ``` -------------------------------- ### Configure Test Timeout in Cargo.toml Source: https://github.com/rust-osdev/bootimage/blob/master/src/help/runner_help.txt Set a timeout in seconds for running test executables. If a test exceeds this duration, it will be terminated. ```toml [package.metadata.bootimage] test-timeout = 300 ``` -------------------------------- ### Configure Test Success Exit Code in Cargo.toml Source: https://github.com/rust-osdev/bootimage/blob/master/src/help/runner_help.txt Set a specific exit code that should be considered a success for test executables. This is useful for integrating with test runners or CI systems. ```toml [package.metadata.bootimage] test-success-exit-code = {integer} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.