From 78af949a4bfc0e5294f72ef2a1547e6a1c64ad96 Mon Sep 17 00:00:00 2001 From: Ashley Ruglys Date: Sat, 18 Feb 2023 17:00:31 +0100 Subject: [PATCH] Allows binding against a non monolithic build --- usd-cpp/build.rs | 21 +++++++++++---------- usd-rs/build.rs | 10 ++++++---- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/usd-cpp/build.rs b/usd-cpp/build.rs index 1119e8d7..366a99a5 100644 --- a/usd-cpp/build.rs +++ b/usd-cpp/build.rs @@ -69,9 +69,9 @@ fn write_lib_info(out_dir: &std::path::PathBuf, info: [std::path::PathBuf; 3]) { write!( std::fs::File::create(locations_path).unwrap(), "\ -pub const INCLUDE : &str = \"{}\"; \n\ -pub const LIBS : &str = \"{}\"; \n\ -pub const LIB : &str = \"{}\"; \n\ +pub const INCLUDE_DIR : &str = \"{}\"; \n\ +pub const LIB_DIR : &str = \"{}\"; \n\ +pub const LIBS : &[&str] = &[\"{}\"]; \n\ ", info[0].to_str().unwrap(), info[1].to_str().unwrap(), @@ -87,9 +87,9 @@ fn write_stub_lib_info(out_dir: &std::path::PathBuf) { write!( std::fs::File::create(locations_path).unwrap(), "\ -pub const INCLUDE : &str = \"\"; \n\ -pub const LIBS : &str = \"\"; \n\ -pub const LIB : &str = \"\"; \n\ +pub const INCLUDE_DIR : &str = \"\"; \n\ +pub const LIB_DIR : &str = \"\"; \n\ +pub const LIBS : &[&str] = [\"\"]; \n\ " ); } @@ -102,11 +102,12 @@ fn write_lib_info_from_env(usd_root: &str, out_dir: &std::path::PathBuf) { write!( std::fs::File::create(locations_path).unwrap(), "\ -pub const INCLUDE : &str = \"{0}/include\"; \n\ -pub const LIBS : &str = \"{0}/lib\"; \n\ -pub const LIB : &str = \"usd_ms\"; \n\ +pub const INCLUDE_DIR : &str = \"{0}/include\"; \n\ +pub const LIB_DIR : &str = \"{0}/lib\"; \n\ +pub const LIBS : &[&str] = &{1}; \n\ ", - usd_root + usd_root, + stringify!(["usd_usd", "usd_sdf", "usd_vt", "usd_gf", "usd_tf"]) ); } diff --git a/usd-rs/build.rs b/usd-rs/build.rs index 204aec1e..0b0843d0 100644 --- a/usd-rs/build.rs +++ b/usd-rs/build.rs @@ -42,14 +42,16 @@ fn main() { } else { // Explicitly link to the usd cpp library. This should propagate upwards // to other libraries - println!("cargo:rustc-link-lib={}", usd_cpp::LIB); - println!("cargo:rustc-link-search={}", usd_cpp::LIBS); + for lib in usd_cpp::LIBS { + println!("cargo:rustc-link-lib={}", lib); + } + println!("cargo:rustc-link-search={}", usd_cpp::LIB_DIR); - //panic!("cargo:rustc-link-libs={}", usd_cpp::LIBS); + //panic!("cargo:rustc-link-libs={}", usd_cpp::LIB_DIR); // Handle the embedded c++ code cpp_build::Config::new() - .include(usd_cpp::INCLUDE) + .include(usd_cpp::INCLUDE_DIR) .flag("-std=c++14") .build("src/lib.rs"); }