mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-01 19:28:05 +08:00
[ADD] add static build support
This commit is contained in:
parent
8ff39470d0
commit
842c01337a
8
Makefile
8
Makefile
@ -3,7 +3,7 @@ VERSION=master
|
||||
WORK_DIR=/go/src/github.com/goodrain/rainbond
|
||||
BASE_NAME=rainbond
|
||||
BASE_DOCKER=./hack/contrib/docker
|
||||
BIN_PATH=./_output/${VERSION}
|
||||
BIN_PATH=./_output/${GOOS}/${VERSION}
|
||||
|
||||
default: help
|
||||
all: image ## build linux binaries, build images for docker
|
||||
@ -19,6 +19,12 @@ endif
|
||||
ifeq ($(origin GOOS), undefined)
|
||||
GOOS = darwin
|
||||
endif
|
||||
ifeq ($(origin STATIC), undefined)
|
||||
STATIC = false
|
||||
else
|
||||
STATIC = true
|
||||
endif
|
||||
|
||||
ifeq ($(origin PUSH), undefined)
|
||||
PUSH = false
|
||||
endif
|
||||
|
@ -81,7 +81,6 @@ func ParseClientCommnad(args []string) {
|
||||
|
||||
}
|
||||
}
|
||||
fmt.Println("client complete")
|
||||
}
|
||||
|
||||
type controllerServiceClient struct {
|
||||
|
@ -31,13 +31,28 @@ function localbuild() {
|
||||
done
|
||||
else
|
||||
echo "build local $1 ${VERSION}"
|
||||
go build -ldflags "-w -s -X github.com/goodrain/rainbond/cmd.version=${release_desc}" -o _output/${GOOS}/${VERSION}/rainbond-$1 ./cmd/$1
|
||||
|
||||
outputname="_output/${GOOS}/${VERSION}/rainbond-$1"
|
||||
if [ "$GOOS" = "windows" ];then
|
||||
outputname="_output/${GOOS}/${VERSION}/rainbond-$1.exe"
|
||||
fi
|
||||
ldflags="-w -s -X github.com/goodrain/rainbond/cmd.version=${release_desc}"
|
||||
if [ "$STATIC" = "true" ];then
|
||||
ldflags="${ldflags} -extldflags '-static'"
|
||||
fi
|
||||
go build -ldflags "${ldflags}" -o ${outputname} ./cmd/$1
|
||||
fi
|
||||
}
|
||||
|
||||
case $1 in
|
||||
*)
|
||||
prepare
|
||||
if [ "$1" = "all" ];then
|
||||
for item in ${build_items[@]}
|
||||
do
|
||||
localbuild $item
|
||||
done
|
||||
fi
|
||||
localbuild $1
|
||||
;;
|
||||
esac
|
||||
|
Loading…
Reference in New Issue
Block a user