-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·117 lines (90 loc) · 3.11 KB
/
release.sh
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bash
set -e
export PATH=${HOME}/.cargo/bin:${PATH}
if [ -z "${TARGET}" ]; then
export TARGET=`rustup show | awk 'match($0, /Default host: ([0-9a-zA-Z\_]).+/) { ver = substr($3, RSTART, RLENGTH); print ver;}'`
fi
echo "Building release for ${TARGET}"
export DIST_PREFIX=${PWD}/target/${TARGET}/release
export BUILD_PREFIX=${DIST_PREFIX}/deps
export RUSTFLAGS=""
export CARGO_INCREMENTAL=1
export CFLAGS=""
export CPPFLAGS=""
export LDFLAGS=""
export OSX_VERSION_MIN="10.9"
export OSX_CPU_ARCH="core2"
export MAC_ARGS="-arch x86_64 -mmacosx-version-min=${OSX_VERSION_MIN} -march=${OSX_CPU_ARCH} -fapplication-extension"
case ${TARGET} in
x86_64-apple-darwin)
export CFLAGS="${CFLAGS} ${MAC_ARGS}"
export CPPFLAGS="${CPPFLAGS} ${MAC_ARGS}"
export LDFLAGS="${LDFLAGS} ${MAC_ARGS}"
export RUSTFLAGS="${RUSTFLAGS} -C link-arg=-fapplication-extension -C link-arg=-mmacosx-version-min=${OSX_VERSION_MIN}"
export OPENSSL_DIR=${BUILD_PREFIX}
export DEP_OPENSSL_LIBRESSL=1
;;
x86_64-unknown-linux-gnu)
export CFLAGS="${CFLAGS}"
export CPPFLAGS="${CPPFLAGS}"
export LDFLAGS="${LDFLAGS}"
;;
x86_64-unknown-linux-musl)
export CFLAGS="${CFLAGS}"
export CPPFLAGS="${CPPFLAGS}"
export LDFLAGS="${LDFLAGS}"
export CC=musl-gcc
;;
wasm32-unknown-emscripten)
export CPPFLAGS="${CPPFLAGS}"
export CFLAGS="-Os"
export CC=emcc
export PKG_CONFIG_ALLOW_CROSS=1
;;
*)
;;
esac
mkdir -p ${DIST_PREFIX}/lib
mkdir -p ${DIST_PREFIX}/include
mkdir -p ${DIST_PREFIX}/bin
echo "Building dependencies for ${TARGET}"
bash dep.sh
RUST_VER_FILE=$(dirname $0)/rust-toolchain
RUST_VER=$(<${RUST_VER_FILE})
rustup override set ${RUST_VER}
case ${TARGET} in
wasm32-unknown-emscripten)
echo "Building sddk for ${TARGET}"
RUST_BACKTRACE=1 cargo build --release -p sddk --target ${TARGET} > /dev/null
;;
x86_64-unknown-linux-musl)
;;
x86_64-unknown-linux-gnu)
;;
*)
echo "Building safedrive CLI for ${TARGET}"
RUST_BACKTRACE=1 cargo build --release -p safedrive --target ${TARGET} > /dev/null
echo "Building safedrive askpass for ${TARGET}"
RUST_BACKTRACE=1 cargo build --release -p askpass --target ${TARGET} > /dev/null
;;
esac
echo "Copying build artifacts for ${TARGET}"
case ${TARGET} in
x86_64-apple-darwin)
install_name_tool -id "@rpath/libsddk.dylib" ${DIST_PREFIX}/libsddk.dylib
cp -a target/${TARGET}/release/safedrive ${DIST_PREFIX}/io.safedrive.SafeDrive.cli
cp -a target/${TARGET}/release/askpass ${DIST_PREFIX}/io.safedrive.SafeDrive.askpass
;;
x86_64-unknown-linux-musl)
cp -a target/${TARGET}/release/rsync ${DIST_PREFIX}/
#cp -a target/${TARGET}/release/safedrive ${DIST_PREFIX}/
;;
x86_64-unknown-linux-gnu)
cp -a target/${TARGET}/release/rsync ${DIST_PREFIX}/
#cp -a target/${TARGET}/release/safedrive ${DIST_PREFIX}/
;;
wasm32-unknown-emscripten)
;;
*)
;;
esac