# Maintainer: pingplug < aur at pingplug dot me > # Contributor: Johannes Löthberg < johannes at kyriasis dot com > # Contributor: Alexander F Rødseth < xyproto at archlinux dot org > # Contributor: Daniel Micay < danielmicay at gmail dot com > # Contributor: userwithuid < userwithuid at gmail dot com > _pkgname=rust _date=2022-02-24 _rustc=1.59.0 pkgname=mingw-w64-rust _prefix=opt/rust pkgver=1.60.0 pkgrel=1 pkgdesc="Systems programming language focused on safety, speed and concurrency (mingw-w64)" arch=('x86_64') url="https://www.rust-lang.org" license=('MIT' 'Apache' 'custom') depends=('gcc-libs' 'curl' 'libgit2' 'mingw-w64-gcc>=10.1.0') optdepends=('mingw-w64-wine: for cargo test support') makedepends=('gdb' 'ninja' 'libffi' 'perl' 'python' 'nodejs' 'procps-ng' 'cmake') options=('!strip' 'staticlibs' '!buildflags') source=("https://static.rust-lang.org/dist/rustc-${pkgver}-src.tar.xz"{,.asc} "https://static.rust-lang.org/dist/${_date}/rust-std-${_rustc}-x86_64-unknown-linux-gnu.tar.xz"{,.asc} "https://static.rust-lang.org/dist/${_date}/rustc-${_rustc}-x86_64-unknown-linux-gnu.tar.xz"{,.asc} "https://static.rust-lang.org/dist/${_date}/cargo-${_rustc}-x86_64-unknown-linux-gnu.tar.xz"{,.asc} "mingw-config.toml") noextract=("rust-std-${_rustc}-x86_64-unknown-linux-gnu.tar.xz" "rustc-${_rustc}-x86_64-unknown-linux-gnu.tar.xz" "cargo-${_rustc}-x86_64-unknown-linux-gnu.tar.xz") sha256sums=('a025876deccbcb3f288d8e02623ea321f94623f31305d3c5c6f17855bb9685db' 'SKIP' 'c854a9ee3dd8e5be9522c1581f75838c1cbae6dece3934b0004f138c4a5024a3' 'SKIP' '838de1fef855ef7733a87862c2575e8da9f3fa11fd0a8ce05c293038ea92356e' 'SKIP' 'f56ebfb333ea46e4429377bf4b16a2ec889d61640a41c3093577cdd8f3c80b96' 'SKIP' 'be414bd9ec996bf9a4b3ff87d495c19492b08d01f462a4492eed643c17bd9a32') validpgpkeys=('108F66205EAEB0AAA8DD5E1C85AB96E6FA1BE5FE') # Rust Language (Tag and Release Signing Key) backup=("opt/rust/cargo/config") prepare() { cd "rustc-${pkgver}-src" cp "${srcdir}"/mingw-config.toml config.toml sed -i "s|\@PREFIX\@|/${_prefix}|" config.toml cd "${srcdir}" mkdir -p "${srcdir}/rustc-${pkgver}-src/build/cache/${_date}" cp rust-std-${_rustc}-x86_64-unknown-linux-gnu.tar.xz "rustc-${pkgver}-src/build/cache/${_date}" cp rustc-${_rustc}-x86_64-unknown-linux-gnu.tar.xz "rustc-${pkgver}-src/build/cache/${_date}" cp cargo-${_rustc}-x86_64-unknown-linux-gnu.tar.xz "rustc-${pkgver}-src/build/cache/${_date}" } build() { cd "rustc-${pkgver}-src" export CFLAGS="-O2 -pipe -fno-plt -Wall -D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4" export CXXFLAGS="-O2 -pipe -fno-plt -Wall -D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4" python ./x.py build } package() { cd "rustc-${pkgver}-src" # rust will build install tools there export CFLAGS="-O2 -pipe -fno-plt -Wall -D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4" export CXXFLAGS="-O2 -pipe -fno-plt -Wall -D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4" # TODO: find a way to disable packaging DESTDIR="${pkgdir}" python ./x.py install --keep-stage 0 --keep-stage 1 # license install -dm755 "${pkgdir}/usr/share/licenses/${pkgname}/"{rust,cargo} mv "${pkgdir}"/${_prefix}/share/doc/rust/LICENSE-*.old "${pkgdir}/usr/share/licenses/${pkgname}/cargo/" rename '.old' '' "${pkgdir}/usr/share/licenses/${pkgname}/cargo/"* mv "${pkgdir}"/${_prefix}/share/doc/rust/{LICENSE-*,COPYRIGHT} "${pkgdir}/usr/share/licenses/${pkgname}/rust/" # remove unused files rm -r "${pkgdir}/etc/" rm -r "${pkgdir}/${_prefix}/share" rm "${pkgdir}/${_prefix}/lib/rustlib/"{manifest-*,install.log,uninstall.sh,components,rust-installer-version} # link shared libraries pushd "${pkgdir}/${_prefix}/lib" ln -sf "rustlib/x86_64-unknown-linux-gnu/lib/"*.so . popd install -dm755 "${pkgdir}/usr/i686-w64-mingw32/bin" && pushd "${pkgdir}/usr/i686-w64-mingw32/bin" ln -sf "../../../${_prefix}/lib/rustlib/i686-pc-windows-gnu/lib/"*.dll . popd install -dm755 "${pkgdir}/usr/x86_64-w64-mingw32/bin" && pushd "${pkgdir}/usr/x86_64-w64-mingw32/bin" ln -sf "../../../${_prefix}/lib/rustlib/x86_64-pc-windows-gnu/lib/"*.dll . popd # strip strip --strip-all "${pkgdir}/${_prefix}/bin/"{cargo,rustc,rustdoc} strip --strip-all "${pkgdir}/${_prefix}/lib/rustlib/x86_64-unknown-linux-gnu/bin/"rust-* strip --strip-all "${pkgdir}/${_prefix}/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld/"* strip --strip-all "${pkgdir}/${_prefix}/libexec/"* strip --strip-unneeded "${pkgdir}/${_prefix}/lib/librustc"*.so strip --strip-unneeded "${pkgdir}/${_prefix}/lib/rustlib/x86_64-unknown-linux-gnu/lib/"*.so i686-w64-mingw32-strip --strip-unneeded "${pkgdir}/${_prefix}/lib/rustlib/i686-pc-windows-gnu/lib/"*.dll x86_64-w64-mingw32-strip --strip-unneeded "${pkgdir}/${_prefix}/lib/rustlib/x86_64-pc-windows-gnu/lib/"*.dll # config install -dm777 "${pkgdir}/opt/rust/cargo" cat << EOF >> "${pkgdir}/opt/rust/cargo/config" [target.i686-pc-windows-gnu] linker = "/usr/bin/i686-w64-mingw32-gcc" ar = "/usr/i686-w64-mingw32/bin/ar" EOF if pacman -T "mingw-w64-wine" ; then cat << EOF >> "${pkgdir}/opt/rust/cargo/config" runner = "/usr/bin/i686-w64-mingw32-wine" EOF fi cat << EOF >> "${pkgdir}/opt/rust/cargo/config" rustflags = [ ] EOF cat << EOF >> "${pkgdir}/opt/rust/cargo/config" [target.x86_64-pc-windows-gnu] linker = "/usr/bin/x86_64-w64-mingw32-gcc" ar = "/usr/x86_64-w64-mingw32/bin/ar" EOF if pacman -T "mingw-w64-wine" ; then cat << EOF >> "${pkgdir}/opt/rust/cargo/config" runner = "/usr/bin/x86_64-w64-mingw32-wine" EOF fi cat << EOF >> "${pkgdir}/opt/rust/cargo/config" rustflags = [ ] EOF } # vim:set ts=2 sw=2 et: