1#!/bin/bash
2
3set -x
4
5# Change to repo root.
6cd $(dirname $0)/../../../..
7
8# Initialize any submodules.
9git submodule update --init --recursive
10
11# Generate the configure script.
12./autogen.sh
13
14# Cross-build for aarch64 and ppc64le. Note: we do these builds first to avoid
15# file permission issues. The Docker builds will create directories owned by
16# root, which causes problems if we try to add new artifacts to those
17# directories afterward.
18sudo apt install -y g++-aarch64-linux-gnu
19protoc-artifacts/build-protoc.sh linux aarch_64 protoc
20
21sudo apt install -y g++-powerpc64le-linux-gnu
22protoc-artifacts/build-protoc.sh linux ppcle_64 protoc
23
24# Use docker image to build linux artifacts.
25DOCKER_IMAGE_NAME=protobuf/protoc_$(sha1sum protoc-artifacts/Dockerfile | cut -f1 -d " ")
26docker pull $DOCKER_IMAGE_NAME
27
28docker run -v $(pwd):/var/local/protobuf --rm $DOCKER_IMAGE_NAME \
29    bash -l /var/local/protobuf/protoc-artifacts/build-protoc.sh \
30    linux x86_64 protoc || {
31  echo "Failed to build protoc for linux + x86_64."
32  exit 1
33}
34
35docker run -v $(pwd):/var/local/protobuf --rm $DOCKER_IMAGE_NAME \
36    bash -l /var/local/protobuf/protoc-artifacts/build-protoc.sh \
37    linux x86_32 protoc || {
38  echo "Failed to build protoc for linux + x86_32."
39  exit 1
40}
41