Skip to content

Commit

Permalink
creating make file
Browse files Browse the repository at this point in the history
  • Loading branch information
dadynaderi1 committed Sep 26, 2024
1 parent cbbfa02 commit 7a18482
Showing 1 changed file with 99 additions and 0 deletions.
99 changes: 99 additions & 0 deletions make.sh
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!"

0 comments on commit 7a18482

Please sign in to comment.