Add full automotive RTOS project
Add kernel (Cortex-M0/M3/M4, Tricore, S32K, RISC-V ports), drivers, middleware (CAN stack, diagnostics, safety), applications, board support, build/test tooling, and documentation.
This commit is contained in:
Executable
+194
@@ -0,0 +1,194 @@
|
||||
#!/bin/bash
|
||||
#==============================================================================
|
||||
# Build all targets for Automotive RTOS
|
||||
#==============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
# Script directory
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||
|
||||
# Color codes
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Build configuration
|
||||
BUILD_DIR="${PROJECT_ROOT}/build"
|
||||
TARGETS=("stm32f407_discovery" "nxp_s32k144_evb" "custom_ecu")
|
||||
BUILD_TYPES=("debug" "release")
|
||||
|
||||
# Create directories
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
|
||||
# Print banner
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo -e "${GREEN} Automotive RTOS Build System${NC}"
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo ""
|
||||
|
||||
# Function to check if toolchain is available
|
||||
check_toolchain() {
|
||||
if ! command -v arm-none-eabi-gcc >/dev/null 2>&1; then
|
||||
echo -e "${RED}Error: arm-none-eabi-gcc not found in PATH${NC}"
|
||||
echo -e "${YELLOW}Please run: bash scripts/setup_environment.sh${NC}"
|
||||
echo -e "${YELLOW}Or install ARM toolchain manually${NC}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to build target
|
||||
build_target() {
|
||||
local target=$1
|
||||
local build_type=$2
|
||||
|
||||
echo -e "${YELLOW}Building ${target} (${build_type})...${NC}"
|
||||
|
||||
local build_dir="${BUILD_DIR}/${target}/${build_type}"
|
||||
mkdir -p "${build_dir}"
|
||||
|
||||
# Check if CMakeLists.txt exists
|
||||
if [ ! -f "${PROJECT_ROOT}/CMakeLists.txt" ]; then
|
||||
echo -e "${YELLOW}No CMakeLists.txt found. Creating basic build...${NC}"
|
||||
|
||||
# Simple direct compilation without CMake
|
||||
cd "${build_dir}"
|
||||
|
||||
# Compile kernel sources
|
||||
for src in "${PROJECT_ROOT}"/kernel/src/*.c; do
|
||||
if [ -f "$src" ]; then
|
||||
echo " Compiling $(basename $src)..."
|
||||
arm-none-eabi-gcc -c "$src" \
|
||||
-I"${PROJECT_ROOT}/kernel/include" \
|
||||
-I"${PROJECT_ROOT}/config" \
|
||||
-mcpu=cortex-m4 -mthumb -O2 -Wall
|
||||
fi
|
||||
done
|
||||
|
||||
# Link object files
|
||||
if ls *.o >/dev/null 2>&1; then
|
||||
echo " Linking..."
|
||||
arm-none-eabi-gcc -o automotive_rtos.elf *.o \
|
||||
-mcpu=cortex-m4 -mthumb -nostdlib -T"${PROJECT_ROOT}/board/${target}/linker_script.ld"
|
||||
echo -e "${GREEN}✓ Build successful${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}No source files found to compile${NC}"
|
||||
fi
|
||||
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Build with CMake if available
|
||||
if command -v cmake >/dev/null 2>&1; then
|
||||
cd "${build_dir}"
|
||||
|
||||
cmake "${PROJECT_ROOT}" \
|
||||
-DTARGET_BOARD=${target} \
|
||||
-DCMAKE_BUILD_TYPE=${build_type} \
|
||||
-DCMAKE_TOOLCHAIN_FILE="${PROJECT_ROOT}/cmake/toolchain-${target}.cmake" \
|
||||
2>/dev/null || {
|
||||
echo -e "${YELLOW}CMake configuration failed. Trying direct build...${NC}"
|
||||
return 1
|
||||
}
|
||||
|
||||
make -j$(nproc 2>/dev/null || echo 4) 2>/dev/null || {
|
||||
echo -e "${YELLOW}Make failed${NC}"
|
||||
return 1
|
||||
}
|
||||
else
|
||||
echo -e "${YELLOW}CMake not found. Skipping ${target}${NC}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✓ ${target} (${build_type}) built successfully${NC}"
|
||||
echo ""
|
||||
return 0
|
||||
}
|
||||
|
||||
# Main build process
|
||||
main() {
|
||||
# Parse arguments
|
||||
local clean_build=false
|
||||
local specific_target=""
|
||||
local specific_type=""
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--clean)
|
||||
clean_build=true
|
||||
shift
|
||||
;;
|
||||
--target)
|
||||
specific_target="$2"
|
||||
shift 2
|
||||
;;
|
||||
--type)
|
||||
specific_type="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo " --clean Clean build"
|
||||
echo " --target <name> Build specific target"
|
||||
echo " --type <type> Build type (debug/release)"
|
||||
echo " -h, --help Show this help"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check toolchain
|
||||
check_toolchain
|
||||
|
||||
# Clean build if requested
|
||||
if [ "${clean_build}" = true ]; then
|
||||
echo -e "${YELLOW}Cleaning build directory...${NC}"
|
||||
rm -rf "${BUILD_DIR}"
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
echo -e "${GREEN}✓ Clean complete${NC}"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Build targets
|
||||
local build_failed=0
|
||||
|
||||
if [ -n "$specific_target" ]; then
|
||||
TARGETS=("$specific_target")
|
||||
fi
|
||||
|
||||
if [ -n "$specific_type" ]; then
|
||||
BUILD_TYPES=("$specific_type")
|
||||
fi
|
||||
|
||||
for target in "${TARGETS[@]}"; do
|
||||
for build_type in "${BUILD_TYPES[@]}"; do
|
||||
if ! build_target "${target}" "${build_type}"; then
|
||||
build_failed=1
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# Print summary
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo -e "${GREEN} Build Summary${NC}"
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
|
||||
if [ ${build_failed} -eq 0 ]; then
|
||||
echo -e "${GREEN}✓ All builds successful${NC}"
|
||||
exit 0
|
||||
else
|
||||
echo -e "${YELLOW}⚠ Some builds had issues${NC}"
|
||||
echo -e "${YELLOW}Check the build output above for details${NC}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Run main
|
||||
main "$@"
|
||||
Executable
+270
@@ -0,0 +1,270 @@
|
||||
#!/bin/bash
|
||||
/**
|
||||
* @file generate_docs.sh
|
||||
* @brief Generate documentation for Automotive RTOS
|
||||
*/
|
||||
|
||||
set -e
|
||||
|
||||
# Script directory
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||
|
||||
# Color codes
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
# Documentation directories
|
||||
DOCS_DIR="${PROJECT_ROOT}/docs"
|
||||
BUILD_DOCS_DIR="${PROJECT_ROOT}/build/docs"
|
||||
DOXYGEN_DIR="${BUILD_DOCS_DIR}/doxygen"
|
||||
HTML_DIR="${DOXYGEN_DIR}/html"
|
||||
PDF_DIR="${DOXYGEN_DIR}/pdf"
|
||||
|
||||
# Print banner
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo -e "${BLUE} Documentation Generator${NC}"
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo ""
|
||||
|
||||
# Check for doxygen
|
||||
check_doxygen() {
|
||||
if ! command -v doxygen >/dev/null 2>&1; then
|
||||
echo -e "${YELLOW}Doxygen not found. Installing...${NC}"
|
||||
sudo apt-get install -y doxygen graphviz
|
||||
fi
|
||||
}
|
||||
|
||||
# Check for other tools
|
||||
check_tools() {
|
||||
# LaTeX for PDF generation
|
||||
if ! command -v pdflatex >/dev/null 2>&1; then
|
||||
echo -e "${YELLOW}LaTeX not found. PDF generation will be skipped.${NC}"
|
||||
GENERATE_PDF=false
|
||||
else
|
||||
GENERATE_PDF=true
|
||||
fi
|
||||
|
||||
# Graphviz for diagrams
|
||||
if ! command -v dot >/dev/null 2>&1; then
|
||||
echo -e "${YELLOW}Graphviz not found. Installing...${NC}"
|
||||
sudo apt-get install -y graphviz
|
||||
fi
|
||||
}
|
||||
|
||||
# Generate doxygen configuration
|
||||
generate_doxygen_config() {
|
||||
echo -e "${YELLOW}Generating Doxygen configuration...${NC}"
|
||||
|
||||
cat > "${BUILD_DOCS_DIR}/Doxyfile" << EOF
|
||||
# Doxygen configuration for Automotive RTOS
|
||||
|
||||
# Project information
|
||||
PROJECT_NAME = "Automotive RTOS"
|
||||
PROJECT_NUMBER = "1.0.0"
|
||||
PROJECT_BRIEF = "Real-time operating system for automotive applications"
|
||||
OUTPUT_DIRECTORY = ${DOXYGEN_DIR}
|
||||
|
||||
# Source files
|
||||
INPUT = ${PROJECT_ROOT}/kernel \
|
||||
${PROJECT_ROOT}/drivers \
|
||||
${PROJECT_ROOT}/middleware \
|
||||
${PROJECT_ROOT}/applications \
|
||||
${PROJECT_ROOT}/config \
|
||||
${PROJECT_ROOT}/board \
|
||||
${PROJECT_ROOT}/README.md
|
||||
|
||||
# Include paths
|
||||
INCLUDE_PATH = ${PROJECT_ROOT}/kernel/include \
|
||||
${PROJECT_ROOT}/drivers/include \
|
||||
${PROJECT_ROOT}/middleware \
|
||||
${PROJECT_ROOT}/config
|
||||
|
||||
# File patterns
|
||||
FILE_PATTERNS = *.c *.h *.md
|
||||
RECURSIVE = YES
|
||||
|
||||
# Output formats
|
||||
GENERATE_HTML = YES
|
||||
GENERATE_LATEX = ${GENERATE_PDF}
|
||||
GENERATE_RTF = NO
|
||||
GENERATE_XML = YES
|
||||
GENERATE_MAN = NO
|
||||
|
||||
# HTML output
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
GENERATE_TREEVIEW = YES
|
||||
DISPLAY_GRAPH = YES
|
||||
|
||||
# LaTeX output
|
||||
LATEX_OUTPUT = pdf
|
||||
COMPACT_LATEX = YES
|
||||
PDF_HYPERLINKS = YES
|
||||
USE_PDFLATEX = YES
|
||||
|
||||
# Diagrams
|
||||
HAVE_DOT = YES
|
||||
DOT_GRAPH_MAX_NODES = 50
|
||||
CALL_GRAPH = YES
|
||||
CALLER_GRAPH = YES
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
|
||||
# Code documentation
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
|
||||
# Warnings
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = YES
|
||||
|
||||
# Source browser
|
||||
SOURCE_BROWSER = YES
|
||||
INLINE_SOURCES = YES
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
|
||||
# Search engine
|
||||
SEARCHENGINE = YES
|
||||
SERVER_BASED_SEARCH = NO
|
||||
|
||||
# Colors
|
||||
HTML_COLORSTYLE_HUE = 220
|
||||
HTML_COLORSTYLE_SAT = 100
|
||||
HTML_COLORSTYLE_GAMMA = 80
|
||||
EOF
|
||||
|
||||
echo -e "${GREEN}✓ Doxygen configuration generated${NC}"
|
||||
}
|
||||
|
||||
# Generate API documentation
|
||||
generate_api_docs() {
|
||||
echo -e "${YELLOW}Generating API documentation...${NC}"
|
||||
|
||||
mkdir -p "${DOCS_DIR}/api"
|
||||
|
||||
# Extract function documentation from headers
|
||||
for header in "${PROJECT_ROOT}"/kernel/include/*.h; do
|
||||
if [ -f "$header" ]; then
|
||||
basename=$(basename "$header" .h)
|
||||
output="${DOCS_DIR}/api/${basename}.md"
|
||||
|
||||
echo "# ${basename} API Documentation" > "$output"
|
||||
echo "" >> "$output"
|
||||
echo "Auto-generated documentation for ${header}" >> "$output"
|
||||
echo "" >> "$output"
|
||||
|
||||
# Extract function prototypes
|
||||
grep -E "^(KernelStatus_t|void|uint|int|bool|float|TaskHandle_t)" "$header" | \
|
||||
while read -r line; do
|
||||
echo "\`\`\`c" >> "$output"
|
||||
echo "$line" >> "$output"
|
||||
echo "\`\`\`" >> "$output"
|
||||
echo "" >> "$output"
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
echo -e "${GREEN}✓ API documentation generated${NC}"
|
||||
}
|
||||
|
||||
# Generate architecture documentation
|
||||
generate_architecture_docs() {
|
||||
echo -e "${YELLOW}Generating architecture documentation...${NC}"
|
||||
|
||||
mkdir -p "${DOCS_DIR}/architecture"
|
||||
|
||||
cat > "${DOCS_DIR}/architecture/system_overview.md" << 'EOF'
|
||||
# System Architecture Overview
|
||||
|
||||
## Introduction
|
||||
|
||||
The Automotive RTOS is designed for safety-critical automotive applications.
|
||||
It provides deterministic real-time performance with priority-based preemptive scheduling.
|
||||
|
||||
## System Layers
|
||||
|
||||
1. **Application Layer**
|
||||
- Engine Control
|
||||
- Brake Control
|
||||
- Body Control
|
||||
- Dashboard
|
||||
|
||||
2. **Middleware Layer**
|
||||
- CAN Stack (ISO 15765-2)
|
||||
- Network Management
|
||||
- Diagnostics (UDS, OBD-II)
|
||||
- Safety Features
|
||||
|
||||
3. **Driver Layer**
|
||||
- CAN Driver
|
||||
- UART Driver
|
||||
- SPI Driver
|
||||
- I2C Driver
|
||||
- GPIO Driver
|
||||
- ADC Driver
|
||||
- PWM Driver
|
||||
|
||||
4. **Kernel Layer**
|
||||
- Task Management
|
||||
- Scheduler
|
||||
- Synchronization
|
||||
- Memory Management
|
||||
- Interrupt Handling
|
||||
|
||||
## Design Principles
|
||||
|
||||
- Deterministic scheduling
|
||||
- Priority inheritance
|
||||
- Memory protection
|
||||
- Stack overflow detection
|
||||
- Fault tolerance
|
||||
- Watchdog integration
|
||||
- E2E protection
|
||||
|
||||
## Safety Features
|
||||
|
||||
- ISO 26262 compliance
|
||||
- ASIL-D ready
|
||||
- Redundancy support
|
||||
- Fault detection
|
||||
- Safe state management
|
||||
EOF
|
||||
|
||||
echo -e "${GREEN}✓ Architecture documentation generated${NC}"
|
||||
}
|
||||
|
||||
# Generate user guide
|
||||
generate_user_guide() {
|
||||
echo -e "${YELLOW}Generating user guide...${NC}"
|
||||
|
||||
mkdir -p "${DOCS_DIR}/user_guide"
|
||||
|
||||
cat > "${DOCS_DIR}/user_guide/getting_started.md" << 'EOF'
|
||||
# Getting Started Guide
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- ARM GCC toolchain
|
||||
- CMake 3.10+
|
||||
- Make
|
||||
- Git
|
||||
|
||||
## Installation
|
||||
|
||||
1. Clone repository:
|
||||
```bash
|
||||
git clone https://github.com/automotive-rtos/rtos.git
|
||||
cd rtos
|
||||
Executable
+169
@@ -0,0 +1,169 @@
|
||||
#!/bin/bash
|
||||
#==============================================================================
|
||||
# Run tests for Automotive RTOS
|
||||
#==============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
# Script directory
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||
|
||||
# Color codes
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Test directories
|
||||
TEST_DIR="${PROJECT_ROOT}/tests"
|
||||
BUILD_TEST_DIR="${PROJECT_ROOT}/build/tests"
|
||||
|
||||
# Test results
|
||||
PASSED=0
|
||||
FAILED=0
|
||||
TOTAL=0
|
||||
|
||||
# Print banner
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo -e "${BLUE} Automotive RTOS Test Runner${NC}"
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo ""
|
||||
|
||||
# Function to compile and run a test
|
||||
run_test_file() {
|
||||
local test_file=$1
|
||||
local test_name=$(basename "${test_file}" .c)
|
||||
local test_binary="${BUILD_TEST_DIR}/${test_name}"
|
||||
|
||||
TOTAL=$((TOTAL + 1))
|
||||
|
||||
echo -e "${YELLOW}Compiling ${test_name}...${NC}"
|
||||
|
||||
# Try to compile
|
||||
if gcc \
|
||||
-I"${PROJECT_ROOT}/kernel/include" \
|
||||
-I"${PROJECT_ROOT}/drivers/include" \
|
||||
-I"${PROJECT_ROOT}/middleware" \
|
||||
-I"${PROJECT_ROOT}/config" \
|
||||
-I"${PROJECT_ROOT}/tests" \
|
||||
"${test_file}" \
|
||||
-o "${test_binary}" \
|
||||
-Wall -Wextra -g -O0 2>"${BUILD_TEST_DIR}/${test_name}_compile.log"; then
|
||||
|
||||
echo -e "${GREEN}✓ Compilation successful${NC}"
|
||||
echo -e "${YELLOW}Running ${test_name}...${NC}"
|
||||
|
||||
# Run test
|
||||
if timeout 30 "${test_binary}" >"${BUILD_TEST_DIR}/${test_name}_run.log" 2>&1; then
|
||||
echo -e "${GREEN}✓ ${test_name} passed${NC}"
|
||||
PASSED=$((PASSED + 1))
|
||||
else
|
||||
echo -e "${RED}✗ ${test_name} failed${NC}"
|
||||
echo -e "${YELLOW} See log: ${BUILD_TEST_DIR}/${test_name}_run.log${NC}"
|
||||
FAILED=$((FAILED + 1))
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}✗ ${test_name} compilation failed${NC}"
|
||||
echo -e "${YELLOW} See log: ${BUILD_TEST_DIR}/${test_name}_compile.log${NC}"
|
||||
FAILED=$((FAILED + 1))
|
||||
fi
|
||||
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Function to run all tests in a directory
|
||||
run_test_directory() {
|
||||
local dir=$1
|
||||
local dir_name=$2
|
||||
|
||||
echo -e "${BLUE}Running ${dir_name}${NC}"
|
||||
echo -e "${BLUE}----------------------------------------${NC}"
|
||||
|
||||
if [ ! -d "$dir" ]; then
|
||||
echo -e "${YELLOW}No ${dir_name} found${NC}"
|
||||
echo ""
|
||||
return
|
||||
fi
|
||||
|
||||
for test_file in "$dir"/test_*.c; do
|
||||
if [ -f "$test_file" ]; then
|
||||
run_test_file "$test_file"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Main function
|
||||
main() {
|
||||
# Parse arguments
|
||||
local run_unit=true
|
||||
local run_integration=true
|
||||
local run_system=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--unit)
|
||||
run_integration=false
|
||||
shift
|
||||
;;
|
||||
--integration)
|
||||
run_unit=false
|
||||
shift
|
||||
;;
|
||||
--all)
|
||||
run_system=true
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo " --unit Run unit tests only"
|
||||
echo " --integration Run integration tests only"
|
||||
echo " --all Run all tests"
|
||||
echo " -h, --help Show this help"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Create build test directory
|
||||
mkdir -p "${BUILD_TEST_DIR}"
|
||||
|
||||
# Run tests
|
||||
if [ "$run_unit" = true ]; then
|
||||
run_test_directory "${TEST_DIR}/unit" "Unit Tests"
|
||||
fi
|
||||
|
||||
if [ "$run_integration" = true ]; then
|
||||
run_test_directory "${TEST_DIR}/integration" "Integration Tests"
|
||||
fi
|
||||
|
||||
if [ "$run_system" = true ]; then
|
||||
run_test_directory "${TEST_DIR}/system" "System Tests"
|
||||
fi
|
||||
|
||||
# Print summary
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo -e "${BLUE} Test Summary${NC}"
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo ""
|
||||
echo -e " Total: ${TOTAL}"
|
||||
echo -e " ${GREEN}Passed: ${PASSED}${NC}"
|
||||
echo -e " ${RED}Failed: ${FAILED}${NC}"
|
||||
echo ""
|
||||
|
||||
if [ ${FAILED} -gt 0 ]; then
|
||||
echo -e "${RED}Some tests failed${NC}"
|
||||
exit 1
|
||||
else
|
||||
echo -e "${GREEN}All tests passed${NC}"
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
# Run main
|
||||
main "$@"
|
||||
Executable
+615
@@ -0,0 +1,615 @@
|
||||
#!/bin/bash
|
||||
#==============================================================================
|
||||
# @file setup_environment.sh
|
||||
# @brief Setup development environment for Automotive RTOS
|
||||
#==============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
# Script directory - handle spaces and special characters properly
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||
|
||||
# Color codes
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
CYAN='\033[0;36m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
#==============================================================================
|
||||
# OS Detection
|
||||
#==============================================================================
|
||||
detect_os() {
|
||||
case "$(uname -s)" in
|
||||
Darwin*)
|
||||
OS="macos"
|
||||
OS_VERSION=$(sw_vers -productVersion 2>/dev/null || echo "unknown")
|
||||
ARCH=$(uname -m)
|
||||
;;
|
||||
Linux*)
|
||||
OS="linux"
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
DISTRO="$ID"
|
||||
elif [ -f /etc/debian_version ]; then
|
||||
DISTRO="debian"
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
DISTRO="redhat"
|
||||
else
|
||||
DISTRO="unknown"
|
||||
fi
|
||||
ARCH=$(uname -m)
|
||||
;;
|
||||
MINGW*|MSYS*|CYGWIN*)
|
||||
OS="windows"
|
||||
;;
|
||||
*)
|
||||
OS="unknown"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# Print Banner
|
||||
#==============================================================================
|
||||
print_banner() {
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo -e "${BLUE} Automotive RTOS Environment Setup${NC}"
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo -e " OS: ${CYAN}${OS}${NC}"
|
||||
if [ "$OS" = "linux" ]; then
|
||||
echo -e " Distro: ${CYAN}${DISTRO}${NC}"
|
||||
fi
|
||||
if [ "$OS" = "macos" ]; then
|
||||
echo -e " Version: ${CYAN}${OS_VERSION}${NC}"
|
||||
fi
|
||||
echo -e " Arch: ${CYAN}${ARCH}${NC}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# Command Check
|
||||
#==============================================================================
|
||||
command_exists() {
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# Install Package - Cross-platform
|
||||
#==============================================================================
|
||||
install_package() {
|
||||
local package=$1
|
||||
|
||||
echo -e "${YELLOW}Installing ${package}...${NC}"
|
||||
|
||||
case "$OS" in
|
||||
macos)
|
||||
if command_exists brew; then
|
||||
brew install "$package" || {
|
||||
echo -e "${YELLOW}Failed to install ${package} via brew${NC}"
|
||||
return 1
|
||||
}
|
||||
else
|
||||
echo -e "${RED}Homebrew not found. Please install Homebrew first:${NC}"
|
||||
echo " /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
linux)
|
||||
case "$DISTRO" in
|
||||
ubuntu|debian)
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y "$package"
|
||||
;;
|
||||
fedora|centos|rhel)
|
||||
sudo dnf install -y "$package" || sudo yum install -y "$package"
|
||||
;;
|
||||
arch)
|
||||
sudo pacman -S --noconfirm "$package"
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Unsupported Linux distribution: ${DISTRO}${NC}"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
windows)
|
||||
echo -e "${YELLOW}Please install ${package} manually on Windows${NC}"
|
||||
echo " Visit: https://${package}.org/download/"
|
||||
return 1
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Unsupported OS${NC}"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo -e "${GREEN}✓ ${package} installed${NC}"
|
||||
return 0
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# Install ARM Toolchain
|
||||
#==============================================================================
|
||||
install_arm_toolchain() {
|
||||
echo -e "${YELLOW}Installing ARM toolchain...${NC}"
|
||||
|
||||
# Check if already installed
|
||||
if command_exists arm-none-eabi-gcc; then
|
||||
echo -e "${GREEN}✓ ARM toolchain already installed: $(arm-none-eabi-gcc --version | head -n1)${NC}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
case "$OS" in
|
||||
macos)
|
||||
if command_exists brew; then
|
||||
echo -e "${YELLOW}Installing ARM toolchain via Homebrew...${NC}"
|
||||
# Try the official tap first
|
||||
brew tap ArmMbed/homebrew-formulae 2>/dev/null || true
|
||||
brew install arm-none-eabi-gcc 2>/dev/null || {
|
||||
echo -e "${YELLOW}Trying alternative installation method...${NC}"
|
||||
# Alternative: download from ARM developer site
|
||||
echo -e "${YELLOW}Please download ARM toolchain from:${NC}"
|
||||
echo " https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads"
|
||||
echo -e "${YELLOW}Choose the macOS (Apple Silicon or Intel) version${NC}"
|
||||
echo -e "${YELLOW}After downloading, add to PATH:${NC}"
|
||||
echo " export PATH=\"/path/to/arm-gnu-toolchain/bin:\$PATH\""
|
||||
}
|
||||
else
|
||||
echo -e "${RED}Homebrew not found${NC}"
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
linux)
|
||||
case "$DISTRO" in
|
||||
ubuntu|debian)
|
||||
sudo apt-get install -y gcc-arm-none-eabi binutils-arm-none-eabi
|
||||
;;
|
||||
fedora|centos|rhel)
|
||||
sudo dnf install -y arm-none-eabi-gcc arm-none-eabi-binutils
|
||||
;;
|
||||
arch)
|
||||
sudo pacman -S --noconfirm arm-none-eabi-gcc arm-none-eabi-binutils
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
windows)
|
||||
echo -e "${YELLOW}Download ARM toolchain from:${NC}"
|
||||
echo " https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Verify installation
|
||||
if command_exists arm-none-eabi-gcc; then
|
||||
echo -e "${GREEN}✓ ARM toolchain installed: $(arm-none-eabi-gcc --version | head -n1)${NC}"
|
||||
return 0
|
||||
else
|
||||
echo -e "${YELLOW}ARM toolchain not found in PATH${NC}"
|
||||
echo -e "${YELLOW}Please add it manually or install from ARM developer site${NC}"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# Install Build Tools
|
||||
#==============================================================================
|
||||
install_build_tools() {
|
||||
echo -e "${YELLOW}Installing build tools...${NC}"
|
||||
|
||||
# CMake
|
||||
if command_exists cmake; then
|
||||
echo -e "${GREEN}✓ CMake already installed: $(cmake --version | head -n1)${NC}"
|
||||
else
|
||||
install_package cmake
|
||||
fi
|
||||
|
||||
# Make
|
||||
if command_exists make; then
|
||||
echo -e "${GREEN}✓ Make already installed${NC}"
|
||||
else
|
||||
install_package make
|
||||
fi
|
||||
|
||||
# Git
|
||||
if command_exists git; then
|
||||
echo -e "${GREEN}✓ Git already installed: $(git --version)${NC}"
|
||||
else
|
||||
install_package git
|
||||
fi
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# Install Debug Tools
|
||||
#==============================================================================
|
||||
install_debug_tools() {
|
||||
echo -e "${YELLOW}Installing debug tools...${NC}"
|
||||
|
||||
case "$OS" in
|
||||
macos)
|
||||
# GDB for ARM
|
||||
if command_exists arm-none-eabi-gdb; then
|
||||
echo -e "${GREEN}✓ ARM GDB already installed${NC}"
|
||||
elif command_exists gdb; then
|
||||
echo -e "${GREEN}✓ GDB installed (may not support ARM targets)${NC}"
|
||||
echo -e "${YELLOW} Consider installing arm-none-eabi-gdb via brew${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}Installing GDB...${NC}"
|
||||
brew install gdb 2>/dev/null || echo -e "${YELLOW} GDB installation skipped${NC}"
|
||||
fi
|
||||
|
||||
# OpenOCD
|
||||
if command_exists openocd; then
|
||||
echo -e "${GREEN}✓ OpenOCD already installed${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}Installing OpenOCD...${NC}"
|
||||
brew install openocd 2>/dev/null || echo -e "${YELLOW} OpenOCD installation skipped${NC}"
|
||||
fi
|
||||
|
||||
# STLink tools
|
||||
if command_exists st-flash; then
|
||||
echo -e "${GREEN}✓ STLink tools already installed${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}Installing STLink tools...${NC}"
|
||||
brew install stlink 2>/dev/null || echo -e "${YELLOW} STLink installation skipped${NC}"
|
||||
fi
|
||||
;;
|
||||
linux)
|
||||
# GDB multiarch
|
||||
if command_exists gdb-multiarch; then
|
||||
echo -e "${GREEN}✓ GDB multiarch already installed${NC}"
|
||||
else
|
||||
install_package gdb-multiarch
|
||||
fi
|
||||
|
||||
# OpenOCD
|
||||
if command_exists openocd; then
|
||||
echo -e "${GREEN}✓ OpenOCD already installed${NC}"
|
||||
else
|
||||
install_package openocd
|
||||
fi
|
||||
|
||||
# STLink tools
|
||||
if command_exists st-flash; then
|
||||
echo -e "${GREEN}✓ STLink tools already installed${NC}"
|
||||
else
|
||||
install_package stlink-tools
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# Install Analysis Tools
|
||||
#==============================================================================
|
||||
install_analysis_tools() {
|
||||
echo -e "${YELLOW}Installing analysis tools...${NC}"
|
||||
|
||||
# Cppcheck
|
||||
if command_exists cppcheck; then
|
||||
echo -e "${GREEN}✓ Cppcheck already installed${NC}"
|
||||
else
|
||||
install_package cppcheck
|
||||
fi
|
||||
|
||||
# Clang
|
||||
if command_exists clang; then
|
||||
echo -e "${GREEN}✓ Clang already installed${NC}"
|
||||
else
|
||||
install_package llvm
|
||||
fi
|
||||
|
||||
# Valgrind (Linux only)
|
||||
if [ "$OS" = "linux" ]; then
|
||||
if command_exists valgrind; then
|
||||
echo -e "${GREEN}✓ Valgrind already installed${NC}"
|
||||
else
|
||||
install_package valgrind
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# Install Python Tools
|
||||
#==============================================================================
|
||||
install_python_tools() {
|
||||
echo -e "${YELLOW}Installing Python tools...${NC}"
|
||||
|
||||
# Python3
|
||||
if command_exists python3; then
|
||||
echo -e "${GREEN}✓ Python3 already installed: $(python3 --version)${NC}"
|
||||
else
|
||||
install_package python3
|
||||
fi
|
||||
|
||||
# Pip3
|
||||
if command_exists pip3; then
|
||||
echo -e "${GREEN}✓ Pip3 already installed${NC}"
|
||||
else
|
||||
install_package python3-pip
|
||||
fi
|
||||
|
||||
# Python packages
|
||||
echo -e "${YELLOW}Installing Python packages...${NC}"
|
||||
pip3 install --user \
|
||||
pyelftools \
|
||||
pyserial \
|
||||
numpy \
|
||||
matplotlib \
|
||||
pytest \
|
||||
coverage \
|
||||
gcovr 2>/dev/null || {
|
||||
echo -e "${YELLOW}Some Python packages may need sudo${NC}"
|
||||
echo -e "${YELLOW}Try: pip3 install --user <package>${NC}"
|
||||
}
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# Setup Project Directories
|
||||
#==============================================================================
|
||||
setup_project_dirs() {
|
||||
echo -e "${YELLOW}Setting up project directories...${NC}"
|
||||
|
||||
mkdir -p "${PROJECT_ROOT}/build"
|
||||
mkdir -p "${PROJECT_ROOT}/build/logs"
|
||||
mkdir -p "${PROJECT_ROOT}/build/misra"
|
||||
mkdir -p "${PROJECT_ROOT}/build/docs"
|
||||
mkdir -p "${PROJECT_ROOT}/build/coverage"
|
||||
mkdir -p "${PROJECT_ROOT}/build/tests"
|
||||
|
||||
echo -e "${GREEN}✓ Project directories created${NC}"
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# Setup Git Hooks
|
||||
#==============================================================================
|
||||
setup_git_hooks() {
|
||||
echo -e "${YELLOW}Setting up git hooks...${NC}"
|
||||
|
||||
if [ -d "${PROJECT_ROOT}/.git" ]; then
|
||||
HOOKS_DIR="${PROJECT_ROOT}/.git/hooks"
|
||||
mkdir -p "${HOOKS_DIR}"
|
||||
|
||||
# Pre-commit hook
|
||||
cat > "${HOOKS_DIR}/pre-commit" << 'EOF'
|
||||
#!/bin/bash
|
||||
# Pre-commit hook for Automotive RTOS
|
||||
|
||||
echo "Running pre-commit checks..."
|
||||
|
||||
# Check for trailing whitespace
|
||||
if git diff --cached --check; then
|
||||
echo "✓ No whitespace issues"
|
||||
else
|
||||
echo "✗ Trailing whitespace found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for large files
|
||||
large_files=$(git diff --cached --name-only | xargs -I{} du -k {} 2>/dev/null | awk '$1 > 1024 {print $2}')
|
||||
if [ -n "$large_files" ]; then
|
||||
echo "✗ Large files detected (>1MB):"
|
||||
echo "$large_files"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✓ Pre-commit checks passed"
|
||||
EOF
|
||||
chmod +x "${HOOKS_DIR}/pre-commit"
|
||||
|
||||
# Pre-push hook
|
||||
cat > "${HOOKS_DIR}/pre-push" << 'EOF'
|
||||
#!/bin/bash
|
||||
# Pre-push hook for Automotive RTOS
|
||||
|
||||
echo "Running pre-push checks..."
|
||||
|
||||
# Run quick static analysis
|
||||
if [ -f "scripts/static_analysis.sh" ]; then
|
||||
bash scripts/static_analysis.sh --quick
|
||||
fi
|
||||
|
||||
echo "✓ Pre-push checks passed"
|
||||
EOF
|
||||
chmod +x "${HOOKS_DIR}/pre-push"
|
||||
|
||||
echo -e "${GREEN}✓ Git hooks installed${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}Not a git repository. Skipping git hooks.${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# Setup VS Code Configuration
|
||||
#==============================================================================
|
||||
setup_vscode() {
|
||||
echo -e "${YELLOW}Setting up VS Code configuration...${NC}"
|
||||
|
||||
VSCODE_DIR="${PROJECT_ROOT}/.vscode"
|
||||
mkdir -p "${VSCODE_DIR}"
|
||||
|
||||
# Only create if files don't exist
|
||||
if [ ! -f "${VSCODE_DIR}/settings.json" ]; then
|
||||
cat > "${VSCODE_DIR}/settings.json" << 'EOF'
|
||||
{
|
||||
"editor.formatOnSave": true,
|
||||
"editor.tabSize": 4,
|
||||
"files.encoding": "utf8",
|
||||
"C_Cpp.default.includePath": [
|
||||
"${workspaceFolder}/kernel/include",
|
||||
"${workspaceFolder}/drivers/include",
|
||||
"${workspaceFolder}/middleware",
|
||||
"${workspaceFolder}/config"
|
||||
],
|
||||
"C_Cpp.default.compilerPath": "/opt/homebrew/bin/arm-none-eabi-gcc"
|
||||
}
|
||||
EOF
|
||||
echo -e "${GREEN}✓ VS Code settings created${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}VS Code settings already exist. Skipping.${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# Setup Environment Variables
|
||||
#==============================================================================
|
||||
setup_env_vars() {
|
||||
echo -e "${YELLOW}Setting up environment variables...${NC}"
|
||||
|
||||
ENV_FILE="${PROJECT_ROOT}/.env"
|
||||
|
||||
# Detect toolchain path
|
||||
if command_exists arm-none-eabi-gcc; then
|
||||
TOOLCHAIN_PATH="$(dirname $(which arm-none-eabi-gcc))"
|
||||
else
|
||||
TOOLCHAIN_PATH="/opt/homebrew/bin"
|
||||
fi
|
||||
|
||||
cat > "${ENV_FILE}" << EOF
|
||||
# Automotive RTOS Environment Variables
|
||||
# Generated on $(date)
|
||||
|
||||
export RTOS_ROOT="${PROJECT_ROOT}"
|
||||
export RTOS_BUILD_DIR="\${RTOS_ROOT}/build"
|
||||
export RTOS_TOOLCHAIN="${TOOLCHAIN_PATH}/arm-none-eabi-"
|
||||
export RTOS_TARGET="stm32f407_discovery"
|
||||
export RTOS_DEBUG_PORT="3333"
|
||||
|
||||
# Add toolchain to PATH if not already there
|
||||
if [[ ":\$PATH:" != *":${TOOLCHAIN_PATH}:"* ]]; then
|
||||
export PATH="${TOOLCHAIN_PATH}:\$PATH"
|
||||
fi
|
||||
EOF
|
||||
|
||||
# Add to shell profile if not already there
|
||||
SHELL_PROFILE=""
|
||||
case "$SHELL" in
|
||||
*/bash)
|
||||
SHELL_PROFILE="$HOME/.bash_profile"
|
||||
[ -f "$HOME/.bashrc" ] && SHELL_PROFILE="$HOME/.bashrc"
|
||||
;;
|
||||
*/zsh)
|
||||
SHELL_PROFILE="$HOME/.zshrc"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$SHELL_PROFILE" ] && [ -f "$SHELL_PROFILE" ]; then
|
||||
if ! grep -q "RTOS_ROOT" "$SHELL_PROFILE"; then
|
||||
echo "" >> "$SHELL_PROFILE"
|
||||
echo "# Automotive RTOS Environment" >> "$SHELL_PROFILE"
|
||||
echo "source ${ENV_FILE}" >> "$SHELL_PROFILE"
|
||||
echo -e "${GREEN}✓ Added to ${SHELL_PROFILE}${NC}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✓ Environment variables configured${NC}"
|
||||
echo -e "${YELLOW}To apply now, run: source ${ENV_FILE}${NC}"
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
# Main Setup Function
|
||||
#==============================================================================
|
||||
main() {
|
||||
detect_os
|
||||
print_banner
|
||||
|
||||
# Parse arguments
|
||||
INSTALL_TOOLCHAIN=true
|
||||
INSTALL_BUILD=true
|
||||
INSTALL_DEBUG=true
|
||||
INSTALL_ANALYSIS=true
|
||||
INSTALL_PYTHON=true
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--minimal)
|
||||
INSTALL_DEBUG=false
|
||||
INSTALL_ANALYSIS=false
|
||||
INSTALL_PYTHON=false
|
||||
shift
|
||||
;;
|
||||
--no-toolchain)
|
||||
INSTALL_TOOLCHAIN=false
|
||||
shift
|
||||
;;
|
||||
--no-debug)
|
||||
INSTALL_DEBUG=false
|
||||
shift
|
||||
;;
|
||||
--no-analysis)
|
||||
INSTALL_ANALYSIS=false
|
||||
shift
|
||||
;;
|
||||
--no-python)
|
||||
INSTALL_PYTHON=false
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo " --minimal Minimal installation"
|
||||
echo " --no-toolchain Skip ARM toolchain"
|
||||
echo " --no-debug Skip debug tools"
|
||||
echo " --no-analysis Skip analysis tools"
|
||||
echo " --no-python Skip Python tools"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Install components
|
||||
if [ "$INSTALL_TOOLCHAIN" = true ]; then
|
||||
install_arm_toolchain || echo -e "${YELLOW}Toolchain installation incomplete${NC}"
|
||||
fi
|
||||
|
||||
if [ "$INSTALL_BUILD" = true ]; then
|
||||
install_build_tools
|
||||
fi
|
||||
|
||||
if [ "$INSTALL_DEBUG" = true ]; then
|
||||
install_debug_tools
|
||||
fi
|
||||
|
||||
if [ "$INSTALL_ANALYSIS" = true ]; then
|
||||
install_analysis_tools
|
||||
fi
|
||||
|
||||
if [ "$INSTALL_PYTHON" = true ]; then
|
||||
install_python_tools
|
||||
fi
|
||||
|
||||
# Setup project
|
||||
setup_project_dirs
|
||||
setup_git_hooks
|
||||
setup_vscode
|
||||
setup_env_vars
|
||||
|
||||
# Print summary
|
||||
echo ""
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo -e "${GREEN} Environment Setup Complete${NC}"
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo ""
|
||||
echo -e "Next steps:"
|
||||
echo -e " 1. Apply environment: ${CYAN}source ${PROJECT_ROOT}/.env${NC}"
|
||||
echo -e " 2. Build project: ${CYAN}bash scripts/build_all.sh${NC}"
|
||||
echo -e " 3. Run tests: ${CYAN}bash scripts/run_tests.sh${NC}"
|
||||
echo ""
|
||||
|
||||
# Check if toolchain is working
|
||||
if command_exists arm-none-eabi-gcc; then
|
||||
echo -e "${GREEN}✓ ARM toolchain ready: $(arm-none-eabi-gcc --version | head -n1)${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}⚠ ARM toolchain not found${NC}"
|
||||
echo -e "${YELLOW} Download from: https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads${NC}"
|
||||
echo -e "${YELLOW} For macOS Apple Silicon, choose: arm-gnu-toolchain-*-darwin-arm64-arm-none-eabi.tar.xz${NC}"
|
||||
echo -e "${YELLOW} Extract and add to PATH${NC}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Run main
|
||||
main "$@"
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
#!/bin/bash
|
||||
#==============================================================================
|
||||
# Static analysis for Automotive RTOS
|
||||
#==============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
# Script directory
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||
|
||||
# Color codes
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Analysis directory
|
||||
ANALYSIS_DIR="${PROJECT_ROOT}/build/analysis"
|
||||
mkdir -p "${ANALYSIS_DIR}"
|
||||
|
||||
# Print banner
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo -e "${BLUE} Static Analysis${NC}"
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo ""
|
||||
|
||||
# Check for cppcheck
|
||||
if command -v cppcheck >/dev/null 2>&1; then
|
||||
echo -e "${YELLOW}Running Cppcheck...${NC}"
|
||||
|
||||
cppcheck \
|
||||
--enable=all \
|
||||
--inconclusive \
|
||||
--std=c11 \
|
||||
-I"${PROJECT_ROOT}/kernel/include" \
|
||||
-I"${PROJECT_ROOT}/drivers/include" \
|
||||
-I"${PROJECT_ROOT}/middleware" \
|
||||
-I"${PROJECT_ROOT}/config" \
|
||||
--suppress=missingInclude \
|
||||
--suppress=missingIncludeSystem \
|
||||
"${PROJECT_ROOT}/kernel" \
|
||||
"${PROJECT_ROOT}/drivers" \
|
||||
"${PROJECT_ROOT}/middleware" \
|
||||
2>&1 | tee "${ANALYSIS_DIR}/cppcheck.log" || true
|
||||
|
||||
echo -e "${GREEN}✓ Cppcheck complete${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}Cppcheck not found. Skipping.${NC}"
|
||||
fi
|
||||
|
||||
# Check for compiler warnings
|
||||
echo -e "${YELLOW}Checking compiler warnings...${NC}"
|
||||
|
||||
if command -v arm-none-eabi-gcc >/dev/null 2>&1; then
|
||||
find "${PROJECT_ROOT}/kernel" "${PROJECT_ROOT}/drivers" "${PROJECT_ROOT}/middleware" \
|
||||
-name "*.c" -exec \
|
||||
arm-none-eabi-gcc \
|
||||
-Wall -Wextra \
|
||||
-fsyntax-only \
|
||||
-I"${PROJECT_ROOT}/kernel/include" \
|
||||
-I"${PROJECT_ROOT}/drivers/include" \
|
||||
-I"${PROJECT_ROOT}/middleware" \
|
||||
-I"${PROJECT_ROOT}/config" \
|
||||
{} \; 2>&1 | tee "${ANALYSIS_DIR}/compiler_warnings.log" || true
|
||||
|
||||
echo -e "${GREEN}✓ Compiler warning check complete${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}ARM toolchain not found. Skipping compiler check.${NC}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo -e "${GREEN} Static Analysis Complete${NC}"
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo -e "Reports saved to: ${ANALYSIS_DIR}"
|
||||
Reference in New Issue
Block a user