-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-release.sh
executable file
·112 lines (90 loc) · 2.3 KB
/
build-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
#!/bin/bash -e
# Standard preambule
plain() {
local mesg=$1; shift
printf " ${mesg}\n" "$@" >&2
}
print_warning() {
local mesg=$1; shift
printf "${YELLOW}=> WARNING: ${mesg}${ALL_OFF}\n" "$@" >&2
}
print_msg1() {
local mesg=$1; shift
printf "${GREEN}==> ${mesg}${ALL_OFF}\n" "$@" >&2
}
print_msg2() {
local mesg=$1; shift
printf "${BLUE} -> ${mesg}${ALL_OFF}\n" "$@" >&2
}
print_error() {
local mesg=$1; shift
printf "${RED}==> ERROR: ${mesg}${ALL_OFF}\n" "$@" >&2
}
ALL_OFF='[00m'
BLUE='[38;5;04m'
GREEN='[38;5;02m'
RED='[38;5;01m'
YELLOW='[38;5;03m'
readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
ARCH_INSTALLS="${ARCH_INSTALLS:-win64 linux}"
if [ ! -d ${HOME}/result ]; then
print_error "directory for the result is not available. Exiting..."
exit 1
fi
if not command -v cmake >/dev/null 2>&1; then
print_error "No cmake found - please, install"
exit 1
fi
for _mingw in ${ARCH_INSTALLS}; do
case ${_mingw} in
win32)
_arch=win32
_msystem=MINGW32
_dist=bin_win32
_gcc=i686-w64-mingw32-gcc
;;
win64)
_arch=win64
_msystem=MINGW64
_dist=bin_win64
_gcc=x86_64-w64-mingw32-gcc
;;
linux)
_glibc=`ldd --version | head -n 1 | awk '{ print $5; }'`
_msystem=
_os=$(uname)
_arch=${_os,,}_$(uname -m)
_dist=bin_${_arch}
_gcc=gcc
;;
esac
if command -v ${_gcc} >/dev/null 2>&1; then
print_msg1 "Building ${_arch} release"
[ -d ${_dist} ] && rm -rf ${_dist}
[ -d Release_${_arch} ] && rm -rf Release_${_arch}
mkdir -p Release_${_arch}
(
cd Release_${_arch}
if [ -z ${_msystem} ]; then
cmake -DCMAKE_BUILD_TYPE=Release ..
make install
else
MSYSTEM=${_msystem} cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=cmake/${_arch}.toolchain ..
MSYSTEM=${_msystem} make install
fi
)
(
if [ -z ${_msystem} ]; then
[ -f ${HOME}/result/lib2inpx-${_arch}-glibc_${_glibc}.tar.xz ] && rm ${HOME}/result/lib2inpx-${_arch}-glibc_${_glibc}.tar.xz
tar --directory ${_dist} --create --xz --file ${HOME}/result/lib2inpx-${_arch}-glibc_${_glibc}.tar.xz .
else
[ -f ${HOME}/result/lib2inpx-${_arch}.7z ] && rm ${HOME}/result/lib2inpx-${_arch}.7z
cd ${_dist}
7z a -r ${HOME}/result/lib2inpx-${_arch}
fi
)
else
print_warning "You don't have installed mingw-w64 toolchain for ${_mingw}."
fi
done
exit 0