Skip to content

Commit 6ae1660

Browse files
committed
Set up dummy build script for docs.rs
Docs.rs has no network access, so we can't `cargo install` the binary dependencies. This is not required for doc generation, so we trick our way around that issue by providing a dummy build script just for docs.rs.
1 parent b285e67 commit 6ae1660

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

Diff for: Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ rustflags = [
105105
llvm-tools = "0.1.1"
106106

107107
[package.metadata.docs.rs]
108-
default-target = "x86_64-unknown-linux-gnu"
108+
rustc-args = ["--cfg", "docsrs_dummy_build"]
109109

110110
[package.metadata.release]
111111
dev-version = false

Diff for: build.rs

+28
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ fn main() {
4646
);
4747
}
4848

49+
#[cfg(not(docsrs_dummy_build))]
4950
fn build_uefi_bootloader(out_dir: &Path) -> PathBuf {
5051
let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".into());
5152
let mut cmd = Command::new(cargo);
@@ -79,6 +80,7 @@ fn build_uefi_bootloader(out_dir: &Path) -> PathBuf {
7980
}
8081
}
8182

83+
#[cfg(not(docsrs_dummy_build))]
8284
fn build_bios_boot_sector(out_dir: &Path) -> PathBuf {
8385
let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".into());
8486
let mut cmd = Command::new(cargo);
@@ -121,6 +123,7 @@ fn build_bios_boot_sector(out_dir: &Path) -> PathBuf {
121123
convert_elf_to_bin(elf_path)
122124
}
123125

126+
#[cfg(not(docsrs_dummy_build))]
124127
fn build_bios_stage_2(out_dir: &Path) -> PathBuf {
125128
let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".into());
126129
let mut cmd = Command::new(cargo);
@@ -161,6 +164,7 @@ fn build_bios_stage_2(out_dir: &Path) -> PathBuf {
161164
convert_elf_to_bin(elf_path)
162165
}
163166

167+
#[cfg(not(docsrs_dummy_build))]
164168
fn build_bios_stage_3(out_dir: &Path) -> PathBuf {
165169
let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".into());
166170
let mut cmd = Command::new(cargo);
@@ -201,6 +205,7 @@ fn build_bios_stage_3(out_dir: &Path) -> PathBuf {
201205
convert_elf_to_bin(elf_path)
202206
}
203207

208+
#[cfg(not(docsrs_dummy_build))]
204209
fn build_bios_stage_4(out_dir: &Path) -> PathBuf {
205210
let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".into());
206211
let mut cmd = Command::new(cargo);
@@ -268,3 +273,26 @@ fn convert_elf_to_bin(elf_path: PathBuf) -> PathBuf {
268273
}
269274
flat_binary_path
270275
}
276+
277+
// dummy implementations because docsrs builds have no network access
278+
279+
#[cfg(docsrs_dummy_build)]
280+
fn build_uefi_bootloader(_out_dir: &Path) -> PathBuf {
281+
PathBuf::new()
282+
}
283+
#[cfg(docsrs_dummy_build)]
284+
fn build_bios_boot_sector(_out_dir: &Path) -> PathBuf {
285+
PathBuf::new()
286+
}
287+
#[cfg(docsrs_dummy_build)]
288+
fn build_bios_stage_2(_out_dir: &Path) -> PathBuf {
289+
PathBuf::new()
290+
}
291+
#[cfg(docsrs_dummy_build)]
292+
fn build_bios_stage_3(_out_dir: &Path) -> PathBuf {
293+
PathBuf::new()
294+
}
295+
#[cfg(docsrs_dummy_build)]
296+
fn build_bios_stage_4(_out_dir: &Path) -> PathBuf {
297+
PathBuf::new()
298+
}

0 commit comments

Comments
 (0)