Changeset View
Changeset View
Standalone View
Standalone View
Mk/Uses/cargo.mk
# This file contains logic to ease porting of Rust packages or | # This file contains logic to ease porting of Rust packages or | ||||
# binaries using the `cargo` command. | # binaries using the `cargo` command. | ||||
# | # | ||||
# Feature: cargo | # Feature: cargo | ||||
# Usage: USES=cargo | # Usage: USES=cargo | ||||
# Valid ARGS: none | # Valid ARGS: none | ||||
# | # | ||||
# MAINTAINER: rust@FreeBSD.org | # MAINTAINER: rust@FreeBSD.org | ||||
.if !defined(_INCLUDE_USES_CARGO_MK) | .if !defined(_INCLUDE_USES_CARGO_MK) | ||||
_INCLUDE_USES_CARGO_MK= yes | _INCLUDE_USES_CARGO_MK= yes | ||||
.if !empty(cargo_ARGS) | . if !empty(cargo_ARGS) | ||||
IGNORE+= USES=cargo takes no arguments | IGNORE+= USES=cargo takes no arguments | ||||
.endif | . endif | ||||
.sinclude "${MASTERDIR}/Makefile.crates" | .sinclude "${MASTERDIR}/Makefile.crates" | ||||
# List of static dependencies. The format is cratename-version. | # List of static dependencies. The format is cratename-version. | ||||
# CARGO_CRATES will be downloaded from MASTER_SITE_CRATESIO. | # CARGO_CRATES will be downloaded from MASTER_SITE_CRATESIO. | ||||
CARGO_CRATES?= | CARGO_CRATES?= | ||||
# List of features to build (space separated list). | # List of features to build (space separated list). | ||||
# Use special token --no-default-features to disable default | # Use special token --no-default-features to disable default | ||||
# features by passing it to cargo build/install/test. | # features by passing it to cargo build/install/test. | ||||
CARGO_FEATURES?= | CARGO_FEATURES?= | ||||
# Name of the local directory for vendoring crates. | # Name of the local directory for vendoring crates. | ||||
CARGO_VENDOR_DIR?= ${WRKSRC}/cargo-crates | CARGO_VENDOR_DIR?= ${WRKSRC}/cargo-crates | ||||
# Default path for cargo manifest. | # Default path for cargo manifest. | ||||
CARGO_CARGOTOML?= ${WRKSRC}/Cargo.toml | CARGO_CARGOTOML?= ${WRKSRC}/Cargo.toml | ||||
CARGO_CARGOLOCK?= ${WRKSRC}/Cargo.lock | CARGO_CARGOLOCK?= ${WRKSRC}/Cargo.lock | ||||
# Save crates inside ${DISTDIR}/rust/crates by default. | # Save crates inside ${DISTDIR}/rust/crates by default. | ||||
CARGO_DIST_SUBDIR?= rust/crates | CARGO_DIST_SUBDIR?= rust/crates | ||||
# Generate list of DISTFILES. | # Generate list of DISTFILES. | ||||
# Prefer canonical file extension .crate going forward | # Prefer canonical file extension .crate going forward | ||||
.if make(makesum) | . if make(makesum) | ||||
CARGO_CRATE_EXT= .crate | CARGO_CRATE_EXT= .crate | ||||
.else | . else | ||||
# If there is a rust/crates/*.tar.gz in distinfo keep using the old | # If there is a rust/crates/*.tar.gz in distinfo keep using the old | ||||
# extension. We need to delay eval until the last moment for | # extension. We need to delay eval until the last moment for | ||||
# DISTINFO_FILE. We cache the command output to avoid multiple | # DISTINFO_FILE. We cache the command output to avoid multiple | ||||
# slow grep runs for every CARGO_CRATE_EXT access. | # slow grep runs for every CARGO_CRATE_EXT access. | ||||
CARGO_CRATE_EXT= ${defined(_CARGO_CRATE_EXT_CACHE):?${_CARGO_CRATE_EXT_CACHE}:${:!if ${GREP} -q '\(${CARGO_DIST_SUBDIR}/.*\.tar\.gz\)' "${DISTINFO_FILE}" 2>/dev/null; then ${ECHO_CMD} .tar.gz; else ${ECHO_CMD} .crate; fi!:_=_CARGO_CRATE_EXT_CACHE}} | CARGO_CRATE_EXT= ${defined(_CARGO_CRATE_EXT_CACHE):?${_CARGO_CRATE_EXT_CACHE}:${:!if ${GREP} -q '\(${CARGO_DIST_SUBDIR}/.*\.tar\.gz\)' "${DISTINFO_FILE}" 2>/dev/null; then ${ECHO_CMD} .tar.gz; else ${ECHO_CMD} .crate; fi!:_=_CARGO_CRATE_EXT_CACHE}} | ||||
.endif | . endif | ||||
_CARGO_CRATES:= ${CARGO_CRATES:N*@git+*} | _CARGO_CRATES:= ${CARGO_CRATES:N*@git+*} | ||||
_CARGO_GIT_SOURCES:= ${CARGO_CRATES:M*@git+*} | _CARGO_GIT_SOURCES:= ${CARGO_CRATES:M*@git+*} | ||||
# enumerate crates for unqiue and sane distfile group names | # enumerate crates for unqiue and sane distfile group names | ||||
_CARGO_CRATES:= ${empty(_CARGO_CRATES):?:${_CARGO_CRATES:range:@i@$i ${_CARGO_CRATES:[$i]}@}} | _CARGO_CRATES:= ${empty(_CARGO_CRATES):?:${_CARGO_CRATES:range:@i@$i ${_CARGO_CRATES:[$i]}@}} | ||||
# split up crates into (index, crate, name, version) 4-tuples | # split up crates into (index, crate, name, version) 4-tuples | ||||
_CARGO_CRATES:= ${_CARGO_CRATES:C/^([-_a-zA-Z0-9]+)-([0-9].*)/\0 \1 \2/} | _CARGO_CRATES:= ${_CARGO_CRATES:C/^([-_a-zA-Z0-9]+)-([0-9].*)/\0 \1 \2/} | ||||
.for _index _crate _name _version in ${_CARGO_CRATES} | . for _index _crate _name _version in ${_CARGO_CRATES} | ||||
# Resolving CRATESIO alias is very inefficient with many MASTER_SITES, consume MASTER_SITE_CRATESIO directly | # Resolving CRATESIO alias is very inefficient with many MASTER_SITES, consume MASTER_SITE_CRATESIO directly | ||||
MASTER_SITES+= ${MASTER_SITE_CRATESIO:S,%SUBDIR%,${_name}/${_version},:S,$,:_cargo_${_index},} | MASTER_SITES+= ${MASTER_SITE_CRATESIO:S,%SUBDIR%,${_name}/${_version},:S,$,:_cargo_${_index},} | ||||
DISTFILES+= ${CARGO_DIST_SUBDIR}/${_crate}${CARGO_CRATE_EXT}:_cargo_${_index} | DISTFILES+= ${CARGO_DIST_SUBDIR}/${_crate}${CARGO_CRATE_EXT}:_cargo_${_index} | ||||
# Provide pointer to the crate's extraction dir | # Provide pointer to the crate's extraction dir | ||||
WRKSRC_crate_${_name}= ${CARGO_VENDOR_DIR}/${_crate} | WRKSRC_crate_${_name}= ${CARGO_VENDOR_DIR}/${_crate} | ||||
# ... also with version suffix in case of multiple versions of the | # ... also with version suffix in case of multiple versions of the | ||||
# same crate | # same crate | ||||
WRKSRC_crate_${_crate}= ${CARGO_VENDOR_DIR}/${_crate} | WRKSRC_crate_${_crate}= ${CARGO_VENDOR_DIR}/${_crate} | ||||
.endfor | . endfor | ||||
_CARGO_AWK= ${AWK} -vCP="${CP}" -vFIND="${FIND}" -vGREP="${GREP}" \ | _CARGO_AWK= ${AWK} -vCP="${CP}" -vFIND="${FIND}" -vGREP="${GREP}" \ | ||||
-vCARGO_VENDOR_DIR="${CARGO_VENDOR_DIR}" \ | -vCARGO_VENDOR_DIR="${CARGO_VENDOR_DIR}" \ | ||||
-vGIT_SOURCES="${_CARGO_GIT_SOURCES}" \ | -vGIT_SOURCES="${_CARGO_GIT_SOURCES}" \ | ||||
-vWRKDIR="${WRKDIR}" -vWRKSRC="${WRKSRC}" \ | -vWRKDIR="${WRKDIR}" -vWRKSRC="${WRKSRC}" \ | ||||
-f${SCRIPTSDIR}/split-url.awk \ | -f${SCRIPTSDIR}/split-url.awk \ | ||||
-f${SCRIPTSDIR}/cargo-crates-git-common.awk -f | -f${SCRIPTSDIR}/cargo-crates-git-common.awk -f | ||||
.if !empty(_CARGO_GIT_SOURCES) | . if !empty(_CARGO_GIT_SOURCES) | ||||
. for _index _site _filename _wrksrc _crates in ${:!${_CARGO_AWK} ${SCRIPTSDIR}/cargo-crates-git-fetch.awk /dev/null!} | . for _index _site _filename _wrksrc _crates in ${:!${_CARGO_AWK} ${SCRIPTSDIR}/cargo-crates-git-fetch.awk /dev/null!} | ||||
MASTER_SITES+= ${_site}:_cargo_git${_index} | MASTER_SITES+= ${_site}:_cargo_git${_index} | ||||
DISTFILES+= ${_filename}:_cargo_git${_index} | DISTFILES+= ${_filename}:_cargo_git${_index} | ||||
. for _crate in ${_crates:S/,/ /g} | . for _crate in ${_crates:S/,/ /g} | ||||
# Make sure the build dependencies checks below can work for git sourced crates too | # Make sure the build dependencies checks below can work for git sourced crates too | ||||
_CARGO_CRATES+= @git ${_crate} ${_crate} @git | _CARGO_CRATES+= @git ${_crate} ${_crate} @git | ||||
# Provide pointer to the crate's extraction dir | # Provide pointer to the crate's extraction dir | ||||
# | # | ||||
# This might not point to the actual crate's sources since a | # This might not point to the actual crate's sources since a | ||||
# single git source can contain multiple crates. We cannot collect | # single git source can contain multiple crates. We cannot collect | ||||
# subdir information until after the full extraction is done and we | # subdir information until after the full extraction is done and we | ||||
# cannot set make variables at that point. This is better than | # cannot set make variables at that point. This is better than | ||||
# nothing. | # nothing. | ||||
WRKSRC_crate_${_crate}= ${WRKDIR}/${_wrksrc} | WRKSRC_crate_${_crate}= ${WRKDIR}/${_wrksrc} | ||||
. endfor | . endfor | ||||
. endfor | . endfor | ||||
.endif | . endif | ||||
# Build dependencies. | # Build dependencies. | ||||
CARGO_BUILDDEP?= yes | CARGO_BUILDDEP?= yes | ||||
.if ${CARGO_BUILDDEP:tl} == "yes" | . if ${CARGO_BUILDDEP:tl} == "yes" | ||||
BUILD_DEPENDS+= ${RUST_DEFAULT}>=1.59.0:lang/${RUST_DEFAULT} | BUILD_DEPENDS+= ${RUST_DEFAULT}>=1.59.0:lang/${RUST_DEFAULT} | ||||
.endif | . endif | ||||
# Location of toolchain (default to lang/rust's toolchain) | # Location of toolchain (default to lang/rust's toolchain) | ||||
CARGO?= ${LOCALBASE}/bin/cargo | CARGO?= ${LOCALBASE}/bin/cargo | ||||
RUSTC?= ${LOCALBASE}/bin/rustc | RUSTC?= ${LOCALBASE}/bin/rustc | ||||
RUSTDOC?= ${LOCALBASE}/bin/rustdoc | RUSTDOC?= ${LOCALBASE}/bin/rustdoc | ||||
# Location of the cargo output directory. | # Location of the cargo output directory. | ||||
CARGO_TARGET_DIR?= ${WRKDIR}/target | CARGO_TARGET_DIR?= ${WRKDIR}/target | ||||
Show All 18 Lines | CARGO_ENV+= \ | ||||
CARGO_BUILD_JOBS=${MAKE_JOBS_NUMBER} \ | CARGO_BUILD_JOBS=${MAKE_JOBS_NUMBER} \ | ||||
CARGO_BUILD_TARGET=${CARGO_BUILD_TARGET} \ | CARGO_BUILD_TARGET=${CARGO_BUILD_TARGET} \ | ||||
CARGO_TARGET_DIR=${CARGO_TARGET_DIR} \ | CARGO_TARGET_DIR=${CARGO_TARGET_DIR} \ | ||||
CARGO_TARGET_${CARGO_BUILD_TARGET:S/-/_/g:tu}_LINKER="${CC}" \ | CARGO_TARGET_${CARGO_BUILD_TARGET:S/-/_/g:tu}_LINKER="${CC}" \ | ||||
RUSTC=${RUSTC} \ | RUSTC=${RUSTC} \ | ||||
RUSTDOC=${RUSTDOC} \ | RUSTDOC=${RUSTDOC} \ | ||||
RUSTFLAGS="${RUSTFLAGS} ${LDFLAGS:C/.+/-C link-arg=&/}" | RUSTFLAGS="${RUSTFLAGS} ${LDFLAGS:C/.+/-C link-arg=&/}" | ||||
.if ${ARCH} != powerpc | . if ${ARCH} != powerpc | ||||
CARGO_ENV+= RUST_BACKTRACE=1 | CARGO_ENV+= RUST_BACKTRACE=1 | ||||
.endif | . endif | ||||
# Adjust -C target-cpu if -march/-mcpu is set by bsd.cpu.mk | # Adjust -C target-cpu if -march/-mcpu is set by bsd.cpu.mk | ||||
.if ${ARCH} == amd64 || ${ARCH} == i386 | . if ${ARCH} == amd64 || ${ARCH} == i386 | ||||
RUSTFLAGS+= ${CFLAGS:M-march=*:S/-march=/-C target-cpu=/} | RUSTFLAGS+= ${CFLAGS:M-march=*:S/-march=/-C target-cpu=/} | ||||
.elif ${ARCH:Mpowerpc*} | . elif ${ARCH:Mpowerpc*} | ||||
RUSTFLAGS+= ${CFLAGS:M-mcpu=*:S/-mcpu=/-C target-cpu=/:S/power/pwr/} | RUSTFLAGS+= ${CFLAGS:M-mcpu=*:S/-mcpu=/-C target-cpu=/:S/power/pwr/} | ||||
.else | . else | ||||
RUSTFLAGS+= ${CFLAGS:M-mcpu=*:S/-mcpu=/-C target-cpu=/} | RUSTFLAGS+= ${CFLAGS:M-mcpu=*:S/-mcpu=/-C target-cpu=/} | ||||
.endif | . endif | ||||
.if defined(PPC_ABI) && ${PPC_ABI} == ELFv1 | . if defined(PPC_ABI) && ${PPC_ABI} == ELFv1 | ||||
USE_GCC?= yes | USE_GCC?= yes | ||||
STRIP_CMD= ${LOCALBASE}/bin/strip # unsupported e_type with base strip | STRIP_CMD= ${LOCALBASE}/bin/strip # unsupported e_type with base strip | ||||
.endif | . endif | ||||
# Helper to shorten cargo calls. | # Helper to shorten cargo calls. | ||||
_CARGO_RUN= ${SETENV} ${MAKE_ENV} ${CARGO_ENV} ${CARGO} | _CARGO_RUN= ${SETENV} ${MAKE_ENV} ${CARGO_ENV} ${CARGO} | ||||
CARGO_CARGO_RUN= cd ${WRKSRC}; ${SETENV} CARGO_FREEBSD_PORTS_SKIP_GIT_UPDATE=1 ${_CARGO_RUN} | CARGO_CARGO_RUN= cd ${WRKSRC}; ${SETENV} CARGO_FREEBSD_PORTS_SKIP_GIT_UPDATE=1 ${_CARGO_RUN} | ||||
# User arguments for cargo targets. | # User arguments for cargo targets. | ||||
CARGO_BUILD_ARGS?= | CARGO_BUILD_ARGS?= | ||||
CARGO_INSTALL_ARGS?= | CARGO_INSTALL_ARGS?= | ||||
CARGO_INSTALL_PATH?= . | CARGO_INSTALL_PATH?= . | ||||
CARGO_TEST_ARGS?= | CARGO_TEST_ARGS?= | ||||
CARGO_UPDATE_ARGS?= | CARGO_UPDATE_ARGS?= | ||||
# Use module targets ? | # Use module targets ? | ||||
CARGO_BUILD?= yes | CARGO_BUILD?= yes | ||||
CARGO_CONFIGURE?= yes | CARGO_CONFIGURE?= yes | ||||
CARGO_INSTALL?= yes | CARGO_INSTALL?= yes | ||||
CARGO_TEST?= yes | CARGO_TEST?= yes | ||||
# rustc stashes intermediary files in TMPDIR (default /tmp) which | # rustc stashes intermediary files in TMPDIR (default /tmp) which | ||||
# might cause issues for users that for some reason space limit | # might cause issues for users that for some reason space limit | ||||
# their /tmp. WRKDIR should have plenty of space. | # their /tmp. WRKDIR should have plenty of space. | ||||
# Allow users and ports to still overwrite it. | # Allow users and ports to still overwrite it. | ||||
.if ${TMPDIR:U/tmp} == /tmp | . if ${TMPDIR:U/tmp} == /tmp | ||||
TMPDIR= ${WRKDIR} | TMPDIR= ${WRKDIR} | ||||
.endif | . endif | ||||
# Manage crate features. | # Manage crate features. | ||||
.if !empty(CARGO_FEATURES:M--no-default-features) | . if !empty(CARGO_FEATURES:M--no-default-features) | ||||
CARGO_BUILD_ARGS+= --no-default-features | CARGO_BUILD_ARGS+= --no-default-features | ||||
CARGO_INSTALL_ARGS+= --no-default-features | CARGO_INSTALL_ARGS+= --no-default-features | ||||
CARGO_TEST_ARGS+= --no-default-features | CARGO_TEST_ARGS+= --no-default-features | ||||
.endif | . endif | ||||
.if !empty(CARGO_FEATURES:N--no-default-features) | . if !empty(CARGO_FEATURES:N--no-default-features) | ||||
CARGO_BUILD_ARGS+= --features='${CARGO_FEATURES:N--no-default-features}' | CARGO_BUILD_ARGS+= --features='${CARGO_FEATURES:N--no-default-features}' | ||||
CARGO_INSTALL_ARGS+= --features='${CARGO_FEATURES:N--no-default-features}' | CARGO_INSTALL_ARGS+= --features='${CARGO_FEATURES:N--no-default-features}' | ||||
CARGO_TEST_ARGS+= --features='${CARGO_FEATURES:N--no-default-features}' | CARGO_TEST_ARGS+= --features='${CARGO_FEATURES:N--no-default-features}' | ||||
.endif | . endif | ||||
.if !defined(WITH_DEBUG) | . if !defined(WITH_DEBUG) | ||||
CARGO_BUILD_ARGS+= --release | CARGO_BUILD_ARGS+= --release | ||||
CARGO_TEST_ARGS+= --release | CARGO_TEST_ARGS+= --release | ||||
.else | . else | ||||
CARGO_INSTALL_ARGS+= --debug | CARGO_INSTALL_ARGS+= --debug | ||||
.endif | . endif | ||||
.if ${_CARGO_CRATES:Mcmake} | . if ${_CARGO_CRATES:Mcmake} | ||||
BUILD_DEPENDS+= cmake:devel/cmake | BUILD_DEPENDS+= cmake:devel/cmake | ||||
.endif | . endif | ||||
.if ${_CARGO_CRATES:Mgettext-sys} | . if ${_CARGO_CRATES:Mgettext-sys} | ||||
CARGO_ENV+= GETTEXT_BIN_DIR=${LOCALBASE}/bin \ | CARGO_ENV+= GETTEXT_BIN_DIR=${LOCALBASE}/bin \ | ||||
GETTEXT_INCLUDE_DIR=${LOCALBASE}/include \ | GETTEXT_INCLUDE_DIR=${LOCALBASE}/include \ | ||||
GETTEXT_LIB_DIR=${LOCALBASE}/lib | GETTEXT_LIB_DIR=${LOCALBASE}/lib | ||||
.endif | . endif | ||||
.if ${_CARGO_CRATES:Mjemalloc-sys} | . if ${_CARGO_CRATES:Mjemalloc-sys} | ||||
BUILD_DEPENDS+= gmake:devel/gmake | BUILD_DEPENDS+= gmake:devel/gmake | ||||
.endif | . endif | ||||
.if ${_CARGO_CRATES:Mlibgit2-sys} | . if ${_CARGO_CRATES:Mlibgit2-sys} | ||||
# Use the system's libgit2 instead of building the bundled version | # Use the system's libgit2 instead of building the bundled version | ||||
CARGO_ENV+= LIBGIT2_SYS_USE_PKG_CONFIG=1 | CARGO_ENV+= LIBGIT2_SYS_USE_PKG_CONFIG=1 | ||||
.endif | . endif | ||||
.if ${_CARGO_CRATES:Mlibssh2-sys} | . if ${_CARGO_CRATES:Mlibssh2-sys} | ||||
# Use the system's libssh2 instead of building the bundled version | # Use the system's libssh2 instead of building the bundled version | ||||
CARGO_ENV+= LIBSSH2_SYS_USE_PKG_CONFIG=1 | CARGO_ENV+= LIBSSH2_SYS_USE_PKG_CONFIG=1 | ||||
.endif | . endif | ||||
.if ${_CARGO_CRATES:Monig_sys} | . if ${_CARGO_CRATES:Monig_sys} | ||||
# onig_sys always prefers the system library but will try to link | # onig_sys always prefers the system library but will try to link | ||||
# statically with it. Since devel/oniguruma doesn't provide a static | # statically with it. Since devel/oniguruma doesn't provide a static | ||||
# library it'll link to libonig.so instead. Strictly speaking setting | # library it'll link to libonig.so instead. Strictly speaking setting | ||||
# RUSTONIG_SYSTEM_LIBONIG is not necessary, but will force onig_sys to | # RUSTONIG_SYSTEM_LIBONIG is not necessary, but will force onig_sys to | ||||
# always use the system's libonig as returned by `pkg-config oniguruma`. | # always use the system's libonig as returned by `pkg-config oniguruma`. | ||||
CARGO_ENV+= RUSTONIG_SYSTEM_LIBONIG=1 | CARGO_ENV+= RUSTONIG_SYSTEM_LIBONIG=1 | ||||
.endif | . endif | ||||
.if ${_CARGO_CRATES:Mopenssl-src} | . if ${_CARGO_CRATES:Mopenssl-src} | ||||
DEV_WARNING+= "Please make sure this port uses the system OpenSSL and consider removing CARGO_CRATES=${CARGO_CRATES:Mopenssl-src-[0-9]*} (a vendored copy of OpenSSL) from the build, e.g., by patching Cargo.toml appropriately." | DEV_WARNING+= "Please make sure this port uses the system OpenSSL and consider removing CARGO_CRATES=${CARGO_CRATES:Mopenssl-src-[0-9]*} (a vendored copy of OpenSSL) from the build, e.g., by patching Cargo.toml appropriately." | ||||
.endif | . endif | ||||
.if ${_CARGO_CRATES:Mopenssl-sys} | . if ${_CARGO_CRATES:Mopenssl-sys} | ||||
# Make sure that openssl-sys can find the correct version of OpenSSL | # Make sure that openssl-sys can find the correct version of OpenSSL | ||||
CARGO_ENV+= OPENSSL_LIB_DIR=${OPENSSLLIB} \ | CARGO_ENV+= OPENSSL_LIB_DIR=${OPENSSLLIB} \ | ||||
OPENSSL_INCLUDE_DIR=${OPENSSLINC} | OPENSSL_INCLUDE_DIR=${OPENSSLINC} | ||||
.endif | . endif | ||||
.if ${_CARGO_CRATES:Mpkg-config} | . if ${_CARGO_CRATES:Mpkg-config} | ||||
.include "${USESDIR}/pkgconfig.mk" | .include "${USESDIR}/pkgconfig.mk" | ||||
.endif | . endif | ||||
.for _index _crate _name _version in ${_CARGO_CRATES} | . for _index _crate _name _version in ${_CARGO_CRATES} | ||||
# Split up semantic version and try to sanitize it by removing | # Split up semantic version and try to sanitize it by removing | ||||
# pre-release identifier (-) or build metadata (+) | # pre-release identifier (-) or build metadata (+) | ||||
. if ${_version:S/./ /:S/./ /:C/[-+].*//:_:[#]} == 3 | . if ${_version:S/./ /:S/./ /:C/[-+].*//:_:[#]} == 3 | ||||
. for _major _minor _patch in $_ | . for _major _minor _patch in $_ | ||||
# FreeBSD 12.0 changed ABI: r318736 and r320043 | # FreeBSD 12.0 changed ABI: r318736 and r320043 | ||||
# https://github.com/rust-lang/libc/commit/78f93220d70e | # https://github.com/rust-lang/libc/commit/78f93220d70e | ||||
# https://github.com/rust-lang/libc/commit/969ad2b73cdc | # https://github.com/rust-lang/libc/commit/969ad2b73cdc | ||||
. if ${_name} == libc && ${_major} == 0 && (${_minor} < 2 || (${_minor} == 2 && ${_patch} < 38)) | . if ${_name} == libc && ${_major} == 0 && (${_minor} < 2 || (${_minor} == 2 && ${_patch} < 38)) | ||||
DEV_ERROR+= "CARGO_CRATES=${_crate} may be unstable on FreeBSD 12.0. Consider updating to the latest version \(higher than 0.2.37\)." | DEV_ERROR+= "CARGO_CRATES=${_crate} may be unstable on FreeBSD 12.0. Consider updating to the latest version \(higher than 0.2.37\)." | ||||
. endif | . endif | ||||
. if ${_name} == libc && ${_major} == 0 && (${_minor} < 2 || (${_minor} == 2 && ${_patch} < 49)) | . if ${_name} == libc && ${_major} == 0 && (${_minor} < 2 || (${_minor} == 2 && ${_patch} < 49)) | ||||
DEV_ERROR+= "CARGO_CRATES=${_crate} may be unstable on aarch64 or not build on armv6, armv7, powerpc64. Consider updating to the latest version \(higher than 0.2.49\)." | DEV_ERROR+= "CARGO_CRATES=${_crate} may be unstable on aarch64 or not build on armv6, armv7, powerpc64. Consider updating to the latest version \(higher than 0.2.49\)." | ||||
. endif | . endif | ||||
# FreeBSD 12.0 updated base OpenSSL in r339270: | # FreeBSD 12.0 updated base OpenSSL in r339270: | ||||
# https://github.com/sfackler/rust-openssl/commit/276577553501 | # https://github.com/sfackler/rust-openssl/commit/276577553501 | ||||
. if ${_name} == openssl && !exists(${PATCHDIR}/patch-openssl-1.1.1) && ${_major} == 0 && (${_minor} < 10 || (${_minor} == 10 && ${_patch} < 4)) | . if ${_name} == openssl && !exists(${PATCHDIR}/patch-openssl-1.1.1) && ${_major} == 0 && (${_minor} < 10 || (${_minor} == 10 && ${_patch} < 4)) | ||||
DEV_WARNING+= "CARGO_CRATES=${_crate} does not support OpenSSL 1.1.1. Consider updating to the latest version \(higher than 0.10.3\)." | DEV_WARNING+= "CARGO_CRATES=${_crate} does not support OpenSSL 1.1.1. Consider updating to the latest version \(higher than 0.10.3\)." | ||||
. endif | . endif | ||||
. endfor | . endfor | ||||
. endif | . endif | ||||
.endfor | . endfor | ||||
_USES_extract+= 600:cargo-extract | _USES_extract+= 600:cargo-extract | ||||
cargo-extract: | cargo-extract: | ||||
# target for preparing crates directory. It will put all crates in | # target for preparing crates directory. It will put all crates in | ||||
# the local crates directory. | # the local crates directory. | ||||
@${ECHO_MSG} "===> Moving crates to ${CARGO_VENDOR_DIR}" | @${ECHO_MSG} "===> Moving crates to ${CARGO_VENDOR_DIR}" | ||||
@${MKDIR} ${CARGO_VENDOR_DIR} | @${MKDIR} ${CARGO_VENDOR_DIR} | ||||
.for _index _crate _name _version in ${_CARGO_CRATES} | . for _index _crate _name _version in ${_CARGO_CRATES} | ||||
. if ${_index} != @git | . if ${_index} != @git | ||||
@${MV} ${WRKDIR}/${_crate} ${CARGO_VENDOR_DIR}/${_crate} | @${MV} ${WRKDIR}/${_crate} ${CARGO_VENDOR_DIR}/${_crate} | ||||
@${PRINTF} '{"package":"%s","files":{}}' \ | @${PRINTF} '{"package":"%s","files":{}}' \ | ||||
$$(${SHA256} -q ${DISTDIR}/${CARGO_DIST_SUBDIR}/${_crate}${CARGO_CRATE_EXT}) \ | $$(${SHA256} -q ${DISTDIR}/${CARGO_DIST_SUBDIR}/${_crate}${CARGO_CRATE_EXT}) \ | ||||
> ${CARGO_VENDOR_DIR}/${_crate}/.cargo-checksum.json | > ${CARGO_VENDOR_DIR}/${_crate}/.cargo-checksum.json | ||||
@if [ -r ${CARGO_VENDOR_DIR}/${_crate}/Cargo.toml.orig ]; then \ | @if [ -r ${CARGO_VENDOR_DIR}/${_crate}/Cargo.toml.orig ]; then \ | ||||
${MV} ${CARGO_VENDOR_DIR}/${_crate}/Cargo.toml.orig \ | ${MV} ${CARGO_VENDOR_DIR}/${_crate}/Cargo.toml.orig \ | ||||
${CARGO_VENDOR_DIR}/${_crate}/Cargo.toml.orig-cargo; \ | ${CARGO_VENDOR_DIR}/${_crate}/Cargo.toml.orig-cargo; \ | ||||
fi | fi | ||||
. endif | . endif | ||||
.endfor | . endfor | ||||
.if ${CARGO_CONFIGURE:tl} == "yes" | . if ${CARGO_CONFIGURE:tl} == "yes" | ||||
_USES_configure+= 250:cargo-configure | _USES_configure+= 250:cargo-configure | ||||
# configure hook. Place a config file for overriding crates-io index | # configure hook. Place a config file for overriding crates-io index | ||||
# by local source directory. | # by local source directory. | ||||
cargo-configure: | cargo-configure: | ||||
# Check that the running kernel has COMPAT_FREEBSD11 required by lang/rust post-ino64 | # Check that the running kernel has COMPAT_FREEBSD11 required by lang/rust post-ino64 | ||||
@${SETENV} CC="${CC}" OPSYS="${OPSYS}" OSVERSION="${OSVERSION}" WRKDIR="${WRKDIR}" \ | @${SETENV} CC="${CC}" OPSYS="${OPSYS}" OSVERSION="${OSVERSION}" WRKDIR="${WRKDIR}" \ | ||||
${SH} ${SCRIPTSDIR}/rust-compat11-canary.sh | ${SH} ${SCRIPTSDIR}/rust-compat11-canary.sh | ||||
@${ECHO_MSG} "===> Cargo config:" | @${ECHO_MSG} "===> Cargo config:" | ||||
@${MKDIR} ${WRKDIR}/.cargo | @${MKDIR} ${WRKDIR}/.cargo | ||||
@: > ${WRKDIR}/.cargo/config.toml | @: > ${WRKDIR}/.cargo/config.toml | ||||
@${ECHO_CMD} "[source.cargo]" >> ${WRKDIR}/.cargo/config.toml | @${ECHO_CMD} "[source.cargo]" >> ${WRKDIR}/.cargo/config.toml | ||||
@${ECHO_CMD} "directory = '${CARGO_VENDOR_DIR}'" >> ${WRKDIR}/.cargo/config.toml | @${ECHO_CMD} "directory = '${CARGO_VENDOR_DIR}'" >> ${WRKDIR}/.cargo/config.toml | ||||
@${ECHO_CMD} "[source.crates-io]" >> ${WRKDIR}/.cargo/config.toml | @${ECHO_CMD} "[source.crates-io]" >> ${WRKDIR}/.cargo/config.toml | ||||
@${ECHO_CMD} "replace-with = 'cargo'" >> ${WRKDIR}/.cargo/config.toml | @${ECHO_CMD} "replace-with = 'cargo'" >> ${WRKDIR}/.cargo/config.toml | ||||
.if !empty(_CARGO_GIT_SOURCES) | . if !empty(_CARGO_GIT_SOURCES) | ||||
@${_CARGO_AWK} ${SCRIPTSDIR}/cargo-crates-git-configure.awk \ | @${_CARGO_AWK} ${SCRIPTSDIR}/cargo-crates-git-configure.awk \ | ||||
/dev/null >> ${WRKDIR}/.cargo/config.toml | /dev/null >> ${WRKDIR}/.cargo/config.toml | ||||
.endif | . endif | ||||
@${CAT} ${WRKDIR}/.cargo/config.toml | @${CAT} ${WRKDIR}/.cargo/config.toml | ||||
@if ! ${GREP} -qF '[profile.release]' ${CARGO_CARGOTOML}; then \ | @if ! ${GREP} -qF '[profile.release]' ${CARGO_CARGOTOML}; then \ | ||||
${ECHO_CMD} "" >> ${CARGO_CARGOTOML}; \ | ${ECHO_CMD} "" >> ${CARGO_CARGOTOML}; \ | ||||
${ECHO_CMD} "[profile.release]" >> ${CARGO_CARGOTOML}; \ | ${ECHO_CMD} "[profile.release]" >> ${CARGO_CARGOTOML}; \ | ||||
${ECHO_CMD} "opt-level = 2" >> ${CARGO_CARGOTOML}; \ | ${ECHO_CMD} "opt-level = 2" >> ${CARGO_CARGOTOML}; \ | ||||
${ECHO_CMD} "debug = false" >> ${CARGO_CARGOTOML}; \ | ${ECHO_CMD} "debug = false" >> ${CARGO_CARGOTOML}; \ | ||||
fi | fi | ||||
@${ECHO_MSG} "===> Updating Cargo.lock" | @${ECHO_MSG} "===> Updating Cargo.lock" | ||||
@${CARGO_CARGO_RUN} update \ | @${CARGO_CARGO_RUN} update \ | ||||
--manifest-path ${CARGO_CARGOTOML} \ | --manifest-path ${CARGO_CARGOTOML} \ | ||||
--verbose \ | --verbose \ | ||||
--verbose \ | --verbose \ | ||||
${CARGO_UPDATE_ARGS} | ${CARGO_UPDATE_ARGS} | ||||
.endif | . endif | ||||
.if !target(do-build) && ${CARGO_BUILD:tl} == "yes" | . if !target(do-build) && ${CARGO_BUILD:tl} == "yes" | ||||
do-build: | do-build: | ||||
@${CARGO_CARGO_RUN} build \ | @${CARGO_CARGO_RUN} build \ | ||||
--manifest-path ${CARGO_CARGOTOML} \ | --manifest-path ${CARGO_CARGOTOML} \ | ||||
--verbose \ | --verbose \ | ||||
--verbose \ | --verbose \ | ||||
${CARGO_BUILD_ARGS} | ${CARGO_BUILD_ARGS} | ||||
.endif | . endif | ||||
.if !target(do-install) && ${CARGO_INSTALL:tl} == "yes" | . if !target(do-install) && ${CARGO_INSTALL:tl} == "yes" | ||||
do-install: | do-install: | ||||
. for path in ${CARGO_INSTALL_PATH} | . for path in ${CARGO_INSTALL_PATH} | ||||
@${CARGO_CARGO_RUN} install \ | @${CARGO_CARGO_RUN} install \ | ||||
--no-track \ | --no-track \ | ||||
--path "${path}" \ | --path "${path}" \ | ||||
--root "${STAGEDIR}${PREFIX}" \ | --root "${STAGEDIR}${PREFIX}" \ | ||||
--verbose \ | --verbose \ | ||||
--verbose \ | --verbose \ | ||||
${CARGO_INSTALL_ARGS} | ${CARGO_INSTALL_ARGS} | ||||
. endfor | . endfor | ||||
.endif | . endif | ||||
.if !target(do-test) && ${CARGO_TEST:tl} == "yes" | . if !target(do-test) && ${CARGO_TEST:tl} == "yes" | ||||
do-test: | do-test: | ||||
@${CARGO_CARGO_RUN} test \ | @${CARGO_CARGO_RUN} test \ | ||||
--manifest-path ${CARGO_CARGOTOML} \ | --manifest-path ${CARGO_CARGOTOML} \ | ||||
--verbose \ | --verbose \ | ||||
--verbose \ | --verbose \ | ||||
${CARGO_TEST_ARGS} | ${CARGO_TEST_ARGS} | ||||
.endif | . endif | ||||
# | # | ||||
# Helper targets for port maintainers | # Helper targets for port maintainers | ||||
# | # | ||||
# cargo-audit generates a vulnerability report using | # cargo-audit generates a vulnerability report using | ||||
# security/cargo-audit based on the crates in Cargo.lock. | # security/cargo-audit based on the crates in Cargo.lock. | ||||
cargo-audit: configure | cargo-audit: configure | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |