Enable ios/arm64 cross compilation

This commit is contained in:
Péter Szilágyi 2015-12-03 20:27:13 +02:00
parent 137971dab5
commit 9e2240bac6
2 changed files with 49 additions and 19 deletions

View File

@ -25,14 +25,19 @@ 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 \
gcc-5-arm-linux-gnueabi g++-5-arm-linux-gnueabi libc6-dev-armel-cross \
gcc-5-arm-linux-gnueabihf g++-5-arm-linux-gnueabihf libc6-dev-armhf-cross \
gcc-5-aarch64-linux-gnu g++-5-aarch64-linux-gnu libc6-dev-arm64-cross \
gcc-5-multilib g++-5-multilib gcc-mingw-w64 g++-mingw-w64 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 && \
ln -s /usr/include/asm-generic /usr/include/asm
apt-get install -y automake autogen build-essential ca-certificates \
gcc-5-arm-linux-gnueabi g++-5-arm-linux-gnueabi libc6-dev-armel-cross \
gcc-5-arm-linux-gnueabihf g++-5-arm-linux-gnueabihf libc6-dev-armhf-cross \
gcc-5-aarch64-linux-gnu g++-5-aarch64-linux-gnu libc6-dev-arm64-cross \
gcc-5-multilib g++-5-multilib gcc-mingw-w64 g++-mingw-w64 clang-3.7 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
# Fix any stock package issues
RUN \
ln -s /usr/include/asm-generic /usr/include/asm && \
ln -s /usr/bin/clang-3.7 /usr/bin/clang && \
ln -s /usr/bin/clang++-3.7 /usr/bin/clang++
# Configure the container for OSX cross compilation
ENV OSX_SDK_PATH https://s3.amazonaws.com/andrew-osx-sdks/MacOSX10.9.sdk.tar.xz
@ -70,15 +75,22 @@ RUN \
ENV PATH /usr/$ANDROID_CHAIN_ARM/bin:$PATH
# Configure the container for iOS cross compilation
ENV IOS_SDK iPhoneOS8.1.sdk.tar.bz2
ENV IOS_SDK_PATH http://iphone.howett.net/sdks/dl/iPhoneOS8.1.sdk.tbz2
ENV IOS_NDK_ARM_7 /usr/local/ios-ndk-arm-7
ENV IOS_NDK_ARM64 /usr/local/ios-ndk-arm64
RUN \
IOS_SDK=iPhoneOS8.1.sdk.tar.bz2 && \
IOS_SDK_PATH=http://iphone.howett.net/sdks/dl/iPhoneOS8.1.sdk.tbz2 && \
$FETCH $IOS_SDK_PATH 41203ed17a29743323cce0dd10b238efcea406e1 && \
mv `basename $IOS_SDK_PATH` $IOS_SDK && \
\
git clone https://github.com/tpoechtrager/cctools-port.git && \
/cctools-port/usage_examples/ios_toolchain/build.sh /$IOS_SDK armv7
ENV PATH /cctools-port/usage_examples/ios_toolchain/target/bin:$PATH
/cctools-port/usage_examples/ios_toolchain/build.sh /$IOS_SDK armv7 && \
mv /cctools-port/usage_examples/ios_toolchain/target $IOS_NDK_ARM_7 && \
/cctools-port/usage_examples/ios_toolchain/build.sh /$IOS_SDK arm64 && \
mv /cctools-port/usage_examples/ios_toolchain/target $IOS_NDK_ARM64 && \
\
rm -rf $IOS_SDK /cctools-port
# Inject the old Go package downloader and tool-chain bootstrapper
ADD bootstrap.sh /bootstrap.sh

View File

@ -329,22 +329,40 @@ for TARGET in $TARGETS; do
LDSTRIP="-s"
fi
# Build the requested darwin binaries
if [ $XGOARCH == "." ] || [ $XGOARCH == "arm" ]; then
if [ $XGOARCH == "." ] || [ $XGOARCH == "arm" ] || [ $XGOARCH == "arm-7" ]; then
if [ "$GO_VERSION" -lt 150 ]; then
echo "Go version too low, skipping ios/arm..."
echo "Go version too low, skipping ios/arm-7..."
else
echo "Bootstrapping ios-$PLATFORM/arm..."
echo "Bootstrapping ios-$PLATFORM/arm-7..."
export PATH=$IOS_NDK_ARM_7/bin:$PATH
GOOS=darwin GOARCH=arm GOARM=7 CGO_ENABLED=1 CC=arm-apple-darwin11-clang go install std
echo "Compiling for ios-$PLATFORM/arm..."
echo "Compiling for ios-$PLATFORM/arm-7..."
CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ HOST=arm-apple-darwin11 PREFIX=/usr/local $BUILD_DEPS /deps ${DEPS_ARGS[@]}
CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm GOARM=7 CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$LDSTRIP $V $LD" -d ./$PACK
CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm GOARM=7 CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$LDSTRIP $V $LD" $BM -o "/build/$NAME-ios-$PLATFORM-arm`extension ios`" ./$PACK
CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm GOARM=7 CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$LDSTRIP $V $LD" $BM -o "/build/$NAME-ios-$PLATFORM-arm-7`extension ios`" ./$PACK
echo "Cleaning up Go runtime for ios-$PLATFORM/arm..."
echo "Cleaning up Go runtime for ios-$PLATFORM/arm-7..."
rm -rf /usr/local/go/pkg/darwin_arm
fi
fi
if [ $XGOARCH == "." ] || [ $XGOARCH == "arm64" ]; then
if [ "$GO_VERSION" -lt 150 ]; then
echo "Go version too low, skipping ios/arm64..."
else
echo "Bootstrapping ios-$PLATFORM/arm64..."
export PATH=$IOS_NDK_ARM64/bin:$PATH
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 CC=arm-apple-darwin11-clang go install std
echo "Compiling for ios-$PLATFORM/arm64..."
CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ HOST=arm-apple-darwin11 PREFIX=/usr/local $BUILD_DEPS /deps ${DEPS_ARGS[@]}
CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go get $V $X "${T[@]}" --ldflags="$LDSTRIP $V $LD" -d ./$PACK
CC=arm-apple-darwin11-clang CXX=arm-apple-darwin11-clang++ GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build $V $X "${T[@]}" --ldflags="$LDSTRIP $V $LD" $BM -o "/build/$NAME-ios-$PLATFORM-arm64`extension ios`" ./$PACK
echo "Cleaning up Go runtime for ios-$PLATFORM/arm64..."
rm -rf /usr/local/go/pkg/darwin_arm64
fi
fi
# Remove any automatically injected deployment target vars
unset IPHONEOS_DEPLOYMENT_TARGET
fi