Commit 474fd316 authored by Feng Xiao's avatar Feng Xiao

Update protoc build scripts.

1. Changed maven script to only do artifact uploading and removed build
script invocation from it. We didn't use maven to invoke the build
script before (we built protoc manually and editted pom.xml to only do
uploading for previous releases), and will not use it in the future (we
will use kokoro to build artifacts).
2. Cleaned up build-protoc.sh and README.md: removed the part about
using maven to build and listed supported platforms explicitly.
parent b23429ea
This diff is collapsed.
#!/bin/bash
# Builds protoc executable into target/protoc.exe; optionally build protoc
# plugins into target/protoc-gen-*.exe
# To be run from Maven.
# Usage: build-protoc.sh <OS> <ARCH> <TARGET>
# <OS> and <ARCH> are ${os.detected.name} and ${os.detected.arch} from os-maven-plugin
# <TARGET> can be "protoc" or "protoc-gen-javalite"
# Builds protoc executable into target/<OS>/<ARCH>/protoc.exe; optionally builds
# protoc plugins into target/<OS>/<ARCH>/protoc-gen-*.exe
#
# The script now supports cross-compiling windows, linux-arm64, and linux-ppc64le in linux-x86
# environment. Required packages:
# - Windows: i686-w64-mingw32-gcc (32bit) and x86_64-w64-mingw32-gcc (64bit)
# - Arm64: g++-aarch64-linux-gnu
# - Ppc64le: g++-powerpc64le-linux-gcc
# Usage: ./build-protoc.sh <OS> <ARCH> <TARGET>
#
# <TARGET> can be "protoc" or "protoc-gen-javalite". Supported <OS> <ARCH>
# combinations:
# HOST <OS> <ARCH> <COMMENT>
# cygwin windows x86_32 Requires: i686-w64-mingw32-gcc
# cygwin windows x86_64 Requires: x86_64-w64-mingw32-gcc
# linux linux aarch_64 Requires: g++-aarch64-linux-gnu
# linux linux x86_32
# linux linux x86_64
# linux windows x86_32 Requires: i686-w64-mingw32-gcc
# linux windows x86_64 Requires: x86_64-w64-mingw32-gcc
# macos osx x86_32
# macos osx x86_64
# mingw windows x86_32
# mingw windows x86_64
#
# Before running this script, make sure you have generated the configure script
# in the parent directory (i.e., run ./autogen.sh there).
OS=$1
ARCH=$2
MAKE_TARGET=$3
if [[ $# < 3 ]]; then
echo "No arguments provided. This script is intended to be run from Maven."
echo "Not enough arguments provided."
exit 1
fi
......@@ -166,13 +176,8 @@ checkDependencies ()
echo "Building protoc, OS=$OS ARCH=$ARCH TARGET=$TARGET"
# Nested double quotes are unintuitive, but it works.
cd "$(dirname "$0")"
WORKING_DIR=$(pwd)
CONFIGURE_ARGS="--disable-shared"
TARGET_FILE=target/$MAKE_TARGET.exe
if [[ "$OS" == windows ]]; then
MAKE_TARGET="${MAKE_TARGET}.exe"
fi
......@@ -253,10 +258,18 @@ fi
export CXXFLAGS LDFLAGS
cd "$WORKING_DIR"/.. && ./configure $CONFIGURE_ARGS &&
cd src && make clean && make $MAKE_TARGET &&
cd "$WORKING_DIR" && mkdir -p target &&
cp ../src/$MAKE_TARGET $TARGET_FILE ||
# Nested double quotes are unintuitive, but it works.
cd "$(dirname "$0")"
WORKING_DIR="$(pwd)"
BUILD_DIR="build/$OS/$ARCH"
TARGET_FILE="target/$OS/$ARCH/$MAKE_TARGET.exe"
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR" &&
../../../../configure $CONFIGURE_ARGS &&
cd src && make $MAKE_TARGET -j8 &&
cd "$WORKING_DIR" && mkdir -p $(dirname $TARGET_FILE) &&
cp $BUILD_DIR/src/$MAKE_TARGET $TARGET_FILE ||
exit 1
if [[ "$OS" == osx ]]; then
......
......@@ -33,36 +33,7 @@
</connection>
</scm>
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.5.0.Final</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>bash</executable>
<arguments>
<argument>build-protoc.sh</argument>
<argument>${os.detected.name}</argument>
<argument>${os.detected.arch}</argument>
<argument>protoc</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
......@@ -77,8 +48,38 @@
<configuration>
<artifacts>
<artifact>
<file>${basedir}/target/protoc.exe</file>
<classifier>${os.detected.name}-${os.detected.arch}</classifier>
<file>${basedir}/target/linux/x86_64/protoc.exe</file>
<classifier>linux-x86_64</classifier>
<type>exe</type>
</artifact>
<artifact>
<file>${basedir}/target/linux/x86_32/protoc.exe</file>
<classifier>linux-x86_32</classifier>
<type>exe</type>
</artifact>
<artifact>
<file>${basedir}/target/windows/x86_64/protoc.exe</file>
<classifier>windows-x86_64</classifier>
<type>exe</type>
</artifact>
<artifact>
<file>${basedir}/target/windows/x86_32/protoc.exe</file>
<classifier>windows-x86_32</classifier>
<type>exe</type>
</artifact>
<artifact>
<file>${basedir}/target/osx/x86_64/protoc.exe</file>
<classifier>osx-x86_64</classifier>
<type>exe</type>
</artifact>
<artifact>
<file>${basedir}/target/osx/x86_32/protoc.exe</file>
<classifier>osx-x86_32</classifier>
<type>exe</type>
</artifact>
<artifact>
<file>${basedir}/target/linux/aarch_64/protoc.exe</file>
<classifier>linux-aarch_64</classifier>
<type>exe</type>
</artifact>
</artifacts>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment