Skip to content

Commit

Permalink
build(opencascade-sys): rework building process of OpenCACADE
Browse files Browse the repository at this point in the history
The previous building process had multiple issues:

- When for example running 'cargo clean && cargo build --workspace
  --release'. Cargo launched two simultaneous compilations of
  opencascade resulting in a race conditions cloning the source code.

- Builds and source code where compiled into the source directory
  instead of the target/ folder.

- Builds of OpenCASCADE did not reflect the correct optmimization level,
  since building happened inside a build-dependency instead of a
  dependency of occara

This new approach fixes all of the above listed issues.
  • Loading branch information
maximmaxim345 committed Jun 27, 2024
1 parent d5a8df2 commit c89a18d
Show file tree
Hide file tree
Showing 6 changed files with 401 additions and 360 deletions.
6 changes: 3 additions & 3 deletions crates/occara/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use walkdir::WalkDir;

fn main() -> miette::Result<()> {
let include_dir = opencascade_sys::include_dir();
let build = opencascade_sys::OpenCascadeSource::new().build();
// Find all cpp files in the cpp directory
let files: Vec<_> = WalkDir::new("cpp")
.into_iter()
Expand Down Expand Up @@ -33,7 +33,7 @@ fn main() -> miette::Result<()> {
// Generate autocxx bindings
let mut autocxx_build = autocxx_build::Builder::new(
"src/ffi.rs",
[&std::path::PathBuf::from("include"), &include_dir],
[&std::path::PathBuf::from("include"), build.include_dir()],
)
.build()?;

Expand All @@ -43,6 +43,6 @@ fn main() -> miette::Result<()> {
.compile("occara-autocxx-bridge");
println!("cargo:rerun-if-changed=src/ffi.rs");

opencascade_sys::link_opencascade();
build.link();
Ok(())
}
File renamed without changes.
2 changes: 0 additions & 2 deletions crates/opencascade-sys/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions crates/opencascade-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[build-dependencies]
cmake = "0.1.50"
walkdir = "2.4.0"
266 changes: 0 additions & 266 deletions crates/opencascade-sys/build.rs

This file was deleted.

Loading

0 comments on commit c89a18d

Please sign in to comment.