From 8e14e77bda2d9641609f1171e944c7307d15c30a Mon Sep 17 00:00:00 2001 From: Zhuowei Zhang Date: Mon, 7 Dec 2015 22:44:19 -0500 Subject: [PATCH 01/14] Use llvm-libc++ as STL, disable building of iconv, build only for armeabi-v7a, build icu 55.1 --- build.sh | 12 +++++++----- setCrossEnvironment-armeabi-v7a.sh | 13 +++++++++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/build.sh b/build.sh index 85ba966..f2c66d4 100755 --- a/build.sh +++ b/build.sh @@ -13,7 +13,7 @@ NDK=`readlink -f $NDK` export CLANG=1 -for ARCH in armeabi armeabi-v7a arm64-v8a x86 x86_64; do +for ARCH in armeabi-v7a; do cd $BUILDDIR @@ -40,7 +40,7 @@ cd $BUILDDIR/$ARCH # =========== libiconv.so =========== -[ -e libiconv.so ] || { +true || [ -e libiconv.so ] || { rm -rf libiconv-1.15 @@ -163,12 +163,14 @@ cd $BUILDDIR/$ARCH rm -rf icu - tar xvf ../icu4c-59_1-src.tgz + [ -e ../icu4c-55_1-src.tgz ] || exit 1 + + tar xvf ../icu4c-55_1-src.tgz cd icu/source - cp -f $BUILDDIR/config.sub . - cp -f $BUILDDIR/config.guess . + #cp -f $BUILDDIR/config.sub . + #cp -f $BUILDDIR/config.guess . [ -d cross ] || { mkdir cross diff --git a/setCrossEnvironment-armeabi-v7a.sh b/setCrossEnvironment-armeabi-v7a.sh index a2a0598..438ad5a 100755 --- a/setCrossEnvironment-armeabi-v7a.sh +++ b/setCrossEnvironment-armeabi-v7a.sh @@ -1,5 +1,7 @@ #!/bin/sh +NDK_STL="libc++" + IFS=' ' @@ -21,7 +23,8 @@ NDK=`readlink -f $NDK` #echo NDK $NDK GCCPREFIX=arm-linux-androideabi [ -z "$NDK_TOOLCHAIN_VERSION" ] && NDK_TOOLCHAIN_VERSION=4.9 -[ -z "$PLATFORMVER" ] && PLATFORMVER=android-15 +[ -z "$PLATFORMVER" ] && PLATFORMVER=android-16 +GCCVER=4.8 LOCAL_PATH=`dirname $0` if which realpath > /dev/null ; then LOCAL_PATH=`realpath $LOCAL_PATH` @@ -29,7 +32,13 @@ else LOCAL_PATH=`cd $LOCAL_PATH && pwd` fi ARCH=armeabi-v7a - +STL_CFLAGS="-isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/include \ +-isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/libs/$ARCH/include" +STL_LDFLAGS="-L$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/libs/$ARCH" +if [[ "$NDK_STL" -eq "libc++" ]] ; then + STL_CFLAGS="-isystem$NDK/sources/cxx-stl/llvm-libc++/include" + STL_LDFLAGS="-L$NDK/sources/cxx-stl/llvm-libc++/libs/$ARCH" +fi CFLAGS=" -fexceptions From 842cf5076b2ddc3b95eecbcc6fa50bce9c755431 Mon Sep 17 00:00:00 2001 From: Zhuowei Zhang Date: Thu, 17 Dec 2015 20:55:08 -0500 Subject: [PATCH 02/14] icu: include all data files in libicudata.so --- build.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/build.sh b/build.sh index f2c66d4..fb59fed 100755 --- a/build.sh +++ b/build.sh @@ -193,7 +193,6 @@ cd $BUILDDIR/$ARCH --prefix=`pwd`/../../ \ --with-cross-build=`pwd`/cross \ --enable-static --disable-shared \ - --with-data-packaging=archive \ || exit 1 # ICULEHB_CFLAGS="-I$BUILDDIR/$ARCH/include" \ From 77064c9ee74331d03387babcf31c9ceafcf9f9dd Mon Sep 17 00:00:00 2001 From: Zhuowei Zhang Date: Wed, 6 Jan 2016 00:25:18 -0500 Subject: [PATCH 03/14] Actually use libc++_shared as STL --- setCrossEnvironment-armeabi-v7a.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/setCrossEnvironment-armeabi-v7a.sh b/setCrossEnvironment-armeabi-v7a.sh index 438ad5a..7815cdc 100755 --- a/setCrossEnvironment-armeabi-v7a.sh +++ b/setCrossEnvironment-armeabi-v7a.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash NDK_STL="libc++" @@ -35,9 +35,11 @@ ARCH=armeabi-v7a STL_CFLAGS="-isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/include \ -isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/libs/$ARCH/include" STL_LDFLAGS="-L$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/libs/$ARCH" -if [[ "$NDK_STL" -eq "libc++" ]] ; then - STL_CFLAGS="-isystem$NDK/sources/cxx-stl/llvm-libc++/include" +STL_LDLIB="-lgnustl_shared -lsupc++" +if [[ "$NDK_STL" == "libc++" ]] ; then + STL_CFLAGS="-isystem$NDK/sources/cxx-stl/llvm-libc++/libcxx/include" STL_LDFLAGS="-L$NDK/sources/cxx-stl/llvm-libc++/libs/$ARCH" + STL_LDLIB="-lc++_shared" fi CFLAGS=" From d749f6ce59d2bc250ac4638c41bb9b9623ef36f2 Mon Sep 17 00:00:00 2001 From: Tim Lundeen Date: Sun, 20 Mar 2016 14:39:48 -0700 Subject: [PATCH 04/14] Fix build to work on MacOS Changed default NDK version from 4.8 to 4.9 --- build.sh | 10 +++++----- setCrossEnvironment-armeabi-v7a.sh | 7 +++++-- setCrossEnvironment-armeabi.sh | 6 +++++- setCrossEnvironment-x86.sh | 6 +++++- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/build.sh b/build.sh index fb59fed..65e38b0 100755 --- a/build.sh +++ b/build.sh @@ -9,7 +9,7 @@ uname -s | grep -i "linux" && NCPU=`cat /proc/cpuinfo | grep -c -i processor` NDK=`which ndk-build` NDK=`dirname $NDK` -NDK=`readlink -f $NDK` +#NDK=`readlink -f $NDK` export CLANG=1 @@ -180,8 +180,8 @@ cd $BUILDDIR/$ARCH cd .. } || exit 1 - sed -i "s@LD_SONAME *=.*@LD_SONAME =@g" config/mh-linux - sed -i "s%ln -s *%cp -f \$(dir \$@)/%g" config/mh-linux + sed -i.tmp "s@LD_SONAME *=.*@LD_SONAME =@g" config/mh-linux + sed -i.tmp "s%ln -s *%cp -f \$(dir \$@)/%g" config/mh-linux env CFLAGS="-I$NDK/sources/android/support/include -frtti -fexceptions" \ LDFLAGS="-frtti -fexceptions -L$BUILDDIR/$ARCH/lib" \ @@ -199,13 +199,13 @@ cd $BUILDDIR/$ARCH # ICULEHB_LIBS="-licu-le-hb" \ # --enable-layoutex \ - sed -i "s@^prefix *= *.*@prefix = .@" icudefs.mk || exit 1 + sed -i.tmp "s@^prefix *= *.*@prefix = .@" icudefs.mk || exit 1 env PATH=`pwd`:$PATH \ $BUILDDIR/setCrossEnvironment-$ARCH.sh \ make -j$NCPU VERBOSE=1 || exit 1 - sed -i "s@^prefix *= *.*@prefix = `pwd`/../../@" icudefs.mk || exit 1 + sed -i.tmp "s@^prefix *= *.*@prefix = `pwd`/../../@" icudefs.mk || exit 1 env PATH=`pwd`:$PATH \ $BUILDDIR/setCrossEnvironment-$ARCH.sh \ diff --git a/setCrossEnvironment-armeabi-v7a.sh b/setCrossEnvironment-armeabi-v7a.sh index 7815cdc..fd028df 100755 --- a/setCrossEnvironment-armeabi-v7a.sh +++ b/setCrossEnvironment-armeabi-v7a.sh @@ -18,13 +18,16 @@ fi NDK=`which ndk-build` NDK=`dirname $NDK` -NDK=`readlink -f $NDK` +#NDK=`readlink -f $NDK` + +grep "64.bit" "$NDK/RELEASE.TXT" >/dev/null 2>&1 && MYARCH="${MYARCH}_64" #echo NDK $NDK GCCPREFIX=arm-linux-androideabi [ -z "$NDK_TOOLCHAIN_VERSION" ] && NDK_TOOLCHAIN_VERSION=4.9 [ -z "$PLATFORMVER" ] && PLATFORMVER=android-16 -GCCVER=4.8 +GCCVER=4.9 + LOCAL_PATH=`dirname $0` if which realpath > /dev/null ; then LOCAL_PATH=`realpath $LOCAL_PATH` diff --git a/setCrossEnvironment-armeabi.sh b/setCrossEnvironment-armeabi.sh index d2752a0..2088cdc 100755 --- a/setCrossEnvironment-armeabi.sh +++ b/setCrossEnvironment-armeabi.sh @@ -16,12 +16,16 @@ fi NDK=`which ndk-build` NDK=`dirname $NDK` -NDK=`readlink -f $NDK` +#NDK=`readlink -f $NDK` + +grep "64.bit" "$NDK/RELEASE.TXT" >/dev/null 2>&1 && MYARCH="${MYARCH}_64" #echo NDK $NDK GCCPREFIX=arm-linux-androideabi [ -z "$NDK_TOOLCHAIN_VERSION" ] && NDK_TOOLCHAIN_VERSION=4.9 [ -z "$PLATFORMVER" ] && PLATFORMVER=android-15 +GCCVER=4.9 + LOCAL_PATH=`dirname $0` if which realpath > /dev/null ; then LOCAL_PATH=`realpath $LOCAL_PATH` diff --git a/setCrossEnvironment-x86.sh b/setCrossEnvironment-x86.sh index e14d083..7d2523a 100755 --- a/setCrossEnvironment-x86.sh +++ b/setCrossEnvironment-x86.sh @@ -16,12 +16,16 @@ fi NDK=`which ndk-build` NDK=`dirname $NDK` -NDK=`readlink -f $NDK` +#NDK=`readlink -f $NDK` + +grep "64.bit" "$NDK/RELEASE.TXT" >/dev/null 2>&1 && MYARCH="${MYARCH}_64" #echo NDK $NDK GCCPREFIX=i686-linux-android [ -z "$NDK_TOOLCHAIN_VERSION" ] && NDK_TOOLCHAIN_VERSION=4.9 [ -z "$PLATFORMVER" ] && PLATFORMVER=android-15 +GCCVER=4.9 + LOCAL_PATH=`dirname $0` if which realpath > /dev/null ; then LOCAL_PATH=`realpath $LOCAL_PATH` From 5fa990baaecbf501cfd68bc51e5f13f7e4614b2f Mon Sep 17 00:00:00 2001 From: Tim Lundeen Date: Sun, 20 Mar 2016 14:47:25 -0700 Subject: [PATCH 05/14] Update README.md to include setting up the build.sh environment --- README.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ab22a53..3bfe397 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,16 @@ Port of libiconv and libicu to Android You will need NDK r15, curl, autoconf, automake, libtool, and git installed. -There are no sources and no patches - everything is done with magical build scripts, -just run build.sh and enjoy. -Don't forget to strip them, because they are huge with debug info included. +There are no sources and no patches - everything is done with magical build scripts: + +(1) Make sure "which ndk-build" shows the correct version to build from + +(2) The scripts assume NDK/toolchain/... version 4.9. If otherwise, edit all the *.sh to + change GCCVER=4.9 as desired. + +(3) Run "./build.sh" and enjoy! + +(4) Don't forget to strip them, because they are huge with debug info included. There is no mips architecture, because there are very few devices using this architecture in the wild. From 7f6bfe59e62ddbf02b27196f5ba5ec67a896ff3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20B=C3=BCgling?= Date: Wed, 20 Apr 2016 15:05:04 +0200 Subject: [PATCH 06/14] Fix for Android NDK r11c Seems like `RELEASE.TXT` is gone, so `arch` is now used to determine if we're running on 64bit or not. I'm unsure how to properly check for this on Windows, though. --- setCrossEnvironment-armeabi-v7a.sh | 2 +- setCrossEnvironment-armeabi.sh | 5 +---- setCrossEnvironment-x86.sh | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/setCrossEnvironment-armeabi-v7a.sh b/setCrossEnvironment-armeabi-v7a.sh index fd028df..3e6ca51 100755 --- a/setCrossEnvironment-armeabi-v7a.sh +++ b/setCrossEnvironment-armeabi-v7a.sh @@ -7,7 +7,7 @@ IFS=' MYARCH=linux-x86_64 if uname -s | grep -i "linux" > /dev/null ; then - MYARCH=linux-x86_64 + MYARCH=linux-`arch` fi if uname -s | grep -i "darwin" > /dev/null ; then MYARCH=darwin-x86_64 diff --git a/setCrossEnvironment-armeabi.sh b/setCrossEnvironment-armeabi.sh index 2088cdc..96ab545 100755 --- a/setCrossEnvironment-armeabi.sh +++ b/setCrossEnvironment-armeabi.sh @@ -5,7 +5,7 @@ IFS=' MYARCH=linux-x86_64 if uname -s | grep -i "linux" > /dev/null ; then - MYARCH=linux-x86_64 + MYARCH=linux-`arch` fi if uname -s | grep -i "darwin" > /dev/null ; then MYARCH=darwin-x86_64 @@ -18,9 +18,6 @@ NDK=`which ndk-build` NDK=`dirname $NDK` #NDK=`readlink -f $NDK` -grep "64.bit" "$NDK/RELEASE.TXT" >/dev/null 2>&1 && MYARCH="${MYARCH}_64" - -#echo NDK $NDK GCCPREFIX=arm-linux-androideabi [ -z "$NDK_TOOLCHAIN_VERSION" ] && NDK_TOOLCHAIN_VERSION=4.9 [ -z "$PLATFORMVER" ] && PLATFORMVER=android-15 diff --git a/setCrossEnvironment-x86.sh b/setCrossEnvironment-x86.sh index 7d2523a..ff1261e 100755 --- a/setCrossEnvironment-x86.sh +++ b/setCrossEnvironment-x86.sh @@ -5,7 +5,7 @@ IFS=' MYARCH=linux-x86_64 if uname -s | grep -i "linux" > /dev/null ; then - MYARCH=linux-x86_64 + MYARCH=linux-`arch` fi if uname -s | grep -i "darwin" > /dev/null ; then MYARCH=darwin-x86_64 From e3acfc65874c0b5d0f3c8b8a51dff1a19a0e78e9 Mon Sep 17 00:00:00 2001 From: Brian Gesiak Date: Mon, 24 Oct 2016 13:06:52 -0700 Subject: [PATCH 07/14] Update for Android NDK r13 Android NDK r13 appears to have removed a level of nesting within LLVM libc++. The "libcxx" subdirectory no longer exists. --- setCrossEnvironment-armeabi-v7a.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setCrossEnvironment-armeabi-v7a.sh b/setCrossEnvironment-armeabi-v7a.sh index 3e6ca51..bf79811 100755 --- a/setCrossEnvironment-armeabi-v7a.sh +++ b/setCrossEnvironment-armeabi-v7a.sh @@ -40,7 +40,7 @@ STL_CFLAGS="-isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/include \ STL_LDFLAGS="-L$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/libs/$ARCH" STL_LDLIB="-lgnustl_shared -lsupc++" if [[ "$NDK_STL" == "libc++" ]] ; then - STL_CFLAGS="-isystem$NDK/sources/cxx-stl/llvm-libc++/libcxx/include" + STL_CFLAGS="-isystem$NDK/sources/cxx-stl/llvm-libc++/include" STL_LDFLAGS="-L$NDK/sources/cxx-stl/llvm-libc++/libs/$ARCH" STL_LDLIB="-lc++_shared" fi From 9626a9f5e37a5d03716803ef02ce84961535b1f6 Mon Sep 17 00:00:00 2001 From: Andrew Druk Date: Fri, 31 Mar 2017 14:45:32 +0300 Subject: [PATCH 08/14] switch on sonames --- build.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/build.sh b/build.sh index 65e38b0..18be6bb 100755 --- a/build.sh +++ b/build.sh @@ -180,8 +180,6 @@ cd $BUILDDIR/$ARCH cd .. } || exit 1 - sed -i.tmp "s@LD_SONAME *=.*@LD_SONAME =@g" config/mh-linux - sed -i.tmp "s%ln -s *%cp -f \$(dir \$@)/%g" config/mh-linux env CFLAGS="-I$NDK/sources/android/support/include -frtti -fexceptions" \ LDFLAGS="-frtti -fexceptions -L$BUILDDIR/$ARCH/lib" \ @@ -199,14 +197,10 @@ cd $BUILDDIR/$ARCH # ICULEHB_LIBS="-licu-le-hb" \ # --enable-layoutex \ - sed -i.tmp "s@^prefix *= *.*@prefix = .@" icudefs.mk || exit 1 - env PATH=`pwd`:$PATH \ $BUILDDIR/setCrossEnvironment-$ARCH.sh \ make -j$NCPU VERBOSE=1 || exit 1 - sed -i.tmp "s@^prefix *= *.*@prefix = `pwd`/../../@" icudefs.mk || exit 1 - env PATH=`pwd`:$PATH \ $BUILDDIR/setCrossEnvironment-$ARCH.sh \ make V=1 install || exit 1 From 98b79f65ed5a8bc775113788952afd557be04889 Mon Sep 17 00:00:00 2001 From: Andrew Druk Date: Tue, 4 Apr 2017 14:01:09 +0300 Subject: [PATCH 09/14] remove version from sonames --- build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.sh b/build.sh index 18be6bb..f389e5c 100755 --- a/build.sh +++ b/build.sh @@ -197,6 +197,9 @@ cd $BUILDDIR/$ARCH # ICULEHB_LIBS="-licu-le-hb" \ # --enable-layoutex \ + sed -i.tmp 's/.$(SO_TARGET_VERSION_MAJOR)//' icudefs.mk + sed -i.tmp 's/$(PKGDATA_VERSIONING) -e/-e/' data/Makefile + env PATH=`pwd`:$PATH \ $BUILDDIR/setCrossEnvironment-$ARCH.sh \ make -j$NCPU VERBOSE=1 || exit 1 From 70dd6a8df151085f1f716ba81e5c03d68d5071b0 Mon Sep 17 00:00:00 2001 From: Gonzalo Larralde Date: Wed, 14 Feb 2018 12:05:07 -0300 Subject: [PATCH 10/14] Add an ENVVAR to append a suffix to the lib names. Swift is expecting this libraries to be named `icuucswift` for Android to avoid name collision with Android's `icuuc`. This should be temporal, a more appropriate solution (if any) should be applied to solve this lib conflict. --- build.sh | 11 +++++++++-- patches/icu_suffix_only_on_libname.patch | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 patches/icu_suffix_only_on_libname.patch diff --git a/build.sh b/build.sh index f389e5c..aa8989b 100755 --- a/build.sh +++ b/build.sh @@ -159,7 +159,7 @@ cd $BUILDDIR/$ARCH cd $BUILDDIR/$ARCH -[ -e libicuuc.a ] || { +[ -e libicuuc$LIBSUFFIX.a ] || { rm -rf icu @@ -167,6 +167,12 @@ cd $BUILDDIR/$ARCH tar xvf ../icu4c-55_1-src.tgz + # The ENVVAR LIBSUFFIX should add the suffix only to the libname and not to the symbols. + # ToDo: Find the right way in Swift to refer to an alternative library with symbol prefixing or any other method to remove this. + if $[ -n "$LIBSUFFIX" ]; then + patch -p0 < ../patches/icu_suffix_only_on_libname.patch + fi + cd icu/source #cp -f $BUILDDIR/config.sub . @@ -189,6 +195,7 @@ cd $BUILDDIR/$ARCH ./configure \ --host=$GCCPREFIX \ --prefix=`pwd`/../../ \ + --with-library-suffix=$LIBSUFFIX \ --with-cross-build=`pwd`/cross \ --enable-static --disable-shared \ || exit 1 @@ -208,7 +215,7 @@ cd $BUILDDIR/$ARCH $BUILDDIR/setCrossEnvironment-$ARCH.sh \ make V=1 install || exit 1 - for f in libicudata libicutest libicui18n libicuio libicutu libicuuc; do + for f in libicudata$LIBSUFFIX libicutest$LIBSUFFIX libicui18n$LIBSUFFIX libicuio$LIBSUFFIX libicule$LIBSUFFIX libiculx$LIBSUFFIX libicutu$LIBSUFFIX libicuuc$LIBSUFFIX; do #cp -f -H ../../lib/$f.so ../../ cp -f ../../lib/$f.a ../../ #$BUILDDIR/setCrossEnvironment-$ARCH.sh \ diff --git a/patches/icu_suffix_only_on_libname.patch b/patches/icu_suffix_only_on_libname.patch new file mode 100644 index 0000000..e773089 --- /dev/null +++ b/patches/icu_suffix_only_on_libname.patch @@ -0,0 +1,18 @@ +--- icu/source/configure 2013-05-23 20:06:32.000000000 +0000 ++++ icu/source/configure.patched 2018-02-21 23:35:25.934967613 +0000 +@@ -7217,14 +7217,7 @@ + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $msg" >&5 + $as_echo "$msg" >&6; } + +-if test "$ICULIBSUFFIX" != "" +-then +- U_HAVE_LIB_SUFFIX=1 +- ICULIBSUFFIXCNAME=`echo _$ICULIBSUFFIX | sed 's/^A-Za-z0-9_/_/g'` +- UCONFIG_CPPFLAGS="${UCONFIG_CPPFLAGS} -DU_HAVE_LIB_SUFFIX=1 -DU_LIB_SUFFIX_C_NAME=${ICULIBSUFFIXCNAME} " +-else +- U_HAVE_LIB_SUFFIX=0 +-fi ++U_HAVE_LIB_SUFFIX=0 + + + From 2e275797810e96b7ccb2f7b02e2f450dc4417922 Mon Sep 17 00:00:00 2001 From: Andrew Breckenridge Date: Thu, 18 Jan 2018 07:44:07 -0800 Subject: [PATCH 11/14] [build-android] Create template for build-android --- build-android.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 build-android.sh diff --git a/build-android.sh b/build-android.sh new file mode 100644 index 0000000..ef8a790 --- /dev/null +++ b/build-android.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# +# *** build-android.sh *** +# +# This script automates editing the libiconv and libicu source code and build +# directives to build the libraries correctly to use when building swift for +# Android. Original instructions that this script automates are available at +# https://github.com/apple/swift/blob/4bf6f5475ddf5c9ff4a7e383bac41c8a0464cd90/docs/Android.md#adding-swift-suffix-to-icu-libraries +# + +set -e + +echo "warning: this script assumes it's running from the root of the libiconv-libicu-android directory" + +# Create armeabi-v7a dir +mkdir armeabi-v7a && cd armeabi-v7a +tar xvf ../icu4c-55_1-src.tgz + +# Edit icu configure file + +# Edit build.sh file + +# 🎉 Run build.sh, with the edited sources +./build.sh + +echo "Done building 🎉🎉🎉" +echo "Check out the armeabi-v7a directory." From 42398b0e6190bbbcf5fc9e34e74ce59141140f7d Mon Sep 17 00:00:00 2001 From: Andrew Breckenridge Date: Fri, 19 Jan 2018 10:03:26 -0800 Subject: [PATCH 12/14] Create `.patch`es with source edits for swift android These patches _should_ be able to be applied using `patch`, they automate the changeset currently described at apple/swift/docs/Android.md --- swift-android-source-patches/build.patch | 34 +++++++++++++++++++ .../icu-configure.patch | 22 ++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 swift-android-source-patches/build.patch create mode 100644 swift-android-source-patches/icu-configure.patch diff --git a/swift-android-source-patches/build.patch b/swift-android-source-patches/build.patch new file mode 100644 index 0000000..9124450 --- /dev/null +++ b/swift-android-source-patches/build.patch @@ -0,0 +1,34 @@ +--- build.sh 2018-01-19 09:56:47.000000000 -0800 ++++ build.sh.new 2018-01-19 09:56:38.000000000 -0800 +@@ -77,11 +77,11 @@ + + # =========== libicuXX.so =========== + +-[ -e libicuuc.so ] || { ++[ -e libicuucswifswiftt.so ] || { + +- [ -e ../icu4c-55_1-src.tgz ] || exit 1 ++# [ -e ../icu4c-55_1-src.tgz ] || exit 1 + +- tar xvf ../icu4c-55_1-src.tgz ++# tar xvf ../icu4c-55_1-src.tgz + + cd icu/source + +@@ -104,6 +104,7 @@ + ./configure \ + --host=arm-linux-androideabi \ + --prefix=`pwd`/../../ \ ++ --with-library-suffix=swift \ + --with-cross-build=`pwd`/cross \ + --enable-static --enable-shared \ + || exit 1 +@@ -119,7 +120,7 @@ + $BUILDDIR/setCrossEnvironment-$ARCH.sh \ + make V=1 install || exit 1 + +- for f in libicudata libicutest libicui18n libicuio libicule libiculx libicutu libicuuc; do ++ for f in libicudataswift libicutestswift libicui18nswift libicuioswift libiculeswift libiculxswift libicutuswift libicuucswift; do + cp -f -H ../../lib/$f.so ../../ + cp -f ../../lib/$f.a ../../ + $BUILDDIR/setCrossEnvironment-$ARCH.sh \ diff --git a/swift-android-source-patches/icu-configure.patch b/swift-android-source-patches/icu-configure.patch new file mode 100644 index 0000000..79c201c --- /dev/null +++ b/swift-android-source-patches/icu-configure.patch @@ -0,0 +1,22 @@ +--- armeabi-v7a/icu/source/configure 2018-01-18 17:31:55.000000000 -0800 ++++ armeabi-v7a/icu/source/configure.new 2018-01-18 17:33:27.000000000 -0800 +@@ -7599,14 +7599,14 @@ + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $msg" >&5 + $as_echo "$msg" >&6; } + +-if test "$ICULIBSUFFIX" != "" +-then +- U_HAVE_LIB_SUFFIX=1 +- ICULIBSUFFIXCNAME=`echo _$ICULIBSUFFIX | sed 's/^A-Za-z0-9_/_/g'` +- UCONFIG_CPPFLAGS="${UCONFIG_CPPFLAGS} -DU_HAVE_LIB_SUFFIX=1 -DU_LIB_SUFFIX_C_NAME=${ICULIBSUFFIXCNAME} " +-else +- U_HAVE_LIB_SUFFIX=0 +-fi ++# if test "$ICULIBSUFFIX" != "" ++# then ++# U_HAVE_LIB_SUFFIX=1 ++# ICULIBSUFFIXCNAME=`echo _$ICULIBSUFFIX | sed 's/^A-Za-z0-9_/_/g'` ++# UCONFIG_CPPFLAGS="${UCONFIG_CPPFLAGS} -DU_HAVE_LIB_SUFFIX=1 -DU_LIB_SUFFIX_C_NAME=${ICULIBSUFFIXCNAME} " ++# else ++U_HAVE_LIB_SUFFIX=0 ++# fi From 39b2731acdeafe7f2344772030cc5aa3f85a39ee Mon Sep 17 00:00:00 2001 From: Andrew Breckenridge Date: Fri, 19 Jan 2018 10:29:00 -0800 Subject: [PATCH 13/14] [build-android] Implement swift-android source patching --- build-android.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) mode change 100644 => 100755 build-android.sh diff --git a/build-android.sh b/build-android.sh old mode 100644 new mode 100755 index ef8a790..cee908f --- a/build-android.sh +++ b/build-android.sh @@ -16,10 +16,15 @@ echo "warning: this script assumes it's running from the root of the libiconv-li # Create armeabi-v7a dir mkdir armeabi-v7a && cd armeabi-v7a tar xvf ../icu4c-55_1-src.tgz +cd .. -# Edit icu configure file +# Patch icu configure file +patch -i swift-android-source-patches/build.patch -# Edit build.sh file +# Patch build.sh file +cd armeabi-v7a/icu/source/ +patch -i ../../../swift-android-source-patches/icu-configure.patch +cd ../../.. # 🎉 Run build.sh, with the edited sources ./build.sh From 3e45a0007be26f2ad4167a44751848c2aa33c327 Mon Sep 17 00:00:00 2001 From: Andrew Breckenridge Date: Fri, 19 Jan 2018 10:31:06 -0800 Subject: [PATCH 14/14] [README] add build-android instructions --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 3bfe397..c7639f7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,13 @@ libiconv-libicu-android ======================= +## Swift android instructions + +Follow the original instructions, but instead of step (3), run ./build-android.sh instead + + +## Original instructions + Port of libiconv and libicu to Android You will need NDK r15, curl, autoconf, automake, libtool, and git installed.