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