Expand description
§cargo-fmi
The cargo-fmi subcommand builds FMU (Functional Mockup Interface) packages from Rust crates.
This crate is part of rust-fmi.
§Overview
The cargo-fmi system automates the process of:
- Building dynamic libraries from Rust FMU dylib crates
- Creating the proper FMU directory structure
- Generating model description XML files
- Packaging everything into a compliant FMU ZIP file
§Install
cargo install cargo-fmi§Usage
§Creating a New Project
cargo fmi new my-model§Building for Single Platform
Build an FMU for the current platform:
cargo fmi --package bouncing_ball bundleThe FMU zip is written to:
target/fmu/<model_identifier>.fmu<model_identifier> is the cdylib target name (hyphens become underscores).
Build for a specific target:
cargo fmi --package bouncing_ball bundle \
--target x86_64-pc-windows-gnu \
--release§Inspecting Model Metadata
Inspect the generated model description for a packaged FMU:
cargo fmi inspect target/fmu/bouncing_ball.fmuAvailable formats:
cargo fmi inspect target/fmu/bouncing_ball.fmu --format model-description
cargo fmi inspect target/fmu/bouncing_ball.fmu --format debug§Package Info
Print the model description struct that would be serialized for packaging:
cargo fmi --package bouncing_ball info§End-to-end example (this repo)
cargo fmi --package can-triggered-output bundleSee the fmi-export README for a complete walkthrough.
§Integration with User Projects
To use this tooling in your own Rust FMI projects:
- Install the Cargo subcommand:
cargo install cargo-fmi- Configure your crate as cdylib in
Cargo.toml:
[lib]
crate-type = ["cdylib"]- Use the bundle command as shown above
§Supported Platforms
The following Rust target -> FMI platform mappings are supported:
| Rust Target | FMI Platform |
|---|---|
| i686-unknown-linux-gnu | x86-linux |
| x86_64-unknown-linux-gnu | x86_64-linux |
| aarch64-unknown-linux-gnu | aarch64-linux |
| x86_64-pc-windows-gnu | x86_64-windows |
| x86_64-pc-windows-msvc | x86_64-windows |
| i686-pc-windows-gnu | x86-windows |
| i686-pc-windows-msvc | x86-windows |
| x86_64-apple-darwin | x86_64-darwin |
| aarch64-apple-darwin | aarch64-darwin |
§License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
§Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.