From 6555fc1dd974f031b7f3ee4aa247e4dff16f8cf2 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Wed, 7 Dec 2022 19:21:07 +0100 Subject: [PATCH] Fix: artifact dependency path needs to be accessed using `env::var_os` instead of `env!` Artifact dependencies are available through the `env!` macro only in binaries/libraries. In build scripts, the env variable is set at runtime instead. --- README.md | 2 +- docs/create-disk-image.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e0cb4d20..202a1984 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ To combine your kernel with a bootloader and create a bootable disk image, follo bindeps = true ``` Alternatively, you can use [`std::process::Command`](https://doc.rust-lang.org/stable/std/process/struct.Command.html) to invoke the build command of your kernel in the `build.rs` script. -- Obtain the path to the kernel executable. When using an artifact dependency, you can retrieve this path using `env!("CARGO_BIN_FILE_MY_KERNEL_my-kernel")` +- Obtain the path to the kernel executable. When using an artifact dependency, you can retrieve this path using `std::env::var_os("CARGO_BIN_FILE_MY_KERNEL_my-kernel")` - Use `bootloader::UefiBoot` and/or `bootloader::BiosBoot` to create a bootable disk image with your kernel. - Do something with the bootable disk images in your `main.rs` function. For example, run them with QEMU. diff --git a/docs/create-disk-image.md b/docs/create-disk-image.md index 67302b4a..b58b951d 100644 --- a/docs/create-disk-image.md +++ b/docs/create-disk-image.md @@ -40,10 +40,10 @@ members = ["kernel"] fn main() { // set by cargo, build scripts should use this directory for output files - let out_dir = env::var_os("OUT_DIR").unwrap(); + let out_dir = std::env::var_os("OUT_DIR").unwrap(); // set by cargo's artifact dependency feature, see // https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#artifact-dependencies - let kernel = env!("CARGO_BIN_FILE_KERNEL_kernel"); + let kernel = std::env::var_os("CARGO_BIN_FILE_KERNEL_kernel"); // create an UEFI disk image (optional) let uefi_path = out_dir.join("uefi.img");