-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ded14d9
commit e6d4093
Showing
1 changed file
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/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() { | ||
python -m pip install -U pip | ||
python -m pip install -U setuptools wheel | ||
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 |