191 lines
6.0 KiB
Bash
191 lines
6.0 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
|
||
|
|
# Qt Screen Lock Detection Demo - Project Verification Script
|
||
|
|
# This script verifies that all project files are present and properly configured
|
||
|
|
|
||
|
|
set -e
|
||
|
|
|
||
|
|
# Colors for output
|
||
|
|
RED='\033[0;31m'
|
||
|
|
GREEN='\033[0;32m'
|
||
|
|
YELLOW='\033[1;33m'
|
||
|
|
BLUE='\033[0;34m'
|
||
|
|
NC='\033[0m' # No Color
|
||
|
|
|
||
|
|
# Counters
|
||
|
|
TOTAL_CHECKS=0
|
||
|
|
PASSED_CHECKS=0
|
||
|
|
FAILED_CHECKS=0
|
||
|
|
|
||
|
|
echo -e "${BLUE}========================================${NC}"
|
||
|
|
echo -e "${BLUE}Qt Screen Lock Demo - Project Verification${NC}"
|
||
|
|
echo -e "${BLUE}========================================${NC}"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Function to check if file exists
|
||
|
|
check_file() {
|
||
|
|
local file=$1
|
||
|
|
local description=$2
|
||
|
|
TOTAL_CHECKS=$((TOTAL_CHECKS + 1))
|
||
|
|
|
||
|
|
if [ -f "$file" ]; then
|
||
|
|
echo -e "${GREEN}✓${NC} $description: ${BLUE}$file${NC}"
|
||
|
|
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
||
|
|
return 0
|
||
|
|
else
|
||
|
|
echo -e "${RED}✗${NC} $description: ${RED}$file (MISSING)${NC}"
|
||
|
|
FAILED_CHECKS=$((FAILED_CHECKS + 1))
|
||
|
|
return 1
|
||
|
|
fi
|
||
|
|
}
|
||
|
|
|
||
|
|
# Function to check if directory exists
|
||
|
|
check_dir() {
|
||
|
|
local dir=$1
|
||
|
|
local description=$2
|
||
|
|
TOTAL_CHECKS=$((TOTAL_CHECKS + 1))
|
||
|
|
|
||
|
|
if [ -d "$dir" ]; then
|
||
|
|
echo -e "${GREEN}✓${NC} $description: ${BLUE}$dir${NC}"
|
||
|
|
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
||
|
|
return 0
|
||
|
|
else
|
||
|
|
echo -e "${RED}✗${NC} $description: ${RED}$dir (MISSING)${NC}"
|
||
|
|
FAILED_CHECKS=$((FAILED_CHECKS + 1))
|
||
|
|
return 1
|
||
|
|
fi
|
||
|
|
}
|
||
|
|
|
||
|
|
# Function to check if file is executable
|
||
|
|
check_executable() {
|
||
|
|
local file=$1
|
||
|
|
local description=$2
|
||
|
|
TOTAL_CHECKS=$((TOTAL_CHECKS + 1))
|
||
|
|
|
||
|
|
if [ -x "$file" ]; then
|
||
|
|
echo -e "${GREEN}✓${NC} $description: ${BLUE}$file${NC}"
|
||
|
|
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
||
|
|
return 0
|
||
|
|
else
|
||
|
|
echo -e "${YELLOW}!${NC} $description: ${YELLOW}$file (Not executable)${NC}"
|
||
|
|
echo -e " ${YELLOW}Run: chmod +x $file${NC}"
|
||
|
|
FAILED_CHECKS=$((FAILED_CHECKS + 1))
|
||
|
|
return 1
|
||
|
|
fi
|
||
|
|
}
|
||
|
|
|
||
|
|
echo -e "${YELLOW}[1/7] Checking Build Configuration...${NC}"
|
||
|
|
check_file "CMakeLists.txt" "CMake configuration"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
echo -e "${YELLOW}[2/7] Checking Build Scripts...${NC}"
|
||
|
|
check_executable "build.sh" "Build script"
|
||
|
|
check_executable "run.sh" "Run script"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
echo -e "${YELLOW}[3/7] Checking Documentation Files...${NC}"
|
||
|
|
check_file "README.md" "Main README"
|
||
|
|
check_file "QUICKSTART.md" "Quick start guide"
|
||
|
|
check_file "ARCHITECTURE.md" "Architecture documentation"
|
||
|
|
check_file "PROJECT_OVERVIEW.md" "Project overview"
|
||
|
|
check_file ".gitignore" "Git ignore file"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
echo -e "${YELLOW}[4/7] Checking Source Directory...${NC}"
|
||
|
|
check_dir "src" "Source directory"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
echo -e "${YELLOW}[5/7] Checking Header Files...${NC}"
|
||
|
|
check_file "src/screenlockdetector.h" "Screen lock detector header"
|
||
|
|
check_file "src/customwidget.h" "Custom widget header"
|
||
|
|
check_file "src/mainwindow.h" "Main window header"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
echo -e "${YELLOW}[6/7] Checking Implementation Files...${NC}"
|
||
|
|
check_file "src/screenlockdetector.cpp" "Screen lock detector implementation"
|
||
|
|
check_file "src/customwidget.cpp" "Custom widget implementation"
|
||
|
|
check_file "src/mainwindow.cpp" "Main window implementation"
|
||
|
|
check_file "src/main.cpp" "Main entry point"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
echo -e "${YELLOW}[7/7] Checking Qt5 Installation...${NC}"
|
||
|
|
TOTAL_CHECKS=$((TOTAL_CHECKS + 1))
|
||
|
|
QT5_DIR="$HOME/sdk/qt-5.15.2"
|
||
|
|
if [ -d "$QT5_DIR" ]; then
|
||
|
|
echo -e "${GREEN}✓${NC} Qt5 directory found: ${BLUE}$QT5_DIR${NC}"
|
||
|
|
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
||
|
|
|
||
|
|
# Check for qmake
|
||
|
|
if [ -f "$QT5_DIR/bin/qmake" ]; then
|
||
|
|
echo -e "${GREEN}✓${NC} qmake found"
|
||
|
|
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
||
|
|
else
|
||
|
|
echo -e "${YELLOW}!${NC} qmake not found in expected location"
|
||
|
|
FAILED_CHECKS=$((FAILED_CHECKS + 1))
|
||
|
|
fi
|
||
|
|
TOTAL_CHECKS=$((TOTAL_CHECKS + 1))
|
||
|
|
else
|
||
|
|
echo -e "${RED}✗${NC} Qt5 directory not found: ${RED}$QT5_DIR${NC}"
|
||
|
|
echo -e " ${YELLOW}Please update the path in CMakeLists.txt if Qt5 is installed elsewhere${NC}"
|
||
|
|
FAILED_CHECKS=$((FAILED_CHECKS + 1))
|
||
|
|
fi
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Summary
|
||
|
|
echo -e "${BLUE}========================================${NC}"
|
||
|
|
echo -e "${BLUE}Verification Summary${NC}"
|
||
|
|
echo -e "${BLUE}========================================${NC}"
|
||
|
|
echo -e "Total Checks: ${TOTAL_CHECKS}"
|
||
|
|
echo -e "${GREEN}Passed: ${PASSED_CHECKS}${NC}"
|
||
|
|
if [ $FAILED_CHECKS -gt 0 ]; then
|
||
|
|
echo -e "${RED}Failed: ${FAILED_CHECKS}${NC}"
|
||
|
|
else
|
||
|
|
echo -e "${GREEN}Failed: ${FAILED_CHECKS}${NC}"
|
||
|
|
fi
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Code statistics
|
||
|
|
if command -v wc &> /dev/null; then
|
||
|
|
echo -e "${BLUE}========================================${NC}"
|
||
|
|
echo -e "${BLUE}Code Statistics${NC}"
|
||
|
|
echo -e "${BLUE}========================================${NC}"
|
||
|
|
|
||
|
|
if [ -d "src" ]; then
|
||
|
|
CPP_LINES=$(find src -name "*.cpp" -exec wc -l {} + 2>/dev/null | tail -1 | awk '{print $1}' || echo "0")
|
||
|
|
H_LINES=$(find src -name "*.h" -exec wc -l {} + 2>/dev/null | tail -1 | awk '{print $1}' || echo "0")
|
||
|
|
TOTAL_LINES=$((CPP_LINES + H_LINES))
|
||
|
|
|
||
|
|
echo "C++ Source Files (.cpp): ${CPP_LINES} lines"
|
||
|
|
echo "Header Files (.h): ${H_LINES} lines"
|
||
|
|
echo "Total Source Code: ${TOTAL_LINES} lines"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
CPP_COUNT=$(find src -name "*.cpp" | wc -l)
|
||
|
|
H_COUNT=$(find src -name "*.h" | wc -l)
|
||
|
|
echo "Number of .cpp files: ${CPP_COUNT}"
|
||
|
|
echo "Number of .h files: ${H_COUNT}"
|
||
|
|
fi
|
||
|
|
echo ""
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Final verdict
|
||
|
|
echo -e "${BLUE}========================================${NC}"
|
||
|
|
if [ $FAILED_CHECKS -eq 0 ]; then
|
||
|
|
echo -e "${GREEN}✓ Project verification PASSED!${NC}"
|
||
|
|
echo -e "${GREEN}All required files are present.${NC}"
|
||
|
|
echo ""
|
||
|
|
echo -e "Next steps:"
|
||
|
|
echo -e " 1. Run ${BLUE}./build.sh${NC} to compile the project"
|
||
|
|
echo -e " 2. Run ${BLUE}./run.sh${NC} to execute the application"
|
||
|
|
echo -e " 3. Read ${BLUE}QUICKSTART.md${NC} for usage guide"
|
||
|
|
else
|
||
|
|
echo -e "${YELLOW}! Project verification completed with warnings${NC}"
|
||
|
|
echo -e "${YELLOW}Some files are missing or not executable.${NC}"
|
||
|
|
echo ""
|
||
|
|
echo -e "Please fix the issues above before building."
|
||
|
|
fi
|
||
|
|
echo -e "${BLUE}========================================${NC}"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
exit $FAILED_CHECKS
|