diff options
author | Valery Piashchynski <[email protected]> | 2020-02-26 16:10:09 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-02-26 16:10:09 +0300 |
commit | 584b63d56e26cf6e5f0d2b8c1720771507ac2fcc (patch) | |
tree | 77c4f9ea3eca0515bb57522e7836964a098b0e2d /build.sh | |
parent | f9c4839266ff5c9aa289b2db0dae1e157011ffd3 (diff) |
Update build.sh, support musl target
Please, make sure, that musl-gcc is installed
Instead, use build type commented in build.sh
Diffstat (limited to 'build.sh')
-rwxr-xr-x | build.sh | 83 |
1 files changed, 52 insertions, 31 deletions
@@ -11,40 +11,61 @@ LDFLAGS="$LDFLAGS -X github.com/spiral/roadrunner/cmd/rr/cmd.BuildTime=$(date +% # remove debug info from binary as well as string and symbol tables LDFLAGS="$LDFLAGS -s" -build(){ - echo Packaging "$1" Build - bdir=roadrunner-${RR_VERSION}-$2-$3 - rm -rf builds/"$bdir" && mkdir -p builds/"$bdir" - GOOS=$2 GOARCH=$3 ./build.sh - - if [ "$2" == "windows" ]; then - mv rr builds/"$bdir"/rr.exe - else - mv rr builds/"$bdir" - fi - - cp README.md builds/"$bdir" - cp CHANGELOG.md builds/"$bdir" - cp LICENSE builds/"$bdir" - cd builds - - if [ "$2" == "linux" ]; then - tar -zcf "$bdir".tar.gz "$bdir" - else - zip -r -q "$bdir".zip "$bdir" - fi - - rm -rf "$bdir" - cd .. +build() { + echo Packaging "$1" Build + bdir=roadrunner-${RR_VERSION}-$2-$3 + rm -rf builds/"$bdir" && mkdir -p builds/"$bdir" + GOOS=$2 GOARCH=$3 ./build.sh + + if [ "$2" == "windows" ]; then + mv rr builds/"$bdir"/rr.exe + else + mv rr builds/"$bdir" + fi + + cp README.md builds/"$bdir" + cp CHANGELOG.md builds/"$bdir" + cp LICENSE builds/"$bdir" + cd builds + + if [ "$2" == "linux" ]; then + tar -zcf "$bdir".tar.gz "$bdir" + else + zip -r -q "$bdir".zip "$bdir" + fi + + rm -rf "$bdir" + cd .. +} + +# For musl build you should have musl-gcc installed. If not, please, use: +# go build -a -ldflags "-linkmode external -extldflags '-static' -s" +build_musl() { + echo Packaging "$2" Build + bdir=roadrunner-${RR_VERSION}-$1-$2-$3 + rm -rf builds/"$bdir" && mkdir -p builds/"$bdir" + CC=musl-gcc GOARCH=amd64 go build -ldflags "$LDFLAGS" -o "$OD/rr" cmd/rr/main.go + + mv rr builds/"$bdir" + + cp README.md builds/"$bdir" + cp CHANGELOG.md builds/"$bdir" + cp LICENSE builds/"$bdir" + cd builds + zip -r -q "$bdir".zip "$bdir" + + rm -rf "$bdir" + cd .. } if [ "$1" == "all" ]; then - rm -rf builds/ - build "Windows" "windows" "amd64" - build "Mac" "darwin" "amd64" - build "Linux" "linux" "amd64" - build "FreeBSD" "freebsd" "amd64" - exit + rm -rf builds/ + build "Windows" "windows" "amd64" + build "Mac" "darwin" "amd64" + build "Linux" "linux" "amd64" + build "FreeBSD" "freebsd" "amd64" + build_musl "unknown" "musl" "amd64" + exit fi go build -ldflags "$LDFLAGS" -o "$OD/rr" cmd/rr/main.go |