-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·183 lines (162 loc) · 8.09 KB
/
setup.sh
File metadata and controls
executable file
·183 lines (162 loc) · 8.09 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/usr/bin/env bash
set -euo pipefail
# ── Parse args ──────────────────────────────────────────────
CI_MODE=false
for arg in "$@"; do
case "$arg" in
--ci) CI_MODE=true ;;
esac
done
# ── Pinned versions (must match CMakeLists.txt) ─────────────
QT_VERSION="6.8.3"
PYTHON_MIN="3.11"
CMAKE_MIN="3.27"
GCC_MIN="12.3"
CLANG_MIN="15.0"
# ── Colours ─────────────────────────────────────────────────
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m'
ok() { echo -e " ${GREEN}OK${NC}"; }
fail() { echo -e " ${RED}ERROR: $1${NC}"; exit 1; }
info() { echo -e " ${YELLOW}$1${NC}"; }
echo ""
echo "================================================"
echo " Fincept Terminal v4.0.1 — Setup"
echo " Pinned: Qt ${QT_VERSION} | CMake ${CMAKE_MIN}+ | Python ${PYTHON_MIN}+"
[ "$CI_MODE" = true ] && echo " (CI mode — skipping interactive steps)"
echo "================================================"
echo ""
# ── Detect OS ───────────────────────────────────────────────
OS="$(uname -s)"
case "$OS" in
Linux*) PLATFORM="linux" ; QT_KIT="gcc_64" ; PRESET="linux-release" ;;
Darwin*) PLATFORM="macos" ; QT_KIT="macos" ; PRESET="macos-release" ;;
*) fail "Unsupported OS: $OS" ;;
esac
echo "Platform: $OS"
echo ""
# ── Helper: version >= min ──────────────────────────────────
version_ge() {
# $1=actual $2=min returns 0 (true) if actual >= min
[ "$(printf '%s\n%s\n' "$2" "$1" | sort -V | head -1)" = "$2" ]
}
# ── Step 1: System dependencies (build tools only) ──────────
echo "[1/7] Installing system build tools..."
if [ "$PLATFORM" = "linux" ]; then
command -v apt-get &>/dev/null || fail "apt-get not found. Install cmake / ninja-build / g++ / python3.11 / python3-pip manually."
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends \
git cmake ninja-build g++ \
python3 python3-pip python3-venv \
libgl1-mesa-dev libglu1-mesa-dev \
libxkbcommon-dev libxkbcommon-x11-dev \
libfontconfig1 libdbus-1-3 \
pkg-config curl
elif [ "$PLATFORM" = "macos" ]; then
if ! command -v brew &>/dev/null; then
[ "$CI_MODE" = true ] && fail "Homebrew not found in CI environment."
info "Homebrew not found. Installing..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
brew install cmake ninja python@3.11 openssl@3 yt-dlp
fi
ok
# ── Step 2: Verify compiler version ─────────────────────────
echo "[2/7] Checking C++ compiler..."
if [ "$PLATFORM" = "linux" ]; then
command -v g++ &>/dev/null || fail "g++ not found."
GCC_VER="$(g++ -dumpfullversion -dumpversion 2>/dev/null || g++ --version | head -1 | awk '{print $NF}')"
echo " g++ ${GCC_VER}"
version_ge "$GCC_VER" "$GCC_MIN" || fail "GCC ${GCC_MIN}+ required. Found ${GCC_VER}. Install g++-12 or newer."
elif [ "$PLATFORM" = "macos" ]; then
command -v clang++ &>/dev/null || fail "clang++ not found. Run: xcode-select --install"
CLANG_VER="$(clang++ --version | head -1 | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -1)"
echo " Apple Clang ${CLANG_VER}"
version_ge "$CLANG_VER" "$CLANG_MIN" || fail "Apple Clang ${CLANG_MIN}+ required (Xcode 15.2+). Found ${CLANG_VER}."
fi
ok
# ── Step 3: Verify CMake version ────────────────────────────
echo "[3/7] Checking CMake..."
command -v cmake &>/dev/null || fail "cmake not found."
CMAKE_VER="$(cmake --version | head -1 | awk '{print $3}')"
echo " cmake ${CMAKE_VER}"
version_ge "$CMAKE_VER" "$CMAKE_MIN" || fail "CMake ${CMAKE_MIN}+ required. Found ${CMAKE_VER}. Download from https://cmake.org/download/"
ok
# ── Step 4: Verify Python version ───────────────────────────
echo "[4/7] Checking Python..."
PYTHON="$(command -v python3.11 || command -v python3 || true)"
[ -n "$PYTHON" ] || fail "python3 not found."
PY_VER="$($PYTHON -c 'import sys; print("%d.%d.%d" % sys.version_info[:3])')"
echo " python ${PY_VER}"
version_ge "$PY_VER" "$PYTHON_MIN" || fail "Python ${PYTHON_MIN}+ required. Found ${PY_VER}."
ok
# ── Step 5: Install pinned Qt ${QT_VERSION} via aqtinstall ──
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
QT_INSTALL_ROOT="${FINCEPT_QT_ROOT:-$SCRIPT_DIR/.qt}"
QT_PREFIX="$QT_INSTALL_ROOT/$QT_VERSION/$QT_KIT"
echo "[5/7] Locating Qt ${QT_VERSION}..."
if [ -n "${Qt6_DIR:-}" ] && [ -f "$Qt6_DIR/lib/cmake/Qt6/Qt6Config.cmake" ]; then
QT_PREFIX="$Qt6_DIR"
info "Using Qt from Qt6_DIR env: $QT_PREFIX"
elif [ -f "$QT_PREFIX/lib/cmake/Qt6/Qt6Config.cmake" ]; then
info "Qt ${QT_VERSION} already installed at $QT_PREFIX"
else
info "Installing Qt ${QT_VERSION} via aqtinstall to $QT_INSTALL_ROOT ..."
# aqtinstall is a stable community tool that downloads exact Qt versions
# from the official Qt mirror. Much smaller than Qt Online Installer and scriptable.
"$PYTHON" -m pip install --user --quiet --upgrade aqtinstall
AQT="$("$PYTHON" -m pip show aqtinstall >/dev/null 2>&1 && "$PYTHON" -m aqt help >/dev/null 2>&1 && echo "$PYTHON -m aqt" || echo "")"
[ -n "$AQT" ] || fail "aqtinstall did not install correctly."
# Qt host/target/arch
if [ "$PLATFORM" = "linux" ]; then
AQT_HOST="linux" ; AQT_TARGET="desktop" ; AQT_ARCH="gcc_64"
else
AQT_HOST="mac" ; AQT_TARGET="desktop" ; AQT_ARCH="macos"
fi
# Modules required to compile Fincept (match find_package COMPONENTS)
AQT_MODULES="qtcharts qtwebsockets qtmultimedia qtspeech"
$AQT install-qt "$AQT_HOST" "$AQT_TARGET" "$QT_VERSION" "$AQT_ARCH" \
--outputdir "$QT_INSTALL_ROOT" \
--modules $AQT_MODULES \
|| fail "aqtinstall failed. Check internet connection or install Qt ${QT_VERSION} manually from https://www.qt.io/download-qt-installer"
[ -f "$QT_PREFIX/lib/cmake/Qt6/Qt6Config.cmake" ] || fail "Qt install completed but Qt6Config.cmake not found at $QT_PREFIX"
fi
export CMAKE_PREFIX_PATH="$QT_PREFIX${CMAKE_PREFIX_PATH:+:$CMAKE_PREFIX_PATH}"
echo " CMAKE_PREFIX_PATH=$QT_PREFIX"
ok
# ── Step 6: Configure (using CMake preset) ──────────────────
APP_DIR="$SCRIPT_DIR/fincept-qt"
[ -d "$APP_DIR" ] || fail "fincept-qt directory not found. Ensure you cloned the full repository."
cd "$APP_DIR"
echo "[6/7] Configuring (preset: $PRESET)..."
# Override the preset's default CMAKE_PREFIX_PATH with the one we just set,
# so the build picks up the aqtinstall location rather than ~/Qt/6.8.3/...
EXTRA_ARGS=""
if [ "$PLATFORM" = "macos" ] && [ -d "/opt/homebrew/opt/openssl@3" ]; then
EXTRA_ARGS="-DOPENSSL_ROOT_DIR=/opt/homebrew/opt/openssl@3"
fi
cmake --preset "$PRESET" -DCMAKE_PREFIX_PATH="$QT_PREFIX" $EXTRA_ARGS \
|| fail "CMake configure failed. See error above."
ok
# ── Step 7: Build ───────────────────────────────────────────
echo "[7/7] Compiling..."
cmake --build --preset "$PRESET" || fail "Build failed. See error above."
ok
# ── Done ────────────────────────────────────────────────────
BIN="$APP_DIR/build/$PRESET/FinceptTerminal"
[ "$PLATFORM" = "macos" ] && BIN="$APP_DIR/build/$PRESET/FinceptTerminal.app/Contents/MacOS/FinceptTerminal"
echo ""
echo "================================================"
echo " Build complete!"
echo " Run: $BIN"
echo "================================================"
echo ""
if [ "$CI_MODE" = true ]; then
exit 0
fi
read -r -p " Launch now? (y/n): " LAUNCH
if [[ "$LAUNCH" =~ ^[Yy]$ ]]; then
"$BIN"
fi