install-rust-fil-sector-builder 1.66 KB
Newer Older
1
2
3
4
5
6
7
8
9
#!/usr/bin/env bash

set -Eeo pipefail

cd "$(dirname "${BASH_SOURCE[0]}")"
source "install-shared.bash"

subm_dir="rust-fil-sector-builder"

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# If the directory is empty, try to download the pre-built tarballs or
# checkout the source code as fallback
if [ -z "$(ls -A $subm_dir)" ]; then
    if download_release_tarball tarball_path "${subm_dir}"; then
        tmp_dir=$(mktemp -d)
        tar -C "$tmp_dir" -xzf "$tarball_path"

        cp "${tmp_dir}/include/sector_builder_ffi.h" .
        cp "${tmp_dir}/lib/libsector_builder_ffi.a" .
        cp "${tmp_dir}/lib/pkgconfig/sector_builder_ffi.pc" .

        cp "${tmp_dir}/bin/paramcache" .

        exit 0
    else
        (>&2 echo "failed to find or obtain precompiled assets for ${subm_dir} - falling back to local build")
        git submodule update --init --recursive $subm_dir
    fi
fi
29

30
31
# Directory is not empty, hence compiling whatever source is in there
build_from_source "${subm_dir}"
32

33
34
mkdir -p include
mkdir -p lib/pkgconfig
35

36
37
38
find "${subm_dir}/target/release" -type f -name sector_builder_ffi.h -exec cp -- "{}" . \;
find "${subm_dir}/target/release" -type f -name libsector_builder_ffi.a -exec cp -- "{}" . \;
find "${subm_dir}" -type f -name sector_builder_ffi.pc -exec cp -- "{}" . \;
39

40
41
42
43
if [[ ! -f "./sector_builder_ffi.h" ]]; then
    (>&2 echo "failed to install sector_builder_ffi.h")
    exit 1
fi
44

45
46
47
48
if [[ ! -f "./libsector_builder_ffi.a" ]]; then
    (>&2 echo "failed to install libsector_builder_ffi.a")
    exit 1
fi
49

50
51
52
if [[ ! -f "./sector_builder_ffi.pc" ]]; then
    (>&2 echo "failed to install sector_builder_ffi.pc")
    exit 1
53
fi
54
55

(>&2 echo "WARNING: paramcache was not installed - you may wish to 'cargo install' it")