Skip to content

Commit

Permalink
Add protoc script which downloads and runs protoc (linkerd#1138)
Browse files Browse the repository at this point in the history
* Add protoc script which downloads and runs protoc
  • Loading branch information
adleong authored Mar 14, 2017
1 parent 7260578 commit f1ff1ae
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ project/plugins/src_managed/
http.pid
npm-debug.log
.sbt-launch.jar
.protoc
.idea
.iml
.DS_Store
Expand Down
1 change: 1 addition & 0 deletions project/Grpc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ object Grpc extends Base {
javaSource <<= (javaSource in Compile),
scalaSource <<= (sourceManaged in Compile) { _ / "compiled_protobuf" },
generatedTargets <<= scalaSource { d => Seq(d -> "*.pb.scala") },
protoc := "./protoc",
grpcGenExec <<= grpcGenExec0,
runProtoc <<= runProtoc0,
protocOptions <<= scalaSource { ss =>
Expand Down
25 changes: 25 additions & 0 deletions protoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -e

if [ "$(uname -s)" = "Darwin" ]; then
os=osx
else
os=linux
fi
arch=$(uname -m)

protocbin=.protoc
protocversion=3.0.0
protocurl="https://github.com/google/protobuf/releases/download/v${protocversion}/protoc-${protocversion}-${os}-${arch}.zip"

if [ ! -f "$protocbin" ]; then
echo "downloading $protocbin" >&2
tmp=$(mktemp -d -t protoc.XXX)
curl -L --silent --fail -o "$tmp/$protocbin.zip" "$protocurl"
unzip -q "$tmp/$protocbin.zip" -d "$tmp"
mv "$tmp/bin/protoc" "$protocbin"
rm -rf "$tmp"
fi

./$protocbin "$@"

0 comments on commit f1ff1ae

Please sign in to comment.