Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix README.md in builds #1935

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,38 @@ pixi run build
```

> :warning: If the build is failing, because it cannot find certain files, chances are high that you need to enable long paths in Windows.

## Ribasim CLI

In order to find out about it's usage call `ribasim --help`

## Libribasim

Libribasim is a shared library that exposes Ribasim functionality to external (non-Julian)
programs. It can be compiled using [PackageCompiler's
create_lib](https://julialang.github.io/PackageCompiler.jl/stable/libs.html), which is set
up in this directory. The C API that is offered to control Ribasim is the C API of the
[Basic Model Interface](https://bmi.readthedocs.io/en/latest/), also known as BMI.

Not all BMI functions are implemented yet.
Couplings to other models are implemented in [`imod_coupler`](https://github.com/Deltares/imod_coupler).

Here is an example of using libribasim from Python:

```python
In [1]: from ctypes import CDLL, c_int, c_char_p, create_string_buffer, byref

In [2]: c_dll = CDLL("libribasim", winmode=0x08) # winmode for Windows

In [3]: argument = create_string_buffer(0)
...: c_dll.init_julia(c_int(0), byref(argument))
Out[3]: 1

In [4]: config_path = "ribasim.toml"

In [5]: c_dll.initialize(c_char_p(config_path.encode()))
Out[5]: 0

In [6]: c_dll.update()
Out[6]: 0
```
51 changes: 11 additions & 40 deletions build/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,6 @@ using PackageCompiler
using TOML
using LibGit2

"""
# Ribasim CLI

In order to find out about it's usage call `ribasim --help`

# Libribasim

Libribasim is a shared library that exposes Ribasim functionality to external (non-Julian)
programs. It can be compiled using [PackageCompiler's
create_lib](https://julialang.github.io/PackageCompiler.jl/stable/libs.html), which is set
up in this directory. The C API that is offered to control Ribasim is the C API of the
[Basic Model Interface](https://bmi.readthedocs.io/en/latest/), also known as BMI.

Not all BMI functions are implemented yet, this has been set up as a proof of concept to
demonstrate that we can use other software such as
[`imod_coupler`](https://github.com/Deltares/imod_coupler) to control Ribasim and couple it to
other models.

Here is an example of using libribasim from Python:

```python
In [1]: from ctypes import CDLL, c_int, c_char_p, create_string_buffer, byref

In [2]: c_dll = CDLL("libribasim", winmode=0x08) # winmode for Windows

In [3]: argument = create_string_buffer(0)
...: c_dll.init_julia(c_int(0), byref(argument))
Out[3]: 1

In [4]: config_path = "ribasim.toml"

In [5]: c_dll.initialize(c_char_p(config_path.encode()))
Out[5]: 0

In [6]: c_dll.update()
Out[6]: 0
```
"""
function main()
project_dir = "../core"
license_file = "../LICENSE"
Expand All @@ -61,13 +23,22 @@ function main()
force = true,
)

readme = @doc(build_app)
add_metadata(project_dir, license_file, output_dir, git_repo, readme)
add_metadata(project_dir, license_file, output_dir, git_repo, readme_start)
run(Cmd(`cargo build --release`; dir = "cli"))
ribasim = Sys.iswindows() ? "ribasim.exe" : "ribasim"
cp("cli/target/release/$ribasim", "ribasim/$ribasim"; force = true)
end

readme_start = """
# Ribasim

Ribasim is a water resources model to simulate the physical behavior of a managed open water system
based on a set of control rules and a prioritized water allocation strategy.

Usage: `ribasim path/to/model/ribasim.toml`
Documentation: https://ribasim.org/
"""

function set_version(filename, version; group = nothing)
data = TOML.parsefile(filename)
if !isnothing(group)
Expand Down