Skip to content

Instantly share code, notes, and snippets.

@liusheng
Last active November 18, 2019 06:48
Show Gist options
  • Save liusheng/d6dd509a371a9b7b07b75673646520b2 to your computer and use it in GitHub Desktop.
Save liusheng/d6dd509a371a9b7b07b75673646520b2 to your computer and use it in GitHub Desktop.
Build protoc-gen-grpc-java_aarch64
#!/bin/bash
set -ex
sudo apt-get install -y openjdk-11-jdk autoconf automake libtool unzip
cdir=$(cd $(dirname -- "$0") && pwd)
git clone https://github.com/google/protobuf.git
pushd protobuf
git checkout v3.5.1.1
./autogen.sh && ./configure --prefix=${cdir}/protobuf-3.5.1/ && make clean install
git checkout v3.0.0-javalite
./autogen.sh && ./configure --prefix=${cdir}/protobuf-v3.0.0-javalite/ && make clean install
popd
export PATH=${cdir}/protobuf-3.5.1/bin:$PATH
export CXXFLAGS="-I${cdir}/protobuf-3.5.1/include -L${cdir}/protobuf-3.5.1/lib"
export LDFLAGS="$CXXFLAGS"
export LD_LIBRARY_PATH="${cdir}/protobuf-3.5.1/lib"
git clone https://github.com/grpc/grpc-java.git
pushd grpc-java
git checkout v1.15.1
sed -i s'/annotation-api:1.2/annotation-api:1.3.2/' build.gradle
git diff -- build.gradle
./gradlew build -x test -x javadoc -Pprotoc-gen-javalite=${cdir}/protobuf-v3.0.0-javalite/bin/protoc-gen-javalite
./gradlew install
popd
diff --git a/buildscripts/build_artifacts_in_docker.sh b/buildscripts/build_artifacts_in_docker.sh
index ca24f24b3..0366e0f87 100755
--- a/buildscripts/build_artifacts_in_docker.sh
+++ b/buildscripts/build_artifacts_in_docker.sh
@@ -3,6 +3,8 @@ set -exu -o pipefail
# Runs all the tests and builds mvn artifacts.
# mvn artifacts are stored in grpc-java/mvn-artifacts/
-ALL_ARTIFACTS=true ARCH=64 "$(dirname $0)"/kokoro/unix.sh
+ALL_ARTIFACTS=true ARCH=x86_64 "$(dirname $0)"/kokoro/unix.sh
# Already ran tests the first time, so skip tests this time
-SKIP_TESTS=true ARCH=32 "$(dirname $0)"/kokoro/unix.sh
+SKIP_TESTS=true ARCH=x86_32 "$(dirname $0)"/kokoro/unix.sh
+
+ALL_ARTIFACTS=true ARCH=aarch_64 "$(dirname $0)"/kokoro/unix.sh
diff --git a/buildscripts/kokoro/unix.sh b/buildscripts/kokoro/unix.sh
index aaa63c1db..9f8783ddd 100755
--- a/buildscripts/kokoro/unix.sh
+++ b/buildscripts/kokoro/unix.sh
@@ -5,8 +5,10 @@
# the correct environment for releases.
# To run locally:
# ./buildscripts/kokoro/unix.sh
-# For 32 bit:
-# ARCH=32 ./buildscripts/kokoro/unix.sh
+# For x86 32 bit:
+# ARCH=x86_32 ./buildscripts/kokoro/unix.sh
+# For aarch64 bit:
+# ARCH=aarch_64 ./buildscripts/kokoro/unix.sh
# This script assumes `set -e`. Removing it may lead to undefined behavior.
set -exu -o pipefail
@@ -24,13 +26,13 @@ cd $(dirname $0)/../..
# TODO(zpencer): always make sure we are using Oracle jdk8
# ARCH is 64 bit unless otherwise specified.
-ARCH="${ARCH:-64}"
+ARCH="${ARCH:-x86_64}"
ARCH="$ARCH" buildscripts/make_dependencies.sh
# Set properties via flags, do not pollute gradle.properties
GRADLE_FLAGS="${GRADLE_FLAGS:-}"
-GRADLE_FLAGS+=" -PtargetArch=x86_$ARCH"
+GRADLE_FLAGS+=" -PtargetArch=$ARCH"
GRADLE_FLAGS+=" -Pcheckstyle.ignoreFailures=false"
GRADLE_FLAGS+=" -PfailOnWarnings=true"
GRADLE_FLAGS+=" -PerrorProne=true"
diff --git a/buildscripts/make_dependencies.sh b/buildscripts/make_dependencies.sh
index c7b847937..b50f18173 100755
--- a/buildscripts/make_dependencies.sh
+++ b/buildscripts/make_dependencies.sh
@@ -5,10 +5,10 @@ set -evux -o pipefail
PROTOBUF_VERSION=3.10.0
-# ARCH is 64 bit unless otherwise specified.
-ARCH="${ARCH:-64}"
+# ARCH is x86_64 bit unless otherwise specified.
+ARCH="${ARCH:-x86_64}"
DOWNLOAD_DIR=/tmp/source
-INSTALL_DIR="/tmp/protobuf-cache/$PROTOBUF_VERSION/$(uname -s)-$(uname -p)-x86_$ARCH"
+INSTALL_DIR="/tmp/protobuf-cache/$PROTOBUF_VERSION/$(uname -s)-$ARCH"
mkdir -p $DOWNLOAD_DIR
# Start with a sane default
@@ -31,8 +31,12 @@ else
fi
pushd $DOWNLOAD_DIR/protobuf-${PROTOBUF_VERSION}
# install here so we don't need sudo
- ./configure CFLAGS=-m"$ARCH" CXXFLAGS=-m"$ARCH" --disable-shared \
- --prefix="$INSTALL_DIR"
+ if [[ "$ARCH" == x86* ]]; then
+ ./configure CFLAGS=-m${ARCH#*_} CXXFLAGS=-m${ARCH#*_} --disable-shared \
+ --prefix="$INSTALL_DIR"
+ elif [[ "$ARCH" == aarch* ]]; then
+ ./configure --disable-shared --host=aarch64-linux-gnu --prefix="$INSTALL_DIR"
+ fi
# the same source dir is used for 32 and 64 bit builds, so we need to clean stale data first
make clean
make V=0 -j$NUM_CPU
@liusheng
Copy link
Author

liusheng commented Nov 11, 2019

> Task :grpc-alts:compileJava FAILED                                                                                                                        
/home/liusheng/grpc-java/alts/src/generated/main/grpc/io/grpc/alts/internal/HandshakerServiceGrpc.java:20: error: cannot find symbol                         
@javax.annotation.Generated(                                                                                                                                
                 ^                                                                                                                                         
  symbol:   class Generated                                                                                                                                  
  location: package javax.annotation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment