SDL{,2}: support building for android

This should be picking up the OpenGL ES headers provided by the NDK.
More testing is needed.
This commit is contained in:
Matthew Bauer 2019-02-22 10:36:48 -05:00
parent 76474b2da7
commit d665b8ccf3
4 changed files with 29 additions and 23 deletions

View File

@ -1,8 +1,9 @@
{ stdenv, config, libGLSupported, fetchurl, fetchpatch, pkgconfig, audiofile, libcap, libiconv { stdenv, config, libGLSupported, fetchurl, fetchpatch, pkgconfig, audiofile, libcap, libiconv
, openglSupport ? libGLSupported, libGL, libGLU , openglSupport ? libGLSupported, libGL, libGLU
, alsaSupport ? stdenv.isLinux, alsaLib , alsaSupport ? stdenv.isLinux && !stdenv.hostPlatform.isAndroid, alsaLib
, x11Support ? !stdenv.isCygwin, libXext, libICE, libXrandr , x11Support ? !stdenv.isCygwin && !stdenv.hostPlatform.isAndroid
, pulseaudioSupport ? config.pulseaudio or stdenv.isLinux, libpulseaudio , libXext, libICE, libXrandr
, pulseaudioSupport ? config.pulseaudio or stdenv.isLinux && !stdenv.hostPlatform.isAndroid, libpulseaudio
, OpenGL, CoreAudio, CoreServices, AudioUnit, Kernel, Cocoa , OpenGL, CoreAudio, CoreServices, AudioUnit, Kernel, Cocoa
, cf-private , cf-private
}: }:
@ -12,9 +13,6 @@
with stdenv.lib; with stdenv.lib;
assert !stdenv.isDarwin -> alsaSupport || pulseaudioSupport;
assert openglSupport -> (stdenv.isDarwin || x11Support && libGL != null && libGLU != null);
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "SDL-${version}"; name = "SDL-${version}";
version = "1.2.15"; version = "1.2.15";
@ -30,18 +28,18 @@ stdenv.mkDerivation rec {
outputs = [ "out" "dev" ]; outputs = [ "out" "dev" ];
outputBin = "dev"; # sdl-config outputBin = "dev"; # sdl-config
nativeBuildInputs = [ pkgconfig ]; nativeBuildInputs = [ pkgconfig ]
++ optional stdenv.isLinux libcap;
propagatedBuildInputs = [ libiconv ] propagatedBuildInputs = [ libiconv ]
++ optionals x11Support [ libXext libICE libXrandr ] ++ optionals x11Support [ libXext libICE libXrandr ]
++ optional stdenv.isLinux libcap
++ optionals openglSupport [ libGL libGLU ] ++ optionals openglSupport [ libGL libGLU ]
++ optional alsaSupport alsaLib ++ optional alsaSupport alsaLib
++ optional pulseaudioSupport libpulseaudio ++ optional pulseaudioSupport libpulseaudio
++ optional stdenv.isDarwin Cocoa; ++ optional stdenv.isDarwin Cocoa;
buildInputs = [ ] buildInputs = [ ]
++ optional (!stdenv.hostPlatform.isMinGW) audiofile ++ optional (!stdenv.hostPlatform.isMinGW && alsaSupport) audiofile
++ optionals stdenv.isDarwin [ ++ optionals stdenv.isDarwin [
AudioUnit CoreAudio CoreServices Kernel OpenGL AudioUnit CoreAudio CoreServices Kernel OpenGL
# Needed for NSDefaultRunLoopMode symbols. # Needed for NSDefaultRunLoopMode symbols.

View File

@ -1,12 +1,16 @@
{ stdenv, config, libGLSupported, fetchurl, pkgconfig { stdenv, config, libGLSupported, fetchurl, pkgconfig
, openglSupport ? libGLSupported, libGL , openglSupport ? libGLSupported, libGL
, alsaSupport ? stdenv.isLinux, alsaLib , alsaSupport ? stdenv.isLinux && !stdenv.hostPlatform.isAndroid, alsaLib
, x11Support ? !stdenv.isCygwin, libX11, xorgproto, libICE, libXi, libXScrnSaver, libXcursor, libXinerama, libXext, libXxf86vm, libXrandr , x11Support ? !stdenv.isCygwin && !stdenv.hostPlatform.isAndroid
, waylandSupport ? stdenv.isLinux, wayland, wayland-protocols, libxkbcommon , libX11, xorgproto, libICE, libXi, libXScrnSaver, libXcursor
, dbusSupport ? stdenv.isLinux, dbus , libXinerama, libXext, libXxf86vm, libXrandr
, waylandSupport ? stdenv.isLinux && !stdenv.hostPlatform.isAndroid
, wayland, wayland-protocols, libxkbcommon
, dbusSupport ? stdenv.isLinux && !stdenv.hostPlatform.isAndroid, dbus
, udevSupport ? false, udev , udevSupport ? false, udev
, ibusSupport ? false, ibus , ibusSupport ? false, ibus
, pulseaudioSupport ? config.pulseaudio or stdenv.isLinux, libpulseaudio , pulseaudioSupport ? config.pulseaudio or stdenv.isLinux && !stdenv.hostPlatform.isAndroid
, libpulseaudio
, AudioUnit, Cocoa, CoreAudio, CoreServices, ForceFeedback, OpenGL , AudioUnit, Cocoa, CoreAudio, CoreServices, ForceFeedback, OpenGL
, audiofile, cf-private, libiconv , audiofile, cf-private, libiconv
}: }:
@ -16,9 +20,6 @@
with stdenv.lib; with stdenv.lib;
assert !stdenv.isDarwin -> alsaSupport || pulseaudioSupport;
assert openglSupport -> (stdenv.isDarwin || x11Support && libGL != null);
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "SDL2-${version}"; name = "SDL2-${version}";
version = "2.0.9"; version = "2.0.9";
@ -44,14 +45,14 @@ stdenv.mkDerivation rec {
++ optionals x11Support [ libX11 xorgproto ]; ++ optionals x11Support [ libX11 xorgproto ];
dlopenBuildInputs = [ ] dlopenBuildInputs = [ ]
++ optional alsaSupport alsaLib ++ optionals alsaSupport [ alsaLib audiofile ]
++ optional dbusSupport dbus ++ optional dbusSupport dbus
++ optional pulseaudioSupport libpulseaudio ++ optional pulseaudioSupport libpulseaudio
++ optional udevSupport udev ++ optional udevSupport udev
++ optionals waylandSupport [ wayland wayland-protocols libxkbcommon ] ++ optionals waylandSupport [ wayland wayland-protocols libxkbcommon ]
++ optionals x11Support [ libICE libXi libXScrnSaver libXcursor libXinerama libXext libXrandr libXxf86vm ]; ++ optionals x11Support [ libICE libXi libXScrnSaver libXcursor libXinerama libXext libXrandr libXxf86vm ];
buildInputs = [ audiofile libiconv ] buildInputs = [ libiconv ]
++ dlopenBuildInputs ++ dlopenBuildInputs
++ optional ibusSupport ibus ++ optional ibusSupport ibus
++ optionals stdenv.isDarwin [ ++ optionals stdenv.isDarwin [

View File

@ -22,5 +22,6 @@ stdenv.mkDerivation rec {
homepage = https://cgit.freedesktop.org/mesa/glu/; homepage = https://cgit.freedesktop.org/mesa/glu/;
license = stdenv.lib.licenses.sgi-b-20; license = stdenv.lib.licenses.sgi-b-20;
platforms = stdenv.lib.platforms.unix; platforms = stdenv.lib.platforms.unix;
broken = stdenv.hostPlatform.isAndroid;
}; };
} }

View File

@ -11650,8 +11650,11 @@ in
## libGL/libGLU/Mesa stuff ## libGL/libGLU/Mesa stuff
# Default libGL implementation, should provide headers and libGL.so/libEGL.so/... to link agains them # Default libGL implementation, should provide headers and
libGL = mesa_noglu.stubs; # libGL.so/libEGL.so/... to link agains them. Android NDK provides
# an OpenGL implementation, we can just use that.
libGL = if stdenv.hostPlatform.useAndroidPrebuilt then stdenv
else mesa_noglu.stubs;
# Default libGLU # Default libGLU
libGLU = mesa_glu; libGLU = mesa_glu;
@ -12453,10 +12456,13 @@ in
schroedinger = callPackage ../development/libraries/schroedinger { }; schroedinger = callPackage ../development/libraries/schroedinger { };
SDL = callPackage ../development/libraries/SDL { SDL = callPackage ../development/libraries/SDL ({
inherit (darwin) cf-private; inherit (darwin) cf-private;
inherit (darwin.apple_sdk.frameworks) OpenGL CoreAudio CoreServices AudioUnit Kernel Cocoa; inherit (darwin.apple_sdk.frameworks) OpenGL CoreAudio CoreServices AudioUnit Kernel Cocoa;
}; } // lib.optionalAttrs stdenv.hostPlatform.isAndroid {
# libGLU doesnt work with Androids SDL
libGLU = null;
});
SDL_sixel = callPackage ../development/libraries/SDL_sixel { }; SDL_sixel = callPackage ../development/libraries/SDL_sixel { };