Description
Fornjot models are Rust packages that are compiled as dynamic libraries, then loaded into the Fornjot application at runtime. Right now, the user needs to add the following to their model's Cargo.toml
to make that work:
[lib]
crate-type = ["cdylib"]
If they don't do that, this results in the following unfriendly error message:
thread 'main' panicked at 'Error reloading model: LibLoading(DlOpen { desc: "target/debug/liberror.so: cannot open shared object file: No such file or directory" })', crates/fj-host/src/lib.rs:279:25
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
It should be possible to use cargo rustc
to compile models, and pass the --crate-type
argument (which has just been stabilized) to compile models as dynamic libraries. This should remove the need to specify the crate type in Cargo.toml
.
The code that compiles models lives in fj-host
:
https://github.com/hannobraun/Fornjot/blob/c5aee575fe443d2e0f91fd198a7b44b88ddff0fc/crates/fj-host/src/lib.rs#L91-L96
Labeling as https://github.com/hannobraun/Fornjot/labels/good%20first%20issue, as this should be a relatively small change, if it works out.