|
1 | 1 | #!/usr/bin/env bash |
2 | | -set -e |
| 2 | +set -euo pipefail |
3 | 3 |
|
4 | 4 | DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" |
5 | 5 | cd "$DIR" |
6 | 6 |
|
7 | 7 | INSTALL_DIR="$DIR/raylib/install" |
8 | 8 |
|
9 | 9 | NJOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)" |
10 | | -CC="ccache ${CC:-cc}" |
| 10 | +if command -v ccache &>/dev/null; then |
| 11 | + CC="ccache ${CC:-cc}" |
| 12 | +else |
| 13 | + CC="${CC:-cc}" |
| 14 | +fi |
| 15 | + |
| 16 | +is_linux_aarch64() { |
| 17 | + [[ "$(uname)" == "Linux" && ( "$(uname -m)" == "aarch64" || "$(uname -m)" == "arm64" ) ]] |
| 18 | +} |
11 | 19 |
|
12 | | -# Detect platform: PLATFORM_COMMA for comma devices, PLATFORM_DESKTOP otherwise |
13 | | -RAYLIB_PLATFORM="${RAYLIB_PLATFORM:-PLATFORM_DESKTOP}" |
14 | | -if [ -f /TICI ]; then |
15 | | - RAYLIB_PLATFORM="PLATFORM_COMMA" |
| 20 | +if [ -n "${RAYLIB_PLATFORM:-}" ]; then |
| 21 | + echo "RAYLIB_PLATFORM is no longer supported; use RAYLIB_BACKEND=desktop or RAYLIB_BACKEND=comma" >&2 |
| 22 | + exit 1 |
16 | 23 | fi |
17 | | -export RAYLIB_PLATFORM |
18 | | - |
19 | | -# Install build dependencies |
20 | | -if [[ "$(uname)" == "Linux" ]]; then |
21 | | - if [ "$RAYLIB_PLATFORM" = "PLATFORM_COMMA" ]; then |
22 | | - # comma device: needs DRM/EGL/GLES headers (usually already present on AGNOS) |
23 | | - # apt may fail on devices due to read-only rootfs or package conflicts — that's OK |
24 | | - if command -v apt-get &>/dev/null; then |
25 | | - if [ "$(id -u)" -eq 0 ]; then |
26 | | - apt-get update && apt-get install -y libdrm-dev libgbm-dev libgles2-mesa-dev libegl1-mesa-dev || true |
27 | | - else |
28 | | - sudo apt-get update && sudo apt-get install -y libdrm-dev libgbm-dev libgles2-mesa-dev libegl1-mesa-dev || true |
29 | | - fi |
30 | | - fi |
31 | | - elif [ "$RAYLIB_PLATFORM" = "PLATFORM_OFFSCREEN" ]; then |
32 | | - # offscreen (CI): needs EGL/GL dev packages (no X11) |
33 | | - if command -v apt-get &>/dev/null; then |
34 | | - if [ "$(id -u)" -eq 0 ]; then |
35 | | - apt-get update && apt-get install -y libegl-dev libgl-dev |
36 | | - else |
37 | | - sudo apt-get update && sudo apt-get install -y libegl-dev libgl-dev |
38 | | - fi |
39 | | - fi |
40 | | - else |
41 | | - # desktop: needs X11/GL dev packages |
42 | | - if command -v dnf &>/dev/null; then |
43 | | - dnf install -y libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel libXi-devel mesa-libGL-devel |
44 | | - elif command -v apt-get &>/dev/null; then |
45 | | - if [ "$(id -u)" -eq 0 ]; then |
46 | | - apt-get update && apt-get install -y libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev libgl-dev |
47 | | - else |
48 | | - sudo apt-get update && sudo apt-get install -y libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev libgl-dev |
49 | | - fi |
50 | | - fi |
| 24 | + |
| 25 | +RAYLIB_BACKEND="${RAYLIB_BACKEND:-}" |
| 26 | +if [ -z "$RAYLIB_BACKEND" ]; then |
| 27 | + RAYLIB_BACKEND="desktop" |
| 28 | + if [ -f /AGNOS ] || [ -f /TICI ]; then |
| 29 | + RAYLIB_BACKEND="comma" |
51 | 30 | fi |
52 | 31 | fi |
53 | 32 |
|
| 33 | +case "$RAYLIB_BACKEND" in |
| 34 | + desktop|comma) ;; |
| 35 | + *) |
| 36 | + echo "Unsupported RAYLIB_BACKEND=$RAYLIB_BACKEND; expected desktop or comma" >&2 |
| 37 | + exit 1 |
| 38 | + ;; |
| 39 | +esac |
| 40 | + |
54 | 41 | # Clone and build raylib C library |
55 | | -RAYLIB_COMMIT="d9d7cc1353ec0f73c97e84ddf0973983d1ee25e2" |
| 42 | +RAYLIB_COMMIT="dff603f4f122163900469e73d113deacd9ec9817" |
56 | 43 |
|
57 | 44 | if [ ! -d "raylib-src/.git" ]; then |
58 | 45 | rm -rf raylib-src |
59 | | - git clone --depth 1 -b platform-offscreen --no-tags https://github.com/commaai/raylib.git raylib-src |
| 46 | + git clone --depth 1 -b master --no-tags https://github.com/commaai/raylib.git raylib-src |
60 | 47 | fi |
61 | 48 |
|
62 | 49 | cd raylib-src |
| 50 | +git remote set-url origin https://github.com/commaai/raylib.git |
63 | 51 | git fetch --depth 1 origin "$RAYLIB_COMMIT" |
64 | 52 | git reset --hard "$RAYLIB_COMMIT" |
65 | 53 |
|
66 | | -cd src |
67 | | -make clean |
68 | | -make -j"$NJOBS" PLATFORM="$RAYLIB_PLATFORM" CC="${CC:-gcc}" |
69 | | - |
70 | 54 | cd "$DIR" |
71 | 55 |
|
72 | 56 | # Install lib + headers |
73 | 57 | rm -rf "$INSTALL_DIR" |
74 | 58 | mkdir -p "$INSTALL_DIR"/{lib,include} |
75 | 59 |
|
76 | | -cp raylib-src/src/libraylib.a "$INSTALL_DIR/lib/" |
77 | 60 | cp raylib-src/src/raylib.h raylib-src/src/raymath.h raylib-src/src/rlgl.h "$INSTALL_DIR/include/" |
78 | 61 |
|
79 | | -# On x86_64 Linux, also build the offscreen variant for CI headless rendering |
80 | | -if [[ "$(uname)" == "Linux" && "$(uname -m)" == "x86_64" && "$RAYLIB_PLATFORM" != "PLATFORM_OFFSCREEN" ]]; then |
81 | | - echo "Building offscreen variant..." |
82 | | - |
83 | | - # Install EGL/GL dev packages needed for offscreen build + bundling |
84 | | - if command -v dnf &>/dev/null; then |
85 | | - dnf install -y mesa-libEGL-devel mesa-libGL-devel libglvnd-opengl libglvnd-core-devel 2>/dev/null || true |
86 | | - elif command -v apt-get &>/dev/null; then |
87 | | - if [ "$(id -u)" -eq 0 ]; then |
88 | | - apt-get update && apt-get install -y libegl-dev libgl-dev |
89 | | - else |
90 | | - sudo apt-get update && sudo apt-get install -y libegl-dev libgl-dev |
91 | | - fi |
92 | | - fi |
| 62 | +build_raylib() { |
| 63 | + local platform="$1" |
| 64 | + local output="$2" |
93 | 65 |
|
94 | | - cd raylib-src/src |
| 66 | + cd "$DIR/raylib-src/src" |
95 | 67 | make clean |
96 | | - make -j"$NJOBS" PLATFORM=PLATFORM_OFFSCREEN CC="${CC:-gcc}" |
97 | | - cp libraylib.a "$INSTALL_DIR/lib/libraylib_offscreen.a" |
| 68 | + make -j"$NJOBS" PLATFORM="$platform" CC="${CC:-gcc}" |
| 69 | + cp libraylib.a "$INSTALL_DIR/lib/$output" |
98 | 70 | cd "$DIR" |
| 71 | +} |
| 72 | + |
| 73 | +if is_linux_aarch64; then |
| 74 | + echo "Building desktop backend..." |
| 75 | + build_raylib PLATFORM_DESKTOP libraylib_desktop.a |
99 | 76 |
|
100 | | - # Bundle GLVND dispatchers so offscreen rendering works without extra system packages |
101 | | - MESA_DIR="$INSTALL_DIR/lib/mesa" |
102 | | - mkdir -p "$MESA_DIR" |
103 | | - ldconfig 2>/dev/null || true |
104 | | - for lib in libEGL.so.1 libOpenGL.so.0 libGLdispatch.so.0; do |
105 | | - src="$(ldconfig -p 2>/dev/null | grep "$lib" | grep -E 'x86.64|libc6,' | awk '{print $NF}' | head -1)" |
106 | | - if [ -n "$src" ] && [ -f "$src" ]; then |
107 | | - cp -L "$src" "$MESA_DIR/" |
108 | | - # Create unversioned symlink for the linker |
109 | | - base="${lib%%.so.*}" |
110 | | - ln -sf "$lib" "$MESA_DIR/${base}.so" |
111 | | - fi |
112 | | - done |
| 77 | + echo "Building comma backend..." |
| 78 | + build_raylib PLATFORM_COMMA libraylib_comma.a |
| 79 | +else |
| 80 | + if [ "$RAYLIB_BACKEND" = "comma" ]; then |
| 81 | + build_raylib PLATFORM_COMMA libraylib_comma.a |
| 82 | + else |
| 83 | + build_raylib PLATFORM_DESKTOP libraylib_desktop.a |
| 84 | + fi |
113 | 85 | fi |
114 | 86 |
|
115 | 87 | # Download raygui header |
116 | | -RAYGUI_COMMIT="76b36b597edb70ffaf96f046076adc20d67e7827" |
| 88 | +RAYGUI_COMMIT="1e03efca48c50c5ea4b4a053d5bf04bad58d3e43" |
117 | 89 | curl -fsSLo "$INSTALL_DIR/include/raygui.h" \ |
118 | 90 | "https://raw.githubusercontent.com/raysan5/raygui/$RAYGUI_COMMIT/src/raygui.h" |
119 | 91 |
|
|
0 commit comments