Skip to content
Draft
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
15 changes: 15 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[build]
jobs = -1

[target.'cfg(all())']
rustflags = [
"-Wclippy::all",
"-Wclippy::pedantic",
"-Wclippy::nursery",
"-Wclippy::unwrap_used",
"-Aclippy::module_name_repetitions",
"-Aclippy::missing_errors_doc",
]

[net]
git-fetch-with-cli = true
79 changes: 79 additions & 0 deletions .github/workflows/ci-rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: rust

on:
push:
branches:
- 'master'
- 'develop'
- 'rust-bindings'
tags-ignore:
- '**'
paths:
- 'rust/**'
- '.github/workflows/ci-rust.yml'

pull_request:
paths:
- 'rust/**'
- '.github/workflows/ci-rust.yml'

workflow_dispatch: ~

env:
CARGO_TERM_COLOR: always
CARGO_NET_GIT_FETCH_WITH_CLI: "true"

jobs:
fmt:
name: fmt
runs-on: ubuntu-latest
defaults:
run:
working-directory: rust
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

- name: Format check
run: cargo fmt --check

clippy:
name: clippy
if: ${{ !github.event.pull_request.head.repo.fork }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: rust
steps:
- uses: actions/checkout@v4

- name: Configure git for private repos
run: git config --global url."https://x-access-token:${{ secrets.GH_REPO_READ_TOKEN }}@github.com/".insteadOf "ssh://git@github.com/"

- uses: dtolnay/rust-toolchain@stable
with:
components: clippy

- name: Clippy
run: cargo clippy --features vendored --all-targets -- -D warnings

test:
name: test
if: ${{ !github.event.pull_request.head.repo.fork }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: rust
steps:
- uses: actions/checkout@v4

- name: Configure git for private repos
run: git config --global url."https://x-access-token:${{ secrets.GH_REPO_READ_TOKEN }}@github.com/".insteadOf "ssh://git@github.com/"

- uses: dtolnay/rust-toolchain@stable

- name: Test
run: cargo test --features vendored
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ python/**/*.cpp
python/**/*.c
python/**/__pycache__
python/**/*.cpython-*

# Rust
rust/target/
rust/Cargo.lock
32 changes: 32 additions & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[workspace]
resolver = "2"
members = ["crates/mir-sys"]

[workspace.package]
edition = "2024"
license = "Apache-2.0"
repository = "https://github.com/ecmwf/mir"
rust-version = "1.90"
readme = "README.md"
keywords = ["ecmwf", "weather", "meteorology", "interpolation", "regridding"]
categories = ["science"]

[workspace.dependencies]
# Internal
mir-sys = { path = "crates/mir-sys" }

# Foundation crates
eckit-sys = { git = "ssh://git@github.com/ecmwf/eckit.git", branch = "rust-bindings", default-features = false }
metkit-sys = { git = "ssh://git@github.com/ecmwf/metkit.git", branch = "rust-bindings", default-features = false }
eccodes-sys = { git = "ssh://git@github.com/ecmwf/eccodes.git", branch = "rust-bindings", default-features = false }
atlas-sys = { git = "ssh://git@github.com/ecmwf/atlas.git", branch = "rust-bindings", default-features = false }

# Build tools
bindman = { git = "ssh://git@github.com/ecmwf/bindman.git", branch = "generate_exception_bridge" }
bindman-build = { git = "ssh://git@github.com/ecmwf/bindman.git", branch = "generate_exception_bridge" }
bindman-utils = { git = "ssh://git@github.com/ecmwf/bindman.git", branch = "generate_exception_bridge" }

# External
cxx = "1.0"
cxx-build = "1.0"
thiserror = "2"
53 changes: 53 additions & 0 deletions rust/crates/mir-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[package]
name = "mir-sys"
version = "1.28.2"
edition.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
readme.workspace = true
keywords.workspace = true
categories.workspace = true
description = "C++ bindings to ECMWF mir (Meteorological Interpolation and Regridding) library using cxx"
links = "mir_sys"
build = "build.rs"

[features]
default = ["vendored"]

# Build strategy (mutually exclusive)
vendored = [
"eckit-sys/vendored",
"eckit-sys/eckit-spec",
"eckit-sys/eckit-geo",
"eckit-sys/geo-codec-grids",
"metkit-sys/vendored",
"metkit-sys/grib",
"eccodes-sys/vendored",
"eccodes-sys/product-grib",
"eccodes-sys/geography",
"eccodes-sys/memfs",
"eccodes-sys/eccodes-threads",
"atlas-sys/vendored",
]
system = [
"eckit-sys/system",
"metkit-sys/system",
"eccodes-sys/system",
"atlas-sys/system",
]

[dependencies]
cxx.workspace = true
eckit-sys = { workspace = true, default-features = false }
metkit-sys = { workspace = true, default-features = false }
eccodes-sys = { workspace = true, default-features = false }
atlas-sys = { workspace = true, default-features = false }
bindman.workspace = true

[build-dependencies]
cxx-build.workspace = true
bindman-build.workspace = true
bindman-utils.workspace = true

[package.metadata.docs.rs]
18 changes: 18 additions & 0 deletions rust/crates/mir-sys/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# mir-sys

Low-level Rust bindings to ECMWF's [mir](https://github.com/ecmwf/mir) (Meteorological Interpolation and Regridding) C++ library.

This crate provides raw FFI bindings using [cxx](https://cxx.rs/). For a safe, ergonomic API, use the higher-level `mir` crate (planned).

## Features

### Build strategy (mutually exclusive)

- `vendored` - Build mir and its dependencies (eckit, metkit, ecCodes, atlas) from source.
- `system` - Link against system-installed mir.

`vendored` is enabled by default.

## License

Apache-2.0
Loading
Loading