Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:

- name: Setup NDK
run: |
sdkmanager --install "ndk;28.0.12433566"
sdkmanager --install "ndk;28.0.12674087"

- name: Build native libraries
run: |
Expand Down
2 changes: 1 addition & 1 deletion platforms/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ android {
}

compileSdkVersion 35
ndkVersion "28.0.12433566"
ndkVersion "28.0.12674087"
defaultConfig {
if (buildAsApplication) {
applicationId "com.github.oopetris"
Expand Down
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)
4 changes: 4 additions & 0 deletions platforms/android/app/jni/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ APP_PLATFORM := android-35
# support 16KB page sizes:
# see: https://developer.android.com/guide/practices/page-sizes
APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true

# support weak api defs:
# see https://developer.android.com/ndk/guides/using-newer-apis
APP_WEAK_API_DEFS := true
2 changes: 1 addition & 1 deletion platforms/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.7.0'
classpath 'com.android.tools.build:gradle:8.7.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
7 changes: 6 additions & 1 deletion platforms/build-3ds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,12 @@ if [ "$COMPILE_TYPE" == "complete_rebuild" ] || [ ! -e "$BUILD_DIR" ]; then
"--wipe" \
--cross-file "$CROSS_FILE" \
"-Dbuildtype=$BUILDTYPE" \
-Ddefault_library=static
-Ddefault_library=static \
-Dcurl:tests=disabled \
-Dcurl:unittests=disabled \
-Dcurl:bearer-auth=enabled \
-Dcurl:brotli=enabled \
-Dcurl:libz=enabled

fi

Expand Down
104 changes: 82 additions & 22 deletions platforms/build-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ if [ ! -d "toolchains" ]; then
mkdir -p toolchains
fi

export NDK_VER_DOWNLOAD="r28-beta1"
export NDK_VER_DESC="r28-beta1"
export NDK_VER_DOWNLOAD="r28-beta2"
export NDK_VER_DESC="r28-beta2"

export BASE_PATH="$PWD/toolchains/android-ndk-$NDK_VER_DESC"
export ANDROID_NDK_HOME="$BASE_PATH"
Expand Down Expand Up @@ -165,36 +165,36 @@ 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

mkdir -p "$BUILD_DIR_MPG123"

cd "$BUILD_DIR_MPG123"

if [ ! -e "mpg123-1.32.6.tar.bz2" ]; then
wget -q "https://www.mpg123.de/download/mpg123-1.32.6.tar.bz2"
MPG123_VERSION="1.32.9"

if [ ! -e "mpg123-$MPG123_VERSION.tar.bz2" ]; then
wget -q "https://www.mpg123.de/download/mpg123-$MPG123_VERSION.tar.bz2"
fi

if [ ! -d "mpg123-1.32.6" ]; then
tar -xf "mpg123-1.32.6.tar.bz2"
if [ ! -d "mpg123-$MPG123_VERSION" ]; then
tar -xf "mpg123-$MPG123_VERSION.tar.bz2"
fi

cd "mpg123-1.32.6"
cd "mpg123-$MPG123_VERSION"

cd ports/cmake/

BUILD_DIR_MPG123="build-mpg123"

mkdir -p "$BUILD_DIR_MPG123"

cd "$BUILD_DIR_MPG123"
Expand Down Expand Up @@ -223,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 @@ -231,23 +289,25 @@ 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

mkdir -p "$BUILD_DIR_OPENSSL"

cd "$BUILD_DIR_OPENSSL"

if [ ! -e "openssl-3.3.0.tar.gz" ]; then
wget -q "https://github.com/openssl/openssl/releases/download/openssl-3.3.0/openssl-3.3.0.tar.gz"
OPENSSL_VERSION="3.4.0"

if [ ! -e "openssl-$OPENSSL_VERSION.tar.gz" ]; then
wget -q "https://github.com/openssl/openssl/releases/download/openssl-$OPENSSL_VERSION/openssl-$OPENSSL_VERSION.tar.gz"
fi

if [ ! -d "openssl-3.3.0" ]; then
tar -xzf "openssl-3.3.0.tar.gz"
if [ ! -d "openssl-$OPENSSL_VERSION" ]; then
tar -xzf "openssl-$OPENSSL_VERSION.tar.gz"
fi

cd "openssl-3.3.0"
cd "openssl-$OPENSSL_VERSION"

OPENSSL_TARGET_ARCH="android-$ARCH"

Expand Down Expand Up @@ -293,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','-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 @@ -318,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 @@ -333,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 @@ -363,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 @@ -372,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
7 changes: 6 additions & 1 deletion platforms/build-switch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@ if [ "$COMPILE_TYPE" == "complete_rebuild" ] || [ ! -e "$BUILD_DIR" ]; then
"--wipe" \
--cross-file "$CROSS_FILE" \
"-Dbuildtype=$BUILDTYPE" \
-Ddefault_library=static
-Ddefault_library=static \
-Dcurl:tests=disabled \
-Dcurl:unittests=disabled \
-Dcurl:bearer-auth=enabled \
-Dcurl:brotli=enabled \
-Dcurl:libz=enabled

fi

Expand Down
14 changes: 12 additions & 2 deletions 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 Expand Up @@ -384,7 +392,9 @@ if build_application
curl_cpp_wrapper = dependency(
'cpr',
required: true,
default_options: {'tests': 'disabled'},
default_options: {
'tests': 'disabled',
},
)

graphics_lib += {
Expand Down
36 changes: 36 additions & 0 deletions tools/options/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,42 @@ if meson.is_cross_build() and host_machine.system() == 'serenity'
]
core_lib += {'compile_args': temp}
temp = 0
elif meson.is_cross_build() and host_machine.system() == 'android'
cpp = meson.get_compiler('cpp')
target_android_api = '35'

android_api = cpp.get_define(
'__ANDROID_API__',
prefix: '#include <features.h>',
).strip('"')
assert(
android_api != '',
'failed to get android_api version',
)

android_compile_args = []
android_link_args = []

# APP_SUPPORT_FLEXIBLE_PAGE_SIZES
android_link_args += '-Wl,-z,max-page-size=16384'

if android_api != target_android_api
android_compile_args += ('-D__ANDROID_API__=' + target_android_api)
endif

android_compile_args += [
'-D__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__',
'-Werror=unguarded-availability',
]

if not meson.is_subproject()
add_global_link_arguments(android_link_args, language: ['cpp'])
add_global_arguments(android_compile_args, language: ['cpp'])
else
add_project_link_arguments(android_link_args, language: ['cpp'])
add_project_arguments(android_compile_args, language: ['cpp'])

endif
endif

cpp = meson.get_compiler('cpp')
Expand Down
Loading