* raylib: add PLATFORM_OFFSCREEN support for headless CI rendering - build.sh: use commaai/raylib platform-offscreen commit, build offscreen variant (libraylib_offscreen.a) alongside desktop for x86_64, bundle GLVND dispatchers (libEGL, libOpenGL, libGLdispatch) in install/lib/mesa/ - build.py: add PLATFORM_OFFSCREEN elif — uses offscreen lib + bundled GLVND with RPATH, links -lOpenGL -lEGL instead of -lGL -lX11 - __init__.py: auto-rebuild CFFI when RAYLIB_PLATFORM env changes (tracks built platform in .raylib_platform marker file) - Bump version to 5.5.0.5 This lets openpilot CI render headlessly via EGL surfaceless + Mesa llvmpipe without needing xvfb or any additional apt packages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * raylib: auto-detect CI and use PLATFORM_OFFSCREEN __init__.py now auto-detects CI on Linux x86_64 and uses PLATFORM_OFFSCREEN + LIBGL_ALWAYS_SOFTWARE=1 automatically. No env vars needed in the consuming CI workflow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
72 lines
2.3 KiB
Python
72 lines
2.3 KiB
Python
import os
|
|
import platform as _platform
|
|
|
|
DIR = os.path.join(os.path.dirname(__file__), "install")
|
|
LIB_DIR = os.path.join(DIR, "lib")
|
|
INCLUDE_DIR = os.path.join(DIR, "include")
|
|
|
|
|
|
def _detect_platform():
|
|
"""Auto-detect the raylib platform. In CI on Linux x86_64, use offscreen EGL rendering."""
|
|
explicit = os.environ.get("RAYLIB_PLATFORM", "")
|
|
if explicit:
|
|
return explicit
|
|
if os.environ.get("CI") and _platform.system() == "Linux" and _platform.machine() == "x86_64":
|
|
return "PLATFORM_OFFSCREEN"
|
|
return ""
|
|
|
|
|
|
def smoketest():
|
|
assert os.path.isfile(os.path.join(LIB_DIR, "libraylib.a")), "libraylib.a not found"
|
|
assert os.path.isfile(os.path.join(INCLUDE_DIR, "raylib.h")), "raylib.h not found"
|
|
|
|
|
|
# Build CFFI extension on first import if not already compiled,
|
|
# or rebuild if the target platform changed since last build.
|
|
def _ensure_cffi_built():
|
|
import glob
|
|
import subprocess
|
|
import sys
|
|
pkg_dir = os.path.dirname(__file__)
|
|
platform_marker = os.path.join(pkg_dir, ".raylib_platform")
|
|
requested = _detect_platform()
|
|
|
|
# Export so build.py picks it up
|
|
if requested:
|
|
os.environ["RAYLIB_PLATFORM"] = requested
|
|
# Mesa llvmpipe for software rendering in headless CI
|
|
if requested == "PLATFORM_OFFSCREEN":
|
|
os.environ.setdefault("LIBGL_ALWAYS_SOFTWARE", "1")
|
|
|
|
cffi_files = glob.glob(os.path.join(pkg_dir, "_raylib_cffi*"))
|
|
|
|
# Rebuild if platform changed
|
|
if cffi_files and requested:
|
|
built_for = open(platform_marker).read().strip() if os.path.isfile(platform_marker) else ""
|
|
if built_for != requested:
|
|
for f in cffi_files:
|
|
os.remove(f)
|
|
cffi_files = []
|
|
|
|
if not cffi_files:
|
|
build_script = os.path.join(pkg_dir, "build.py")
|
|
if os.path.isfile(build_script) and os.path.isfile(os.path.join(LIB_DIR, "libraylib.a")):
|
|
try:
|
|
subprocess.check_call([sys.executable, build_script], cwd=os.path.dirname(pkg_dir))
|
|
with open(platform_marker, "w") as f:
|
|
f.write(requested)
|
|
except subprocess.CalledProcessError:
|
|
pass
|
|
|
|
_ensure_cffi_built()
|
|
|
|
# CFFI bindings (available when graphics libraries are present)
|
|
try:
|
|
from ._raylib_cffi import ffi, lib as rl
|
|
from raylib._raylib_cffi.lib import * # noqa: F403
|
|
from raylib.colors import * # noqa: F403
|
|
from raylib.defines import * # noqa: F403
|
|
from .version import __version__
|
|
except (ImportError, OSError):
|
|
pass
|