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

Draft: Allows binding against a non monolithic build #17

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
21 changes: 11 additions & 10 deletions usd-cpp/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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\
"
);
}
Expand All @@ -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"])
);
}

Expand Down
10 changes: 6 additions & 4 deletions usd-rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down