mirror of
https://github.com/status-im/xgo.git
synced 2025-01-11 11:25:44 +00:00
Support building Android NDK binaries.
This commit is contained in:
parent
0407d11cec
commit
921735e9a6
@ -21,10 +21,11 @@ RUN chmod +x $FETCH
|
||||
# Make sure apt-get is up to date and dependent packages are installed
|
||||
RUN \
|
||||
apt-get update && \
|
||||
apt-get install -y automake autogen build-essential ca-certificates \
|
||||
apt-get install -y automake autogen build-essential ca-certificates \
|
||||
gcc-arm-linux-gnueabi libc6-dev-armel-cross gcc-multilib gcc-mingw-w64 \
|
||||
clang llvm-dev libtool libxml2-dev uuid-dev libssl-dev pkg-config \
|
||||
patch make xz-utils cpio wget unzip git mercurial bzr --no-install-recommends
|
||||
clang llvm-dev libtool libxml2-dev uuid-dev libssl-dev pkg-config \
|
||||
patch make xz-utils cpio wget unzip p7zip git mercurial bzr \
|
||||
--no-install-recommends
|
||||
|
||||
# Configure the container for OSX cross compilation
|
||||
ENV OSX_SDK_PATH https://github.com/trevd/android_platform_build2/raw/master/osxsdks10.6.tar.gz
|
||||
@ -33,16 +34,29 @@ ENV OSX_SDK MacOSX10.6.sdk
|
||||
RUN \
|
||||
git clone https://github.com/tpoechtrager/osxcross.git && \
|
||||
\
|
||||
$FETCH $OSX_SDK_PATH f526b4ae9806e8d31e3b094e3f004f8f160a3fad
|
||||
|
||||
RUN \
|
||||
$FETCH $OSX_SDK_PATH f526b4ae9806e8d31e3b094e3f004f8f160a3fad && \
|
||||
tar -xzf `basename $OSX_SDK_PATH` --strip-components 1 SDKs/$OSX_SDK && \
|
||||
tar -cjf /osxcross/tarballs/$OSX_SDK.tar.bz2 $OSX_SDK && \
|
||||
rm -rf `basename $OSX_SDK_PATH` $OSX_SDK && \
|
||||
\
|
||||
UNATTENDED=yes /osxcross/build.sh
|
||||
|
||||
ENV PATH /osxcross/target/bin:$PATH
|
||||
|
||||
# Configure the container for Android cross compilation
|
||||
ENV ANDROID_NDK_PATH http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin
|
||||
ENV ANDROID_NDK android-ndk-r10e
|
||||
ENV ANDROID_PLATROOT /usr/local/$ANDROID_NDK/platforms/
|
||||
ENV ANDROID_PLATFORM android-21
|
||||
|
||||
RUN \
|
||||
$FETCH $ANDROID_NDK_PATH c685e5f106f8daa9b5449d0a4f21ee8c0afcb2f6 && \
|
||||
7zr x `basename $ANDROID_NDK_PATH` "$ANDROID_NDK/platforms/*/arch-arm/*" -o/usr/local > /dev/null && \
|
||||
7zr x `basename $ANDROID_NDK_PATH` "$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8" -o/usr/local > /dev/null && \
|
||||
rm -rf `basename $ANDROID_NDK_PATH`
|
||||
|
||||
ENV PATH /usr/local/$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin:$PATH
|
||||
|
||||
|
||||
# Inject the old Go package downloader and tool-chain bootstrapper
|
||||
ADD bootstrap.sh /bootstrap.sh
|
||||
|
@ -39,3 +39,7 @@ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 CC=o64-clang go install std
|
||||
|
||||
echo "Bootstrapping darwin/386..."
|
||||
GOOS=darwin GOARCH=386 CGO_ENABLED=1 CC=o32-clang go install std
|
||||
|
||||
echo "Bootstrapping android/arm..."
|
||||
SYSROOT=$ANDROID_PLATROOT/$ANDROID_PLATFORM/arch-arm
|
||||
GOOS=android GOARCH=arm GOARM=7 CGO_ENABLED=1 CC=arm-linux-androideabi-gcc CGO_CFLAGS="--sysroot=$SYSROOT" CGO_LDFLAGS="--sysroot=$SYSROOT" go install std
|
||||
|
@ -64,6 +64,12 @@ if [ "$FLAG_V" == "true" ]; then V=-v; fi
|
||||
if [ "$FLAG_RACE" == "true" ]; then R=-race; fi
|
||||
|
||||
# Build for each platform individually
|
||||
echo "Compiling for android/arm..."
|
||||
export ANDROID_SYSROOT=$ANDROID_PLATROOT/$ANDROID_PLATFORM/arch-arm
|
||||
CC="arm-linux-androideabi-gcc --sysroot=$ANDROID_SYSROOT" HOST=arm-linux-androideabi PREFIX=$ANDROID_SYSROOT/usr $BUILD_DEPS /deps
|
||||
CC=arm-linux-androideabi-gcc GOOS=android GOARCH=arm GOARM=7 CGO_ENABLED=1 CGO_CFLAGS="--sysroot=$ANDROID_SYSROOT" CGO_LDFLAGS="--sysroot=$ANDROID_SYSROOT" go get -v -x -d ./$PACK
|
||||
CC=arm-linux-androideabi-gcc GOOS=android GOARCH=arm GOARM=7 CGO_ENABLED=1 CGO_CFLAGS="--sysroot=$ANDROID_SYSROOT" CGO_LDFLAGS="--sysroot=$ANDROID_SYSROOT" go build -v -x $V $R -o $NAME-android-arm$R ./$PACK
|
||||
|
||||
echo "Compiling for linux/amd64..."
|
||||
HOST=x86_64-linux PREFIX=/usr/local $BUILD_DEPS /deps
|
||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go get -d ./$PACK
|
||||
@ -100,4 +106,4 @@ CC=o32-clang GOOS=darwin GOARCH=386 CGO_ENABLED=1 go get -d ./$PACK
|
||||
CC=o32-clang GOOS=darwin GOARCH=386 CGO_ENABLED=1 go build -ldflags=-s $V -o $NAME-darwin-386 ./$PACK
|
||||
|
||||
echo "Moving binaries to host..."
|
||||
cp `ls -t | head -n 7` /build
|
||||
cp `ls -t | head -n 8` /build
|
||||
|
@ -2,13 +2,13 @@
|
||||
#
|
||||
# Contains the a dependency builder to iterate over all installed dependencies
|
||||
# and cross compile them to the requested target platform.
|
||||
#
|
||||
#
|
||||
# Usage: build_deps.sh <dependency folder>
|
||||
#
|
||||
# Needed environment variables:
|
||||
# CC - C cross compiler to use for the build
|
||||
# HOST - Target platform to build (used to find the needed tool-chains)
|
||||
# PREFIX - File-system path where to install the built binaries
|
||||
# CC - C cross compiler to use for the build
|
||||
# HOST - Target platform to build (used to find the needed tool-chains)
|
||||
# PREFIX - File-system path where to install the built binaries
|
||||
set -e
|
||||
|
||||
# Remove any previous build leftovers, and copy a fresh working set (clean doesn't work for cross compiling)
|
||||
|
Loading…
x
Reference in New Issue
Block a user