-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cbbfa02
commit 7a18482
Showing
1 changed file
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/bin/bash | ||
|
||
set -e # Exit immediately if a command exits with a non-zero status | ||
set -u # Treat unset variables as an error when substituting | ||
set -o pipefail # Consider failures in pipes | ||
|
||
# Function to check and install dependencies for apt-based distros | ||
install_apt_dependencies() { | ||
local dependencies=("$@") | ||
for package in "${dependencies[@]}"; do | ||
if ! command -v "$package" &> /dev/null; then | ||
echo "🔍 $package is not installed. Installing..." | ||
if sudo apt-get install -y "$package"; then | ||
echo "✅ $package installed successfully." | ||
else | ||
echo "❌ Failed to install $package. Please check your package manager." | ||
exit 1 | ||
fi | ||
else | ||
echo "✅ $package is already installed." | ||
fi | ||
done | ||
} | ||
|
||
# Function to check and install dependencies for macOS | ||
install_brew_dependencies() { | ||
local dependencies=("$@") | ||
for package in "${dependencies[@]}"; do | ||
if ! command -v "$package" &> /dev/null; then | ||
echo "🔍 $package is not installed. Installing..." | ||
if brew install "$package"; then | ||
echo "✅ $package installed successfully." | ||
else | ||
echo "❌ Failed to install $package. Please check your package manager." | ||
exit 1 | ||
fi | ||
else | ||
echo "✅ $package is already installed." | ||
fi | ||
done | ||
} | ||
|
||
# Determine OS and install dependencies | ||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | ||
DEPENDENCIES=(glslc cmake ninja-build vulkan-tools libglfw3-dev libglm-dev) | ||
install_apt_dependencies "${DEPENDENCIES[@]}" | ||
elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
# Check if Homebrew is installed | ||
if ! command -v brew &> /dev/null; then | ||
echo "❌ Homebrew is not installed. Please install Homebrew first: https://brew.sh" | ||
exit 1 | ||
fi | ||
DEPENDENCIES=(glslang-tools cmake ninja vulkan-tools glfw glm) | ||
install_brew_dependencies "${DEPENDENCIES[@]}" | ||
else | ||
echo "❌ Unsupported OS: $OSTYPE" | ||
exit 1 | ||
fi | ||
|
||
# Ensure compile.sh is executable | ||
if [ ! -x compile.sh ]; then | ||
chmod +x compile.sh | ||
fi | ||
|
||
# Run the shader compilation script | ||
echo "🛠️ Starting shader compilation..." | ||
if ./compile.sh; then | ||
echo "✅ Shader compilation completed successfully! Time to build the project!" | ||
else | ||
echo "❌ Shader compilation failed. Please check the errors above." | ||
exit 1 | ||
fi | ||
|
||
# Clean previous build if it exists | ||
if [ -d "build" ]; then | ||
echo "🧹 Cleaning previous build..." | ||
rm -rf build | ||
fi | ||
|
||
# Create a new build directory and build | ||
mkdir -p build | ||
cd build | ||
|
||
echo "🔧 Configuring the project with CMake..." | ||
cmake -G Ninja .. | ||
|
||
echo "🚀 Building the project with Ninja..." | ||
ninja | ||
|
||
# Optionally run the executable if the build was successful | ||
if [ -f "./NeonEngine" ]; then | ||
echo "🚀 Running the NeonEngine executable..." | ||
./NeonEngine | ||
else | ||
echo "❌ NeonEngine executable not found. Build may have failed." | ||
exit 1 | ||
fi | ||
|
||
echo "🎉 Done! Your project is all set up!" |