-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.sh
executable file
·81 lines (68 loc) · 1.34 KB
/
build.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
#!/bin/bash -e
ADDON_ARCH="$1"
LANGUAGE_NAME="$2"
LANGUAGE_VERSION="$3"
function map_posix_tools() {
tar() {
gtar "$@"
return $!
}
export -f tar
readlink() {
greadlink "$@"
return $!
}
export -f readlink
find() {
gfind "$@"
return $!
}
export -f find
}
function install_osx_compiler() {
brew install \
boost \
cmake \
coreutils \
eigen \
findutils \
gnu-tar \
pkg-config
map_posix_tools
}
function install_linux_cross_compiler() {
sudo apt -qq update
sudo apt install --no-install-recommends -y \
binfmt-support \
qemu \
qemu-user-static
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
}
function build_native() {
ADDON_ARCH=${ADDON_ARCH} ./package.sh
}
function build_cross_compiled() {
docker run --rm -t -v $PWD:/build webthingsio/toolchain-${ADDON_ARCH}-${LANGUAGE_NAME}-${LANGUAGE_VERSION} bash -c "cd /build; ADDON_ARCH=${ADDON_ARCH} ./package.sh"
}
case "${ADDON_ARCH}" in
darwin-x64)
install_osx_compiler
build_native
;;
linux-arm)
install_linux_cross_compiler
build_cross_compiled
;;
linux-arm64)
install_linux_cross_compiler
build_cross_compiled
;;
linux-x64)
install_linux_cross_compiler
build_cross_compiled
;;
*)
echo "Unsupported architecture"
exit 1
;;
esac