Changeset View
Changeset View
Standalone View
Standalone View
Mk/Uses/rust.mk
- This file was added.
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | native \ No newline at end of property |
svn:keywords | null | FreeBSD=%H \ No newline at end of property |
svn:mime-type | null | text/plain \ No newline at end of property |
# Provide support for Rust | |||||
# | |||||
# Feature: rust | |||||
# Usage: USES=rust | |||||
# Valid ARGS: build (default), nightly, run | |||||
# | |||||
# build add a build dependency on Rust | |||||
# nightly allow nightly features during the build. Use this instead | |||||
# of depending on lang/rust-nightly directly | |||||
# run add a run dependency on Rust | |||||
# | |||||
# MAINTAINER: rust@FreeBSD.org | |||||
.if !defined(_INCLUDE_USES_RUST_MK) | |||||
_INCLUDE_USES_RUST_MK= yes | |||||
_valid_ARGS= build nightly run | |||||
.for _arg in ${rust_ARGS} | |||||
. if empty(_valid_ARGS:M${_arg}) | |||||
IGNORE= 'USES+= rust:${rust_ARGS}' usage: argument [${_arg}] is not recognized | |||||
. endif | |||||
.endfor | |||||
.if empty(rust_ARGS) | |||||
rust_ARGS+= build | |||||
.endif | |||||
_RUST_VERSION= 1.51.0 | |||||
.if ${rust_ARGS:Mbuild} | |||||
BUILD_DEPENDS+= ${RUST_DEFAULT}>=${_RUST_VERSION}:lang/${RUST_DEFAULT} | |||||
.endif | |||||
.if ${rust_ARGS:Mrun} | |||||
RUN_DEPENDS+= ${RUST_DEFAULT}>=${_RUST_VERSION}:lang/${RUST_DEFAULT} | |||||
.endif | |||||
# We use absolute paths to the tools to not accidentally use installed | |||||
# rustup toolchains | |||||
CARGO?= ${LOCALBASE}/bin/cargo | |||||
RUSTC?= ${LOCALBASE}/bin/rustc | |||||
RUSTDOC?= ${LOCALBASE}/bin/rustdoc | |||||
RUSTFMT?= ${LOCALBASE}/bin/rustfmt | |||||
# Hook for sccache support? | |||||
RUSTC_WRAPPER?= | |||||
# Adjust -C target-cpu if -march/-mcpu is set by bsd.cpu.mk | |||||
.if ${ARCH} == amd64 || ${ARCH} == i386 | |||||
RUSTFLAGS+= ${CFLAGS:M-march=*:S/-march=/-C target-cpu=/} | |||||
.elif ${ARCH:Mpowerpc64*} | |||||
RUSTFLAGS+= ${CFLAGS:M-mcpu=*:S/-mcpu=/-C target-cpu=/:S/power/pwr/} | |||||
.else | |||||
RUSTFLAGS+= ${CFLAGS:M-mcpu=*:S/-mcpu=/-C target-cpu=/} | |||||
.endif | |||||
# CARGO_BUILD_JOBS: configure number of jobs to run | |||||
# RUST_BACKTRACE: produce backtraces when something in the build panics | |||||
# RUSTFLAGS: custom flags to pass to all rustc invocations, make | |||||
# sure we use CC as linker driver and respect LDFLAGS | |||||
_RUST_ENV+= CARGO=${CARGO} \ | |||||
CARGO_BUILD_JOBS=${MAKE_JOBS_NUMBER} \ | |||||
RUST_BACKTRACE=1 \ | |||||
RUSTC=${RUSTC} \ | |||||
RUSTDOC=${RUSTDOC} \ | |||||
RUSTFMT=${RUSTFMT} \ | |||||
RUSTFLAGS="${RUSTFLAGS} -C linker=${CC:Q} ${LDFLAGS:C/.+/-C link-arg=&/}" | |||||
.if ${rust_ARGS:Mnightly} | |||||
_RUST_ENV+= RUSTC_BOOTSTRAP=1 | |||||
.endif | |||||
.if !empty(RUSTC_WRAPPER) | |||||
_RUST_ENV+= RUSTC_WRAPPER=${RUSTC_WRAPPER} | |||||
.endif | |||||
CONFIGURE_ENV+= ${_RUST_ENV} | |||||
MAKE_ENV+= ${_RUST_ENV} | |||||
.if !defined(RUST_KEEP_VENDOR_CHECKSUMS) | |||||
# Disable cargo vendor checksums by default; make sure porters do not need to | |||||
# manually fix .cargo-checksum.json files when patching crates | |||||
_USES_extract+= 600:rust-disable-vendor-checksums | |||||
rust-disable-vendor-checksums: | |||||
@${FIND} ${WRKDIR} -name .cargo-checksum.json -type f \ | |||||
-exec ${SED} -i '' -e 's/"files":{[^}]*}/"files":{}/' {} \+ | |||||
.endif | |||||
.endif |