From 53eb59686163f40639cfd284f03089079e237b2d Mon Sep 17 00:00:00 2001 From: Parker TenBroeck <51721964+ParkerTenBroeck@users.noreply.github.com> Date: Wed, 11 Mar 2026 13:40:36 -0400 Subject: [PATCH] fixed artifact dep --- .cargo/config.toml | 2 ++ Cargo.lock | 1 + relay/Cargo.toml | 5 +++- relay/build.rs | 60 ++++++--------------------------------------- relay/src/build.rs | 3 +-- run_relay.sh | 2 +- rust-toolchain.toml | 2 ++ 7 files changed, 18 insertions(+), 57 deletions(-) create mode 100644 .cargo/config.toml create mode 100644 rust-toolchain.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..dfa84e8 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[unstable] +bindeps = true diff --git a/Cargo.lock b/Cargo.lock index 63c29a4..a09f738 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -464,6 +464,7 @@ version = "0.1.0" dependencies = [ "axum", "futures-util", + "libvhdl_conn", "serde", "serde_json", "tokio", diff --git a/relay/Cargo.toml b/relay/Cargo.toml index 0e17f78..edd4682 100644 --- a/relay/Cargo.toml +++ b/relay/Cargo.toml @@ -9,4 +9,7 @@ tokio = { version = "1", features = ["rt-multi-thread", "macros", "process", "io tower-http = { version = "0.6", features = ["fs", "trace"] } futures-util = "0.3" serde = { version = "1", features = ["derive"] } -serde_json = "1" \ No newline at end of file +serde_json = "1" + +[build-dependencies] +libvhdl_conn = { path = "../libvhdl_conn", artifact = "staticlib" } diff --git a/relay/build.rs b/relay/build.rs index 3223646..0ec142e 100644 --- a/relay/build.rs +++ b/relay/build.rs @@ -1,58 +1,12 @@ -use std::path::PathBuf; -use std::process::Command; +use std::env; fn main() { - // silly hack of sorts because bindeps are unstable + let artifact_path = env::var_os("CARGO_STATICLIB_FILE_LIBVHDL_CONN") + .expect("missing staticlib artifact for build-dependency `libvhdl_conn`"); - - let manifest_dir = PathBuf::from( - std::env::var("CARGO_MANIFEST_DIR") - .expect("CARGO_MANIFEST_DIR was not set by Cargo"), + println!("cargo:rerun-if-changed={}", artifact_path.display()); + println!( + "cargo:rustc-env=EMBEDDED_VHDL_CONN_LIB_PATH={}", + artifact_path.display() ); - let workspace_root = manifest_dir - .parent() - .expect("relay crate should live under a workspace root"); - - println!("cargo:rerun-if-changed={}", workspace_root.join("conn").display()); - - let isolated_target_dir = workspace_root.join("target").join("conn-build"); - - let status = Command::new("cargo") - .arg("build") - .arg("--package") - .arg("libvhdl_conn") - .arg("--release") - .arg("--lib") - .arg("--target-dir") - .arg(&isolated_target_dir) - .current_dir(workspace_root) - .status() - .expect("failed to spawn cargo build for conn"); - - if !status.success() { - panic!( - "build script failed: `cargo build --package conn --release --lib` exited with {status}" - ); - } - - // Copy the built staticlib into the workspace release target path used by relay/src/build.rs. - let isolated_release_dir = isolated_target_dir.join("release"); - let out_release_dir = workspace_root.join("target").join("release"); - std::fs::create_dir_all(&out_release_dir).expect("failed to create workspace target/release"); - - // conn currently builds as libvhdl_conn.a; keep a compatibility alias for relay/src/build.rs (libvhdl_ui.a). - let src_lib = isolated_release_dir.join("libvhdl_conn.a"); - if !src_lib.exists() { - panic!( - "build script failed: expected static library not found at {}", - src_lib.display() - ); - } - - let dst_conn = out_release_dir.join("libvhdl_conn.a"); - std::fs::copy(&src_lib, &dst_conn).expect("failed to copy libconn.a into workspace target/release"); - - let dst_compat = out_release_dir.join("libvhdl_conn.a"); - std::fs::copy(&src_lib, &dst_compat) - .expect("failed to copy compatibility libvhdl_conn.a into workspace target/release"); } diff --git a/relay/src/build.rs b/relay/src/build.rs index f89c149..a2798c5 100644 --- a/relay/src/build.rs +++ b/relay/src/build.rs @@ -5,8 +5,7 @@ use tokio::process::{Child, Command}; use crate::HResult; -const EMBEDDED_VHDL_UI_LIB: &[u8] = - include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/../target/release/libvhdl_conn.a")); +const EMBEDDED_VHDL_UI_LIB: &[u8] = include_bytes!(env!("EMBEDDED_VHDL_CONN_LIB_PATH")); async fn ensure_ok(child: Child) -> Result<(), Box> { let result = child.wait_with_output().await?; diff --git a/run_relay.sh b/run_relay.sh index 6fceba8..71cd682 100755 --- a/run_relay.sh +++ b/run_relay.sh @@ -3,5 +3,5 @@ set -euo pipefail pushd relay >/dev/null -cargo run --release -- "$@" +cargo +nightly run -Z bindeps --release -- "$@" popd >/dev/null diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..5d56faf --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "nightly"