Skip to main content

Crate cargo_fmi

Crate cargo_fmi 

Source
Expand description

§cargo-fmi

github crates.io docs.rs build status

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:

  1. Building dynamic libraries from Rust FMU dylib crates
  2. Creating the proper FMU directory structure
  3. Generating model description XML files
  4. 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 bundle

The 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.fmu

Available 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 bundle

See the fmi-export README for a complete walkthrough.

§Integration with User Projects

To use this tooling in your own Rust FMI projects:

  1. Install the Cargo subcommand:
cargo install cargo-fmi
  1. Configure your crate as cdylib in Cargo.toml:
[lib]
crate-type = ["cdylib"]
  1. Use the bundle command as shown above

§Supported Platforms

The following Rust target -> FMI platform mappings are supported:

Rust TargetFMI Platform
i686-unknown-linux-gnux86-linux
x86_64-unknown-linux-gnux86_64-linux
aarch64-unknown-linux-gnuaarch64-linux
x86_64-pc-windows-gnux86_64-windows
x86_64-pc-windows-msvcx86_64-windows
i686-pc-windows-gnux86-windows
i686-pc-windows-msvcx86-windows
x86_64-apple-darwinx86_64-darwin
aarch64-apple-darwinaarch64-darwin

§License

Licensed under either of

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.

§Feature flags

Functions§

entrypoint
entrypoint_from