From d665b8ccf3781d56d3cd23b767af67286e11e5db Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Fri, 22 Feb 2019 10:36:48 -0500 Subject: [PATCH] SDL{,2}: support building for android This should be picking up the OpenGL ES headers provided by the NDK. More testing is needed. --- pkgs/development/libraries/SDL/default.nix | 16 +++++++------- pkgs/development/libraries/SDL2/default.nix | 21 ++++++++++--------- .../libraries/mesa-glu/default.nix | 1 + pkgs/top-level/all-packages.nix | 14 +++++++++---- 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/pkgs/development/libraries/SDL/default.nix b/pkgs/development/libraries/SDL/default.nix index e2ff66a4708..007cd02957b 100644 --- a/pkgs/development/libraries/SDL/default.nix +++ b/pkgs/development/libraries/SDL/default.nix @@ -1,8 +1,9 @@ { stdenv, config, libGLSupported, fetchurl, fetchpatch, pkgconfig, audiofile, libcap, libiconv , openglSupport ? libGLSupported, libGL, libGLU -, alsaSupport ? stdenv.isLinux, alsaLib -, x11Support ? !stdenv.isCygwin, libXext, libICE, libXrandr -, pulseaudioSupport ? config.pulseaudio or stdenv.isLinux, libpulseaudio +, alsaSupport ? stdenv.isLinux && !stdenv.hostPlatform.isAndroid, alsaLib +, x11Support ? !stdenv.isCygwin && !stdenv.hostPlatform.isAndroid +, libXext, libICE, libXrandr +, pulseaudioSupport ? config.pulseaudio or stdenv.isLinux && !stdenv.hostPlatform.isAndroid, libpulseaudio , OpenGL, CoreAudio, CoreServices, AudioUnit, Kernel, Cocoa , cf-private }: @@ -12,9 +13,6 @@ with stdenv.lib; -assert !stdenv.isDarwin -> alsaSupport || pulseaudioSupport; -assert openglSupport -> (stdenv.isDarwin || x11Support && libGL != null && libGLU != null); - stdenv.mkDerivation rec { name = "SDL-${version}"; version = "1.2.15"; @@ -30,18 +28,18 @@ stdenv.mkDerivation rec { outputs = [ "out" "dev" ]; outputBin = "dev"; # sdl-config - nativeBuildInputs = [ pkgconfig ]; + nativeBuildInputs = [ pkgconfig ] + ++ optional stdenv.isLinux libcap; propagatedBuildInputs = [ libiconv ] ++ optionals x11Support [ libXext libICE libXrandr ] - ++ optional stdenv.isLinux libcap ++ optionals openglSupport [ libGL libGLU ] ++ optional alsaSupport alsaLib ++ optional pulseaudioSupport libpulseaudio ++ optional stdenv.isDarwin Cocoa; buildInputs = [ ] - ++ optional (!stdenv.hostPlatform.isMinGW) audiofile + ++ optional (!stdenv.hostPlatform.isMinGW && alsaSupport) audiofile ++ optionals stdenv.isDarwin [ AudioUnit CoreAudio CoreServices Kernel OpenGL # Needed for NSDefaultRunLoopMode symbols. diff --git a/pkgs/development/libraries/SDL2/default.nix b/pkgs/development/libraries/SDL2/default.nix index d82b25fb892..8f1b7d93d00 100644 --- a/pkgs/development/libraries/SDL2/default.nix +++ b/pkgs/development/libraries/SDL2/default.nix @@ -1,12 +1,16 @@ { stdenv, config, libGLSupported, fetchurl, pkgconfig , openglSupport ? libGLSupported, libGL -, alsaSupport ? stdenv.isLinux, alsaLib -, x11Support ? !stdenv.isCygwin, libX11, xorgproto, libICE, libXi, libXScrnSaver, libXcursor, libXinerama, libXext, libXxf86vm, libXrandr -, waylandSupport ? stdenv.isLinux, wayland, wayland-protocols, libxkbcommon -, dbusSupport ? stdenv.isLinux, dbus +, alsaSupport ? stdenv.isLinux && !stdenv.hostPlatform.isAndroid, alsaLib +, x11Support ? !stdenv.isCygwin && !stdenv.hostPlatform.isAndroid +, libX11, xorgproto, libICE, libXi, libXScrnSaver, libXcursor +, libXinerama, libXext, libXxf86vm, libXrandr +, waylandSupport ? stdenv.isLinux && !stdenv.hostPlatform.isAndroid +, wayland, wayland-protocols, libxkbcommon +, dbusSupport ? stdenv.isLinux && !stdenv.hostPlatform.isAndroid, dbus , udevSupport ? false, udev , 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 , audiofile, cf-private, libiconv }: @@ -16,9 +20,6 @@ with stdenv.lib; -assert !stdenv.isDarwin -> alsaSupport || pulseaudioSupport; -assert openglSupport -> (stdenv.isDarwin || x11Support && libGL != null); - stdenv.mkDerivation rec { name = "SDL2-${version}"; version = "2.0.9"; @@ -44,14 +45,14 @@ stdenv.mkDerivation rec { ++ optionals x11Support [ libX11 xorgproto ]; dlopenBuildInputs = [ ] - ++ optional alsaSupport alsaLib + ++ optionals alsaSupport [ alsaLib audiofile ] ++ optional dbusSupport dbus ++ optional pulseaudioSupport libpulseaudio ++ optional udevSupport udev ++ optionals waylandSupport [ wayland wayland-protocols libxkbcommon ] ++ optionals x11Support [ libICE libXi libXScrnSaver libXcursor libXinerama libXext libXrandr libXxf86vm ]; - buildInputs = [ audiofile libiconv ] + buildInputs = [ libiconv ] ++ dlopenBuildInputs ++ optional ibusSupport ibus ++ optionals stdenv.isDarwin [ diff --git a/pkgs/development/libraries/mesa-glu/default.nix b/pkgs/development/libraries/mesa-glu/default.nix index 4e35d6ed24d..cb238a6a5ae 100644 --- a/pkgs/development/libraries/mesa-glu/default.nix +++ b/pkgs/development/libraries/mesa-glu/default.nix @@ -22,5 +22,6 @@ stdenv.mkDerivation rec { homepage = https://cgit.freedesktop.org/mesa/glu/; license = stdenv.lib.licenses.sgi-b-20; platforms = stdenv.lib.platforms.unix; + broken = stdenv.hostPlatform.isAndroid; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4ca0101f309..9ce80e4640e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11650,8 +11650,11 @@ in ## libGL/libGLU/Mesa stuff - # Default libGL implementation, should provide headers and libGL.so/libEGL.so/... to link agains them - libGL = mesa_noglu.stubs; + # Default libGL implementation, should provide headers and + # 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 libGLU = mesa_glu; @@ -12453,10 +12456,13 @@ in schroedinger = callPackage ../development/libraries/schroedinger { }; - SDL = callPackage ../development/libraries/SDL { + SDL = callPackage ../development/libraries/SDL ({ inherit (darwin) cf-private; inherit (darwin.apple_sdk.frameworks) OpenGL CoreAudio CoreServices AudioUnit Kernel Cocoa; - }; + } // lib.optionalAttrs stdenv.hostPlatform.isAndroid { + # libGLU doesn’t work with Android’s SDL + libGLU = null; + }); SDL_sixel = callPackage ../development/libraries/SDL_sixel { };