Skip to content

Commit

Permalink
fix: android, build flac manually
Browse files Browse the repository at this point in the history
also use pkg-config for android, by setting the correct pkg_conf_libdir variable and using the host pkg-config
  • Loading branch information
Totto16 committed Nov 20, 2024
1 parent 16cdae5 commit 5542d29
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 18 deletions.
8 changes: 1 addition & 7 deletions platforms/android/app/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ LOCAL_SRC_FILES := $(shell find "${SUBPROJECTS_PATH}" -name libogg.so)
include $(PREBUILT_SHARED_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE := flac
LOCAL_SRC_FILES := $(shell find "${SUBPROJECTS_PATH}" -name libFLAC.so)
include $(PREBUILT_SHARED_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE := sdl2_image
LOCAL_SRC_FILES := $(shell find "${SUBPROJECTS_PATH}" -name libsdl2image.so)
Expand Down Expand Up @@ -105,7 +99,7 @@ include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := main
LOCAL_SHARED_LIBRARIES := SDL2 sdl2_ttf freetype png16 sdl2_mixer vorbis vorbisfile ogg flac sdl2_image fmt keyutils oopetris_core oopetris_recordings oopetris_graphics oopetris
LOCAL_SHARED_LIBRARIES := SDL2 sdl2_ttf freetype png16 sdl2_mixer vorbis vorbisfile ogg sdl2_image fmt keyutils oopetris_core oopetris_recordings oopetris_graphics oopetris
LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -lOpenSLES -llog -landroid
LOCAL_LDFLAGS := -Wl,--no-undefined
include $(BUILD_SHARED_LIBRARY)
76 changes: 66 additions & 10 deletions platforms/build-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,15 @@ for INDEX in "${ARCH_KEYS_INDEX[@]}"; do

## BUILD dependencies not buildable with meson (to complicated to port)

## build mpg123 with autotools (meson port is to much work atm, for this feature)
## build mpg123 with cmake (meson port is to much work atm, for this feature)

LAST_DIR="$PWD"

cd "$SYS_ROOT"

BUILD_DIR_MPG123="build-mpg123"

BUILD_MPG123_FILE="$SYS_ROOT/$BUILD_DIR_MPG123/build_succesfull.meta"
BUILD_MPG123_FILE="$SYS_ROOT/$BUILD_DIR_MPG123/build_successfull.meta"

if [ "$COMPILE_TYPE" == "complete_rebuild" ] || ! [ -e "$BUILD_MPG123_FILE" ]; then

Expand All @@ -195,8 +195,6 @@ for INDEX in "${ARCH_KEYS_INDEX[@]}"; do

cd ports/cmake/

BUILD_DIR_MPG123="build-mpg123"

mkdir -p "$BUILD_DIR_MPG123"

cd "$BUILD_DIR_MPG123"
Expand Down Expand Up @@ -225,6 +223,64 @@ for INDEX in "${ARCH_KEYS_INDEX[@]}"; do

cd "$LAST_DIR"

## build flac with cmake (meson port doesn't work for 32 bits machines atm) (we need to check for fseeko and ftello correctly in there)

LAST_DIR="$PWD"

cd "$SYS_ROOT"

BUILD_DIR_FLAC="build-flac"

BUILD_FLAC_FILE="$SYS_ROOT/$BUILD_DIR_FLAC/build_successfull.meta"

if [ "$COMPILE_TYPE" == "complete_rebuild" ] || ! [ -e "$BUILD_FLAC_FILE" ]; then

mkdir -p "$BUILD_DIR_FLAC"

cd "$BUILD_DIR_FLAC"

FLAC_VERSION="1.4.3"

if [ ! -e "flac-$FLAC_VERSION.tar.xz" ]; then
wget -q "https://github.com/xiph/flac/releases/download/$FLAC_VERSION/flac-$FLAC_VERSION.tar.xz"
fi

if [ ! -d "flac-$FLAC_VERSION" ]; then
tar -xf "flac-$FLAC_VERSION.tar.xz"
fi

cd "flac-$FLAC_VERSION"

mkdir -p "$BUILD_DIR_FLAC"

cd "$BUILD_DIR_FLAC"

cmake .. --install-prefix "$SYS_ROOT/usr" "-DCMAKE_SYSROOT=$SYS_ROOT" -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
"-DCMAKE_SYSTEM_NAME=Android" \
"-DCMAKE_SYSTEM_VERSION=$SDK_VERSION" \
"-DCMAKE_ANDROID_ARCH_ABI=$KEY" \
"-DCMAKE_ANDROID_NDK=$ANDROID_NDK" \
"-DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang" \
-DBUILD_PROGRAMS=OFF \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_CXXLIBS=OFF \
-DBUILD_DOCS=OFF \
-DWITH_OGG=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DINSTALL_PKGCONFIG_MODULES=ON


cmake --build .

cmake --install .

touch "$BUILD_FLAC_FILE"

fi

cd "$LAST_DIR"

## build openssl with make (meson port is to much work atm, for this feature)

LAST_DIR="$PWD"
Expand All @@ -233,7 +289,7 @@ for INDEX in "${ARCH_KEYS_INDEX[@]}"; do

BUILD_DIR_OPENSSL="build-openssl"

BUILD_OPENSSL_FILE="$SYS_ROOT/$BUILD_DIR_OPENSSL/build_succesfull.meta"
BUILD_OPENSSL_FILE="$SYS_ROOT/$BUILD_DIR_OPENSSL/build_successfull.meta"

if [ "$COMPILE_TYPE" == "complete_rebuild" ] || ! [ -e "$BUILD_OPENSSL_FILE" ]; then

Expand Down Expand Up @@ -297,7 +353,7 @@ for INDEX in "${ARCH_KEYS_INDEX[@]}"; do
MESON_CPU_FAMILY="aarch64"
fi

export COMPILE_FLAGS="'--sysroot=${SYS_ROOT:?}','-fPIE','-fPIC','--target=$ARM_COMPILER_TRIPLE','-D__ANDROID_API__=$SDK_VERSION', '-DAUDIO_PREFER_MP3'"
export COMPILE_FLAGS="'--sysroot=${SYS_ROOT:?}','-fPIE','-fPIC','--target=$ARM_COMPILER_TRIPLE','-D__ANDROID_API__=$SDK_VERSION', '-DBITNESS=$BITNESS','-DAUDIO_PREFER_MP3'"

export LINK_FLAGS="'-fPIE','-L$SYS_ROOT/usr/lib'"

Expand All @@ -322,7 +378,7 @@ as = '$AS'
ranlib = '$RANLIB'
strip = '$STRIP'
objcopy = '$OBJCOPY'
pkg-config = 'false'
pkg-config = 'pkg-config'
llvm-config = '$LLVM_CONFIG'
[built-in options]
Expand All @@ -337,7 +393,7 @@ prefix = '$SYS_ROOT'
libdir = '$LIB_PATH'
[properties]
pkg_config_libdir = '$LIB_PATH'
pkg_config_libdir = '$SYS_ROOT/usr/lib/pkgconfig'
sys_root = '${SYS_ROOT}'
EOF
Expand Down Expand Up @@ -367,7 +423,7 @@ meson.override_dependency(
EOF
fi

export LIBRARY_PATH="$LIBRARY_PATH:usr/lib/$ARM_NAME_TRIPLE/$SDK_VERSION:$LIB_PATH"
export LIBRARY_PATH="$LIBRARY_PATH:$SYS_ROOT/usr/lib/$ARM_NAME_TRIPLE/$SDK_VERSION:$LIB_PATH"

if [ "$COMPILE_TYPE" == "complete_rebuild" ] || [ ! -e "$BUILD_DIR" ]; then

Expand All @@ -376,7 +432,7 @@ EOF
"--prefix=$SYS_ROOT" \
"--wipe" \
"--includedir=$INC_PATH" \
"--libdir=usr/lib/$ARM_NAME_TRIPLE/$SDK_VERSION" \
"--libdir=$SYS_ROOT/usr/lib/$ARM_NAME_TRIPLE/$SDK_VERSION" \
--cross-file "./platforms/crossbuild-android-$ARM_TARGET_ARCH.ini" \
"-Dbuildtype=$BUILDTYPE" \
-Dsdl2:use_hidapi=enabled \
Expand Down
10 changes: 9 additions & 1 deletion tools/dependencies/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ if meson.is_cross_build()
# )
# endif
elif host_machine.system() == 'android'
# noop

flac_dep = dependency(
'flac',
allow_fallback: false,
required: true,
)

meson.override_dependency('libflac', flac_dep)

elif host_machine.system() == 'emscripten'

# check if the command line flags are supported and a simple example compiles
Expand Down

0 comments on commit 5542d29

Please sign in to comment.