Skip to content

Commit

Permalink
try
Browse files Browse the repository at this point in the history
  • Loading branch information
electronstudio committed Oct 16, 2024
1 parent 2154d36 commit b0da316
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 176 deletions.
17 changes: 8 additions & 9 deletions raylib/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
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
Expand Down Expand Up @@ -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"
Expand All @@ -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"
"""
Expand Down Expand Up @@ -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))


Expand All @@ -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 = []
Expand All @@ -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
Expand All @@ -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())
Expand All @@ -211,7 +210,7 @@ def build_windows():
#include "raymath.h"
"""

if not USE_SDL2:
if RAYLIB_PLATFORM=="Desktop":
ffi_includes += """
#include "GLFW/glfw3.h"
"""
Expand All @@ -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))
Expand Down
Loading

0 comments on commit b0da316

Please sign in to comment.