-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·95 lines (82 loc) · 3.69 KB
/
build.sh
File metadata and controls
executable file
·95 lines (82 loc) · 3.69 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
#!/data/data/com.termux/files/usr/bin/bash
# build.sh — Build abt on Termux (Android 15)
# Run this once to compile the abt binary itself.
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
BUILD_DIR="$SCRIPT_DIR/build_abt"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
log_info() { echo -e "${GREEN}[abt]${NC} $*"; }
log_warn() { echo -e "${YELLOW}[abt]${NC} $*"; }
log_error() { echo -e "${RED}[abt]${NC} $*" >&2; }
log_step() { echo -e "\n${CYAN}──── $* ────${NC}"; }
# ── Check dependencies ────────────────────────────────────────────────────────
log_step "Checking Termux dependencies"
MISSING=()
for pkg in cmake clang make python; do
if ! command -v "$pkg" &>/dev/null; then
MISSING+=("$pkg")
fi
done
if [ ${#MISSING[@]} -gt 0 ]; then
log_warn "Missing packages: ${MISSING[*]}"
log_info "Installing with pkg..."
pkg install -y "${MISSING[@]}"
fi
# Optional: libcurl for dependency fetching
if ! pkg list-installed 2>/dev/null | grep -q libcurl; then
log_warn "libcurl not found — dependency fetching will be disabled"
log_warn "Install with: pkg install libcurl"
EXTRA_FLAGS="-DABT_USE_CURL=OFF"
fi
# ── Generate tiny_dex ─────────────────────────────────────────────────────────
log_step "Generating runtime assets"
python3 "$SCRIPT_DIR/runtime/tiny_dex/generate_tiny_dex.py"
log_info "classes.dex: OK"
# ── Configure ─────────────────────────────────────────────────────────────────
log_step "Configuring CMake"
mkdir -p "$BUILD_DIR"
cmake -B "$BUILD_DIR" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang \
${EXTRA_FLAGS} \
"$SCRIPT_DIR"
# ── Build ─────────────────────────────────────────────────────────────────────
log_step "Building abt"
JOBS=$(nproc 2>/dev/null || echo 4)
cmake --build "$BUILD_DIR" --parallel "$JOBS"
# ── Verify ────────────────────────────────────────────────────────────────────
log_step "Verifying"
ABT_BIN="$SCRIPT_DIR/bin/abt"
if [ -f "$ABT_BIN" ]; then
log_info "Binary: $ABT_BIN"
ls -lh "$ABT_BIN"
file "$ABT_BIN" 2>/dev/null || true
else
log_error "Binary not found at $ABT_BIN"
exit 1
fi
# ── PATH suggestion ────────────────────────────────────────────────────────────
echo ""
echo -e "${GREEN}✓ Build successful!${NC}"
echo ""
echo "Add to your PATH:"
echo " export PATH=\"$SCRIPT_DIR/bin:\$PATH\""
echo ""
echo "Then use:"
echo " abt info # check environment"
echo " abt build # build your project"
echo " abt build --release # release build"
echo " abt watch # incremental rebuild"
echo " abt install # build + adb install"
echo ""
echo "Create a project file (AbtProject.cmake):"
echo ' abt_project(MyApp)'
echo ' abt_set_package(com.example.myapp)'
echo ' abt_set_min_sdk(24)'
echo ' abt_add_sources(src/main.cpp)'
echo ' abt_link_libraries(android log EGL GLESv3)'