build-style/cargo.sh: add
This commit is contained in:
parent
17eda45988
commit
0318d0385a
|
@ -734,6 +734,10 @@ The current list of available `build_style` scripts is the following:
|
|||
`do_configure()`, `do_build()`, etc., and may overwrite default `do_fetch()` and
|
||||
`do_extract()` that fetch and extract files defined in `distfiles` variable.
|
||||
|
||||
- `cargo` For packages written in rust that use Cargo for building.
|
||||
Configuration arguments (such as `--features`) can be defined in the variable
|
||||
`configure_args` and are passed to cargo during `do_build`.
|
||||
|
||||
- `cmake` For packages that use the CMake build system, configuration arguments
|
||||
can be passed in via `configure_args`. The `cmake_builddir` variable may be
|
||||
defined to specify the directory for building under `build_wrksrc` instead of
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#
|
||||
# This helper is for building rust projects which use cargo for building
|
||||
#
|
||||
|
||||
do_configure() {
|
||||
mkdir -p .cargo
|
||||
# respect makejobs, do cross stuff
|
||||
cat > .cargo/config <<EOF
|
||||
[build]
|
||||
jobs = ${makejobs#*j}
|
||||
target = "${RUST_TARGET}"
|
||||
|
||||
[target.${RUST_TARGET}]
|
||||
linker = "${CC}"
|
||||
EOF
|
||||
}
|
||||
|
||||
do_build() {
|
||||
: ${make_cmd:=cargo}
|
||||
|
||||
${make_cmd} build --release ${configure_args}
|
||||
}
|
||||
|
||||
do_check() {
|
||||
: ${make_cmd:=cargo}
|
||||
|
||||
${make_cmd} test --release ${make_check_args}
|
||||
}
|
||||
|
||||
do_install() {
|
||||
: ${make_cmd:=cargo}
|
||||
|
||||
${make_cmd} install --root="${DESTDIR}/usr" ${make_install_args}
|
||||
rm "${DESTDIR}"/usr/.crates.toml
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
hostmakedepends+=" cargo"
|
||||
|
||||
if [ "$CROSS_BUILD" ]; then
|
||||
makedepends+=" rust"
|
||||
fi
|
||||
|
||||
# Use the config we set in do_configure
|
||||
export CARGO_HOME="$wrksrc/.cargo"
|
||||
|
||||
export PKG_CONFIG_ALLOW_CROSS=1
|
Loading…
Reference in New Issue