Unverified Commit f3063470 authored by 7c6f434c's avatar 7c6f434c Committed by GitHub
Browse files

love2d: add Darwin platform support (#444969)

parents 5f03e425 a2877cb3
Loading
Loading
Loading
Loading
+25 −6
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
  libGL,
  openal,
  luajit,
  lua5_1,
  freetype,
  physfs,
  libmodplug,
@@ -40,11 +41,8 @@ stdenv.mkDerivation rec {
  ];
  buildInputs = [
    SDL2
    xorg.libX11 # SDl2 optional depend, for SDL_syswm.h
    libGLU
    libGL
    openal
    luajit
    (if stdenv.isDarwin then lua5_1 else luajit)
    freetype
    physfs
    libmodplug
@@ -54,22 +52,43 @@ stdenv.mkDerivation rec {
    libtheora
    which
    libtool
  ]
  ++ lib.optionals stdenv.isLinux [
    xorg.libX11 # SDL2 optional depend, for SDL_syswm.h
    libGLU
    libGL
  ];

  preConfigure = "$shell ./platform/unix/automagic";

  configureFlags = [
    "--with-lua=luajit"
    (if stdenv.isDarwin then "--with-lua=lua" else "--with-lua=luajit")
  ];

  env.NIX_CFLAGS_COMPILE = "-DluaL_reg=luaL_Reg"; # needed since luajit-2.1.0-beta3

  # Fix Darwin bundle/dylib linking and macOS function calls
  preBuild = lib.optionalString stdenv.isDarwin ''
    # Fix libtool to use dynamiclib instead of bundle for Darwin
    substituteInPlace libtool \
      --replace "-bundle" "-dynamiclib" \
      --replace "-Wl,-bundle" "-Wl,-dynamiclib"

    substituteInPlace src/love.cpp \
      --replace "love::macosx::checkDropEvents()" "std::string(\"\")" \
      --replace "love::macosx::getLoveInResources()" "std::string(\"\")"
  '';

  postFixup = lib.optionalString stdenv.isDarwin ''
    install_name_tool -change ".libs/liblove-11.5.so" "$out/lib/liblove-11.5.so" "$out/bin/love"
  '';

  meta = {
    homepage = "https://love2d.org";
    description = "Lua-based 2D game engine/scripting language";
    mainProgram = "love";
    license = lib.licenses.zlib;
    platforms = lib.platforms.linux;
    platforms = lib.platforms.linux ++ lib.platforms.darwin;
    maintainers = [ lib.maintainers.raskin ];
  };
}