1.\" $OpenBSD: cargo-module.5,v 1.10 2025/01/13 18:20:47 kirill Exp $ 2.\" 3.\" Copyright (c) 2008 Marc Espie 4.\" Copyright (c) 2017 Daniel Jakots 5.\" 6.\" All rights reserved. 7.\" 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" notice, this list of conditions and the following disclaimer in the 15.\" documentation and/or other materials provided with the distribution. 16.\" 17.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 18.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 21.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27.\" 28.Dd $Mdocdate: January 13 2025 $ 29.Dt CARGO-MODULE 5 30.Os 31.Sh NAME 32.Nm cargo-module 33.Nd devel/cargo port module 34.Sh DESCRIPTION 35This manual page documents the behavior of setting 36.Li MODULES=devel/cargo 37in the 38.Xr ports 7 39tree. 40.Pp 41Automates download and compilation of dependencies of a Rust project using 42.Xr cargo 1 . 43.Pp 44During 45.Cm fetch , 46static dependencies ("crates") listed in 47.Ev MODCARGO_CRATES 48are downloaded using 49.Ev MODCARGO_DIST_SUBDIR 50as 51.Ev DIST_SUBDIR . 52.Pp 53During 54.Cm post-extract , 55crates defined in 56.Ev MODCARGO_CRATES 57are moved to the 58.Ev MODCARGO_VENDOR_DIR 59directory. 60.Pp 61During 62.Cm post-patch , 63crate-metadata are generated using 64.Pa devel/cargo-generate-vendor . 65.Pp 66With 67.Ev CONFIGURE_STYLE 68set to 69.Sq cargo , 70cargo is configured to use 71.Ev MODCARGO_VENDOR_DIR 72instead of the standard crates-io network source. 73Finally, any crates listed in 74.Ev MODCARGO_CRATES_UPDATE 75are updated. 76.Pp 77.Ev MODCARGO_RUSTFLAGS 78can be used to pass custom flags to all 79.Xr rustc 1 80invocations. 81.Pp 82.Pa lang/rust 83is added to 84.Ev MODULES , 85and 86.Pa devel/cargo-generate-vendor 87is added to 88.Ev BUILD_DEPENDS . 89.Pp 90This module defines: 91.Bl -tag -width MODCARGO_INSTALL_TARGET_PATHS 92.It Ev MODCARGO_CARGOTOML 93Path to cargo manifest. 94Defaults to 95.Pa ${WRKSRC}/Cargo.toml . 96.It Ev MODCARGO_CARGOLOCK 97Path to 98.Pa Cargo.lock , 99which is used only by the 100.Cm modcargo-gen-crates 101target. 102Defaults to 103.Pa ${MODCARGO_CARGOTOML:toml=lock} . 104.It Ev MODCARGO_CRATES 105Crates that will be downloaded by the module. 106.It Ev MODCARGO_CRATES_UPDATE 107List of crates to update, overriding the version listed in Cargo.lock. 108.It Ev MODCARGO_FEATURES 109List of features to be used when building. 110.It Ev MODCARGO_INSTALL_TARGET_PATHS 111List of paths to pass to 112.Cm cargo install 113instead of 114.Pa \&. . 115Needs to be set for some virtual manifests. 116.It Ev MODCARGO_VENDOR_DIR 117Name of the local directory for vendoring crates. 118Defaults to 119.Pa ${WRKSRC}/modcargo-crates . 120.It Ev MODCARGO_WANTLIB 121Architecture-specific 122.Ev WANTLIB 123entries required by all Rust code. 124It is a copy of 125.Ev MODRUST_WANTLIB 126provided for simplicity. 127.El 128.Pp 129This module adds three 130.Xr make 1 131targets: 132.Bl -tag -width modcargo-gen-crates-licenses 133.It Cm modcargo-metadata 134Rerun the generation of crates' metadata. 135.It Cm modcargo-gen-crates 136Generate the 137.Ev MODCARGO_CRATES 138list from Cargo.lock (a preliminary crates list is not required). 139.It Cm modcargo-gen-crates-licenses 140Generate the 141.Ev MODCARGO_CRATES 142list with license information from crates present in the 143.Ev MODCARGO_VENDOR_DIR 144directory. 145.El 146.Sh SEE ALSO 147.Xr port-modules 5 148