Files
linamh/dev-lang/mrustc/mrustc-0.12.0-r1.ebuild

91 lines
2.3 KiB
Bash

# Copyright 2024-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit edo multiprocessing rust-toolchain toolchain-funcs
RUST_VERSION=1.90.0
MRUSTC_RUST_VER=1.90.0
DESCRIPTION="Mutabah's Rust Compiler"
HOMEPAGE="https://github.com/thepowersgang/mrustc"
SRC_URI="https://github.com/thepowersgang/mrustc/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
DEPEND="virtual/zlib:="
RDEPEND="
${DEPEND}
sys-devel/gcc:*
"
BDEPEND="sys-devel/gcc:*"
PATCHES=(
"${FILESDIR}/${PN}-0.11.2-dont-strip-bins.patch"
"${FILESDIR}/${PN}-0.12.0-default-to-rust-1_90.patch"
"${FILESDIR}/${PN}-0.12.0-build-with-provided-rust.patch"
"${FILESDIR}/${PN}-0.12.0-git-be-gone.patch"
"${FILESDIR}/${PN}-0.12.0-no-glibcxx-assertions-workaround.patch"
"${FILESDIR}/${PN}-0.12.0-cc65.patch"
)
QA_FLAGS_IGNORED="
usr/lib/rust/${P}/bin/mrustc
usr/lib/rust/${P}/bin/minicargo
usr/lib/rust/${P}/lib/rustlib/$(rust_abi)/lib/*.rlib
"
src_configure() {
:
}
src_compile() {
if ! tc-is-gcc ; then
export CC=${CHOST}-gcc
export CXX=${CHOST}-g++
tc-is-gcc || die "tc-is-gcc failed in spite of CC=${CC}"
fi
export PARLEVEL=$(makeopts_jobs)
export RUSTC_VERSION=${MRUSTC_RUST_VER}
export MRUSTC_TARGET_VER=${RUSTC_VERSION%.*}
export RUSTCSRC="${WORKDIR}/rustc-${RUST_VERSION}-src"
export RUSTC_SRC_PROVIDED=1
export V=''
emake all
emake -C tools/minicargo/
emake -e -f minicargo.mk LIBS
}
src_test() {
emake -e -f minicargo.mk local_tests
edo "${S}"/bin/mrustc -L "${S}"/output-${MRUSTC_RUST_VER}/ \
-g "${S}/../rustc-${RUST_VERSION}-src/tests/ui/parallel-rustc/hello_world.rs" -o "${T}"/hello
"${T}"/hello || die "Failed to run hello_world built with mrustc"
}
src_install() {
into /usr/lib/rust/${P}
dobin bin/mrustc
dobin bin/minicargo
local lib patch
local libs=( "${S}"/output-*/*.rlib* )
insinto "/usr/lib/rust/${P}/lib/rustlib/$(rust_abi)/lib"
for lib in "${libs[@]}"; do
if [[ ${lib} != *.c && ${lib} != *.d && ${lib} != *.txt ]]; then
doins "${lib}"
fi
done
insinto /usr/share/${P}
doins -r "${S}/script-overrides/"
insinto /usr/share/${P}/targets
newins "${FILESDIR}/cc65.toml" cc65.toml
insinto /usr/share/${P}/patches
for patch in "${S}"/rustc-*.patch "${S}"/rustc-*-overrides.toml; do
doins "${patch}"
done
}