Update build for cross-compiling using CGO
This commit is contained in:
parent
91b94bd230
commit
3f0fa81f18
11
build.sh
11
build.sh
|
@ -19,7 +19,6 @@ GO_BUILD_OPTIONS=-v
|
||||||
#GO_BUILD_OPTIONS="-a -v"
|
#GO_BUILD_OPTIONS="-a -v"
|
||||||
DEFAULT_TARGET=amd64
|
DEFAULT_TARGET=amd64
|
||||||
|
|
||||||
|
|
||||||
#######################################################################################
|
#######################################################################################
|
||||||
# functions
|
# functions
|
||||||
|
|
||||||
|
@ -35,17 +34,25 @@ usage() {
|
||||||
|
|
||||||
build_linux_amd64() {
|
build_linux_amd64() {
|
||||||
echo -e "\nBuilding for 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
|
env GOOS=linux GOARCH=amd64 go build ${GO_BUILD_OPTIONS} -ldflags "$(govvv -flags)" -o ${APP}-linux-amd64
|
||||||
echo -e "\t\t${GREEN}... done${NC}"
|
echo -e "\t\t${GREEN}... done${NC}"
|
||||||
}
|
}
|
||||||
|
|
||||||
build_linux_arm() {
|
build_linux_arm() {
|
||||||
echo -e "\nBuilding for 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
|
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 "\t\t${GREEN}... done${NC}"
|
||||||
|
|
||||||
echo -e "\nstipping arm binary:"
|
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}"
|
echo -e "\t\t${GREEN}... done${NC}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user