Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SDL from Homebrew package manager on macOS #60

Merged
merged 4 commits into from
Dec 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ able to use the library however they wish without restrictions.

There are a number of variables which can be set to control the compilation:

* SDL_PLATFORM = Can be set to one of the following values: linux, windows, macosx, ios or android
* SDL_PLATFORM = Can be set to one of the following values: linux, windows, macosx, macos_homebrew, ios or android
* SDL_MODE = Can be one of: debug or release. Defaults to debug.

```
Expand Down
19 changes: 17 additions & 2 deletions build/gnat/sdlada.gpr
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
library project SDLAda is
type Platform_Type is ("linux", "bsd", "windows", "macosx", "ios", "android");
type Platform_Type is ("linux", "bsd", "windows", "macosx", "macos_homebrew", "ios", "android");
type Mode_Type is ("debug", "release");

Platform : Platform_Type := external ("SDL_PLATFORM", "linux");
Mode : Mode_Type := external ("SDL_MODE", "debug");

Source_Platform := "";

case Platform is
when "macos_homebrew" =>
Source_Platform := "../../src/macosx";

when others =>
Source_Platform := "../../src/" & Platform;
end case;

for Languages use ("Ada", "C");
for Source_Dirs use ("../../src", "../../src/" & Platform, "gen/src/",
for Source_Dirs use ("../../src", Source_Platform, "gen/src/",

-- For SDL.Image.
"../../src/image",
Expand Down Expand Up @@ -37,6 +47,11 @@ library project SDLAda is
when "linux" | "bsd" | "android" | "windows" =>
C_Switches := C_Switches & ("-I/usr/include/SDL2", "-D_REENTRANT");

when "macos_homebrew" =>
C_Switches := C_Switches & ("-DSDL_HOMEBREW",
"-I/usr/local/include/SDL2",
"-D_REENTRANT");

when others =>
null;
end case;
Expand Down
18 changes: 18 additions & 0 deletions build/gnat/tests.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,22 @@ project Tests is
"ttf.adb");

package Compiler renames SDLAda.Compiler;

package Linker is

Linker_Switches := ();

case Sdlada.Platform is
when "macos_homebrew" =>
Linker_Switches := Linker_Switches & ("-lSDL2",
"-lSDL2_ttf",
"-lSDL2_image");
when others =>
null;
end case;

for Switches ("Ada") use Linker_Switches;

end Linker;

end Tests;
2 changes: 1 addition & 1 deletion src/image/version_images.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* 3. This notice may not be removed or altered from any source
* distribution.
**********************************************************************************************************************/
#ifdef __APPLE__
#if defined(__APPLE__) && !defined (SDL_HOMEBREW)
#include <SDL2_image/SDL_image.h>
#else
#include <SDL_image.h>
Expand Down
2 changes: 1 addition & 1 deletion src/ttf/version_ttf.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* 3. This notice may not be removed or altered from any source
* distribution.
**********************************************************************************************************************/
#ifdef __APPLE__
#if defined(__APPLE__) && !defined(SDL_HOMEBREW)
#include <SDL2_ttf/SDL_ttf.h>
#else
#include <SDL_ttf.h>
Expand Down