Index: head/Mk/Uses/cargo.mk =================================================================== --- head/Mk/Uses/cargo.mk (revision 480252) +++ head/Mk/Uses/cargo.mk (revision 480253) @@ -1,277 +1,283 @@ # $FreeBSD$ # # This file contains logic to ease porting of Rust packages or # binaries using the `cargo` command. # # Feature: cargo # Usage: USES=cargo # Valid ARGS: none # # MAINTAINER: ports@FreeBSD.org .if !defined(_INCLUDE_USES_CARGO_MK) _INCLUDE_USES_CARGO_MK= yes .if !empty(cargo_ARGS) IGNORE+= USES=cargo takes no arguments .endif # List of static dependencies. The format is cratename-version. # CARGO_CRATES will be downloaded from MASTER_SITES_CRATESIO. CARGO_CRATES?= # List of features to build (space separated list). CARGO_FEATURES?= # Name of the local directory for vendoring crates. CARGO_VENDOR_DIR?= ${WRKSRC}/cargo-crates # Default path for cargo manifest. CARGO_CARGOTOML?= ${WRKSRC}/Cargo.toml CARGO_CARGOLOCK?= ${WRKSRC}/Cargo.lock # Define MASTER_SITES_CRATESIO for crates.io MASTER_SITES_CRATESIO= https://crates.io/api/v1/crates # Save crates inside ${DISTDIR}/rust/crates by default. CARGO_DIST_SUBDIR?= rust/crates # Generate list of DISTFILES. .for _crate in ${CARGO_CRATES} MASTER_SITES+= ${MASTER_SITES_CRATESIO}/${_crate:C/^(.*)-[0-9].*/\1/}/${_crate:C/^.*-([0-9].*)/\1/}/download?dummy=/:cargo_${_crate:S/-//g:S/.//g} DISTFILES+= ${CARGO_DIST_SUBDIR}/${_crate}.tar.gz:cargo_${_crate:S/-//g:S/.//g} .endfor # Build dependencies. CARGO_BUILDDEP?= yes .if ${CARGO_BUILDDEP:tl} == "yes" BUILD_DEPENDS+= rust>=1.19.0_2:lang/rust .endif # Location of cargo binary (default to lang/rust's Cargo binary) CARGO_CARGO_BIN?= ${LOCALBASE}/bin/cargo # Location of the cargo output directory. CARGO_TARGET_DIR?= ${WRKDIR}/target # Environment for cargo # - CARGO_HOME: local cache of the registry index # - CARGO_BUILD_JOBS: configure number of jobs to run # - CARGO_TARGET_DIR: location of where to place all generated artifacts # - RUSTC: path of rustc binary (default to lang/rust) # - RUSTDOC: path of rustdoc binary (default to lang/rust) # - RUSTFLAGS: custom flags to pass to all compiler invocations that Cargo performs # # XXX LDFLAGS => -C link-arg=$1 (via RUSTFLAGS) CARGO_ENV+= \ CARGO_HOME=${WRKDIR}/cargo-home \ CARGO_BUILD_JOBS=${MAKE_JOBS_NUMBER} \ CARGO_TARGET_DIR=${CARGO_TARGET_DIR} \ RUSTC=${LOCALBASE}/bin/rustc \ RUSTDOC=${LOCALBASE}/bin/rustdoc \ RUSTFLAGS="${RUSTFLAGS}" # 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=/} .else RUSTFLAGS+= ${CFLAGS:M-mcpu=*:S/-mcpu=/-C target-cpu=/} .endif # Helper to shorten cargo calls. CARGO_CARGO_RUN= \ cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${CARGO_ENV} \ ${CARGO_CARGO_BIN} # User arguments for cargo targets. CARGO_BUILD_ARGS?= CARGO_INSTALL_ARGS?= CARGO_TEST_ARGS?= CARGO_UPDATE_ARGS?= # Use module targets ? CARGO_BUILD?= yes CARGO_CONFIGURE?= yes CARGO_INSTALL?= yes CARGO_TEST?= yes CARGO_USE_GITHUB?= no # If your application has multiple Cargo.toml files which all use # git-sourced dependencies and require the use of CARGO_USE_GITHUB and # GH_TUPLE, then you add them to CARGO_GH_CARGOTOML to also point them # to the correct offline sources. CARGO_GH_CARGOTOML?= ${CARGO_CARGOTOML} # Manage crate features. .if !empty(CARGO_FEATURES) CARGO_BUILD_ARGS+= --features='${CARGO_FEATURES}' CARGO_INSTALL_ARGS+= --features='${CARGO_FEATURES}' CARGO_TEST_ARGS+= --features='${CARGO_FEATURES}' .endif .if !defined(WITH_DEBUG) CARGO_BUILD_ARGS+= --release CARGO_TEST_ARGS+= --release .else CARGO_INSTALL_ARGS+= --debug .endif .if ${CARGO_CRATES:Mbacktrace-sys-[0-9]*} BUILD_DEPENDS+= gmake:devel/gmake .endif .if ${CARGO_CRATES:Mcmake-[0-9]*} BUILD_DEPENDS+= cmake:devel/cmake .endif .if ${CARGO_CRATES:Mfreetype-sys-[0-9]*} LIB_DEPENDS+= libfreetype.so:print/freetype2 .endif .if ${CARGO_CRATES:Mgettext-sys-[0-9]*} .include "${USESDIR}/gettext.mk" CARGO_ENV+= GETTEXT_BIN_DIR=${LOCALBASE}/bin \ GETTEXT_INCLUDE_DIR=${LOCALBASE}/include \ GETTEXT_LIB_DIR=${LOCALBASE}/lib .endif .if ${CARGO_CRATES:Mlibc-[0-9]*} # FreeBSD 12.0 changed ABI: r318736 and r320043 # https://github.com/rust-lang/libc/commit/78f93220d70e # https://github.com/rust-lang/libc/commit/969ad2b73cdc _libc_VER= ${CARGO_CRATES:Mlibc-[0-9]*:C/.*-//} . if ${_libc_VER:R:R} == 0 && (${_libc_VER:R:E} < 2 || ${_libc_VER:R:E} == 2 && ${_libc_VER:E} < 38) DEV_WARNING+= "CARGO_CRATES=libc-0.2.37 or older maybe unstable on FreeBSD 12.0. Consider updating to the latest version." . endif .undef _libc_VER .endif .if ${CARGO_CRATES:Mlibgit2-sys-[0-9]*} # Use the system's libgit2 instead of building the bundled version CARGO_ENV+= LIBGIT2_SYS_USE_PKG_CONFIG=1 LIB_DEPENDS+= libgit2.so:devel/libgit2 .endif +.if ${CARGO_CRATES:Mlibssh2-sys-[0-9]*} +# Use the system's libssh2 instead of building the bundled version +CARGO_ENV+= LIBSSH2_SYS_USE_PKG_CONFIG=1 +LIB_DEPENDS+= libssh2.so:security/libssh2 +.endif + .if ${CARGO_CRATES:Monig_sys-[0-9]*} # onig_sys always prefers the system library but will try to link # statically with it. Since devel/oniguruma doesn't provide a static # library it'll link to libonig.so instead. Strictly speaking setting # RUSTONIG_SYSTEM_LIBONIG is not necessary, but will force onig_sys to # always use the system's libonig as returned by `pkg-config oniguruma`. CARGO_ENV+= RUSTONIG_SYSTEM_LIBONIG=1 LIB_DEPENDS+= libonig.so:devel/oniguruma .endif .if ${CARGO_CRATES:Mopenssl-sys-[0-9]*} # Make sure that openssl-sys can find the correct version of OpenSSL .include "${USESDIR}/ssl.mk" CARGO_ENV+= OPENSSL_LIB_DIR=${OPENSSLLIB} \ OPENSSL_INCLUDE_DIR=${OPENSSLINC} .endif .if ${CARGO_CRATES:Mpkg-config-[0-9]*} .include "${USESDIR}/pkgconfig.mk" .endif .if ${CARGO_CRATES:Mthrussh-libsodium-[0-9]*} LIB_DEPENDS+= libsodium.so:security/libsodium .endif _USES_extract+= 600:cargo-extract cargo-extract: # target for preparing crates directory. It will put all crates in # the local crates directory. @${ECHO_MSG} "===> Moving crates to ${CARGO_VENDOR_DIR}" @${MKDIR} ${CARGO_VENDOR_DIR} .for _crate in ${CARGO_CRATES} @${MV} ${WRKDIR}/${_crate} ${CARGO_VENDOR_DIR}/${_crate} @${PRINTF} '{"package":"%s","files":{}}' \ $$(${SHA256} -q ${DISTDIR}/${CARGO_DIST_SUBDIR}/${_crate}.tar.gz) \ > ${CARGO_VENDOR_DIR}/${_crate}/.cargo-checksum.json .endfor .if ${CARGO_USE_GITHUB:tl} == "yes" _USES_patch+= 600:cargo-patch-github .for _group in ${GH_TUPLE:C@^[^:]*:[^:]*:[^:]*:(([^:/]*)?)((/.*)?)@\2@} _CARGO_GH_PATCH_CARGOTOML:= ${_CARGO_GH_PATCH_CARGOTOML} \ -e 's@git = "(https|http|git)://github.com/${GH_ACCOUNT_${_group}}/${GH_PROJECT_${_group}}(\.git)?"@path = "${WRKSRC_${_group}}"@' .endfor cargo-patch-github: @${SED} -i.dist -E ${_CARGO_GH_PATCH_CARGOTOML} ${CARGO_GH_CARGOTOML} .endif .if !target(do-configure) && ${CARGO_CONFIGURE:tl} == "yes" # configure hook. Place a config file for overriding crates-io index # by local source directory. do-configure: @${MKDIR} ${WRKDIR}/.cargo @${ECHO_CMD} "[source.cargo]" > ${WRKDIR}/.cargo/config @${ECHO_CMD} "directory = '${CARGO_VENDOR_DIR}'" >> ${WRKDIR}/.cargo/config @${ECHO_CMD} "[source.crates-io]" >> ${WRKDIR}/.cargo/config @${ECHO_CMD} "replace-with = 'cargo'" >> ${WRKDIR}/.cargo/config @if ! ${GREP} -qF '[profile.release]' ${CARGO_CARGOTOML}; then \ ${ECHO_CMD} "" >> ${CARGO_CARGOTOML}; \ ${ECHO_CMD} "[profile.release]" >> ${CARGO_CARGOTOML}; \ ${ECHO_CMD} "opt-level = 2" >> ${CARGO_CARGOTOML}; \ ${ECHO_CMD} "debug = false" >> ${CARGO_CARGOTOML}; \ fi @${CARGO_CARGO_RUN} update \ --manifest-path ${CARGO_CARGOTOML} \ --verbose \ ${CARGO_UPDATE_ARGS} .endif .if !target(do-build) && ${CARGO_BUILD:tl} == "yes" do-build: @${CARGO_CARGO_RUN} build \ --manifest-path ${CARGO_CARGOTOML} \ --verbose \ ${CARGO_BUILD_ARGS} .endif .if !target(do-install) && ${CARGO_INSTALL:tl} == "yes" do-install: @${CARGO_CARGO_RUN} install \ --root "${STAGEDIR}${PREFIX}" \ --verbose \ ${CARGO_INSTALL_ARGS} @${RM} -- "${STAGEDIR}${PREFIX}/.crates.toml" .endif .if !target(do-test) && ${CARGO_TEST:tl} == "yes" do-test: @${CARGO_CARGO_RUN} test \ --manifest-path ${CARGO_CARGOTOML} \ --verbose \ ${CARGO_TEST_ARGS} .endif # # Helper targets for port maintainers # # cargo-crates will output the crates list from Cargo.lock. If there # is no Cargo.lock for some reason, try and generate it first. cargo-crates: extract @if [ ! -r "${CARGO_CARGOLOCK}" ]; then \ ${ECHO_MSG} "===> ${CARGO_CARGOLOCK} not found. Trying to generate it..."; \ ${CARGO_CARGO_RUN} generate-lockfile \ --manifest-path ${CARGO_CARGOTOML} \ --verbose; \ fi @${SETENV} USE_GITHUB=${USE_GITHUB} \ ${AWK} -f ${SCRIPTSDIR}/cargo-crates.awk ${CARGO_CARGOLOCK} # cargo-crates-licenses will try to grab license information from # all downloaded crates. cargo-crates-licenses: configure @${FIND} ${CARGO_VENDOR_DIR} -name 'Cargo.toml' -maxdepth 2 \ -exec ${GREP} -H '^license' {} \; \ | ${SED} \ -e 's@^${CARGO_VENDOR_DIR}/@@' \ -e 's@/Cargo.toml:license.*= *"@|@' \ -e 's@"$$@@g' | sort | /usr/bin/column -t -s '|' .endif Index: head/lang/rust/Makefile =================================================================== --- head/lang/rust/Makefile (revision 480252) +++ head/lang/rust/Makefile (revision 480253) @@ -1,403 +1,406 @@ # Created by: Jyun-Yan You # $FreeBSD$ PORTNAME= rust PORTVERSION?= 1.29.0 -PORTREVISION?= +PORTREVISION?= 1 CATEGORIES= lang MASTER_SITES= http://static.rust-lang.org/dist/:src \ LOCAL/dumbbell/rust:rust_bootstrap \ https://static.rust-lang.org/dist/:rust_bootstrap \ LOCAL/dumbbell/rust:cargo_bootstrap \ https://static.rust-lang.org/dist/:cargo_bootstrap \ https://s3.amazonaws.com/rust-lang-ci/cargo-builds/:cargo_bootstrap \ LOCAL/marino:bootstrap DISTNAME?= ${PORTNAME}c-${PORTVERSION}-src DISTFILES?= ${NIGHTLY_SUBDIR}${DISTNAME}${EXTRACT_SUFX}:src \ ${RUSTC_BOOTSTRAP}:rust_bootstrap \ ${RUST_STD_BOOTSTRAP}:rust_bootstrap \ ${CARGO_BOOTSTRAP}:cargo_bootstrap DIST_SUBDIR?= rust EXTRACT_ONLY?= ${DISTFILES:N*\:*bootstrap:C/:.*//} MAINTAINER= rust@FreeBSD.org COMMENT= Language with a focus on memory safety and concurrency LICENSE= APACHE20 \ MIT LICENSE_COMB= dual # APACHE20 license is standard, see Templates/Licenses/APACHE20 LICENSE_FILE_MIT= ${WRKSRC}/LICENSE-MIT BUILD_DEPENDS= cmake:devel/cmake -LIB_DEPENDS= libcurl.so:ftp/curl \ +LIB_DEPENDS= libgit2.so:devel/libgit2 \ + libcurl.so:ftp/curl \ libssh2.so:security/libssh2 ONLY_FOR_ARCHS?= aarch64 amd64 i386 ONLY_FOR_ARCHS_REASON= requires prebuilt bootstrap compiler BROKEN_aarch64= fails to build: bootstrap compiler crashes # FIXME: The bootstrapped rustc adds -L/usr/local/lib in front of # the LDFLAGS. When stage0's rustc is linked, it picks the installed # librust*so and fails. #CONFLICTS_BUILD?= rust-nightly #CONFLICTS_BUILD+= ${PKGBASE} CONFLICTS_INSTALL?= rust-nightly # See WRKSRC/src/stage0.txt for this date and version values. BOOTSTRAPS_DATE?= 2018-08-02 RUST_BOOTSTRAP_VERSION?= 1.28.0 RUSTC_BOOTSTRAP= ${BOOTSTRAPS_DATE_${ARCH}:U${BOOTSTRAPS_DATE}}/rustc-${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}-${RUST_TARGET}.tar.gz RUST_STD_BOOTSTRAP= ${BOOTSTRAPS_DATE_${ARCH}:U${BOOTSTRAPS_DATE}}/rust-std-${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}-${RUST_TARGET}.tar.gz CARGO_BOOTSTRAP_VERSION?= 0.29.0 CARGO_BOOTSTRAP= ${BOOTSTRAPS_DATE_${ARCH}:U${BOOTSTRAPS_DATE}}/cargo-${CARGO_BOOTSTRAP_VERSION_${ARCH}:U${CARGO_BOOTSTRAP_VERSION}}-${RUST_TARGET}.tar.gz RUST_CHANNEL= ${PKGNAMESUFFIX:Ustable:S/^-//} # Rust's target arch string is different from *BSD arch strings RUST_ARCH_aarch64= aarch64 RUST_ARCH_amd64= x86_64 RUST_ARCH_i386= i686 RUST_ARCH_x86_64= x86_64 # dragonfly RUST_TARGET= ${RUST_ARCH_${ARCH}}-unknown-${OPSYS:tl} PLIST_SUB+= RUST_TARGET=${RUST_TARGET} USES= compiler gmake libedit pkgconfig python:2.7,build ssl tar:xz OPTIONS_DEFINE= DOCS GDB LLNEXTGEN SOURCES GDB_DESC= Install ports gdb (necessary for debugging rust programs) LLNEXTGEN_DESC= Build with grammar verification SOURCES_DESC= Install source files GDB_RUN_DEPENDS= ${LOCALBASE}/bin/gdb:devel/gdb LLNEXTGEN_BUILD_DEPENDS= LLnextgen:devel/llnextgen # Rust manifests list all files and directories installed by rust-installer. # We use them in: # - pre-install to cleanup the ${STAGEDIR} # - post-install to populate the ${TMPPLIST} RUST_MANIFESTS= lib/rustlib/manifest-cargo \ lib/rustlib/manifest-clippy-preview \ lib/rustlib/manifest-rls-preview \ lib/rustlib/manifest-rustc \ lib/rustlib/manifest-rustfmt-preview \ lib/rustlib/manifest-rust-analysis-${RUST_TARGET} \ lib/rustlib/manifest-rust-std-${RUST_TARGET} RUST_DOCS_MANIFEST= lib/rustlib/manifest-rust-docs RUST_SRC_MANIFEST= lib/rustlib/manifest-rust-src DOCS_VARS= rust_manifests+=${RUST_DOCS_MANIFEST} SOURCES_VARS= rust_manifests+=${RUST_SRC_MANIFEST} PLIST_FILES= lib/rustlib/components \ lib/rustlib/rust-installer-version .include X_PY_ENV= HOME="${WRKDIR}" \ + LIBGIT2_SYS_USE_PKG_CONFIG=1 \ + LIBSSH2_SYS_USE_PKG_CONFIG=1 \ OPENSSL_DIR="${OPENSSLBASE}" X_PY_CMD= ${PYTHON_CMD} ${WRKSRC}/x.py CRATES_PATCHED_BY_FBSD10_FIX= src/vendor/libssh2-sys \ src/vendor/lzma-sys pre-fetch: # FIXME: This is the same check for CONFLICTS as the standard # one, except port origins are not compared. This allows # the port to conflict with itself, because Rust would pick # installed Rust libraries instead of freshly built ones. @conflicts_with=$$( \ { ${PKG_QUERY} -g "%n-%v %p %o" ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_BUILD:C/.+/'&'/} 2>/dev/null || : ; } \ | while read pkgname prfx orgn; do \ if [ "/${PREFIX}" = "/$${prfx}" ]; then \ ${ECHO_CMD} -n " $${pkgname}"; \ fi; \ done); \ if [ -n "$${conflicts_with}" ]; then \ ${ECHO_MSG}; \ ${ECHO_MSG} "===> ${PKGNAME} conflicts with installed package(s): "; \ for entry in $${conflicts_with}; do \ ${ECHO_MSG} " $${entry}"; \ done; \ ${ECHO_MSG}; \ ${ECHO_MSG} " They will not build together."; \ ${ECHO_MSG} " Please remove them first with pkg delete."; \ exit 1;\ fi RUST_STD_DIR= ${RUST_STD_BOOTSTRAP:T:R:R} post-extract: @${MKDIR} \ ${WRKSRC}/build/cache/${BOOTSTRAPS_DATE_${ARCH}:U${BOOTSTRAPS_DATE}} \ ${WRKSRC}/build/cache/${BOOTSTRAPS_DATE_${ARCH}:U${BOOTSTRAPS_DATE}} ${LN} -sf ${DISTDIR}/${DIST_SUBDIR}/${RUSTC_BOOTSTRAP} \ ${WRKSRC}/build/cache/${BOOTSTRAPS_DATE_${ARCH}:U${BOOTSTRAPS_DATE}} ${LN} -sf ${DISTDIR}/${DIST_SUBDIR}/${RUST_STD_BOOTSTRAP} \ ${WRKSRC}/build/cache/${BOOTSTRAPS_DATE_${ARCH}:U${BOOTSTRAPS_DATE}} ${LN} -sf ${DISTDIR}/${DIST_SUBDIR}/${CARGO_BOOTSTRAP} \ ${WRKSRC}/build/cache/${BOOTSTRAPS_DATE_${ARCH}:U${BOOTSTRAPS_DATE}} post-patch: @${REINPLACE_CMD} -e 's|gdb|${LOCALBASE}/bin/gdb|' \ ${WRKSRC}/src/etc/rust-gdb # If we override the versions and date of the bootstraps (for instance # on aarch64 where we provide our own bootstraps), we need to update # places where they are recorded. @${REINPLACE_CMD} -e \ 's|^date:.*|date: ${BOOTSTRAPS_DATE_${ARCH}:U${BOOTSTRAPS_DATE}}|' \ ${WRKSRC}/src/stage0.txt @${REINPLACE_CMD} -e \ 's|^rustc:.*|rustc: ${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}|' \ ${WRKSRC}/src/stage0.txt @${REINPLACE_CMD} -e \ 's|^cargo:.*|cargo: ${CARGO_BOOTSTRAP_VERSION_${ARCH}:U${CARGO_BOOTSTRAP_VERSION}}|' \ ${WRKSRC}/src/stage0.txt # After patching crates, we need to update their corresponding # `.cargo-checksum.json` to reflect the new checksums verified by Cargo. @for dir in "${WRKSRC}/src/vendor/libc" \ "${WRKSRC}/src/vendor/libgit2-sys" \ "${WRKSRC}/src/vendor/openssl" \ "${WRKSRC}/src/vendor/openssl-sys"; do \ if ! test -d "$$dir"; then \ continue; \ fi; \ cd "$$dir"; \ for file in $$(${FIND} * -name "*.orig"); do \ old_checksum=$$(${SHA256} -q "$$file"); \ new_checksum=$$(${SHA256} -q "$${file%%.orig}"); \ regex="$$regex -e s|\"$${file%%.orig}\":\"$$old_checksum\"|\"$${file%%.orig}\":\"$$new_checksum\"|"; \ done; \ if test "$$regex"; then \ ${REINPLACE_CMD} -E $$regex .cargo-checksum.json; \ fi; \ done # We make a backup of a few files before the FreeBSD 10 autotools # fix is applied. We'll need them in `do-configure` to update the # `.cargo-checksum.json` files. @for crate in ${CRATES_PATCHED_BY_FBSD10_FIX}; do \ if ! test -d "${WRKSRC}/$$crate"; then \ continue; \ fi; \ for file in $$(${FIND} "${WRKSRC}/$$crate" -name "config.rpath"); do \ ${CP} "$$file" "$$file.orig"; \ done; \ done .if defined(WITH_CCACHE_BUILD) && !defined(NO_CCACHE) CCACHE_VALUE= "${CCACHE_WRAPPER_PATH:C,/libexec/ccache$,,}/bin/ccache" .else CCACHE_VALUE= false .endif pre-configure: @for file in \ ${WRKSRC}/src/vendor/backtrace-sys/src/libbacktrace/configure \ ${WRKSRC}/src/vendor/backtrace-sys/src/libbacktrace/config/libtool.m4; do \ mv "$$file" "$$file.dont-fix"; \ done do-configure: ${SED} -E \ -e 's,%PREFIX%,${PREFIX},' \ -e 's,%SYSCONFDIR%,${PREFIX}/etc,' \ -e 's,%MANDIR%,${MANPREFIX}/man,' \ -e 's,%PYTHON_CMD%,${PYTHON_CMD},' \ -e 's,%CHANNEL%,${RUST_CHANNEL},' \ -e 's,%TARGET%,${RUST_TARGET},' \ -e 's,%CCACHE%,${CCACHE_VALUE},' \ < ${FILESDIR}/config.toml \ > ${WRKSRC}/config.toml # The FreeBSD 10 autotools fix may modify some files just before # `do-configure`. Like after `extra-path-ino64`, we need to update # `.cargo-checksum.json`. @for crate in ${CRATES_PATCHED_BY_FBSD10_FIX}; do \ if ! test -d "${WRKSRC}/$$crate"; then \ continue; \ fi; \ cd "${WRKSRC}/$$crate"; \ for file in $$(${FIND} * -name "*.orig"); do \ old_checksum=$$(${SHA256} -q "$$file"); \ new_checksum=$$(${SHA256} -q "$${file%%.orig}"); \ regex="$$regex -e s|\"$${file%%.orig}\":\"$$old_checksum\"|\"$${file%%.orig}\":\"$$new_checksum\"|"; \ done; \ if test "$$regex"; then \ ${REINPLACE_CMD} -E $$regex .cargo-checksum.json; \ fi; \ done post-configure: @for file in \ ${WRKSRC}/src/vendor/backtrace-sys/src/libbacktrace/configure \ ${WRKSRC}/src/vendor/backtrace-sys/src/libbacktrace/config/libtool.m4; do \ mv "$$file.dont-fix" "$$file"; \ done post-configure-DOCS-on: ${REINPLACE_CMD} -e 's,%DOCS%,true,' ${WRKSRC}/config.toml post-configure-DOCS-off: ${REINPLACE_CMD} -e 's,%DOCS%,false,' ${WRKSRC}/config.toml do-build: cd ${WRKSRC} && \ ${SETENV} ${X_PY_ENV} \ ${X_PY_CMD} build \ --verbose \ --config ./config.toml \ --jobs ${MAKE_JOBS_NUMBER} # In case the previous "make stage" failed, this ensures rust's # install.sh won't backup previously staged files before reinstalling # new ones. Otherwise, the staging directory is polluted with unneeded # files. pre-install: @for f in ${RUST_MANIFESTS} ${RUST_DOCS_MANIFEST} ${RUST_SRC_MANIFEST}; do \ if test -f "${STAGEDIR}${PREFIX}/$$f"; then \ ${SED} -E -e 's,^(file|dir):,${STAGEDIR},' \ < "${STAGEDIR}${PREFIX}/$$f" \ | ${XARGS} ${RM} -r; \ ${RM} "${STAGEDIR}${PREFIX}/$$f"; \ fi; \ done @for f in ${PLIST_FILES}; do \ ${RM} "${STAGEDIR}${PREFIX}/$$f"; \ done do-install: cd ${WRKSRC} && \ ${SETENV} ${X_PY_ENV} \ DESTDIR=${STAGEDIR} \ ${X_PY_CMD} 'install' \ --verbose \ --config ./config.toml \ --jobs ${MAKE_JOBS_NUMBER} # In post-install, we use the manifests generated during Rust install # to in turn generate the PLIST. We do that, instead of the regular # `pkg-plist`, because several libraries have a computed filename based # on the absolute path of the source files. As it is user-specific, we # can't know their filename in advance. # # Both rustc and Cargo components install the same README.md and LICENSE # files. The install process backs up the first copy to install the # second. Thus here, we need to remove those backups. We also need to # dedup the entries in the generated PLIST, because both components' # manifests list them. # # We fix manpage entries in the generated manifests because Rust # installs them uncompressed but the Ports framework compresses them. post-install: for f in ${RUST_MANIFESTS}; do \ ${REINPLACE_CMD} -E \ -e 's|:${STAGEDIR}|:|' \ -e 's|(man/man[1-9]/.*\.[0-9])|\1.gz|' \ ${STAGEDIR}${PREFIX}/$$f; \ ${RM} ${STAGEDIR}${PREFIX}/$$f.bak; \ ${ECHO} "${PREFIX}/$$f" >> ${TMPPLIST}; \ ${AWK} '\ /^file:/ { \ file=$$0; \ sub(/^file:/, "", file); \ print file; \ } \ /^dir:/ { \ dir=$$0; \ sub(/^dir:/, "", dir); \ system("find ${STAGEDIR}" dir " -type f | ${SED} -E -e \"s|${STAGEDIR}||\""); \ }' \ ${STAGEDIR}${PREFIX}/$$f >> ${TMPPLIST}; \ done ${RM} ${STAGEDIR}${PREFIX}/share/doc/rust/*.old ${SORT} -u < ${TMPPLIST} > ${TMPPLIST}.uniq ${MV} ${TMPPLIST}.uniq ${TMPPLIST} @${RM} \ ${STAGEDIR}${PREFIX}/lib/rustlib/install.log \ ${STAGEDIR}${PREFIX}/lib/rustlib/uninstall.sh # FIXME: Static libraries in lib/rustlib/*/lib/*.rlib are not stripped, # but they contain non-object files which make strip(1) unhappy. @${STRIP_CMD} \ ${STAGEDIR}${PREFIX}/bin/cargo \ ${STAGEDIR}${PREFIX}/bin/cargo-clippy \ ${STAGEDIR}${PREFIX}/bin/cargo-fmt \ ${STAGEDIR}${PREFIX}/bin/clippy-driver \ ${STAGEDIR}${PREFIX}/bin/rls \ ${STAGEDIR}${PREFIX}/bin/rustc \ ${STAGEDIR}${PREFIX}/bin/rustdoc \ ${STAGEDIR}${PREFIX}/bin/rustfmt \ ${STAGEDIR}${PREFIX}/lib/*.so \ ${STAGEDIR}${PREFIX}/lib/rustlib/*/lib/*.so \ ${STAGEDIR}${PREFIX}/lib/rustlib/*/codegen-backends/*.so # We set `extended = true` in config.toml because we want to build # Cargo at the same time. However, this installs the rust-src component # as well. If the user doesn't want that, I don't know how to prevent # its install. So for now, use the rust-src manifest to remove it from # ${STAGEDIR}. post-install-SOURCES-off: if test -f "${STAGEDIR}${PREFIX}/${RUST_SRC_MANIFEST}"; then \ ${SED} -E -e 's,^(file|dir):,,' \ < "${STAGEDIR}${PREFIX}/${RUST_SRC_MANIFEST}" \ | ${XARGS} ${RM} -r; \ ${RM} "${STAGEDIR}${PREFIX}/${RUST_SRC_MANIFEST}"; \ ${RM} -r "${STAGEDIR}${PREFIX}/lib/rustlib/src"; \ fi # Note that make test does not work when rust is already installed. do-test: cd ${WRKSRC} && \ ${SETENV} ${X_PY_ENV} \ ALLOW_NONZERO_RLIMIT_CORE=1 \ ${X_PY_CMD} test \ --verbose \ --config ./config.toml \ --jobs ${MAKE_JOBS_NUMBER} makesum-all-archs: ${MAKE} makesum ARCH=${ONLY_FOR_ARCHS:O:[1]} .for arch in ${ONLY_FOR_ARCHS:O:[2..-1]} ${MAKE} makesum ARCH=${arch} DISTINFO_FILE=${DISTINFO_FILE}.${arch} ${GREP} ${RUST_ARCH_${arch}} ${DISTINFO_FILE}.${arch} >> ${DISTINFO_FILE} ${RM} ${DISTINFO_FILE}.${arch} .endfor BOOTSTRAPS_SOURCE_PKG_FBSDVER= 10 BOOTSTRAPS_SOURCE_PKG_FBSDVER_aarch64= 11 BOOTSTRAPS_SOURCE_PKG_REV= BOOTSTRAPS_SOURCE_PKG_URL= https://pkg.freebsd.org/FreeBSD:${BOOTSTRAPS_SOURCE_PKG_FBSDVER_${ARCH}:U${BOOTSTRAPS_SOURCE_PKG_FBSDVER}}:${ARCH}/latest/All/rust-${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}${BOOTSTRAPS_SOURCE_PKG_REV}.txz BOOTSTRAPS_SOURCE_PKG= ${_DISTDIR}/${BOOTSTRAPS_DATE_${ARCH}:U${BOOTSTRAPS_DATE}}/rust-${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}-${ARCH}.txz package-to-bootstraps: ${BOOTSTRAPS_SOURCE_PKG} ${MKDIR} ${WRKDIR}/bootstraps ${RM} -r ${WRKDIR}/bootstraps/usr ${EXTRACT_CMD} \ -C ${WRKDIR}/bootstraps \ --strip-components 3 \ ${EXTRACT_BEFORE_ARGS} ${BOOTSTRAPS_SOURCE_PKG} ${LOCALBASE} # `rustc` bootstrap. ${RM} -r ${WRKDIR}/bootstraps/rustc-${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}-${RUST_TARGET} ${MKDIR} ${WRKDIR}/bootstraps/rustc-${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}-${RUST_TARGET} cd ${WRKDIR}/bootstraps/rustc-${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}-${RUST_TARGET} && \ ${MKDIR} rustc/bin rustc/lib && \ ${MV} ${WRKDIR}/bootstraps/bin/rust* rustc/bin && \ ${MV} ${WRKDIR}/bootstraps/lib/*.so rustc/lib ${TAR} -cz --format=ustar -C ${WRKDIR}/bootstraps \ -f ${_DISTDIR}/${RUSTC_BOOTSTRAP} \ rustc-${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}-${RUST_TARGET} # `rust-std` bootstrap. ${RM} -r ${WRKDIR}/bootstraps/rust-std-${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}-${RUST_TARGET} ${MKDIR} ${WRKDIR}/bootstraps/rust-std-${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}-${RUST_TARGET} cd ${WRKDIR}/bootstraps/rust-std-${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}-${RUST_TARGET} && \ ${MKDIR} rust-std-${RUST_TARGET}/lib/rustlib/${RUST_TARGET} && \ ${MV} ${WRKDIR}/bootstraps/lib/rustlib/${RUST_TARGET}/lib rust-std-${RUST_TARGET}/lib/rustlib/${RUST_TARGET} ${TAR} -cz --format=ustar -C ${WRKDIR}/bootstraps \ -f ${_DISTDIR}/${RUST_STD_BOOTSTRAP} \ rust-std-${RUST_BOOTSTRAP_VERSION_${ARCH}:U${RUST_BOOTSTRAP_VERSION}}-${RUST_TARGET} ${BOOTSTRAPS_SOURCE_PKG}: ${MKDIR} ${@:H} ${FETCH_CMD} -o $@ ${BOOTSTRAPS_SOURCE_PKG_URL} .include