Skip to content

Commit 150d149

Browse files
committed
Streamline Vulkan SDK setup and dependency handling
- Transitioned CI workflow to use LunarG's official Vulkan SDK tarball for Linux. - Removed platform-specific Vulkan SDK package installations in favor of consistent tarball handling. - Added new scripts for building and installing tinygltf and KTX dependencies from source. - Updated Linux dependency scripts to standardize package installations across distributions. - Improved build instructions to use Ninja by default.
1 parent e1a1d13 commit 150d149

File tree

2 files changed

+163
-95
lines changed

2 files changed

+163
-95
lines changed

.github/workflows/simple_engine_ci.yml

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -80,37 +80,29 @@ jobs:
8080
run: |
8181
set -euo pipefail
8282
sudo apt-get update
83-
sudo apt-get install -y wget gnupg ca-certificates
84-
wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
85-
86-
# Pick the correct LunarG repo list for the runner's Ubuntu codename.
87-
codename=""
88-
if [ -f /etc/os-release ]; then
89-
. /etc/os-release
90-
codename="${VERSION_CODENAME:-}"
83+
sudo apt-get install -y curl ca-certificates xz-utils
84+
85+
echo "Downloading Vulkan SDK from LunarG..."
86+
# Use the official LunarG download endpoint (latest Linux tarball).
87+
# We avoid distro packages so this matches what students are expected to do.
88+
SDK_TGZ="${RUNNER_TEMP}/vulkansdk-linux.tar.xz"
89+
curl -L --fail -o "$SDK_TGZ" "https://sdk.lunarg.com/sdk/download/latest/linux/vulkansdk-linux-x86_64.tar.xz"
90+
91+
SDK_DIR="${RUNNER_TEMP}/VulkanSDK"
92+
rm -rf "$SDK_DIR"
93+
mkdir -p "$SDK_DIR"
94+
tar -xJf "$SDK_TGZ" -C "$SDK_DIR"
95+
96+
# The tarball extracts into a versioned subdirectory.
97+
VULKAN_SDK_PATH="$(find "$SDK_DIR" -maxdepth 1 -type d -name '1.*' | sort -r | head -n 1)"
98+
if [ -z "${VULKAN_SDK_PATH:-}" ]; then
99+
echo "Failed to locate extracted Vulkan SDK directory under $SDK_DIR" >&2
100+
exit 1
91101
fi
92-
if [ -z "$codename" ] && command -v lsb_release >/dev/null 2>&1; then
93-
codename="$(lsb_release -sc)"
94-
fi
95-
if [ -z "$codename" ]; then
96-
codename="jammy"
97-
fi
98-
99-
listUrl="https://packages.lunarg.com/vulkan/lunarg-vulkan-${codename}.list"
100-
listPath="/etc/apt/sources.list.d/lunarg-vulkan-${codename}.list"
101-
if ! sudo wget -qO "$listPath" "$listUrl"; then
102-
echo "Warning: failed to fetch ${listUrl}; falling back to jammy list"
103-
codename="jammy"
104-
listUrl="https://packages.lunarg.com/vulkan/lunarg-vulkan-${codename}.list"
105-
listPath="/etc/apt/sources.list.d/lunarg-vulkan-${codename}.list"
106-
sudo wget -qO "$listPath" "$listUrl"
107-
fi
108-
109-
sudo apt-get update
110-
sudo apt-get install -y vulkan-sdk
111102
112-
# We configure with Ninja on Linux; ensure it's available.
113-
sudo apt-get install -y ninja-build
103+
echo "VULKAN_SDK=$VULKAN_SDK_PATH" >> "$GITHUB_ENV"
104+
echo "$VULKAN_SDK_PATH/bin" >> "$GITHUB_PATH"
105+
echo "CMAKE_PREFIX_PATH=$VULKAN_SDK_PATH" >> "$GITHUB_ENV"
114106
115107
# Use the engine's dependency install scripts instead of calling vcpkg directly in CI.
116108
- name: Bootstrap vcpkg (Windows)

attachments/simple_engine/install_dependencies_linux.sh

Lines changed: 142 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -30,80 +30,158 @@ fi
3030
echo "Detected OS: $OS $VER"
3131

3232
# Function to install dependencies on Ubuntu/Debian
33+
require_vulkan_headers() {
34+
if [ -n "${VULKAN_SDK:-}" ] && [ -f "${VULKAN_SDK}/include/vulkan/vulkan.h" ]; then
35+
return 0
36+
fi
37+
if [ -f "/usr/include/vulkan/vulkan.h" ]; then
38+
return 0
39+
fi
40+
echo ""
41+
echo "Vulkan SDK (or Vulkan development headers) not found."
42+
echo "Install the Vulkan SDK from LunarG, then re-run this script."
43+
echo "https://vulkan.lunarg.com/"
44+
exit 1
45+
}
46+
47+
build_and_install_tinygltf() {
48+
if [ -f "/usr/local/lib/cmake/tinygltf/tinygltfConfig.cmake" ] || [ -f "/usr/lib/cmake/tinygltf/tinygltfConfig.cmake" ]; then
49+
return 0
50+
fi
51+
local workRoot="$1"
52+
echo "Installing tinygltf (from source)..."
53+
rm -rf "${workRoot}/tinygltf" "${workRoot}/tinygltf-build"
54+
git clone --depth 1 https://github.com/syoyo/tinygltf.git "${workRoot}/tinygltf"
55+
cmake -S "${workRoot}/tinygltf" -B "${workRoot}/tinygltf-build" -G Ninja \
56+
-DCMAKE_BUILD_TYPE=Release \
57+
-DBUILD_SHARED_LIBS=OFF \
58+
-DTINYGLTF_BUILD_LOADER_EXAMPLE=OFF \
59+
-DTINYGLTF_BUILD_GL_EXAMPLES=OFF \
60+
-DTINYGLTF_BUILD_STB_IMAGE=ON
61+
cmake --build "${workRoot}/tinygltf-build" --parallel
62+
sudo cmake --install "${workRoot}/tinygltf-build"
63+
}
64+
65+
build_and_install_ktx() {
66+
if [ -f "/usr/local/lib/cmake/KTX/KTXConfig.cmake" ] || [ -f "/usr/lib/cmake/KTX/KTXConfig.cmake" ]; then
67+
return 0
68+
fi
69+
require_vulkan_headers
70+
local workRoot="$1"
71+
echo "Installing KTX-Software (from source)..."
72+
rm -rf "${workRoot}/KTX-Software" "${workRoot}/KTX-Software-build"
73+
git clone --depth 1 --branch v4.3.2 https://github.com/KhronosGroup/KTX-Software.git "${workRoot}/KTX-Software"
74+
cmake -S "${workRoot}/KTX-Software" -B "${workRoot}/KTX-Software-build" -G Ninja \
75+
-DCMAKE_BUILD_TYPE=Release \
76+
-DBUILD_SHARED_LIBS=OFF \
77+
-DKTX_FEATURE_TESTS=OFF \
78+
-DKTX_FEATURE_TOOLS=OFF \
79+
-DKTX_FEATURE_VULKAN=ON
80+
cmake --build "${workRoot}/KTX-Software-build" --parallel
81+
sudo cmake --install "${workRoot}/KTX-Software-build"
82+
}
83+
3384
install_ubuntu_debian() {
34-
echo "Installing dependencies for Ubuntu/Debian..."
35-
36-
# Update package list
37-
sudo apt update
38-
39-
# Install build essentials
40-
sudo apt install -y build-essential cmake git
41-
42-
# Install other dependencies
43-
sudo apt install -y \
44-
libglfw3-dev \
45-
libglm-dev \
46-
libopenal-dev \
47-
libktx-dev
48-
49-
# Install Slang compiler (for shader compilation)
50-
echo "Installing Slang compiler..."
51-
if [ ! -f /usr/local/bin/slangc ]; then
52-
SLANG_VERSION="2024.1.21"
53-
wget "https://github.com/shader-slang/slang/releases/download/v${SLANG_VERSION}/slang-${SLANG_VERSION}-linux-x86_64.tar.gz"
54-
tar -xzf "slang-${SLANG_VERSION}-linux-x86_64.tar.gz"
55-
sudo cp slang/bin/slangc /usr/local/bin/
56-
sudo chmod +x /usr/local/bin/slangc
57-
rm -rf slang "slang-${SLANG_VERSION}-linux-x86_64.tar.gz"
58-
fi
85+
echo "Installing dependencies for Ubuntu/Debian..."
86+
87+
sudo apt-get update
88+
89+
sudo apt-get install -y \
90+
build-essential \
91+
cmake \
92+
git \
93+
ninja-build \
94+
pkg-config \
95+
ca-certificates \
96+
curl \
97+
zip \
98+
unzip \
99+
tar \
100+
libglfw3-dev \
101+
libglm-dev \
102+
libopenal-dev \
103+
nlohmann-json3-dev \
104+
libx11-dev \
105+
libxrandr-dev \
106+
libxinerama-dev \
107+
libxcursor-dev \
108+
libxi-dev \
109+
zlib1g-dev \
110+
libpng-dev \
111+
libzstd-dev
112+
113+
local workRoot
114+
workRoot="${HOME}/.cache/simple_engine_deps"
115+
mkdir -p "${workRoot}"
116+
117+
build_and_install_tinygltf "${workRoot}"
118+
build_and_install_ktx "${workRoot}"
119+
120+
echo ""
121+
echo "Note: This script does not install Vulkan or slangc."
122+
echo "Install the Vulkan SDK from LunarG (it includes slangc) if you need shader compilation."
59123
}
60124

61125
# Function to install dependencies on Fedora/RHEL/CentOS
62126
install_fedora_rhel() {
63127
echo "Installing dependencies for Fedora/RHEL/CentOS..."
64128

65-
# Install build essentials
66-
sudo dnf install -y gcc gcc-c++ cmake git
67-
68-
# Install Vulkan SDK
69-
echo "Installing Vulkan SDK..."
70-
sudo dnf install -y vulkan-devel vulkan-tools
71-
72-
# Install other dependencies
73-
sudo dnf install -y \
74-
glfw-devel \
75-
glm-devel \
76-
openal-soft-devel
77-
78-
# Note: Some packages might need to be built from source on RHEL/CentOS
79-
echo "Note: Some dependencies (libktx, tinygltf) may need to be built from source"
80-
echo "Please refer to the project documentation for manual installation instructions"
129+
sudo dnf install -y \
130+
gcc \
131+
gcc-c++ \
132+
cmake \
133+
git \
134+
ninja-build \
135+
pkgconf-pkg-config \
136+
glfw-devel \
137+
glm-devel \
138+
openal-soft-devel \
139+
nlohmann-json-devel \
140+
zlib-devel \
141+
libpng-devel \
142+
zstd-devel
143+
144+
local workRoot
145+
workRoot="${HOME}/.cache/simple_engine_deps"
146+
mkdir -p "${workRoot}"
147+
148+
build_and_install_tinygltf "${workRoot}"
149+
build_and_install_ktx "${workRoot}"
150+
151+
echo ""
152+
echo "Note: This script does not install Vulkan or slangc."
81153
}
82154

83155
# Function to install dependencies on Arch Linux
84156
install_arch() {
85157
echo "Installing dependencies for Arch Linux..."
86158

87-
# Update package database
88-
sudo pacman -Sy
89-
90-
# Install build essentials
91-
sudo pacman -S --noconfirm base-devel cmake git
92-
93-
# Install dependencies
94-
sudo pacman -S --noconfirm \
95-
vulkan-devel \
96-
glfw-wayland \
97-
glm \
98-
openal
99-
100-
# Install AUR packages (requires yay or another AUR helper)
101-
if command -v yay &> /dev/null; then
102-
yay -S --noconfirm libktx
103-
else
104-
echo "Note: Please install yay or another AUR helper to install libktx packages"
105-
echo "Alternatively, build these dependencies from source"
106-
fi
159+
sudo pacman -Sy
160+
161+
162+
sudo pacman -S --noconfirm \
163+
base-devel \
164+
cmake \
165+
git \
166+
ninja \
167+
pkgconf \
168+
glfw \
169+
glm \
170+
openal \
171+
nlohmann-json \
172+
zlib \
173+
libpng \
174+
zstd
175+
176+
local workRoot
177+
workRoot="${HOME}/.cache/simple_engine_deps"
178+
mkdir -p "${workRoot}"
179+
180+
build_and_install_tinygltf "${workRoot}"
181+
build_and_install_ktx "${workRoot}"
182+
183+
echo ""
184+
echo "Note: This script does not install Vulkan or slangc."
107185
}
108186

109187
# Install dependencies based on detected OS
@@ -138,9 +216,7 @@ echo "Dependencies installation completed!"
138216
echo ""
139217
echo "To build the Simple Game Engine:"
140218
echo "1. cd to the simple_engine directory"
141-
echo "2. mkdir build && cd build"
142-
echo "3. cmake .."
143-
echo "4. make -j$(nproc)"
219+
echo "2. cmake -S . -B build -G Ninja"
220+
echo "3. cmake --build build --target SimpleEngine --parallel $(nproc)"
144221
echo ""
145-
echo "Or use the provided CMake build command:"
146-
echo "cmake --build cmake-build-debug --target SimpleEngine -j 10"
222+
echo "If you have Vulkan SDK installed, shader compilation uses slangc from the SDK automatically."

0 commit comments

Comments
 (0)