| OLD | NEW | 
|    1 #!/bin/bash |    1 #!/bin/bash | 
|    2  |    2  | 
|    3 # Builds protoc executable into target/protoc.exe; optionally build protoc |    3 # Builds protoc executable into target/protoc.exe | 
|    4 # plugins into target/protoc-gen-*.exe |  | 
|    5 # To be run from Maven. |    4 # To be run from Maven. | 
|    6 # Usage: build-protoc.sh <OS> <ARCH> <TARGET> |    5 # Usage: build-protoc.sh <OS> <ARCH> | 
|    7 # <OS> and <ARCH> are ${os.detected.name} and ${os.detected.arch} from os-maven-
     plugin |    6 # <OS> and <ARCH> are ${os.detected.name} and ${os.detected.arch} from os-maven-
     plugin | 
|    8 # <TARGET> can be "protoc" or "protoc-gen-javalite" |  | 
|    9 OS=$1 |    7 OS=$1 | 
|   10 ARCH=$2 |    8 ARCH=$2 | 
|   11 MAKE_TARGET=$3 |  | 
|   12  |    9  | 
|   13 if [[ $# < 3 ]]; then |   10 if [[ $# < 2 ]]; then | 
|   14   echo "No arguments provided. This script is intended to be run from Maven." |   11   echo "No arguments provided. This script is intended to be run from Maven." | 
|   15   exit 1 |   12   exit 1 | 
|   16 fi |   13 fi | 
|   17  |   14  | 
|   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  |  | 
|   28 # Under Cygwin, bash doesn't have these in PATH when called from Maven which |   15 # Under Cygwin, bash doesn't have these in PATH when called from Maven which | 
|   29 # runs in Windows version of Java. |   16 # runs in Windows version of Java. | 
|   30 export PATH="/bin:/usr/bin:$PATH" |   17 export PATH="/bin:/usr/bin:$PATH" | 
|   31  |   18  | 
|   32 ############################################################################ |   19 ############################################################################ | 
|   33 # Helper functions |   20 # Helper functions | 
|   34 ############################################################################ |   21 ############################################################################ | 
|   35 E_PARAM_ERR=98 |   22 E_PARAM_ERR=98 | 
|   36 E_ASSERT_FAILED=99 |   23 E_ASSERT_FAILED=99 | 
|   37  |   24  | 
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  132   if [[ $ret == 0 ]]; then |  119   if [[ $ret == 0 ]]; then | 
|  133     fail "found unexpected dependencies (listed above)." |  120     fail "found unexpected dependencies (listed above)." | 
|  134   elif [[ $ret != 1 ]]; then |  121   elif [[ $ret != 1 ]]; then | 
|  135     fail "Error when checking dependencies." |  122     fail "Error when checking dependencies." | 
|  136   fi  # grep returns 1 when "not found", which is what we expect |  123   fi  # grep returns 1 when "not found", which is what we expect | 
|  137   echo "Dependencies look good." |  124   echo "Dependencies look good." | 
|  138   echo |  125   echo | 
|  139 } |  126 } | 
|  140 ############################################################################ |  127 ############################################################################ | 
|  141  |  128  | 
|  142 echo "Building protoc, OS=$OS ARCH=$ARCH TARGET=$TARGET" |  129 echo "Building protoc, OS=$OS ARCH=$ARCH" | 
|  143  |  130  | 
|  144 # Nested double quotes are unintuitive, but it works. |  131 # Nested double quotes are unintuitive, but it works. | 
|  145 cd "$(dirname "$0")" |  132 cd "$(dirname "$0")" | 
|  146  |  133  | 
|  147 WORKING_DIR=$(pwd) |  134 WORKING_DIR=$(pwd) | 
|  148 CONFIGURE_ARGS="--disable-shared" |  135 CONFIGURE_ARGS="--disable-shared" | 
|  149  |  136  | 
|  150 TARGET_FILE=target/$MAKE_TARGET.exe |  137 MAKE_TARGET="protoc" | 
|  151 if [[ "$OS" == windows ]]; then |  138 if [[ "$OS" == windows ]]; then | 
|  152   MAKE_TARGET="${MAKE_TARGET}.exe" |  139   MAKE_TARGET="${MAKE_TARGET}.exe" | 
|  153 fi |  140 fi | 
|  154  |  141  | 
|  155 # Override the default value set in configure.ac that has '-g' which produces |  142 # Override the default value set in configure.ac that has '-g' which produces | 
|  156 # huge binary. |  143 # huge binary. | 
|  157 CXXFLAGS="-DNDEBUG" |  144 CXXFLAGS="-DNDEBUG" | 
|  158 LDFLAGS="" |  145 LDFLAGS="" | 
|  159  |  146  | 
|  160 if [[ "$(uname)" == CYGWIN* ]]; then |  147 if [[ "$(uname)" == CYGWIN* ]]; then | 
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  215  |  202  | 
|  216 # Statically link libgcc and libstdc++. |  203 # Statically link libgcc and libstdc++. | 
|  217 # -s to produce stripped binary. |  204 # -s to produce stripped binary. | 
|  218 # And they don't work under Mac. |  205 # And they don't work under Mac. | 
|  219 if [[ "$OS" != osx ]]; then |  206 if [[ "$OS" != osx ]]; then | 
|  220   LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++ -s" |  207   LDFLAGS="$LDFLAGS -static-libgcc -static-libstdc++ -s" | 
|  221 fi |  208 fi | 
|  222  |  209  | 
|  223 export CXXFLAGS LDFLAGS |  210 export CXXFLAGS LDFLAGS | 
|  224  |  211  | 
 |  212 TARGET_FILE=target/protoc.exe | 
 |  213  | 
|  225 cd "$WORKING_DIR"/.. && ./configure $CONFIGURE_ARGS && |  214 cd "$WORKING_DIR"/.. && ./configure $CONFIGURE_ARGS && | 
|  226   cd src && make clean && make $MAKE_TARGET && |  215   cd src && make clean && make $MAKE_TARGET && | 
|  227   cd "$WORKING_DIR" && mkdir -p target && |  216   cd "$WORKING_DIR" && mkdir -p target && | 
|  228   cp ../src/$MAKE_TARGET $TARGET_FILE || |  217   (cp ../src/protoc $TARGET_FILE || cp ../src/protoc.exe $TARGET_FILE) || | 
|  229   exit 1 |  218   exit 1 | 
|  230  |  219  | 
|  231 if [[ "$OS" == osx ]]; then |  220 if [[ "$OS" == osx ]]; then | 
|  232   # Since Mac linker doesn't accept "-s", we need to run strip |  221   # Since Mac linker doesn't accept "-s", we need to run strip | 
|  233   strip $TARGET_FILE || exit 1 |  222   strip $TARGET_FILE || exit 1 | 
|  234 fi |  223 fi | 
|  235  |  224  | 
|  236 checkArch $TARGET_FILE && checkDependencies $TARGET_FILE |  225 checkArch $TARGET_FILE && checkDependencies $TARGET_FILE | 
| OLD | NEW |