Created
September 16, 2019 14:40
-
-
Save golightlyb/c6baaa1143a2689f49d0f429f489af82 to your computer and use it in GitHub Desktop.
Simple script to cross-compile a go project in parallel
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
# Requires GNU Parallel | |
# e.g. `sudo apt-get install parallel` | |
CC_WIN32=i686-w64-mingw32-gcc | |
CC_WIN64=x86_64-w64-mingw32-gcc | |
name=`basename \`pwd\`` | |
tasks=" | |
env GOOS=linux GOARCH=386 CGO_ENABLED=1 go build -trimpath -o bin/${name}32 | |
env GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -trimpath -o bin/${name}64 | |
env CC=$CC_WIN32 GOOS=windows GOARCH=386 CGO_ENABLED=1 go build -trimpath -o bin/${name}32.exe | |
env CC=$CC_WIN64 GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build -trimpath -o bin/${name}64.exe | |
"; | |
printf "$tasks" | parallel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment