Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --cfg=docsrs in rustflags and rustdocflags #8

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,14 @@ fn do_main() -> Result<()> {
}

let mut rustflags = metadata.rustc_args.clone();
rustflags.insert(0, "--cfg=docsrs".to_owned());
if let Some(encoded_rustflags) = env::var_os("CARGO_ENCODED_RUSTFLAGS") {
if let Some(encoded_rustflags) = encoded_rustflags.to_str() {
rustflags.splice(0..0, encoded_rustflags.split('\x1f').map(str::to_owned));
rustflags.splice(1..1, encoded_rustflags.split('\x1f').map(str::to_owned));
}
} else if let Some(env_rustflags) = env::var_os("RUSTFLAGS") {
if let Some(env_rustflags) = env_rustflags.to_str() {
rustflags.splice(0..0, env_rustflags.split_whitespace().map(str::to_owned));
rustflags.splice(1..1, env_rustflags.split_whitespace().map(str::to_owned));
}
}

Expand All @@ -199,14 +200,17 @@ fn do_main() -> Result<()> {
));

let mut rustdocflags = metadata.rustdoc_args.clone();
rustdocflags.insert(0, "-Zunstable-options".to_owned());
rustdocflags.splice(
0..0,
["-Zunstable-options".to_owned(), "--cfg=docsrs".to_owned()],
);
if let Some(encoded_rustdocflags) = env::var_os("CARGO_ENCODED_RUSTDOCFLAGS") {
if let Some(encoded_rustdocflags) = encoded_rustdocflags.to_str() {
rustdocflags.splice(1..1, encoded_rustdocflags.split('\x1f').map(str::to_owned));
rustdocflags.splice(2..2, encoded_rustdocflags.split('\x1f').map(str::to_owned));
}
} else if let Some(env_rustdocflags) = env::var_os("RUSTDOCFLAGS") {
if let Some(env_rustdocflags) = env_rustdocflags.to_str() {
rustdocflags.splice(1..1, env_rustdocflags.split_whitespace().map(str::to_owned));
rustdocflags.splice(2..2, env_rustdocflags.split_whitespace().map(str::to_owned));
}
}
rustdocflags.push("--extern-html-root-takes-precedence".to_owned());
Expand Down
Loading