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

build(cargo): skip external build script with rust-analyzer #6325

Merged
merged 1 commit into from
Oct 31, 2023
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
26 changes: 20 additions & 6 deletions crates/turborepo-lib/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,31 @@ fn check_tls_config() {
fn main() -> Result<(), Box<dyn std::error::Error>> {
check_tls_config();

tonic_build::configure()
let tonic_build_result = tonic_build::configure()
.build_server(true)
.file_descriptor_set_path("src/daemon/file_descriptor_set.bin")
.compile(&["turbod.proto"], &["../../cli/internal/turbodprotocol"])?;

capnpc::CompilerCommand::new()
.compile(&["turbod.proto"], &["../../cli/internal/turbodprotocol"]);
let capnpc_result = capnpc::CompilerCommand::new()
.file("./src/hash/proto.capnp")
.import_path("./src/hash/std") // we need to include the 'stdlib' for capnp-go
.default_parent_module(vec!["hash".to_string()])
.run()
.expect("schema compiler command");
.run();

let invocation = std::env::var("RUSTC_WRAPPER").unwrap_or_default();
if invocation.ends_with("rust-analyzer") {
if tonic_build_result.is_err() {
println!("cargo:warning=tonic_build failed, but continuing with rust-analyzer");
}

if capnpc_result.is_err() {
println!("cargo:warning=capnpc failed, but continuing with rust-analyzer");
}

return Ok(());
} else {
tonic_build_result.expect("tonic_build command");
capnpc_result.expect("schema compiler command");
}

Ok(())
}
3 changes: 2 additions & 1 deletion crates/turborepo/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ fn main() {
let is_ci_release =
&profile == "release" && matches!(env::var("RELEASE_TURBO_CLI"), Ok(v) if v == "true");

if !is_ci_release {
let invocation = std::env::var("RUSTC_WRAPPER").unwrap_or_default();
if !is_ci_release && !invocation.ends_with("rust-analyzer") {
build_local_go_binary(profile);
}
}
Expand Down
Loading