From c3143e11aaacbbfac483f33a3bdb8a65c5074357 Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Sat, 16 Sep 2023 12:23:56 -0400 Subject: [PATCH] build fixes --- veilid-cli/Cargo.toml | 2 +- veilid-core/Cargo.toml | 4 ++-- veilid-core/build.rs | 35 ++++++++++++++++++++++++++--------- veilid-wasm/Cargo.toml | 2 +- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/veilid-cli/Cargo.toml b/veilid-cli/Cargo.toml index 11b6e51b..a3b39d02 100644 --- a/veilid-cli/Cargo.toml +++ b/veilid-cli/Cargo.toml @@ -54,7 +54,7 @@ flexi_logger = { version = "^0", features = ["use_chrono_for_offset"] } thiserror = "^1" crossbeam-channel = "^0" hex = "^0" -veilid-tools = { version = "0.2.0", path = "../veilid-tools" } +veilid-tools = { version = "0.2.1", path = "../veilid-tools" } json = "^0" stop-token = { version = "^0", default-features = false } diff --git a/veilid-core/Cargo.toml b/veilid-core/Cargo.toml index d1ff28cd..18492796 100644 --- a/veilid-core/Cargo.toml +++ b/veilid-core/Cargo.toml @@ -59,7 +59,7 @@ network-result-extra = ["veilid-tools/network-result-extra"] [dependencies] # Tools -veilid-tools = { version = "0.2.0", path = "../veilid-tools", features = [ +veilid-tools = { version = "0.2.1", path = "../veilid-tools", features = [ "tracing", ], default-features = false } paste = "1.0.14" @@ -182,7 +182,7 @@ socket2 = { version = "0.5.3", features = ["all"] } # Dependencies for WASM builds only [target.'cfg(target_arch = "wasm32")'.dependencies] -veilid-tools = { version = "0.2.0", path = "../veilid-tools", default-features = false, features = [ +veilid-tools = { version = "0.2.1", path = "../veilid-tools", default-features = false, features = [ "rt-wasm-bindgen", ] } diff --git a/veilid-core/build.rs b/veilid-core/build.rs index 5b8f7f8a..ff3592c6 100644 --- a/veilid-core/build.rs +++ b/veilid-core/build.rs @@ -1,15 +1,27 @@ use std::path::PathBuf; use std::process::{Command, Stdio}; -fn get_workspace_dir() -> PathBuf { - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("..") - .canonicalize() - .expect("want workspace dir") +fn search_file, P: AsRef>(start: T, name: P) -> Option { + let start_path = PathBuf::from(start.as_ref()).canonicalize().ok(); + let mut path = start_path.as_ref().map(|x| x.as_path()); + while let Some(some_path) = path { + let file_path = some_path.join(name.as_ref()); + if file_path.exists() { + return Some(file_path.to_owned()); + } + path = some_path.parent(); + } + None } + fn get_desired_capnp_version_string() -> String { - std::fs::read_to_string(get_workspace_dir().join(".capnp_version")) - .expect("should find .capnp_version file") + let capnp_path = search_file(env!("CARGO_MANIFEST_DIR"), ".capnp_version") + .expect("should find .capnp_version file"); + std::fs::read_to_string(&capnp_path) + .expect(&format!( + "can't read .capnp_version file here: {:?}", + capnp_path + )) .trim() .to_owned() } @@ -32,8 +44,13 @@ fn get_capnp_version_string() -> String { } fn get_desired_protoc_version_string() -> String { - std::fs::read_to_string(get_workspace_dir().join(".protoc_version")) - .expect("should find .protoc_version file") + let protoc_path = search_file(env!("CARGO_MANIFEST_DIR"), ".protoc_version") + .expect("should find .protoc_version file"); + std::fs::read_to_string(&protoc_path) + .expect(&format!( + "can't read .protoc_version file here: {:?}", + protoc_path + )) .trim() .to_owned() } diff --git a/veilid-wasm/Cargo.toml b/veilid-wasm/Cargo.toml index 059cfd70..2abb4c45 100644 --- a/veilid-wasm/Cargo.toml +++ b/veilid-wasm/Cargo.toml @@ -15,7 +15,7 @@ default = ["veilid-core/default-wasm"] crypto-test = ["veilid-core/crypto-test"] [dependencies] -veilid-core = { version = "0.2.0", path = "../veilid-core", default-features = false } +veilid-core = { version = "0.2.1", path = "../veilid-core", default-features = false } tracing = { version = "^0", features = ["log", "attributes"] } tracing-wasm = "^0"