Add script to build dependencies for android

This commit is contained in:
loonycyborg 2023-05-28 13:25:43 +03:00
parent accf0fba57
commit 1cddf6b30c
No known key found for this signature in database
GPG key ID: 6E8233FAB8F26D61
23 changed files with 474 additions and 0 deletions

View file

@ -0,0 +1,5 @@
Intended usage:
* modify setup-toolchains.py with correct path to your ndk and the desired api level
* run ./build-android-deps.sh
Builds will be done in /tmp/android-build. Resulting builds will be in /tmp/android-prefix. They can be passed to wesnoth's scons script with prefix option, e.g. prefix=/tmp/android-prefix/armeabi-v7a

View file

@ -0,0 +1,13 @@
diff --git a/Makefile.in b/Makefile.in
index d4eeee402..6cfd9b13c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -136,7 +136,7 @@ LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@
LT_RELEASE = @LT_RELEASE@
LT_REVISION = @LT_REVISION@
-LT_LDFLAGS = -no-undefined -rpath $(libdir) -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
+LT_LDFLAGS = -no-undefined -rpath $(libdir) -release $(LT_RELEASE) -avoid-version
all: $(srcdir)/configure Makefile $(objects)/$(TARGET) $(objects)/$(SDLMAIN_TARGET) $(objects)/$(SDLTEST_TARGET)

View file

@ -0,0 +1 @@
--disable-hidapi --disable-audio

View file

@ -0,0 +1,13 @@
diff --git a/Makefile.am b/Makefile.am
index 0669f2b..d8bb07c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -66,7 +66,7 @@ EXTRA_DIST = \
libSDL2_image_la_LDFLAGS = \
-no-undefined \
-release $(LT_RELEASE) \
- -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) $(LT_EXTRA)
+ -avoid-version
libSDL2_image_la_LIBADD = $(IMG_LIBS)
if USE_VERSION_RC
libSDL2_image_la_DEPENDENCIES = version.o

View file

@ -0,0 +1 @@
CFLAGS=-DSDL_MAIN_HANDLED

View file

@ -0,0 +1,13 @@
diff --git a/Makefile.in b/Makefile.in
index 006a8fb9..64c6b72a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -78,7 +78,7 @@ LT_CURRENT = @LT_CURRENT@
LT_RELEASE = @LT_RELEASE@
LT_REVISION = @LT_REVISION@
LT_EXTRA = @LT_EXTRA@
-LT_LDFLAGS = -no-undefined -rpath $(libdir) -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) $(LT_EXTRA)
+LT_LDFLAGS = -no-undefined -rpath $(libdir) -release $(LT_RELEASE) -avoid-version
all: $(srcdir)/configure Makefile $(objects)/$(TARGET) $(objects)/playwave$(EXE) $(objects)/playmus$(EXE)

View file

@ -0,0 +1 @@
CFLAGS=-DSDL_MAIN_HANDLED

View file

@ -0,0 +1 @@
--layout=versioned --with-regex --with-iostreams --with-system --with-filesystem --with-random --with-program_options --with-context --with-coroutine --with-thread --with-locale

View file

@ -0,0 +1,25 @@
From 5dddf9d8c961240837e7910af185adc9b3f0bfad Mon Sep 17 00:00:00 2001
From: huangqinjin <huangqinjin@gmail.com>
Date: Fri, 12 Oct 2018 10:27:07 +0800
Subject: [PATCH] do not add version suffix for android
---
boostcpp.jam | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/boostcpp.jam b/boostcpp.jam
index dea1a43ea06..c74082ecd1a 100644
--- a/boostcpp.jam
+++ b/boostcpp.jam
@@ -197,8 +197,10 @@ rule tag ( name : type ? : property-set )
# version suffix is not needed -- the linker expects the
# libFoo.1.2.3.dylib format. AIX linkers do not accept version suffixes
# either. Pgi compilers can not accept a library with version suffix.
+ # For android, if we link to libFoo.so, which is a soft link to libFoo.so.1.2.3,
+ # the android studio will only pack the former into the final apk.
if $(type) = SHARED_LIB &&
- ! [ $(property-set).get <target-os> ] in windows cygwin darwin aix &&
+ ! [ $(property-set).get <target-os> ] in windows cygwin darwin aix android &&
! [ $(property-set).get <toolset> ] in pgi
{
result = $(result).$(BOOST_VERSION) ;

View file

@ -0,0 +1,169 @@
#!/bin/bash -xe
SOURCES=(
https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz
https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.17.tar.gz
https://ftp.gnu.org/pub/gnu/gettext/gettext-0.21.1.tar.gz
https://sourceforge.net/projects/libpng/files/libpng16/1.6.39/libpng-1.6.39.tar.xz
https://sourceforge.net/projects/freetype/files/freetype2/2.13.0/freetype-2.13.0.tar.xz
https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.42/pcre2-10.42.tar.bz2
https://github.com/libffi/libffi/releases/download/v3.4.4/libffi-3.4.4.tar.gz
https://download.gnome.org/sources/glib/2.76/glib-2.76.1.tar.xz
https://www.cairographics.org/releases/pixman-0.42.2.tar.gz
https://github.com/libexpat/libexpat/releases/download/R_2_5_0/expat-2.5.0.tar.xz
https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.14.2.tar.xz
https://www.cairographics.org/releases/cairo-1.16.0.tar.xz
https://github.com/harfbuzz/harfbuzz/releases/download/7.1.0/harfbuzz-7.1.0.tar.xz
https://download.gnome.org/sources/pango/1.50/pango-1.50.14.tar.xz
https://github.com/libsdl-org/SDL/releases/download/release-2.26.4/SDL2-2.26.4.tar.gz
https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.6.3.tar.gz
https://downloads.xiph.org/releases/ogg/libogg-1.3.5.tar.xz
https://ftp.osuosl.org/pub/xiph/releases/vorbis/libvorbis-1.3.7.tar.xz
https://github.com/libsdl-org/SDL_mixer/releases/download/release-2.6.3/SDL2_mixer-2.6.3.tar.gz
https://boostorg.jfrog.io/artifactory/main/release/1.81.0/source/boost_1_81_0.tar.bz2
https://www.openssl.org/source/openssl-3.1.0.tar.gz
https://curl.se/download/curl-8.1.1.tar.xz
)
PACKAGES=()
./setup-toolchains.py
ORIGIN=`pwd`
mkdir -p /tmp/android-build/src
pushd /tmp/android-build/src
for url in ${SOURCES[@]}
do
wget -nc $url
archive=`basename $url`
package=${archive%.*.*}
if [ ! -d $package ]
then
tar -xf $archive
if [ -f $ORIGIN/${package%-*}.patch ]
then
patch=$ORIGIN/${package%-*}.patch
patch -d $package -p1 -i $patch
fi
if [ -f $ORIGIN/${package%-*}.autotools.patch ]
then
patch=$ORIGIN/${package%-*}.autotools.patch
pushd $package
patch -p1 -i $patch
if [[ $package == *"SDL2"* ]]
then
./autogen.sh
if [ -f android-project/app/jni/Android.mk ]
then
mkdir -p ../SDL2-ndk-build/jni
cp android-project/app/jni/Android.mk ../SDL2-ndk-build/jni/
cp android-project/app/jni/Application.mk ../SDL2-ndk-build/jni/
fi
ln -sf ../../$package ../SDL2-ndk-build/jni/${package%-*}
else
autoreconf
fi
popd
fi
fi
PACKAGES+=($package)
done
popd
for prefix in /tmp/android-prefix/*
do
abi=`basename $prefix`
rm -rf /tmp/android-build/$abi
. /tmp/android-prefix/$abi/android.env
export PKG_CONFIG_PATH=/tmp/android-prefix/$abi/lib/pkgconfig
for package in ${PACKAGES[@]}
do
if [ -f ${package%-*}.config ]
then
extra_flags=`cat ${package%-*}.config`
else
extra_flags=
fi
if [[ $package == boost* ]]
then
if [ -f ${package%%_*}.config ]
then
extra_flags=`cat ${package%%_*}.config`
fi
fi
host_arg="--host=$HOST"
src_dir=/tmp/android-build/src/$package
build_dir=/tmp/android-build/$abi/$package
mkdir -p $build_dir
if [ -f $src_dir/configure ]
then
pushd $build_dir
$src_dir/configure $host_arg --prefix=/tmp/android-prefix/$abi $extra_flags
make -j`nproc`
make install
popd
continue
fi
if [ -f $src_dir/Configure ] #openssl's Perl configure
then
pushd $src_dir
if [ -f Makefile ]
then
make clean
fi
./Configure --prefix=/tmp/android-prefix/$abi $extra_flags android-$ANDROID_ARCH -D__ANDROID_API__=$API
make -j`nproc`
make install
popd
continue
fi
if [ -f $src_dir/meson.build ]
then
meson setup --cross-file /tmp/android-prefix/$abi/android.ini $build_dir $src_dir -Dprefix=/tmp/android-prefix/$abi $extra_flags
ninja -C $build_dir
ninja -C $build_dir install
continue
fi
if [ -f $src_dir/Jamroot ]
then
pushd $src_dir
rm -rf ./bin.v2
if [ ! -f ./b2 ]
then
./bootstrap.sh
fi
if [[ $ANDROID_ARCH == *"arm"* ]]
then
BCABI="aapcs"
BOOSTARCH="arm"
else
BCABI="sysv"
BOOSTARCH="x86"
fi
./b2 --user-config=/tmp/android-prefix/$abi/android.jam --prefix=/tmp/android-prefix/$abi target-os=android architecture=$BOOSTARCH address-model=$BITNESS abi=$BCABI binary-format=elf install $extra_flags
popd
continue
fi
if [ -f $src_dir/Makefile ] # bzip uses plain Make
then
pushd $src_dir
make clean
make install CC="$CC -fPIC" AR="$AR" RANLIB="$RANLIB" PREFIX=/tmp/android-prefix/$abi
popd
continue
fi
done
done
cd /tmp/android-build/src/SDL2-ndk-build
$NDK/ndk-build
for lib in libs/*/*.so
do
instdir=$(basename $(dirname $lib))
cp $lib /tmp/android-prefix/$instdir/lib/
done

View file

@ -0,0 +1 @@
--disable-xlib --disable-xlib-xrender --disable-pdf --disable-full-testing --disable-ps --disable-svg

View file

@ -0,0 +1 @@
--with-openssl

View file

@ -0,0 +1 @@
--without-docbook

View file

@ -0,0 +1,40 @@
diff -rupN --no-dereference fontconfig-2.14.2/configure.ac fontconfig-2.14.2-new/configure.ac
--- fontconfig-2.14.2/configure.ac 2023-01-27 06:46:22.000000000 +0100
+++ fontconfig-2.14.2-new/configure.ac 2023-01-28 23:01:06.642068717 +0100
@@ -749,6 +749,21 @@ fi
AM_CONDITIONAL(HAVE_PTHREAD, $have_pthread)
+#
+# Allow not building tests
+#
+
+default_tests="yes"
+
+AC_ARG_ENABLE(tests,
+ [AC_HELP_STRING([--disable-tests],
+ [Don't build tests])],
+ ,
+ enable_tests=$default_tests)
+
+AM_CONDITIONAL(ENABLE_TESTS, test "x$enable_tests" = xyes)
+
+
dnl ===========================================================================
#
diff -rupN --no-dereference fontconfig-2.14.2/Makefile.am fontconfig-2.14.2-new/Makefile.am
--- fontconfig-2.14.2/Makefile.am 2021-10-20 12:03:19.000000000 +0200
+++ fontconfig-2.14.2-new/Makefile.am 2023-01-28 23:01:06.642068717 +0100
@@ -24,7 +24,10 @@
SUBDIRS=fontconfig fc-case fc-lang src \
fc-cache fc-cat fc-conflist fc-list fc-match \
fc-pattern fc-query fc-scan fc-validate conf.d \
- its po po-conf test
+ its po po-conf
+if ENABLE_TESTS
+SUBDIRS += test
+endif
if ENABLE_DOCS
SUBDIRS += doc
endif

View file

@ -0,0 +1 @@
--disable-docs --disable-tests

View file

@ -0,0 +1 @@
--with-brotli=no --with-png=no --with-harfbuzz=no

View file

@ -0,0 +1,35 @@
diff --git a/Makefile.am b/Makefile.am
index 5a7184c6c..ee468d8ba 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,7 +19,7 @@
AUTOMAKE_OPTIONS = 1.5 gnu no-dependencies
ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = gnulib-local gettext-runtime libtextstyle gettext-tools
+SUBDIRS = gnulib-local gettext-runtime
changelog_etc = \
gettext-runtime/ChangeLog.0 \
diff --git a/configure.ac b/configure.ac
index f4e54ea6b..c6e7cc109 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,7 +37,7 @@ dnl Checks for typedefs, structures, and compiler characteristics.
dnl Checks for library functions.
-AC_CONFIG_SUBDIRS([gettext-runtime libtextstyle gettext-tools])
+AC_CONFIG_SUBDIRS([gettext-runtime])
AM_EXTRA_RECURSIVE_TARGETS([maintainer-update-po])
@@ -49,7 +49,7 @@ AC_CANONICAL_HOST
dnl Optional Features: AC_ARG_ENABLE calls
dnl Optional Packages: AC_ARG_WITH calls
dnl Some influential environment variables: AC_ARG_VAR calls
-esyscmd([{ cd gettext-runtime && autoconf --trace=AC_ARG_ENABLE:'$n([$1],[$2])' --trace=AC_ARG_WITH:'$n([$1],[$2])' --trace=AC_ARG_VAR:'$n($@)' && cd ..; cd libtextstyle && autoconf --trace=AC_ARG_ENABLE:'$n([$1],[$2])' --trace=AC_ARG_WITH:'$n([$1],[$2])' --trace=AC_ARG_VAR:'$n($@)' && cd ..; { cd gettext-tools && autoconf --trace=AC_ARG_ENABLE:'$n([$1],[$2])' --trace=AC_ARG_WITH:'$n([$1],[$2])' --trace=AC_ARG_VAR:'$n($@)' && cd ..; } | grep -v installed.libtextstyle | grep -v installed.csharp | grep -v 'installed C#'; } | sed -f build-aux/ac-help.sed ])
+esyscmd([{ cd gettext-runtime && autoconf --trace=AC_ARG_ENABLE:'$n([$1],[$2])' --trace=AC_ARG_WITH:'$n([$1],[$2])' --trace=AC_ARG_VAR:'$n($@)' && cd ..; cd libtextstyle && autoconf --trace=AC_ARG_ENABLE:'$n([$1],[$2])' --trace=AC_ARG_WITH:'$n([$1],[$2])' --trace=AC_ARG_VAR:'$n($@)' && cd ..; } | sed -f build-aux/ac-help.sed ])
AC_CONFIG_FILES([Makefile])

View file

@ -0,0 +1,41 @@
diff --git a/glib/gthreadprivate.h b/glib/gthreadprivate.h
index 9c847e039..21ea3cca7 100644
--- a/glib/gthreadprivate.h
+++ b/glib/gthreadprivate.h
@@ -61,6 +61,7 @@ struct _GRealThread
* This must not be called with a timeout parameter as that differs
* in size between the two syscall variants!
*/
+#undef __NR_futex_time64
#if defined(__NR_futex) && defined(__NR_futex_time64)
#define g_futex_simple(uaddr, futex_op, ...) \
G_STMT_START \
diff --git a/meson.build b/meson.build
index 0cbc9689f..d3668817f 100644
--- a/meson.build
+++ b/meson.build
@@ -903,15 +903,15 @@ if cc.compiles('''#include <linux/futex.h>
}''', name : 'futex(2) system call')
glib_conf.set('HAVE_FUTEX', 1)
endif
-if cc.compiles('''#include <linux/futex.h>
- #include <sys/syscall.h>
- #include <unistd.h>
- int main (int argc, char ** argv) {
- syscall (__NR_futex_time64, NULL, FUTEX_WAKE, FUTEX_WAIT);
- return 0;
- }''', name : 'futex(2) system call')
- glib_conf.set('HAVE_FUTEX_TIME64', 1)
-endif
+#if cc.compiles('''#include <linux/futex.h>
+# #include <sys/syscall.h>
+# #include <unistd.h>
+# int main (int argc, char ** argv) {
+# syscall (__NR_futex_time64, NULL, FUTEX_WAKE, FUTEX_WAIT);
+# return 0;
+# }''', name : 'futex(2) system call')
+# glib_conf.set('HAVE_FUTEX_TIME64', 1)
+#endif
# Check for eventfd(2)
if cc.links('''#include <sys/eventfd.h>

View file

@ -0,0 +1 @@
--with-icu=no

View file

@ -0,0 +1,12 @@
diff --git a/libpng.pc.in b/libpng.pc.in
index de127d4f8..3e7e2c58a 100644
--- a/libpng.pc.in
+++ b/libpng.pc.in
@@ -6,7 +6,6 @@ includedir=@includedir@/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
Name: libpng
Description: Loads and saves PNG files
Version: @PNGLIB_VERSION@
-Requires.private: zlib
Libs: -L${libdir} -lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
Libs.private: @LIBS@
Cflags: -I${includedir}

View file

@ -0,0 +1,13 @@
diff --git a/configure.ac b/configure.ac
index 14a267f8..5211f629 100644
--- a/configure.ac
+++ b/configure.ac
@@ -133,7 +133,7 @@ else
case $host in
*86-*-linux*)
DEBUG="-g -Wall -Wextra -D_REENTRANT -D__NO_MATH_INLINES -fsigned-char"
- CFLAGS="-O3 -Wall -Wextra -ffast-math -mno-ieee-fp -D_REENTRANT -fsigned-char"
+ CFLAGS="-O3 -Wall -Wextra -ffast-math -D_REENTRANT -fsigned-char"
# PROFILE="-Wall -Wextra -pg -g -O3 -ffast-math -D_REENTRANT -fsigned-char -fno-inline -static"
PROFILE="-Wall -Wextra -pg -g -O3 -ffast-math -mno-ieee-fp -D_REENTRANT -fsigned-char -fno-inline"

View file

@ -0,0 +1 @@
--disable-arm-a64-neon --disable-arm-simd --disable-arm-neon --disable-gcc-inline-asm

View file

@ -0,0 +1,84 @@
#!/bin/env python3
import json
from subprocess import run
from pathlib import Path
ndk = Path("/opt/android-sdk-update-manager/ndk/23.1.7779620")
api = 29
abis = json.load(open(ndk / "meta/abis.json"))
for abi, abi_data in abis.items():
triple = abi_data["llvm_triple"]
arch = abi_data["arch"]
prefix = Path("/tmp/android-prefix/" + abi)
prefix.mkdir(parents = True, exist_ok = True)
with open(prefix / "android.env", "w") as envfile:
envfile.write(f"""
export NDK={ndk}
export ANDROID_NDK_ROOT={ndk}
export ANDROID_ARCH={arch}
export BITNESS={abi_data["bitness"]}
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
export PATH=$TOOLCHAIN/bin:$PATH
export TARGET={triple}
export HOST={abi_data["triple"]}
export API={api}
export AR=$TOOLCHAIN/bin/llvm-ar
export CC="$TOOLCHAIN/bin/clang -target $TARGET$API"
export AS=$CC
export CXX="$TOOLCHAIN/bin/clang++ -target $TARGET$API"
export LD=$TOOLCHAIN/bin/ld
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
export STRIP=$TOOLCHAIN/bin/llvm-strip
export PKG_CONFIG=/usr/bin/pkg-config
export PKG_CONFIG_LIBDIR={prefix}/lib/pkgconfig
export PKG_CONFIG_PATH={prefix}/lib/pkgconfig
""")
with open(prefix / "android.ini", "w") as crossfile:
crossfile.write(f"""
[constants]
ndk_home = '{ndk}'
toolchain = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64'
target = '{triple}'
api = '{api}'
common_flags = ['-target', target + api]
prefix = '{prefix}'
[host_machine]
system = 'android'
cpu = '{arch}'
cpu_family = '{arch}'
endian = 'little'
[properties]
sys_root = '{prefix}'
pkg_config_libdir = '{prefix}' / 'lib/pkgconfig'
[built-in options]
libdir = prefix / 'lib'
includedir = prefix / 'include'
c_args = common_flags + ['-I' + includedir]
cpp_args = common_flags + ['-I' + includedir]
c_link_args = common_flags + ['-L' + libdir]
cpp_link_args = common_flags + ['-L' + libdir]
[binaries]
ar = toolchain / 'bin/llvm-ar'
c = toolchain / 'bin' / 'clang'
cxx = toolchain / 'bin' / 'clang++'
ld = toolchain / 'bin/ld'
ranlib = toolchain / 'bin/llvm-ranlib'
strip = toolchain / 'bin/llvm-strip'
""")
with open(prefix / "android.jam", "w") as jamfile:
jamfile.write(f"""
using clang : android
: {ndk}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
: <compileflags>"--target={triple}{api}" <linkflags>"--target={triple}{api}"
<compileflags>-I{prefix}/include <linkflags>-L{prefix}/lib
;
""")