Skip to content

Commit

Permalink
Include cxxbridge-cmd in Cargo.lock, check version consistency
Browse files Browse the repository at this point in the history
This adds cxxbridge-cmd to Cargo.lock per
dtolnay/cxx#1407 (comment)

It adds an MSRV to `src/taskchampion-cpp/Cargo.toml` so that the
version of `Cargo.lock` is stil compatible with the MSRV.

It additionally adds a check of the Cargo metadata for all of the cxx*
versions agreeing.
  • Loading branch information
djmitche committed Dec 1, 2024
1 parent e5ab1bc commit 1b55aad
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 11 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,19 @@ jobs:
with:
command: fmt
args: --all -- --check

cargo-metadata:
runs-on: ubuntu-latest
name: "Cargo Metadata"
steps:
- uses: actions/checkout@v4

- uses: actions-rs/toolchain@v1
with:
profile: minimal
components: rustfmt
toolchain: stable
override: true

- name: "Check metadata"
run: ".github/workflows/metadata-check.sh"
48 changes: 48 additions & 0 deletions .github/workflows/metadata-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#! /bin/bash

# Check the 'cargo metadata' for various requirements

set -e

META=$(mktemp)
trap 'rm -rf -- "${META}"' EXIT

cargo metadata --locked --format-version 1 > "${META}"

get_version() {
local package="${1}"
jq -r '.packages[] | select(.name == "'"${package}"'") | .version' "${META}"
}

# check that the cxx packages all have the same version
cxx_version=$(get_version "cxx")
cxx_build_version=$(get_version "cxx-build")
cxxbridge_cmd_version=$(get_version "cxx-build")
cxxbridge_flags_version=$(get_version "cxxbridge-flags")
cxxbridge_macro_version=$(get_version "cxxbridge-macro")

ok=true
echo "Found cxx version ${cxx_version}"
if [ "${cxx_version}" != "${cxx_build_version}" ]; then
echo "Found differing cxx-build version ${cxx_build_version}"
ok = false
fi
if [ "${cxx_version}" != "${cxxbridge_cmd_version}" ]; then
echo "Found differing cxxbridge-cmd version ${cxxbridge_cmd_version}"
ok = false
fi
if [ "${cxx_version}" != "${cxxbridge_flags_version}" ]; then
echo "Found differing cxxbridge-flags version ${cxxbridge_flags_version}"
ok = false
fi
if [ "${cxx_version}" != "${cxxbridge_macro_version}" ]; then
echo "Found differing cxxbridge-macro version ${cxxbridge_macro_version}"
ok = false
fi

if ! $ok; then
echo "All cxx packages must be at the same version. Fix this in src/taskchampion-cpp/Cargo.toml."
exit 1
else
echo "✓ All cxx packages are at the same version."
fi
1 change: 1 addition & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ jobs:
# If this version is old enough to cause errors, or older than the
# TaskChampion MSRV, bump it to the MSRV of the currently-required
# TaskChampion package; if necessary, bump that version as well.
# This should match the MSRV in `src/taskchampion-cpp/Cargo.toml`.
toolchain: "1.73.0" # MSRV
override: true

Expand Down
68 changes: 60 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/taskchampion-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.22)
make_minimum_required (VERSION 3.22)

OPTION(SYSTEM_CORROSION "Use system provided corrosion instead of vendored version" OFF)
if(SYSTEM_CORROSION)
Expand Down
15 changes: 13 additions & 2 deletions src/taskchampion-cpp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,28 @@ name = "taskchampion-lib"
version = "0.1.0"
edition = "2021"
publish = false
rust-version = "1.73.0" # MSRV

[lib]
crate-type = ["staticlib"]

[dependencies]
taskchampion = "0.9.0"
cxx = "1.0.124"
# All three cxx* dependencies must have precisely the same version.
cxx = "=1.0.124"

[features]
# use native CA roots, instead of bundled
tls-native-roots = ["taskchampion/tls-native-roots"]

[build-dependencies]
cxx-build = "1.0"
# All three cxx* dependencies must have precisely the same version.
cxx-build = "=1.0.124"

# Include cxxbridge-cmd in Cargo.lock along with the others. This gives a
# warning "ignoring invalid dependency `cxxbridge-cmd` which is missing a lib
# target" but this can be safely ignored.
# See https://github.com/dtolnay/cxx/issues/1407#issuecomment-2509136343
[target.'cfg(any())'.dependencies]
# All three cxx* dependencies must have precisely the same version.
cxxbridge-cmd = "=1.0.124"

0 comments on commit 1b55aad

Please sign in to comment.