summaryrefslogtreecommitdiff
path: root/apps/compiler/compiler.sh
blob: e27b35c2deb8a4ab152c8148bbef4f50605701ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash

set -e

CURRENT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source "$CURRENT_PATH/includes/includes.sh"
source "$AC_PATH_APPS/bash_shared/menu_system.sh"

# Menu definition using the new system
# Format: "key|short|description"
comp_menu_items=(
    "build|b|Configure and compile"
    "clean|cl|Clean build files"
    "configure|cfg|Run CMake"
    "compile|cmp|Compile only"
    "all|a|clean, configure and compile"
    "ccacheClean|cc|Clean ccache files, normally not needed"
    "ccacheShowStats|cs|show ccache statistics"
    "quit|q|Close this menu"
)

# Menu command handler - called by menu system for each command
function handle_compiler_command() {
    local key="$1"
    shift
    
    case "$key" in
        "build")
            comp_build
            ;;
        "clean")
            comp_clean
            ;;
        "configure")
            comp_configure
            ;;
        "compile")
            comp_compile
            ;;
        "all")
            comp_all
            ;;
        "ccacheClean")
            comp_ccacheClean
            ;;
        "ccacheShowStats")
            comp_ccacheShowStats
            ;;
        "quit")
            echo "Closing compiler menu..."
            return 0
            ;;
        *)
            echo "Invalid option. Use --help to see available commands."
            return 1
            ;;
    esac
}

# Hook support (preserved from original)
runHooks "ON_AFTER_OPTIONS" # you can create your custom options

# Run the menu system
menu_run_with_items "ACORE COMPILER" handle_compiler_command -- "${comp_menu_items[@]}" -- "$@"