Here is the first c++/rust cmake port. If you want to build it you need: devel/corrosion and devel/cxxbridge-cmd from ports@. Of course this is a dependency for KDE Plasma 6.7. KDE started to accept rust code in KDE code base and there a more ports will use it.
First of all, I'd like to explain how this works – though this only
applies to ONE Cargo dependency in a CMake project. I think we can give
this some further thought should we encounter this problem.
1.) First, use devel/cargo to point to the toml file and generate
".include "crates.inc"".
MODCARGO_CARGOTOML = ${WRKSRC}/rust/Cargo.toml
2.) We need corrosion
BUILD_DEPENDS = devel/corrosion
CONFIGURE_ARGS += -DINSTALLED_CXXBRIDGE=${LOCALBASE}/bin/cxxbridge-cmd
3.) Here’s the "hack" we should be discussing. I faked a new config.toml
which points to your ${MODCARGO_VENDOR_DIR} (aka. Where are your
crates.inc). This is was a quick and "not an rust user" solution
https://doc.rust-lang.org/cargo/reference/source-replacement.html
What do you think? I think this pattern could work for other
cmake/c++/rust ports too.
CONFIGURE_ENV += CARGO_HOME=${WRKDIR}/cargo-home
MAKE_ENV += CARGO_HOME=${WRKDIR}/cargo-home
pre-configure:
mkdir -p ${WRKDIR}/cargo-home
printf '%s\n' \
'[source.crates-io]' \
'replace-with = "modcargo"' \
'[source.modcargo]' \
'directory = "${MODCARGO_VENDOR_DIR}"' \
'[net]' \
'offline = true' \
> ${WRKDIR}/cargo-home/config.toml
The result certainly works without any problems.
Information for inst:cxx-rust-cssparser-1.0.0
Comment:
library for parsing CSS using the Rust cssparser crate
Required by:
kde-plamsa-union-6.7.0
Description:
A C++ library for parsing CSS that uses the Rust cssparser crate internally.
Maintainer: The OpenBSD ports mailing-list <[email protected]>
WWW: https://invent.kde.org/libraries/cxx-rust-cssparser
cxx-rust-cssparser-1.0.0.tar.gz
Description: application/tar-gz
