Skip to content

Commit 7ba044a

Browse files
authored
Merge pull request #1853 from pherl/3.0.0-GA
Make protoc-artifacts able to build plugins.
2 parents b6b521b + 7c9c314 commit 7ba044a

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

protoc-artifacts/build-protoc.sh

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
11
#!/bin/bash
22

3-
# Builds protoc executable into target/protoc.exe
3+
# Builds protoc executable into target/protoc.exe; optionally build protoc
4+
# plugins into target/protoc-gen-*.exe
45
# To be run from Maven.
5-
# Usage: build-protoc.sh <OS> <ARCH>
6+
# Usage: build-protoc.sh <OS> <ARCH> <TARGET>
67
# <OS> and <ARCH> are ${os.detected.name} and ${os.detected.arch} from os-maven-plugin
8+
# <TARGET> can be "protoc" or "protoc-gen-javalite"
79
OS=$1
810
ARCH=$2
11+
MAKE_TARGET=$3
912

10-
if [[ $# < 2 ]]; then
13+
if [[ $# < 3 ]]; then
1114
echo "No arguments provided. This script is intended to be run from Maven."
1215
exit 1
1316
fi
1417

18+
case $MAKE_TARGET in
19+
protoc-gen-javalite)
20+
;;
21+
protoc)
22+
;;
23+
*)
24+
echo "Target ""$TARGET"" invalid."
25+
exit 1
26+
esac
27+
1528
# Under Cygwin, bash doesn't have these in PATH when called from Maven which
1629
# runs in Windows version of Java.
1730
export PATH="/bin:/usr/bin:$PATH"
@@ -126,15 +139,14 @@ checkDependencies ()
126139
}
127140
############################################################################
128141

129-
echo "Building protoc, OS=$OS ARCH=$ARCH"
142+
echo "Building protoc, OS=$OS ARCH=$ARCH TARGET=$TARGET"
130143

131144
# Nested double quotes are unintuitive, but it works.
132145
cd "$(dirname "$0")"
133146

134147
WORKING_DIR=$(pwd)
135148
CONFIGURE_ARGS="--disable-shared"
136149

137-
MAKE_TARGET="protoc"
138150
if [[ "$OS" == windows ]]; then
139151
MAKE_TARGET="${MAKE_TARGET}.exe"
140152
fi
@@ -209,12 +221,13 @@ fi
209221

210222
export CXXFLAGS LDFLAGS
211223

212-
TARGET_FILE=target/protoc.exe
224+
TARGET_FILE=target/$MAKE_TARGET.exe
213225

214226
cd "$WORKING_DIR"/.. && ./configure $CONFIGURE_ARGS &&
215-
cd src && make clean && make $MAKE_TARGET &&
227+
cd src && make clean && make $MAKE_TARGET -j4 &&
216228
cd "$WORKING_DIR" && mkdir -p target &&
217-
(cp ../src/protoc $TARGET_FILE || cp ../src/protoc.exe $TARGET_FILE) ||
229+
(cp ../src/$MAKE_TARGET $TARGET_FILE ||
230+
cp ../src/$MAKE_TARGET.exe $TARGET_FILE) ||
218231
exit 1
219232

220233
if [[ "$OS" == osx ]]; then

protoc-artifacts/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<argument>build-protoc.sh</argument>
6060
<argument>${os.detected.name}</argument>
6161
<argument>${os.detected.arch}</argument>
62+
<argument>protoc</argument>
6263
</arguments>
6364
</configuration>
6465
</plugin>

0 commit comments

Comments
 (0)