# 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=2019-02-28 _rustc=1.33.0 _cargo=0.34.0 pkgname=mingw-w64-rust _prefix=opt/rust pkgver=1.34.2 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' 'python' '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.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-${_cargo}-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-${_cargo}-x86_64-unknown-linux-gnu.tar.xz") sha256sums=('2b3b3a5462aa31d07f39721af73ef394803ceae3472e2470f28b7ee0b12e38ef' 'SKIP' '6f20343ed73faf5fdfc423bec38a9bb1910a0a962af6f2dddd7184407543ed0e' 'SKIP' '57c5ced1a826d34f26e50adf041528dd0000f2a59e8be32d2359386843382ce1' 'SKIP' '1730c8ebcacc1327eb28b328cb9f5a2c612bb3d9efff9c350647adf19f304e15' 'SKIP' 'd7b86ebb3382c838cb931ed0292e4a8133dd524beed7abe0f3ab8d7bc5973d04') validpgpkeys=('108F66205EAEB0AAA8DD5E1C85AB96E6FA1BE5FE') # Rust Language (Tag and Release Signing Key) backup=("opt/rust/cargo/config") PKGEXT=".pkg.tar.gz" prepare() { cd "rustc-${pkgver}-src" cp "${srcdir}"/mingw-config.toml config.toml sed -i "s|\@PREFIX\@|/${_prefix}|" config.toml # 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" sed -i "s|tar.gz|tar.xz|" "src/bootstrap/bootstrap.py" 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-${_cargo}-x86_64-unknown-linux-gnu.tar.xz "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" # BUG: x.py install will build rust a second time #python ./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 DESTDIR="${pkgdir}" python ./x.py install # 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-lld strip --strip-unneeded "${pkgdir}/${_prefix}/lib/rustlib/x86_64-unknown-linux-gnu/lib/"*.so strip --strip-unneeded "${pkgdir}/${_prefix}/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/"*.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: