Skip to content

Add libwflow shared library #998

Description

@visr

Feature type

Adding new functionality

Improvement Description

Right now we compile Wflow.jl with PackageCompiler to wflow_cli.exe. BMI usage is only supported via Julia, not via a C API. I propose to use the same approach as Ribasim. In Ribasim we use JuliaC to compile libribasim. This contains the BMI functions via a C API, plus other functions deemed useful. Then we have a small Rust CLI using clap. That parses the command line options, loads libribasim and starts the simulation.

  • libwflow: having a shared library makes integration into other software easier, for instance iMOD coupler, or possibly a GUI
  • CLI: add support for flags like --help and --version, brought up in Update docs for MSIX, remove WiX installer #996
  • JuliaC vs PackageCompiler: either could work, but JuliaC is a bit faster to compile. Note this is without trimming. If we want to experiment with trimming (small binaries), we'd be using the right tool already.
  • Rust: Ribasim compiled both libribasim and ribasim.exe separately for a while, but you are essentially (slowly) compiling the same code twice. If you have libwflow, the CLI can be tiny. When we distribute it is always the shared library + the CLI. We chose Rust since it is good at this kind of stuff. It is only about 60 lines of code. You can add the Rust toolchain to the Pixi environment. This does make it bigger.
  • Having similar approach between Wflow and Ribasim can make maintenance easier.

Implementation Description

All in all this does add some complexity compared to the current setup, but we gain several features, and copy most of the code from Ribasim.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions