Compare commits
1 Commits
master
...
raylib-uni
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47e6adeb3d |
143
raylib/build.sh
143
raylib/build.sh
@@ -1,5 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -euo pipefail
|
||||||
|
|
||||||
|
export SOURCE_DATE_EPOCH=0
|
||||||
|
export ZERO_AR_DATE=1
|
||||||
|
|
||||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
|
||||||
cd "$DIR"
|
cd "$DIR"
|
||||||
@@ -7,30 +10,36 @@ cd "$DIR"
|
|||||||
INSTALL_DIR="$DIR/raylib/install"
|
INSTALL_DIR="$DIR/raylib/install"
|
||||||
|
|
||||||
NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"
|
NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"
|
||||||
CC="ccache ${CC:-cc}"
|
if command -v ccache >/dev/null 2>&1; then
|
||||||
|
CC="${CC:-ccache cc}"
|
||||||
# Detect platform: PLATFORM_COMMA for comma devices, PLATFORM_DESKTOP otherwise
|
else
|
||||||
RAYLIB_PLATFORM="${RAYLIB_PLATFORM:-PLATFORM_DESKTOP}"
|
CC="${CC:-cc}"
|
||||||
if [ -f /TICI ]; then
|
|
||||||
RAYLIB_PLATFORM="PLATFORM_COMMA"
|
|
||||||
fi
|
fi
|
||||||
export RAYLIB_PLATFORM
|
|
||||||
|
|
||||||
# Install build dependencies
|
is_linux() {
|
||||||
if [[ "$(uname)" == "Linux" ]]; then
|
[[ "$(uname)" == "Linux" ]]
|
||||||
if [ "$RAYLIB_PLATFORM" = "PLATFORM_COMMA" ]; then
|
}
|
||||||
|
|
||||||
|
install_linux_deps() {
|
||||||
|
local platform="$1"
|
||||||
|
if ! is_linux; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$platform" = "PLATFORM_COMMA" ]; then
|
||||||
# comma device: needs DRM/EGL/GLES headers (usually already present on AGNOS)
|
# comma device: needs DRM/EGL/GLES headers (usually already present on AGNOS)
|
||||||
# apt may fail on devices due to read-only rootfs or package conflicts — that's OK
|
# apt may fail on devices due to read-only rootfs or package conflicts; that's OK.
|
||||||
if command -v apt-get &>/dev/null; then
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
if [ "$(id -u)" -eq 0 ]; then
|
if [ "$(id -u)" -eq 0 ]; then
|
||||||
apt-get update && apt-get install -y libdrm-dev libgbm-dev libgles2-mesa-dev libegl1-mesa-dev || true
|
apt-get update && apt-get install -y libdrm-dev libgbm-dev libgles2-mesa-dev libegl1-mesa-dev || true
|
||||||
else
|
else
|
||||||
sudo apt-get update && sudo apt-get install -y libdrm-dev libgbm-dev libgles2-mesa-dev libegl1-mesa-dev || true
|
sudo apt-get update && sudo apt-get install -y libdrm-dev libgbm-dev libgles2-mesa-dev libegl1-mesa-dev || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
elif [ "$RAYLIB_PLATFORM" = "PLATFORM_OFFSCREEN" ]; then
|
elif [ "$platform" = "PLATFORM_OFFSCREEN" ]; then
|
||||||
# offscreen (CI): needs EGL/GL dev packages (no X11)
|
if command -v dnf >/dev/null 2>&1; then
|
||||||
if command -v apt-get &>/dev/null; then
|
dnf install -y mesa-libEGL-devel mesa-libGL-devel libglvnd-opengl libglvnd-core-devel 2>/dev/null || true
|
||||||
|
elif command -v apt-get >/dev/null 2>&1; then
|
||||||
if [ "$(id -u)" -eq 0 ]; then
|
if [ "$(id -u)" -eq 0 ]; then
|
||||||
apt-get update && apt-get install -y libegl-dev libgl-dev
|
apt-get update && apt-get install -y libegl-dev libgl-dev
|
||||||
else
|
else
|
||||||
@@ -38,10 +47,9 @@ if [[ "$(uname)" == "Linux" ]]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# desktop: needs X11/GL dev packages
|
if command -v dnf >/dev/null 2>&1; then
|
||||||
if command -v dnf &>/dev/null; then
|
|
||||||
dnf install -y libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel libXi-devel mesa-libGL-devel
|
dnf install -y libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel libXi-devel mesa-libGL-devel
|
||||||
elif command -v apt-get &>/dev/null; then
|
elif command -v apt-get >/dev/null 2>&1; then
|
||||||
if [ "$(id -u)" -eq 0 ]; then
|
if [ "$(id -u)" -eq 0 ]; then
|
||||||
apt-get update && apt-get install -y libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev libgl-dev
|
apt-get update && apt-get install -y libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev libgl-dev
|
||||||
else
|
else
|
||||||
@@ -49,55 +57,72 @@ if [[ "$(uname)" == "Linux" ]]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
}
|
||||||
|
|
||||||
# Clone and build raylib C library
|
# RAYLIB_COMMIT matches the openpilot third_party/raylib pin this package replaces.
|
||||||
RAYLIB_COMMIT="d9d7cc1353ec0f73c97e84ddf0973983d1ee25e2"
|
RAYLIB_COMMIT="${RAYLIB_COMMIT:-3425bd9d1fb292ede4d80f97a1f4f258f614cffc}"
|
||||||
|
RAYLIB_OFFSCREEN_COMMIT="${RAYLIB_OFFSCREEN_COMMIT:-d9d7cc1353ec0f73c97e84ddf0973983d1ee25e2}"
|
||||||
|
RAYGUI_COMMIT="${RAYGUI_COMMIT:-76b36b597edb70ffaf96f046076adc20d67e7827}"
|
||||||
|
|
||||||
if [ ! -d "raylib-src/.git" ]; then
|
if [ ! -d "raylib-src/.git" ]; then
|
||||||
rm -rf raylib-src
|
rm -rf raylib-src
|
||||||
git clone --depth 1 -b platform-offscreen --no-tags https://github.com/commaai/raylib.git raylib-src
|
git clone --depth 1 -b master --no-tags https://github.com/commaai/raylib.git raylib-src
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd raylib-src
|
|
||||||
git fetch --depth 1 origin "$RAYLIB_COMMIT"
|
|
||||||
git reset --hard "$RAYLIB_COMMIT"
|
|
||||||
|
|
||||||
cd src
|
|
||||||
make clean
|
|
||||||
make -j"$NJOBS" PLATFORM="$RAYLIB_PLATFORM" CC="${CC:-gcc}"
|
|
||||||
|
|
||||||
cd "$DIR"
|
|
||||||
|
|
||||||
# Install lib + headers
|
|
||||||
rm -rf "$INSTALL_DIR"
|
rm -rf "$INSTALL_DIR"
|
||||||
mkdir -p "$INSTALL_DIR"/{lib,include}
|
mkdir -p "$INSTALL_DIR"/{lib,include}
|
||||||
|
|
||||||
cp raylib-src/src/libraylib.a "$INSTALL_DIR/lib/"
|
if [ -n "${RAYLIB_VARIANTS:-}" ]; then
|
||||||
cp raylib-src/src/raylib.h raylib-src/src/raymath.h raylib-src/src/rlgl.h "$INSTALL_DIR/include/"
|
read -r -a VARIANTS <<< "$RAYLIB_VARIANTS"
|
||||||
|
elif [[ -f /TICI || -f /AGNOS ]]; then
|
||||||
|
VARIANTS=(comma)
|
||||||
|
elif is_linux && [[ "$(uname -m)" == "x86_64" ]]; then
|
||||||
|
VARIANTS=(desktop offscreen)
|
||||||
|
elif is_linux && [[ "$(uname -m)" == "aarch64" ]]; then
|
||||||
|
VARIANTS=(desktop comma)
|
||||||
|
else
|
||||||
|
VARIANTS=(desktop)
|
||||||
|
fi
|
||||||
|
|
||||||
# On x86_64 Linux, also build the offscreen variant for CI headless rendering
|
build_variant() {
|
||||||
if [[ "$(uname)" == "Linux" && "$(uname -m)" == "x86_64" && "$RAYLIB_PLATFORM" != "PLATFORM_OFFSCREEN" ]]; then
|
local variant="$1"
|
||||||
echo "Building offscreen variant..."
|
local platform="PLATFORM_DESKTOP"
|
||||||
|
local commit="$RAYLIB_COMMIT"
|
||||||
|
|
||||||
# Install EGL/GL dev packages needed for offscreen build + bundling
|
if [ "$variant" = "comma" ]; then
|
||||||
if command -v dnf &>/dev/null; then
|
platform="PLATFORM_COMMA"
|
||||||
dnf install -y mesa-libEGL-devel mesa-libGL-devel libglvnd-opengl libglvnd-core-devel 2>/dev/null || true
|
elif [ "$variant" = "offscreen" ]; then
|
||||||
elif command -v apt-get &>/dev/null; then
|
platform="PLATFORM_OFFSCREEN"
|
||||||
if [ "$(id -u)" -eq 0 ]; then
|
commit="$RAYLIB_OFFSCREEN_COMMIT"
|
||||||
apt-get update && apt-get install -y libegl-dev libgl-dev
|
|
||||||
else
|
|
||||||
sudo apt-get update && sudo apt-get install -y libegl-dev libgl-dev
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd raylib-src/src
|
echo "Building raylib $variant ($platform)"
|
||||||
make clean
|
install_linux_deps "$platform"
|
||||||
make -j"$NJOBS" PLATFORM=PLATFORM_OFFSCREEN CC="${CC:-gcc}"
|
|
||||||
cp libraylib.a "$INSTALL_DIR/lib/libraylib_offscreen.a"
|
|
||||||
cd "$DIR"
|
|
||||||
|
|
||||||
# Bundle GLVND dispatchers so offscreen rendering works without extra system packages
|
cd "$DIR/raylib-src"
|
||||||
|
git fetch --depth 1 origin "$commit"
|
||||||
|
git reset --hard "$commit"
|
||||||
|
git clean -xdff .
|
||||||
|
|
||||||
|
cd src
|
||||||
|
make clean
|
||||||
|
make -j"$NJOBS" PLATFORM="$platform" CC="$CC"
|
||||||
|
|
||||||
|
mkdir -p "$INSTALL_DIR/lib/$variant"
|
||||||
|
cp libraylib.a "$INSTALL_DIR/lib/$variant/libraylib.a"
|
||||||
|
if [ "$variant" = "${VARIANTS[0]}" ]; then
|
||||||
|
cp raylib.h raymath.h rlgl.h "$INSTALL_DIR/include/"
|
||||||
|
cp libraylib.a "$INSTALL_DIR/lib/libraylib.a"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
for variant in "${VARIANTS[@]}"; do
|
||||||
|
build_variant "$variant"
|
||||||
|
done
|
||||||
|
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
if is_linux && [[ "$(uname -m)" == "x86_64" && " ${VARIANTS[*]} " == *" offscreen "* ]]; then
|
||||||
MESA_DIR="$INSTALL_DIR/lib/mesa"
|
MESA_DIR="$INSTALL_DIR/lib/mesa"
|
||||||
mkdir -p "$MESA_DIR"
|
mkdir -p "$MESA_DIR"
|
||||||
ldconfig 2>/dev/null || true
|
ldconfig 2>/dev/null || true
|
||||||
@@ -105,17 +130,21 @@ if [[ "$(uname)" == "Linux" && "$(uname -m)" == "x86_64" && "$RAYLIB_PLATFORM" !
|
|||||||
src="$(ldconfig -p 2>/dev/null | grep "$lib" | grep -E 'x86.64|libc6,' | awk '{print $NF}' | head -1)"
|
src="$(ldconfig -p 2>/dev/null | grep "$lib" | grep -E 'x86.64|libc6,' | awk '{print $NF}' | head -1)"
|
||||||
if [ -n "$src" ] && [ -f "$src" ]; then
|
if [ -n "$src" ] && [ -f "$src" ]; then
|
||||||
cp -L "$src" "$MESA_DIR/"
|
cp -L "$src" "$MESA_DIR/"
|
||||||
# Create unversioned symlink for the linker
|
|
||||||
base="${lib%%.so.*}"
|
base="${lib%%.so.*}"
|
||||||
ln -sf "$lib" "$MESA_DIR/${base}.so"
|
ln -sf "$lib" "$MESA_DIR/${base}.so"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Download raygui header
|
|
||||||
RAYGUI_COMMIT="76b36b597edb70ffaf96f046076adc20d67e7827"
|
|
||||||
curl -fsSLo "$INSTALL_DIR/include/raygui.h" \
|
curl -fsSLo "$INSTALL_DIR/include/raygui.h" \
|
||||||
"https://raw.githubusercontent.com/raysan5/raygui/$RAYGUI_COMMIT/src/raygui.h"
|
"https://raw.githubusercontent.com/raysan5/raygui/$RAYGUI_COMMIT/src/raygui.h"
|
||||||
|
|
||||||
|
cat > "$INSTALL_DIR/build-info.txt" <<EOF
|
||||||
|
raylib_commit=$RAYLIB_COMMIT
|
||||||
|
raylib_offscreen_commit=$RAYLIB_OFFSCREEN_COMMIT
|
||||||
|
raygui_commit=$RAYGUI_COMMIT
|
||||||
|
variants=${VARIANTS[*]}
|
||||||
|
EOF
|
||||||
|
|
||||||
echo "Installed raylib to $INSTALL_DIR"
|
echo "Installed raylib to $INSTALL_DIR"
|
||||||
du -sh "$INSTALL_DIR"
|
du -sh "$INSTALL_DIR"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "raylib"
|
name = "raylib"
|
||||||
version = "5.5.0.8"
|
version = "5.5.0.10"
|
||||||
description = "raylib + pyray Python bindings (commaai fork)"
|
description = "raylib + pyray Python bindings (commaai fork)"
|
||||||
requires-python = ">=3.8"
|
requires-python = ">=3.8"
|
||||||
dependencies = ["cffi>=1.17.1"]
|
dependencies = ["cffi>=1.17.1"]
|
||||||
|
|||||||
@@ -1,71 +1,111 @@
|
|||||||
|
import importlib
|
||||||
import os
|
import os
|
||||||
import platform as _platform
|
import platform as _platform
|
||||||
|
|
||||||
DIR = os.path.join(os.path.dirname(__file__), "install")
|
DIR = os.path.join(os.path.dirname(__file__), "install")
|
||||||
LIB_DIR = os.path.join(DIR, "lib")
|
LIB_ROOT = os.path.join(DIR, "lib")
|
||||||
INCLUDE_DIR = os.path.join(DIR, "include")
|
INCLUDE_DIR = os.path.join(DIR, "include")
|
||||||
|
BUILD_INFO = os.path.join(DIR, "build-info.txt")
|
||||||
|
|
||||||
|
_PLATFORM_BY_VARIANT = {
|
||||||
|
"comma": "PLATFORM_COMMA",
|
||||||
|
"desktop": "PLATFORM_DESKTOP",
|
||||||
|
"offscreen": "PLATFORM_OFFSCREEN",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def _detect_platform():
|
def _normalize_variant(value):
|
||||||
"""Auto-detect the raylib platform. In CI on Linux x86_64, use offscreen EGL rendering."""
|
if value in ("PLATFORM_COMMA", "comma"):
|
||||||
explicit = os.environ.get("RAYLIB_PLATFORM", "")
|
return "comma"
|
||||||
|
if value in ("PLATFORM_OFFSCREEN", "offscreen"):
|
||||||
|
return "offscreen"
|
||||||
|
if value in ("PLATFORM_DESKTOP", "desktop", ""):
|
||||||
|
return "desktop"
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def _detect_variant():
|
||||||
|
explicit = os.environ.get("RAYLIB_VARIANT") or os.environ.get("RAYLIB_PLATFORM", "")
|
||||||
if explicit:
|
if explicit:
|
||||||
return explicit
|
return _normalize_variant(explicit)
|
||||||
|
if os.path.isfile("/TICI") or os.path.isfile("/AGNOS"):
|
||||||
|
return "comma"
|
||||||
if os.environ.get("CI") and _platform.system() == "Linux" and _platform.machine() == "x86_64":
|
if os.environ.get("CI") and _platform.system() == "Linux" and _platform.machine() == "x86_64":
|
||||||
return "PLATFORM_OFFSCREEN"
|
return "offscreen"
|
||||||
return ""
|
return "desktop"
|
||||||
|
|
||||||
|
|
||||||
|
VARIANT = _detect_variant()
|
||||||
|
LIB_DIR = os.path.join(LIB_ROOT, VARIANT)
|
||||||
|
if not os.path.isfile(os.path.join(LIB_DIR, "libraylib.a")):
|
||||||
|
LIB_DIR = LIB_ROOT
|
||||||
|
|
||||||
|
|
||||||
|
def _module_name(variant):
|
||||||
|
return f"_raylib_cffi_{variant}" if variant else "_raylib_cffi"
|
||||||
|
|
||||||
|
|
||||||
|
def _import_cffi_module():
|
||||||
|
names = [_module_name(VARIANT), "_raylib_cffi"]
|
||||||
|
seen = set()
|
||||||
|
for name in names:
|
||||||
|
if name in seen:
|
||||||
|
continue
|
||||||
|
seen.add(name)
|
||||||
|
try:
|
||||||
|
return importlib.import_module(f".{name}", __name__)
|
||||||
|
except ImportError:
|
||||||
|
continue
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def smoketest():
|
def smoketest():
|
||||||
assert os.path.isfile(os.path.join(LIB_DIR, "libraylib.a")), "libraylib.a not found"
|
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"
|
assert os.path.isfile(os.path.join(INCLUDE_DIR, "raylib.h")), "raylib.h not found"
|
||||||
|
assert os.path.isfile(os.path.join(INCLUDE_DIR, "raymath.h")), "raymath.h not found"
|
||||||
|
assert os.path.isfile(os.path.join(INCLUDE_DIR, "rlgl.h")), "rlgl.h not found"
|
||||||
|
assert os.path.isfile(os.path.join(INCLUDE_DIR, "raygui.h")), "raygui.h not found"
|
||||||
|
assert os.path.isfile(BUILD_INFO), "build-info.txt not found"
|
||||||
|
try:
|
||||||
|
import _cffi_backend # noqa: F401
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
return
|
||||||
|
assert _import_cffi_module() is not None, f"CFFI module for {VARIANT} not found"
|
||||||
|
import pyray # noqa: F401
|
||||||
|
|
||||||
|
|
||||||
# Build CFFI extension on first import if not already compiled,
|
|
||||||
# or rebuild if the target platform changed since last build.
|
|
||||||
def _ensure_cffi_built():
|
def _ensure_cffi_built():
|
||||||
import glob
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
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 _import_cffi_module() is not None:
|
||||||
if requested:
|
return
|
||||||
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*"))
|
build_script = os.path.join(os.path.dirname(__file__), "build.py")
|
||||||
|
if not os.path.isfile(build_script) or not os.path.isfile(os.path.join(LIB_DIR, "libraylib.a")):
|
||||||
|
return
|
||||||
|
|
||||||
# Rebuild if platform changed
|
env = os.environ.copy()
|
||||||
if cffi_files and requested:
|
env["RAYLIB_VARIANT"] = VARIANT
|
||||||
built_for = open(platform_marker).read().strip() if os.path.isfile(platform_marker) else ""
|
env["RAYLIB_PLATFORM"] = _PLATFORM_BY_VARIANT.get(VARIANT, "PLATFORM_DESKTOP")
|
||||||
if built_for != requested:
|
env["RAYLIB_CFFI_MODULE"] = f"raylib.{_module_name(VARIANT)}"
|
||||||
for f in cffi_files:
|
|
||||||
os.remove(f)
|
try:
|
||||||
cffi_files = []
|
subprocess.check_call([sys.executable, build_script], cwd=os.path.dirname(os.path.dirname(__file__)), env=env)
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
pass
|
||||||
|
|
||||||
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()
|
_ensure_cffi_built()
|
||||||
|
|
||||||
# CFFI bindings (available when graphics libraries are present)
|
_cffi_module = _import_cffi_module()
|
||||||
try:
|
if _cffi_module is not None:
|
||||||
from ._raylib_cffi import ffi, lib as rl
|
ffi = _cffi_module.ffi
|
||||||
from raylib._raylib_cffi.lib import * # noqa: F403
|
rl = _cffi_module.lib
|
||||||
|
for _name in dir(rl):
|
||||||
|
if not _name.startswith("_"):
|
||||||
|
globals()[_name] = getattr(rl, _name)
|
||||||
|
|
||||||
from raylib.colors import * # noqa: F403
|
from raylib.colors import * # noqa: F403
|
||||||
from raylib.defines import * # noqa: F403
|
from raylib.defines import * # noqa: F403
|
||||||
from .version import __version__
|
from .version import __version__
|
||||||
except (ImportError, OSError):
|
|
||||||
pass
|
|
||||||
|
|||||||
@@ -11,8 +11,11 @@ from cffi import FFI
|
|||||||
|
|
||||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||||
RAYLIB_INCLUDE_PATH = os.path.join(HERE, "install", "include")
|
RAYLIB_INCLUDE_PATH = os.path.join(HERE, "install", "include")
|
||||||
RAYLIB_LIB_PATH = os.path.join(HERE, "install", "lib")
|
RAYLIB_VARIANT = os.getenv("RAYLIB_VARIANT", "")
|
||||||
|
RAYLIB_LIB_ROOT = os.path.join(HERE, "install", "lib")
|
||||||
|
RAYLIB_LIB_PATH = os.path.join(RAYLIB_LIB_ROOT, RAYLIB_VARIANT) if RAYLIB_VARIANT else RAYLIB_LIB_ROOT
|
||||||
RAYLIB_PLATFORM = os.getenv("RAYLIB_PLATFORM", "")
|
RAYLIB_PLATFORM = os.getenv("RAYLIB_PLATFORM", "")
|
||||||
|
RAYLIB_CFFI_MODULE = os.getenv("RAYLIB_CFFI_MODULE", "raylib._raylib_cffi")
|
||||||
|
|
||||||
ffibuilder = FFI()
|
ffibuilder = FFI()
|
||||||
|
|
||||||
@@ -105,13 +108,9 @@ def build_ffi():
|
|||||||
extra_link_args.remove('-lGL')
|
extra_link_args.remove('-lGL')
|
||||||
extra_link_args += ['-lGLESv2', '-lEGL', '-lgbm', '-ldrm']
|
extra_link_args += ['-lGLESv2', '-lEGL', '-lgbm', '-ldrm']
|
||||||
elif RAYLIB_PLATFORM == "PLATFORM_OFFSCREEN":
|
elif RAYLIB_PLATFORM == "PLATFORM_OFFSCREEN":
|
||||||
# Use offscreen variant if available, otherwise fall back to default
|
|
||||||
offscreen_lib = os.path.join(RAYLIB_LIB_PATH, 'libraylib_offscreen.a')
|
|
||||||
if os.path.isfile(offscreen_lib):
|
|
||||||
extra_link_args[extra_link_args.index('-lraylib')] = '-lraylib_offscreen'
|
|
||||||
extra_link_args.remove('-lGL')
|
extra_link_args.remove('-lGL')
|
||||||
# Use bundled GLVND dispatchers if available, with RPATH for runtime
|
# Use bundled GLVND dispatchers if available, with RPATH for runtime
|
||||||
mesa_dir = os.path.join(RAYLIB_LIB_PATH, 'mesa')
|
mesa_dir = os.path.join(RAYLIB_LIB_ROOT, 'mesa')
|
||||||
if os.path.isdir(mesa_dir):
|
if os.path.isdir(mesa_dir):
|
||||||
extra_link_args += [f'-L{mesa_dir}', f'-Wl,-rpath,$ORIGIN/install/lib/mesa']
|
extra_link_args += [f'-L{mesa_dir}', f'-Wl,-rpath,$ORIGIN/install/lib/mesa']
|
||||||
extra_link_args += ['-lOpenGL', '-lEGL']
|
extra_link_args += ['-lOpenGL', '-lEGL']
|
||||||
@@ -121,7 +120,7 @@ def build_ffi():
|
|||||||
libraries = []
|
libraries = []
|
||||||
|
|
||||||
print("extra_link_args: " + str(extra_link_args))
|
print("extra_link_args: " + str(extra_link_args))
|
||||||
ffibuilder.set_source("raylib._raylib_cffi",
|
ffibuilder.set_source(RAYLIB_CFFI_MODULE,
|
||||||
ffi_includes,
|
ffi_includes,
|
||||||
py_limited_api=True,
|
py_limited_api=True,
|
||||||
include_dirs=[RAYLIB_INCLUDE_PATH],
|
include_dirs=[RAYLIB_INCLUDE_PATH],
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
__version__ = "5.5.0.8"
|
__version__ = "5.5.0.10"
|
||||||
|
|||||||
@@ -18,15 +18,37 @@ class BuildRaylib(build_py):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
raylib_pkg_dir = os.path.join(pkg_dir, "raylib")
|
||||||
build_script = os.path.join(pkg_dir, "build.sh")
|
build_script = os.path.join(pkg_dir, "build.sh")
|
||||||
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
|
||||||
|
|
||||||
# Build CFFI extension so it's included in the wheel
|
# Build CFFI extensions so they are included in the wheel, and make sure stale
|
||||||
cffi_so = glob.glob(os.path.join(pkg_dir, "raylib", "_raylib_cffi*"))
|
# local extensions from another raylib platform do not leak into the wheel.
|
||||||
if not cffi_so:
|
for path in glob.glob(os.path.join(raylib_pkg_dir, "_raylib_cffi*")):
|
||||||
build_cffi = os.path.join(pkg_dir, "raylib", "build.py")
|
os.remove(path)
|
||||||
if os.path.isfile(build_cffi):
|
|
||||||
subprocess.check_call([sys.executable, build_cffi], cwd=pkg_dir)
|
build_cffi = os.path.join(raylib_pkg_dir, "build.py")
|
||||||
|
if os.path.isfile(build_cffi):
|
||||||
|
variants = [
|
||||||
|
os.path.basename(path)
|
||||||
|
for path in sorted(glob.glob(os.path.join(raylib_pkg_dir, "install", "lib", "*")))
|
||||||
|
if os.path.isfile(os.path.join(path, "libraylib.a"))
|
||||||
|
]
|
||||||
|
if not variants:
|
||||||
|
variants = [""]
|
||||||
|
|
||||||
|
platform_by_variant = {
|
||||||
|
"comma": "PLATFORM_COMMA",
|
||||||
|
"desktop": "PLATFORM_DESKTOP",
|
||||||
|
"offscreen": "PLATFORM_OFFSCREEN",
|
||||||
|
"": os.environ.get("RAYLIB_PLATFORM", ""),
|
||||||
|
}
|
||||||
|
for variant in variants:
|
||||||
|
env = os.environ.copy()
|
||||||
|
env["RAYLIB_VARIANT"] = variant
|
||||||
|
env["RAYLIB_PLATFORM"] = platform_by_variant.get(variant, "PLATFORM_DESKTOP")
|
||||||
|
env["RAYLIB_CFFI_MODULE"] = f"raylib._raylib_cffi_{variant}" if variant else "raylib._raylib_cffi"
|
||||||
|
subprocess.check_call([sys.executable, build_cffi], cwd=pkg_dir, env=env)
|
||||||
|
|
||||||
super().run()
|
super().run()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user