Update build for cross-compiling using CGO
This commit is contained in:
		
							
								
								
									
										11
									
								
								build.sh
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								build.sh
									
									
									
									
									
								
							@@ -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}"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user