diff --git a/make.sh b/make.sh new file mode 100644 index 0000000..7167d69 --- /dev/null +++ b/make.sh @@ -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!"