82 lines
1.6 KiB
Bash
Executable File
82 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
|
|
|
# Exit on error
|
|
set -e
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
JOBS=4
|
|
# Determine number of CPU cores for parallel build
|
|
if command -v nproc >/dev/null 2>&1; then
|
|
JOBS=$(nproc)
|
|
fi
|
|
|
|
|
|
# Function to print status messages
|
|
print_status() {
|
|
echo -e "${GREEN}[*] $1${NC}"
|
|
}
|
|
|
|
print_error() {
|
|
echo -e "${RED}[!] $1${NC}"
|
|
}
|
|
|
|
print_warning() {
|
|
echo -e "${YELLOW}[!] $1${NC}"
|
|
}
|
|
|
|
# ensure we have latest dehydrate.
|
|
dehydrate -u
|
|
|
|
# Check if build directory exists, if not create it
|
|
if [ ! -d "build" ]; then
|
|
print_status "Creating build directory..."
|
|
mkdir build
|
|
fi
|
|
|
|
# Enter build directory
|
|
cd build
|
|
|
|
# Check if CMake is installed
|
|
if ! command -v cmake &> /dev/null; then
|
|
print_error "CMake is not installed. Please install CMake first."
|
|
exit 1
|
|
fi
|
|
|
|
# Check if make is installed
|
|
if ! command -v make &> /dev/null; then
|
|
print_error "Make is not installed. Please install Make first."
|
|
exit 1
|
|
fi
|
|
|
|
# Configure with CMake
|
|
print_status "Configuring with CMake..."
|
|
cmake .. -DCMAKE_BUILD_TYPE=Debug
|
|
#cmake .. -DCMAKE_BUILD_TYPE=Release
|
|
|
|
# Build the project
|
|
print_status "Building project..."
|
|
make -j"$JOBS"
|
|
|
|
# Check if build was successful
|
|
if [ $? -eq 0 ]; then
|
|
print_status "Build successful!"
|
|
else
|
|
print_error "Build failed!"
|
|
exit 1
|
|
fi
|
|
|
|
print_status "Auto-installing dropshell locally..."
|
|
mkdir -p "${HOME}/.local/bin"
|
|
cp "$SCRIPT_DIR/build/dropshell" "${HOME}/.local/bin/dropshell"
|
|
|
|
# Return to original directory
|
|
cd ..
|
|
|
|
print_status "Build process completed!" |