Files
ports/main/rust/spkgbuild
2023-12-29 06:51:48 +00:00

97 lines
2.4 KiB
Plaintext
Executable File

# description : The Rust programming language is designed to be a safe, concurrent, practical language
# depends : curl cmake python3 llvm libssh2
name=rust
version=1.75.0
#2023-12-28
release=1
_date=2023-11-16
_rust=1.74.0
_cargo=$_rust
_triplet=x86_64-unknown-linux-gnu
source="https://static.rust-lang.org/dist/rustc-$version-src.tar.xz
https://static.rust-lang.org/dist/$_date/rust-std-$_rust-$_triplet.tar.xz
https://static.rust-lang.org/dist/$_date/rustc-$_rust-$_triplet.tar.xz
https://static.rust-lang.org/dist/$_date/cargo-$_cargo-$_triplet.tar.xz
0001-bootstrap-Change-libexec-dir.patch
0002-compiler-Change-LLVM-targets.patch
0004-compiler-Use-wasm-ld-for-wasm-targets.patch
0005-lang-rust-Allow-build-with-LibreSSL-3.8.2.patch"
noextract="rust-std-$_rust-$_triplet.tar.xz
rustc-$_rust-$_triplet.tar.xz
cargo-$_cargo-$_triplet.tar.xz"
options="!emptydirs !strip"
build() {
cd rustc-$version-src
# Patch bootstrap so that rust-analyzer-proc-macro-srv
# is in /usr/lib instead of /usr/libexec
patch -Np1 -i $SRC/0001-bootstrap-Change-libexec-dir.patch
# Use our *-pc-linux-gnu targets, making LTO with clang simpler
patch -Np1 -i $SRC/0002-compiler-Change-LLVM-targets.patch
# Use our wasm-ld
patch -Np1 -i $SRC/0004-compiler-Use-wasm-ld-for-wasm-targets.patch
# Fix build for libressl users
# Thanks to freebsd for this patch
patch -Np1 -i $SRC/0005-lang-rust-Allow-build-with-LibreSSL-3.8.2.patch
mkdir -p build/cache/$_date
cp $SRC/rust-std-$_rust-$_triplet.tar.xz build/cache/$_date/
cp $SRC/rustc-$_rust-$_triplet.tar.xz build/cache/$_date/
cp $SRC/cargo-$_cargo-$_triplet.tar.xz build/cache/$_date/
cat << EOF > config.toml
[llvm]
targets = "X86"
link-shared = true
[build]
docs = false
extended = true
locked-deps = true
vendor = true
python = "/usr/bin/python3"
tools = ["cargo", "clippy", "rustdoc", "rustfmt"]
[install]
prefix = "/usr"
[rust]
description = "Venom"
channel = "stable"
[target.$_triplet]
llvm-config = "/usr/bin/llvm-config"
EOF
mkdir "$SRC/rust"
export CARGO_HOME="$SRC/rust"
export RUST_BACKTRACE=1
{ [ ! -e /usr/include/libssh2.h ] || \
export LIBSSH2_SYS_USE_PKG_CONFIG=1; }
# Fix for rust src hash missmatch
sed -i 's/"files":{[^}]*}/"files":{}/' \
./vendor/*/.cargo-checksum.json
python3 ./x.py build
DESTDIR=$PKG python3 ./x.py install -v
rm -rf $PKG/usr/lib/rustlib/components
rm -rf $PKG/usr/lib/rustlib/manifest-rustc
rm -rf $PKG/usr/lib/rustlib/rust-installer-version
rm -rf $PKG/etc
}