-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
90 additions
and
17 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,46 @@ | ||
#!/usr/bin/env bash | ||
Version=2.0.0 | ||
|
||
export GOARCH=amd64 | ||
|
||
Platform=$1 | ||
|
||
|
||
if [[ "$Platform" == "" ]]; then | ||
Platform=$(go env GOHOSTOS) | ||
fi | ||
|
||
|
||
function ReportError() | ||
{ | ||
if [ $? -ne 0 ] ; then read -rsp $'Errors occurred...\n' ; fi | ||
} | ||
|
||
trap ReportError EXIT | ||
set -e | ||
|
||
if [[ "$Platform" == "" ]]; then | ||
Platform=$(go env GOHOSTOS) | ||
fi | ||
|
||
#export GOARCH=amd64 | ||
|
||
BuildSourcePackage="github.com/davyxu/protoplus/build" | ||
BinaryPackage="github.com/davyxu/protoplus/cmd/protoplus" | ||
BinaryName="protoplus" | ||
|
||
BuildBinary() | ||
{ | ||
set -e | ||
TargetDir=bin/"${1}" | ||
mkdir -p "${TargetDir}" | ||
export GOOS=${1} | ||
|
||
BuildTime=$(date -R) | ||
GitCommit=$(git rev-parse HEAD) | ||
VersionString="-X \"${BuildSourcePackage}.BuildTime=${BuildTime}\" -X \"${BuildSourcePackage}.Version=${Version}\" -X \"${BuildSourcePackage}.GitCommit=${GitCommit}\"" | ||
|
||
go build -v -p 4 -o "${TargetDir}"/${BinaryName} -ldflags "${VersionString}" ${BinaryPackage} | ||
PackageDir=$(pwd) | ||
cd "${TargetDir}" | ||
tar zcvf "${PackageDir}"/${BinaryName}-${Version}-"${1}"-x86_64.tar.gz ${BinaryName} | ||
cd "${PackageDir}" | ||
go build -p 4 -o "${TargetDir}"/${BinaryName} -ldflags "${VersionString}" ${BinaryPackage} | ||
echo "${TargetDir}"/${BinaryName} | ||
} | ||
|
||
|
||
|
||
if [[ ${1} == "" ]]; then | ||
BuildBinary windows | ||
BuildBinary linux | ||
BuildBinary darwin | ||
else | ||
BuildBinary "${1}" | ||
fi | ||
BuildBinary "${Platform}" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
Platform=$1 | ||
|
||
|
||
if [[ "$Platform" == "" ]]; then | ||
Platform=$(go env GOHOSTOS) | ||
fi | ||
|
||
|
||
function ReportError() | ||
{ | ||
if [ $? -ne 0 ] ; then read -rsp $'Errors occurred...\n' ; fi | ||
} | ||
|
||
trap ReportError EXIT | ||
set -e | ||
|
||
BuildGoPlugin() | ||
{ | ||
TargetDir=bin/"${1}" | ||
mkdir -p "${TargetDir}" | ||
export GOOS=${1} | ||
|
||
# Download & compile protoc-gen-go | ||
go get google.golang.org/protobuf/cmd/protoc-gen-go | ||
go build -o "${TargetDir}"/protoc-gen-go google.golang.org/protobuf/cmd/protoc-gen-go | ||
echo "${TargetDir}"/protoc-gen-go | ||
} | ||
|
||
|
||
|
||
|
||
DownloadProtoc() | ||
{ | ||
#export http_proxy="http://127.0.0.1:7890" | ||
#export https_proxy="http://127.0.0.1:7890" | ||
|
||
wget https://github.com/protocolbuffers/protobuf/releases/download/v21.6/protoc-21.6-win64.zip | ||
} | ||
|
||
|
||
BuildGoPlugin "${Platform}" |
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
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
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