ci(lesavka): reuse process contract server build
This commit is contained in:
parent
72adce5322
commit
147845d079
@ -12,6 +12,7 @@ use std::io::Read;
|
||||
use std::net::TcpListener;
|
||||
use std::path::PathBuf;
|
||||
use std::process::{Command, Stdio};
|
||||
use std::sync::OnceLock;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
fn cargo_binary(name: &str) -> Option<PathBuf> {
|
||||
@ -45,31 +46,36 @@ fn build_current_binary(name: &str) -> Option<PathBuf> {
|
||||
if name != "lesavka-server" {
|
||||
return None;
|
||||
}
|
||||
let cargo = option_env!("CARGO").unwrap_or("cargo");
|
||||
let target_dir = workspace_root().join("target/process-contract-debug");
|
||||
let _ = fs::remove_dir_all(&target_dir);
|
||||
let mut command = Command::new(cargo);
|
||||
let status = command
|
||||
.current_dir(workspace_root())
|
||||
.env_remove("CARGO_BUILD_RUSTFLAGS")
|
||||
.env_remove("CARGO_ENCODED_RUSTFLAGS")
|
||||
.env_remove("CARGO_LLVM_COV")
|
||||
.env_remove("CARGO_LLVM_COV_TARGET_DIR")
|
||||
.env_remove("CARGO_TARGET_DIR")
|
||||
.env_remove("LLVM_COV")
|
||||
.env_remove("RUSTFLAGS")
|
||||
.env_remove("RUSTDOCFLAGS")
|
||||
.env_remove("LLVM_PROFILE_FILE")
|
||||
.arg("build")
|
||||
.arg("--target-dir")
|
||||
.arg(&target_dir)
|
||||
.args(["-p", "lesavka_server", "--bin", name])
|
||||
.status()
|
||||
.ok()?;
|
||||
status
|
||||
.success()
|
||||
.then(|| target_dir.join("debug").join(name))
|
||||
.filter(|path| path.exists() && path.is_file())
|
||||
static SERVER_BINARY: OnceLock<Option<PathBuf>> = OnceLock::new();
|
||||
SERVER_BINARY
|
||||
.get_or_init(|| {
|
||||
let cargo = option_env!("CARGO").unwrap_or("cargo");
|
||||
let target_dir = workspace_root().join("target/process-contract-debug");
|
||||
let _ = fs::remove_dir_all(&target_dir);
|
||||
let mut command = Command::new(cargo);
|
||||
let status = command
|
||||
.current_dir(workspace_root())
|
||||
.env_remove("CARGO_BUILD_RUSTFLAGS")
|
||||
.env_remove("CARGO_ENCODED_RUSTFLAGS")
|
||||
.env_remove("CARGO_LLVM_COV")
|
||||
.env_remove("CARGO_LLVM_COV_TARGET_DIR")
|
||||
.env_remove("CARGO_TARGET_DIR")
|
||||
.env_remove("LLVM_COV")
|
||||
.env_remove("RUSTFLAGS")
|
||||
.env_remove("RUSTDOCFLAGS")
|
||||
.env_remove("LLVM_PROFILE_FILE")
|
||||
.arg("build")
|
||||
.arg("--target-dir")
|
||||
.arg(&target_dir)
|
||||
.args(["-p", "lesavka_server", "--bin", name])
|
||||
.status()
|
||||
.ok()?;
|
||||
status
|
||||
.success()
|
||||
.then(|| target_dir.join("debug").join(name))
|
||||
.filter(|path| path.exists() && path.is_file())
|
||||
})
|
||||
.clone()
|
||||
}
|
||||
|
||||
fn find_binary(name: &str) -> Option<PathBuf> {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user