This commit is contained in:
Richard Smith 2024-10-16 02:30:45 +01:00
parent 2154d36b41
commit b0da316441
5 changed files with 106 additions and 177 deletions

View file

@ -26,7 +26,6 @@ import subprocess
import time
RAYLIB_PLATFORM = os.getenv("RAYLIB_PLATFORM", "Desktop")
USE_SDL2 = True if RAYLIB_PLATFORM == "SDL" else False
def check_raylib_installed():
return subprocess.run(['pkg-config', '--exists', 'raylib'], text=True, stdout=subprocess.PIPE).returncode == 0
@ -108,7 +107,7 @@ def build_unix():
if not check_raylib_installed():
raise Exception("ERROR: raylib not found by pkg-config. Please install pkg-config and Raylib.")
if USE_SDL2 and not check_SDL_installed():
if RAYLIB_PLATFORM=="SDL" and not check_SDL_installed():
raise Exception("ERROR: SDL2 not found by pkg-config. Please install pkg-config and SDL2.")
raylib_h = get_the_include_path() + "/raylib.h"
@ -131,7 +130,7 @@ def build_unix():
"""
glfw3_h = get_the_include_path() + "/GLFW/glfw3.h"
if not USE_SDL2 and check_header_exists(glfw3_h):
if RAYLIB_PLATFORM=="Desktop" and check_header_exists(glfw3_h):
ffi_includes += """
#include "GLFW/glfw3.h"
"""
@ -159,7 +158,7 @@ def build_unix():
ffibuilder.cdef(pre_process_header(raygui_h))
if os.path.isfile(physac_h):
ffibuilder.cdef(pre_process_header(physac_h))
if not USE_SDL2 and os.path.isfile(glfw3_h):
if RAYLIB_PLATFORM=="Desktop" and os.path.isfile(glfw3_h):
ffibuilder.cdef(pre_process_header(glfw3_h))
@ -168,7 +167,7 @@ def build_unix():
extra_link_args = [get_the_lib_path() + '/libraylib.a', '-framework', 'OpenGL', '-framework', 'Cocoa',
'-framework', 'IOKit', '-framework', 'CoreFoundation', '-framework',
'CoreVideo']
if USE_SDL2:
if RAYLIB_PLATFORM=="SDL":
extra_link_args += ['/usr/local/lib/libSDL2.a', '-framework', 'CoreHaptics', '-framework', 'ForceFeedback',
'-framework', 'GameController']
libraries = []
@ -177,7 +176,7 @@ def build_unix():
print("BUILDING FOR LINUX")
extra_link_args = get_lib_flags() + [ '-lm', '-lpthread', '-lGL',
'-lrt', '-lm', '-ldl', '-lX11', '-lpthread', '-latomic']
if USE_SDL2:
if RAYLIB_PLATFORM=="SDL":
extra_link_args += ['-lSDL2']
extra_compile_args = ["-Wno-incompatible-pointer-types", "-D_CFFI_NO_LIMITED_API"]
libraries = [] # Not sure why but we put them in extra_link_args instead so *shouldnt* be needed here
@ -198,7 +197,7 @@ def build_unix():
def build_windows():
print("BUILDING FOR WINDOWS")
ffibuilder.cdef(open("raylib/raylib.h.modified").read())
if not USE_SDL2:
if RAYLIB_PLATFORM=="Desktop":
ffibuilder.cdef(open("raylib/glfw3.h.modified").read())
ffibuilder.cdef(open("raylib/rlgl.h.modified").read())
ffibuilder.cdef(open("raylib/raygui.h.modified").read())
@ -211,7 +210,7 @@ def build_windows():
#include "raymath.h"
"""
if not USE_SDL2:
if RAYLIB_PLATFORM=="Desktop":
ffi_includes += """
#include "GLFW/glfw3.h"
"""
@ -224,7 +223,7 @@ def build_windows():
#include "physac.h"
"""
libraries = ['raylib', 'gdi32', 'shell32', 'user32', 'OpenGL32', 'winmm']
if USE_SDL2:
if RAYLIB_PLATFORM=="SDL":
libraries += ['SDL2']
print("libraries: "+str(libraries))