aboutsummaryrefslogtreecommitdiff
path: root/extra/rust/build
blob: fa5c547cc8c6641f3b043680b386345b9f848a40 (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
#!/bin/sh -e

patch -p1 < musl.patch

# This package mimics the download process of rust's 'x.py'
# bootstrap library to allow for the removal of the internet
# connection requirement per build.
{
    mkdir -p "${cache_dir:=build/cache/2020-02-27}"

    for tarball in *.tar.xz\?no-extract; do
        mv -f "$tarball" "$cache_dir/${tarball%%\?no-extract}"
    done
}

# 'rust' checksums files in 'vendor/', but we patch a few.
for vendor in libc openssl-sys; do
    sed -i 's/\("files":{\)[^}]*/\1/' "vendor/$vendor/.cargo-checksum.json"
done

cat > config.toml <<EOF
[llvm]
link-shared = true

[build]
build  = "x86_64-unknown-linux-musl"
host   = [ "x86_64-unknown-linux-musl" ]
target = [ "x86_64-unknown-linux-musl" ]

docs           = false
compiler-docs  = false
extended       = true
submodules     = false
python         = "python3"
locked-deps    = true
vendor         = true
sanitizers     = false
profiler       = false
full-bootstrap = false

[install]
prefix = "/usr"

[rust]
channel          = "stable"
rpath            = false
codegen-units    = 1
debuginfo-level  = 0
debug            = false
backtrace        = false
jemalloc         = false
debug-assertions = false
codegen-tests    = false

[target.x86_64-unknown-linux-musl]
llvm-config = "/usr/bin/llvm-config"
crt-static  = false
EOF

export DESTDIR="$1" 

python3 ./x.py build -j "$(nproc)"
python3 ./x.py install