NAME="rustc"
DESC="Rust programming language"
VERSION="1.71.1"
FILES=("https://static.rust-lang.org/dist/rustc-$VERSION-src.tar.xz")
HASHES=("b6f9973de878e37a589f0989e4138480")
DEPENDS=("curl" "libssh2")

PACKAGE() {
  tar xf $NAME-$VERSION-src.tar.xz
  cd $NAME-$VERSION-src

  cat << EOF > config.toml
changelog-seen = 2

[llvm]
targets = "X86"
link-shared = true

[build]
docs = false
extended = true
locked-deps = true
tools = ["cargo", "clippy", "rustdoc", "rustfmt"]
vendor = true

[install]
prefix = "$ROOTDIR/usr"
docdir = "share/doc/rustc-$VERSION"

[rust]
channel = "stable"
description = "for MatterLinux"

[target.x86_64-unknown-linux-gnu]
llvm-config = "/usr/bin/llvm-config"

[target.i686-unknown-linux-gnu]
llvm-config = "/usr/bin/llvm-config"
EOF

  mkdir -pv "$ROOTDIR/usr/share/doc"
  python3 ./x.py build
  python3 ./x.py install
  find "$ROOTDIR/usr" -name "*.old" -delete
  
  cd .. && rm -r $NAME-$VERSION-src
}
