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
19 changes: 19 additions & 0 deletions .ci/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,22 @@ time = "01:00:00"

[[matrix.build-hpc.include]]
options = ""

# Publishing the crates, only from publish-crates.yml: no patches and the default features, as a
# crates.io user gets them, so mir-sys builds its C++ from the release tag.
[packages.mir-crates]
compiler-inputs = ["cxx-compiler", "rust-compiler"]
allow-stale-deps = true

[matrix.rust-publish]
packages = ["mir-crates"]
publishes = false

[[matrix.rust-publish.include]]
job-script = "./.ci/runner/rust-publish.sh.j2"
runs-on = "arc-runner-very-large"
cxx-compiler = "g++-13"
c-compiler = "gcc-13"
rust-compiler = "rust-1.90"
container = "eccr.ecmwf.int/public-ci-images/ubuntu24.04-gcc13-gfortran13-boost-qt6-rust1.90"
platform = "ubuntu-24.04"
3 changes: 3 additions & 0 deletions .ci/runner/rust-publish.sh.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{# SPDX-FileCopyrightText: 1996- European Centre for Medium-Range Weather Forecasts (ECMWF)
SPDX-License-Identifier: Apache-2.0 #}
{% extends "ci-infrastructure/rust-bindings-publish.sh.j2" %}
68 changes: 68 additions & 0 deletions .github/workflows/publish-crates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# SPDX-FileCopyrightText: 1996- European Centre for Medium-Range Weather Forecasts (ECMWF)
# SPDX-License-Identifier: Apache-2.0

name: publish-crates

# A release tag dry-runs the crates as a sanity check; publishing is manual only: dispatch on any ref with mode=publish.
# mir-sys builds its C++ from the tag of its version, so a dry run fails until that tag exists.
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
inputs:
mode:
type: choice
options: [dry-run, publish]
default: dry-run

permissions:
contents: read

jobs:
resolve:
runs-on: arc-runner-normal
container:
image: eccr.ecmwf.int/public-ci-images/ubuntu24.04-base:latest
outputs:
matrix: ${{ toJSON(fromJSON(steps.r.outputs.json)['rust-publish']) }}
steps:
- name: Announce image
uses: ecmwf/ci-infrastructure/actions/announce-image@main
- id: mint
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
client-id: ${{ secrets.CI_PERMISSIONS_APP_CLIENT_ID }}
private-key: ${{ secrets.CI_PERMISSIONS_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
- id: r
uses: ecmwf/ci-infrastructure/actions/resolve-deps@main
with:
matrix: rust-publish
token: ${{ steps.mint.outputs.token }}
client-id: ${{ secrets.CI_PERMISSIONS_APP_CLIENT_ID }}
app-private-key: ${{ secrets.CI_PERMISSIONS_APP_PRIVATE_KEY }}

publish:
needs: resolve
name: publish (${{ matrix._resolved['job-name'] }})
runs-on: ${{ matrix['runs-on'] }}
container:
image: ${{ matrix.container }}
strategy:
matrix: ${{ fromJSON(needs.resolve.outputs.matrix) }}
steps:
- name: Announce image
uses: ecmwf/ci-infrastructure/actions/announce-image@main
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6

- name: Publish the crates
uses: ecmwf/ci-infrastructure/actions/run-job-script@main
env:
CI_CARGO_PUBLISH: ${{ inputs.mode == 'publish' && 'publish' || 'dry-run' }}
CARGO_REGISTRY_TOKEN: ${{ inputs.mode == 'publish' && secrets.CARGO_REGISTRY_TOKEN || '' }}
with:
job-script: ${{ matrix.job-script }}
matrix-leg: ${{ toJSON(matrix) }}
package: mir-crates
18 changes: 8 additions & 10 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,18 @@ categories = ["science"]

[workspace.dependencies]
# Internal
mir-sys = { path = "crates/mir-sys" }
mir-sys = { version = "1.30", path = "crates/mir-sys", default-features = false }

# Foundation crates
eckit-sys = { git = "ssh://git@github.com/ecmwf/eckit.git", branch = "develop", default-features = false }
# Pinned to match metkit-sys: a differing spec resolves to a second eccodes-sys,
# and both declare `links = "eccodes_sys"`.
eccodes-sys = { git = "ssh://git@github.com/ecmwf/rust-wrappers-playground.git", rev = "1c0e477", default-features = false }
atlas-sys = { git = "ssh://git@github.com/ecmwf/atlas.git", branch = "rust-bindings", default-features = false }
metkit-sys = { git = "ssh://git@github.com/ecmwf/metkit.git", rev = "fa8e791", default-features = false }
eckit-sys = { version = "2.5", default-features = false }
eccodes-sys = { version = "2.50", default-features = false }
atlas-sys = { version = "0.47", default-features = false }
metkit-sys = { version = "1.22", default-features = false }

# Build tools
bindman = { git = "ssh://git@github.com/ecmwf/bindman.git", rev = "47edf68" }
bindman-build = { git = "ssh://git@github.com/ecmwf/bindman.git", rev = "47edf68" }
bindman-utils = { git = "ssh://git@github.com/ecmwf/bindman.git", rev = "47edf68" }
bindman = "0.2"
bindman-build = "0.2"
bindman-utils = "0.2"

# External
cxx = "1.0"
Expand Down
5 changes: 4 additions & 1 deletion rust/crates/mir-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ links = "mir_sys"
build = "build.rs"

[features]
default = ["vendored"]
default = ["vendored", "download-masks"]

# Download land-sea masks during the vendored build (ENABLE_MIR_DOWNLOAD_MASKS)
download-masks = []

# Build strategy (mutually exclusive)
vendored = [
Expand Down
5 changes: 5 additions & 0 deletions rust/crates/mir-sys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ CMake locates the libraries through `CMAKE_PREFIX_PATH`.

`vendored` is enabled by default.

### Vendored build options

- `download-masks` - Download the land-sea mask files during the vendored build
(`ENABLE_MIR_DOWNLOAD_MASKS`). Enabled by default; no effect with `system`.

## License

Apache-2.0
10 changes: 9 additions & 1 deletion rust/crates/mir-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ fn build_system() {

bindman_utils::link_cpp_stdlib();

// Rpaths for this crate's own test binaries; consumers emit their own.
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", lib_dir.display());
bindman_utils::emit_rpaths();

println!("cargo:root={}", root.display());
println!("cargo:include={}", mir_include.display());

Expand Down Expand Up @@ -216,7 +220,11 @@ fn build_vendored() {
))
.arg("-DENABLE_TESTS=OFF")
.arg("-DBUILD_TESTING=OFF")
.arg("-DENABLE_BUILD_TOOLS=OFF");
.arg("-DENABLE_BUILD_TOOLS=OFF")
.arg(format!(
"-DENABLE_MIR_DOWNLOAD_MASKS={}",
bindman_utils::on_off(cfg!(feature = "download-masks"))
));

#[cfg(target_os = "macos")]
cmd.arg("-DCMAKE_INSTALL_NAME_DIR=@rpath");
Expand Down
1 change: 1 addition & 0 deletions rust/crates/mir-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ include!(concat!(env!("OUT_DIR"), "/mir_exceptions.rs"));
pub mod ffi {
unsafe extern "C++" {
include!("MirBridge.h");
include!("mir_exceptions.h");

// Cross-crate ExternType from eckit-sys
#[namespace = "eckit_bridge"]
Expand Down
Loading