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

fix: replace is_crate_type_lib by filter_crate_type to support extra crate-types #67

Merged
merged 2 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
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
15 changes: 11 additions & 4 deletions rap/src/bin/cargo-rap/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,17 @@ pub fn is_current_compile_crate() -> bool {
ARGS.is_current_compile_crate()
}

pub fn is_crate_type_lib() -> bool {
get_arg_flag_value("--crate-type")
.map(|s| s == "lib" || s == "rlib" || s == "staticlib")
.unwrap_or(false)
/// Returns true for crate types to be checked;
/// returns false for some special crate types that can't be handled by rap.
/// For example, skip build.rs which causes linking errors in rap.
pub fn filter_crate_type() -> bool {
if let Some(s) = get_arg_flag_value("--crate-type") {
if s == "bin" && get_arg_flag_value("--crate-name") == Some("build_script_build") {
return false;
}
}
// NOTE: tests don't have --crate-type, they are handled with --test by rustc
return true;
}

pub fn get_arg(pos: usize) -> Option<&'static str> {
Expand Down
4 changes: 2 additions & 2 deletions rap/src/bin/cargo-rap/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ fn phase_rustc_wrapper() {

let is_direct = args::is_current_compile_crate();
// rap only checks local crates
if is_direct && args::is_crate_type_lib() {
if is_direct && args::filter_crate_type() {
run_rap();
return;
}

// for dependencies, run rustc as usual
// for dependencies and some special crate types, run rustc as usual
run_rustc();
}

Expand Down