lispgames / cl-sdl2-mixer

Bindings for SDL2_mixer
MIT License
12 stars 11 forks source link

Add spec aarch64-apple-darwin9 (Apple Silicon) #13

Closed iamFIREcracker closed 3 weeks ago

iamFIREcracker commented 1 month ago

This PR adds specs for Apple Silicon, finally making it possible to run Sketch on newer macs (see related links below). Also, tested on a MacBook Air M2 and it all seems to be working just fine.

Steps to regenerate the specs (I used nix)

First off, force quicklisp to use a version of cl-sdl2 which supports Apple Silicon (e.g., you can clone my fork into ~/quicklisp/local-projects, or wherever your quicklisp installation lives). Note: you won't need this step anymore once changes are merged upstream (see: https://github.com/lispgames/cl-sdl2/pull/167).

ln -s ~/Workspace/cl-sdl2 .quicklisp/local-projects/

Next, drop the following lines in a file named shell.nix at the root of the repository, and then, in the same directory, run nix-shell (this will take care of installing SDL2_mixer and c2ffi).

shell.nix ``` let pkgs = import ( fetchTarball { name = "2024-06-04"; url = "https://github.com/NixOS/nixpkgs/archive/7cd59482fa339f91017a78ca1bdc253c8c70e891.tar.gz"; } ) {}; in pkgs.mkShell { packages = [ pkgs.SDL2 pkgs.SDL2_mixer pkgs.c2ffi pkgs.sbcl ]; LD_LIBRARY_PATH = "${pkgs.SDL2}/lib:${pkgs.SDL2_mixer}/lib"; /* SDL2/SDL2_mixer would import SDL like "SDL_stdinc.h" and not like "SDL2/SDL_stdinc.h" so to let c2ffi resolve that import correctly, we need to include ${pkgs.SDL2.dev}/include/SDL2 and not ${pkgs.SDL2.dev}/include */ C_INCLUDE_PATH = "${pkgs.SDL2.dev}/include/SDL2:${pkgs.SDL2_mixer.dev}/include"; } ```

Remove the already existing specs (autowrap will try to generate the spec files only if missing):

$ rm -f src/spec/SDL_mixer.*.spec

Load :SDL2-MIXER (this will get autowrap to generate the various spec files:

$ sbcl \
    --load "sdl2-mixer.asd" \
    --eval "(ql:quickload '(:sdl2-mixer))" \
    --eval "(uiop:quit)"
iamFIREcracker commented 1 month ago

Fixes: #12

fitzsim commented 3 weeks ago

This looks good. But I as am testing it I get this error which seems totally unrelated to your changes:

SDL2-MIXER(4): (autowrap:define-bitmask-from-enum (init-flags sdl2-ffi:mix-init-flags))

debugger invoked on a SB-INT:SIMPLE-READER-PACKAGE-ERROR in thread
#<THREAD "main thread" RUNNING {100257071C}>:
  Symbol "MIX-INIT-FLAGS" not found in the SDL2-FFI package.

This seems to fix it, but why doesn't anyone else need this?

--- a/src/autowrap.lisp
+++ b/src/autowrap.lisp
@@ -15,6 +15,7 @@
                    (uiop:split-string (uiop:getenv "C_INCLUDE_PATH") :separator ":")))
   :include-sources ("SDL_mixer.h")
   :exclude-constants ("^(?!MIX)")
-  :symbol-exceptions (("SDL_RWops" . "SDL-RWOPS"))
+  :symbol-exceptions (("SDL_RWops" . "SDL-RWOPS")
+                      ("MIX_InitFlags" . "MIX-INIT-FLAGS"))

I am using this Debian version of SDL2 mixer:

libsdl2-mixer-dev:ppc64el 2.6.2+dfsg-2
fitzsim commented 3 weeks ago

It is not directly related to your patch but could you please try that mix-init-flags patch and confirm it does not break things for you? If so, I will push it too separately.

fitzsim commented 3 weeks ago

This looks good. But I as am testing it I get this error which seems totally unrelated to your changes:

SDL2-MIXER(4): (autowrap:define-bitmask-from-enum (init-flags sdl2-ffi:mix-init-flags))

debugger invoked on a SB-INT:SIMPLE-READER-PACKAGE-ERROR in thread
#<THREAD "main thread" RUNNING {100257071C}>:
  Symbol "MIX-INIT-FLAGS" not found in the SDL2-FFI package.

This seems to fix it, but why doesn't anyone else need this?

There is newer patch to try in #6.