forked from filecoin-project/filecoin-ffi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-filecoin
executable file
·47 lines (34 loc) · 1.47 KB
/
install-filecoin
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
#!/usr/bin/env bash
set -Exeo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
source "install-shared.bash"
rust_sources_dir="rust"
if [ "${FFI_BUILD_FROM_SOURCE}" != "1" ] && download_release_tarball tarball_path "${rust_sources_dir}" "filecoin-ffi"; then
tmp_dir=$(mktemp -d)
tar -C "$tmp_dir" -xzf "$tarball_path"
find -L "${tmp_dir}" -type f -name filecoin.h -exec cp -- "{}" . \;
find -L "${tmp_dir}" -type f -name libfilecoin.a -exec cp -- "{}" . \;
find -L "${tmp_dir}" -type f -name filecoin.pc -exec cp -- "{}" . \;
(>&2 echo "successfully installed prebuilt libfilecoin")
else
(>&2 echo "building libfilecoin from local sources (dir = ${rust_sources_dir})")
build_from_source "filecoin" "${rust_sources_dir}"
mkdir -p include
mkdir -p lib/pkgconfig
find -L "${rust_sources_dir}/target/release" -type f -name filecoin.h -exec cp -- "{}" . \;
find -L "${rust_sources_dir}/target/release" -type f -name libfilecoin.a -exec cp -- "{}" . \;
find -L "${rust_sources_dir}" -type f -name filecoin.pc -exec cp -- "{}" . \;
if [[ ! -f "./filecoin.h" ]]; then
(>&2 echo "failed to install filecoin.h")
exit 1
fi
if [[ ! -f "./libfilecoin.a" ]]; then
(>&2 echo "failed to install libfilecoin.a")
exit 1
fi
if [[ ! -f "./filecoin.pc" ]]; then
(>&2 echo "failed to install filecoin.pc")
exit 1
fi
(>&2 echo "successfully built and installed libfilecoin from source")
fi