Update build for cross-compiling using CGO

This commit is contained in:
Siegfried Siegert 2020-09-13 17:57:50 +02:00
parent 91b94bd230
commit 3f0fa81f18

View File

@ -19,7 +19,6 @@ GO_BUILD_OPTIONS=-v
#GO_BUILD_OPTIONS="-a -v"
DEFAULT_TARGET=amd64
#######################################################################################
# functions
@ -35,17 +34,25 @@ usage() {
build_linux_amd64() {
echo -e "\nBuilding for Linux amd64:"
env GOOS=linux GOARCH=amd64 go build ${GO_BUILD_OPTIONS} -ldflags "$(govvv -flags)" -o ${APP}-linux-amd64
echo -e "\t\t${GREEN}... done${NC}"
}
build_linux_arm() {
echo -e "\nBuilding for arm:"
# setup environment
export CGO_ENABLED=1
export PATH=$PATH:/opt/devel/ptu4/buildrootBuild/host/usr/bin
export CC=arm-linux-gcc
export PKG_CONFIG_PATH=/opt/devel/ptu4/buildrootBuild/host/usr/lib/pkgconfig
env GOOS=linux GOARCH=arm go build ${GO_BUILD_OPTIONS} -ldflags "$(govvv -flags)" -o ${APP}-linux-arm
echo -e "\t\t${GREEN}... done${NC}"
echo -e "\nstipping arm binary:"
strip -o ${TARGET}-linux-arm-stripped ${TARGET}-linux-arm
strip -o ${TARGET}-linux-arm-stripped ${APP}-linux-arm
echo -e "\t\t${GREEN}... done${NC}"
}