# Maintainer: pingplug # Contributor: Johannes Löthberg # Contributor: Alexander F Rødseth # Contributor: Daniel Micay # Contributor: userwithuid _pkgname=rust _date=2018-05-10 _rustc=1.26.0 _cargo=0.27.0 pkgname=mingw-w64-rust pkgver=1.27.1 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') optdepends=('mingw-w64-wine: for cargo test support') makedepends=('gdb' 'ninja' 'libffi' 'perl' 'python2' 'nodejs' '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.gz"{,.asc} "https://static.rust-lang.org/dist/${_date}/rustc-${_rustc}-x86_64-unknown-linux-gnu.tar.gz"{,.asc} "https://static.rust-lang.org/dist/${_date}/cargo-${_cargo}-x86_64-unknown-linux-gnu.tar.gz"{,.asc} "mingw-config.toml") noextract=("rust-std-${_rustc}-x86_64-unknown-linux-gnu.tar.gz" "rustc-${_rustc}-x86_64-unknown-linux-gnu.tar.gz" "cargo-${_cargo}-x86_64-unknown-linux-gnu.tar.gz") sha256sums=('948e2645057960ee1c03d9f0e8f78133a5f73d9ca9a24bc56126e395a212d25c' 'SKIP' 'e27cb5c21541a500c8df919e15c8d3b002456ebbe573122e7b058cf5b4c3c13a' 'SKIP' '7ca9a30010602aaf2244c376a3cc5baa89429d54da17b8ba1cb0cdfdc846cc61' 'SKIP' 'f50b64a7610401f4c1afe21de238663f33c621b7fc42c51401090ebd48e69fec' 'SKIP' '36962a9dd01b6d3d480fe17c8ba3c4620d5dd6b8cc6efc600991006e08917269') validpgpkeys=('108F66205EAEB0AAA8DD5E1C85AB96E6FA1BE5FE') # Rust Language (Tag and Release Signing Key) backup=("opt/${_pkgname}/cargo/config") PKGEXT=".pkg.tar.gz" prepare() { cd "rustc-${pkgver}-src" cp "${srcdir}"/mingw-config.toml config.toml sed -i "s|\@PREFIX\@|/opt/${_pkgname}|" config.toml cd "${srcdir}" mkdir -p "${srcdir}/rustc-${pkgver}-src/build/cache/${_date}" cp rust-std-${_rustc}-x86_64-unknown-linux-gnu.tar.gz "${srcdir}/rustc-${pkgver}-src/build/cache/${_date}" cp rustc-${_rustc}-x86_64-unknown-linux-gnu.tar.gz "${srcdir}/rustc-${pkgver}-src/build/cache/${_date}" cp cargo-${_cargo}-x86_64-unknown-linux-gnu.tar.gz "${srcdir}/rustc-${pkgver}-src/build/cache/${_date}" } build() { cd "rustc-${pkgver}-src" export CFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4" export CXXFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4" python2 ./x.py build } package() { cd "rustc-${pkgver}-src" # rust will build install tools there export CFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4" export CXXFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4" # TODO: find a way to disable packaging # use level 0 to speed up xz packaging sed -i 's|XzEncoder::new(create_new_file(tar_xz)?, 6)|XzEncoder::new(create_new_file(tar_xz)?, 0)|' "src/tools/rust-installer/src/tarballer.rs" DESTDIR="${pkgdir}" python2 ./x.py install # license install -dm755 "${pkgdir}/usr/share/licenses/${pkgname}/"{rust,cargo} mv "${pkgdir}"/opt/${_pkgname}/share/doc/rust/LICENSE-*.old "${pkgdir}/usr/share/licenses/${pkgname}/cargo/" rename '.old' '' "${pkgdir}/usr/share/licenses/${pkgname}/cargo/"* mv "${pkgdir}"/opt/${_pkgname}/share/doc/rust/{LICENSE-*,COPYRIGHT} "${pkgdir}/usr/share/licenses/${pkgname}/rust/" # remove unused files rm -r "${pkgdir}/etc/" rm -r "${pkgdir}/opt/${_pkgname}/share" rm "${pkgdir}/opt/${_pkgname}/lib/rustlib/"{manifest-*,install.log,uninstall.sh,components,rust-installer-version} # link shared libraries pushd "${pkgdir}/opt/${_pkgname}/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 "../../../opt/${_pkgname}/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 "../../../opt/${_pkgname}/lib/rustlib/x86_64-pc-windows-gnu/lib/"*.dll . popd # strip strip --strip-all "${pkgdir}/opt/${_pkgname}/bin/"{cargo,rustc,rustdoc} strip --strip-all "${pkgdir}/opt/${_pkgname}/lib/rustlib/x86_64-unknown-linux-gnu/bin/"lld strip --strip-unneeded "${pkgdir}/opt/${_pkgname}/lib/rustlib/x86_64-unknown-linux-gnu/lib/"*.so strip --strip-unneeded "${pkgdir}/opt/${_pkgname}/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/"*.so i686-w64-mingw32-strip --strip-unneeded "${pkgdir}/opt/${_pkgname}/lib/rustlib/i686-pc-windows-gnu/lib/"*.dll x86_64-w64-mingw32-strip --strip-unneeded "${pkgdir}/opt/${_pkgname}/lib/rustlib/x86_64-pc-windows-gnu/lib/"*.dll # config install -dm777 "${pkgdir}/opt/${_pkgname}/cargo" cat << EOF >> "${pkgdir}/opt/${_pkgname}/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/${_pkgname}/cargo/config" runner = "/usr/bin/i686-w64-mingw32-wine" EOF fi cat << EOF >> "${pkgdir}/opt/${_pkgname}/cargo/config" rustflags = [ EOF cat << EOF >> "${pkgdir}/opt/${_pkgname}/cargo/config" ] EOF cat << EOF >> "${pkgdir}/opt/${_pkgname}/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/${_pkgname}/cargo/config" runner = "/usr/bin/x86_64-w64-mingw32-wine" EOF fi cat << EOF >> "${pkgdir}/opt/${_pkgname}/cargo/config" rustflags = [ EOF if pacman -T "mingw-w64-crt-git>5.0.4.20171219" ; then cat << EOF >> "${pkgdir}/opt/${_pkgname}/cargo/config" "-C", "link-arg=-lmsvcrt", EOF fi cat << EOF >> "${pkgdir}/opt/${_pkgname}/cargo/config" ] EOF } # vim:set ts=2 sw=2 et: