Skip to content

Commit

Permalink
增加pb二进制拉取shell
Browse files Browse the repository at this point in the history
  • Loading branch information
davyxu committed Sep 18, 2022
1 parent c215928 commit deb2ad3
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 17 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ example/csharp/Example/bin
example/csharp/Example/obj
api/csharp/ProtoPlus/obj
api/csharp/ProtoPlus/bin
bin
*.gz
tests/reg_gen.go
bin/windows
bin/darwin
bin/linux
42 changes: 27 additions & 15 deletions Make.sh
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}"
43 changes: 43 additions & 0 deletions MakeProtobufBinaries.sh
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}"
6 changes: 5 additions & 1 deletion cmd/protoplus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,22 @@ type GenEntry struct {

var (
genEntryList = []*GenEntry{
// 单文件生成
{name: "ppgo_out", usage: "output protoplus message serialize golang source file", outfile: ppgo.GenGo},
{name: "ppgoreg_out", usage: "output protoplus message register entry in golang", outfile: ppgo.GenGoReg},
{name: "ppcs_out", usage: "output protoplus message serialize csharp source file", outfile: ppcs.GenCS},
{name: "ppcsreg_out", usage: "output protoplus message register entry in csharp", outfile: ppcs.GenCSReg},
{name: "pbscheme_out", usage: "output google protobuf schema file as single file", outfile: pbscheme.GenProto},

// 使用例子: protoc $(cat filelist.txt)
// 文件夹输出 使用例子: protoc $(cat filelist.txt)
{name: "pbscheme_dir", usage: "output google protobuf schema files into dir", outfile: pbscheme.GenProtoDir},
{name: "ppscheme_out", usage: "output protoplus scheme json file", outfile: ppscheme.GenJson},
{name: "route_out", usage: "output route table json file", outfile: route.GenJson},

// 输出类型描述
{name: "ppscheme", usage: "output protoplus scheme json to std out", execute: ppscheme.OutputJson},

// 输出路由
{name: "route", usage: "output route table json to std out", execute: route.OutputJson},
}
)
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ require (
// 测试用
github.com/davyxu/golexer v0.1.1-0.20200202091144-a15ddde83f6a
github.com/davyxu/ulexer v0.0.0-20200713054812-c9bb8db3521f
github.com/golang/protobuf v1.5.2 // indirect
github.com/stretchr/testify v1.7.0
google.golang.org/protobuf v1.28.1 // indirect
)

replace github.com/davyxu/ulexer => ../ulexer
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davyxu/golexer v0.1.1-0.20200202091144-a15ddde83f6a h1:VYps2zwgBJPNuLGLiPrR4w6ud6cJpwlBA1OOytrCpx4=
github.com/davyxu/golexer v0.1.1-0.20200202091144-a15ddde83f6a/go.mod h1:dCUDBJcBQ9/AOzz6++KvSetGgVf5zXphevt6LQvKy0A=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
Expand Down

0 comments on commit deb2ad3

Please sign in to comment.