summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 731ceda3e89f3f89efbaeb4a54b30c8fb4a52b84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Maintainer: Gonzalo Exequiel Pedone <hipersayan DOT x AT gmail DOT com>
# Contributor: Sven-Hendrik Haase <svenstaro@archlinux.org>

_android_arch=armv7a-eabi

pkgname=android-${_android_arch}-sdl2
pkgver=2.30.9
pkgrel=1
arch=('any')
pkgdesc="A library for portable low-level access to a video framebuffer, audio output, mouse, and keyboard (Version 2) (Android ${_android_arch})"
url="https://www.libsdl.org"
license=('MIT')
groups=('android-sdl2')
depends=("android-${_android_arch}-libxext"
         "android-${_android_arch}-libxrender"
         "android-${_android_arch}-libx11"
         "android-${_android_arch}-libxcursor"
         "android-${_android_arch}-hidapi"
         "android-${_android_arch}-libusb")
makedepends=('android-cmake'
             "android-${_android_arch}-alsa-lib"
             "android-${_android_arch}-libxrandr"
             "android-${_android_arch}-libxinerama"
             "android-${_android_arch}-libxkbcommon"
             "android-${_android_arch}-libxss")
optdepends=("android-${_android_arch}-alsa-lib: ALSA audio driver")
options=(!strip !buildflags staticlibs !emptydirs)
source=("https://github.com/libsdl-org/SDL/releases/download/release-${pkgver}/SDL2-${pkgver}.tar.gz"{,.sig})
md5sums=('57393a5e1a46dd19ae40968a301c70a3'
         'SKIP')
validpgpkeys=('1528635D8053A57F77D1E08630A59377A7763BE6') # Sam Lantinga
clases_file_name=sdl2.jar

build() {
    cd "${srcdir}/SDL2-${pkgver}"
    source android-env ${_android_arch}

    android-${_android_arch}-cmake \
        -S . \
        -B build \
        -DSDL_HIDAPI_LIBUSB=ON \
        -DSDL_STATIC=ON \
        -DSDL_RPATH=OFF \
        -DSDL_ALSA=ON \
        -DALSA_INCLUDE_DIRS="${ANDROID_PREFIX_INCLUDE}" \
        -DALSA_LIBRARY="${ANDROID_PREFIX_LIB}/libalsa.so"
    make -C build $MAKEFLAGS

    # Build Java files

    java_source_build_dir="${PWD}/build/java"
    mkdir -p "${java_source_build_dir}"

    java_sourceslist_path="${java_source_build_dir}/java_sources.txt"

    classes_root="${java_source_build_dir}/classes"

    mkdir -p "${classes_root}/META-INF"
    cp "${PWD}/LICENSE.txt" "${classes_root}/META-INF"
    java_sourceslist_path="${java_source_build_dir}/java_sources.txt"

    echo "Collecting sources for ${clases_file_name}"
    find "${PWD}/android-project/app/src/main/java" -name "*.java" > "${java_sourceslist_path}"

    echo "Compiling classes"
    javac -encoding utf-8 -classpath "${ANDROID_SDK_JAR}" -d "${classes_root}" "@${java_sourceslist_path}"

    java_classeslist_path="${java_source_build_dir}/java_classes.txt"

    pushd "${classes_root}"
        find "." -name "*.class" > "${java_classeslist_path}"
        find "META-INF" -name "*" >> "${java_classeslist_path}"
        echo "Creating ${clases_file_name}"
        jar -cf "${srcdir}/SDL2-${pkgver}/build/${clases_file_name}" "@${java_classeslist_path}"
    popd
}

package() {
    cd "${srcdir}/SDL2-${pkgver}"
    source android-env ${_android_arch}

    make -C build DESTDIR="$pkgdir" install
    ${ANDROID_STRIP} -g --strip-unneeded "${pkgdir}/${ANDROID_PREFIX_LIB}"/*.so
    ${ANDROID_STRIP} -g "${pkgdir}/${ANDROID_PREFIX_LIB}"/*.a

    mkdir -p "${pkgdir}/${ANDROID_PREFIX_SHARE}/java"
    cp -vf "${srcdir}/SDL2-${pkgver}/build/${clases_file_name}" "${pkgdir}/${ANDROID_PREFIX_SHARE}/java"
    mkdir -p "${pkgdir}/${ANDROID_PREFIX_SHARE}/sdl2"
    cp -rf android-project "${pkgdir}/${ANDROID_PREFIX_SHARE}/sdl2/android-project"
    cp -rf build-scripts "${pkgdir}/${ANDROID_PREFIX_SHARE}/sdl2/build-scripts"
}