summaryrefslogtreecommitdiff
path: root/repo/devel/rustc.xibuild
blob: 0aadc6b1a452e4c55ca6396b2f5365f1c6f59fce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh

MAKEDEPS="cmake llvm"
DEPS="curl gcc libssh2"

PKG_VER=1.58.1
SOURCE=https://static.rust-lang.org/dist/rustc-$PKG_VER-src.tar.gz
DESC="Systems programming language focused on safety, speed and concurrency"

prepare () {
    mkdir -p $PKG_DEST/opt/rustc-$PKG_VER             &&
    ln -sf rustc-$PKG_VER $PKG_DEST/opt/rustc

    openssl_file=vendor/openssl-sys/build/main.rs
    checksum_before=$(sha256sum $openssl_file | cut -d' ' -f1)
    sed -i "240i (3, 4, _) => ('3', '4', 'x')," $openssl_file
    checksum_after=$(sha256sum $openssl_file | cut -d' ' -f1)
    echo "checksum before: $checksum_before"
    echo "checksum after: $checksum_after"

    sed -i "s/$checksum_before/$checksum_after/g" vendor/openssl-sys/.cargo-checksum.json

}

build () {
    export RUSTFLAGS="$RUSTFLAGS -C link-arg=-lffi" &&
    target=x86_64-unknown-linux-musl
    build=x86_64-unknown-linux-musl
    ./configure \
        --build="$build" \
        --host="$target" \
        --target="$target" \
		--prefix="/usr" \
		--release-channel="stable" \
		--llvm-root="/usr/lib/" \
		--disable-docs \
		--enable-extended \
		--tools="analysis,cargo,src,rustfmt" \
		--enable-llvm-link-shared \
		--enable-option-checking \
		--enable-locked-deps \
		--enable-vendor \
		--set="rust.musl-root=/usr" \
		--set="rust.codegen-units=1" \
		--set="rust.codegen-units-std=1" \
		--set="rust.parallel-compiler=false" \
		--set="target.$target.llvm-config=/usr/bin/llvm-config" \
		--set="target.$target.musl-root=/usr" \
		--set="target.$target.crt-static=false" \
		--set="target.$target.cc=gcc" \
		--set="target.$target.cxx=c++" \
		--set="target.$target.ar=ar" \
		--set="target.$target.linker=gcc" \
		--set="target.$build.musl-root=/usr" \
		--set="target.$build.crt-static=false" \
		--set="target.$build.cc=gcc" \
		--set="target.$build.cxx=c++" \
		--set="target.$build.ar=ar" \
		--set="target.$build.linker=gcc"

        python ./x.py dist --jobs $JOBS

}

package () {
    export LIBSSH2_SYS_USE_PKG_CONFIG=1 &&
    DESTDIR=${PWD}/install python3 ./x.py install &&
    unset LIBSSH2_SYS_USE_PKG_CONFIG

    chown -R root:root install &&
    cp -a install/* $PKG_DEST

    mkdir -p $PKG_DEST/etc/profile.d/
    cat > $PKG_DEST/etc/profile.d/rustc.sh << "EOF"
# Begin /etc/profile.d/rustc.sh

pathprepend /opt/rustc/bin           PATH

# End /etc/profile.d/rustc.sh
EOF
    mkdir -p $PKG_DEST/etc/ld.so.conf.d
cat >> $PKG_DEST/etc/ld.so.conf.d/rustc.conf << EOF
# Begin rustc addition

/opt/rustc/lib

# End rustc addition
EOF

}