-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathembodi
More file actions
executable file
·190 lines (159 loc) · 4.79 KB
/
Copy pathembodi
File metadata and controls
executable file
·190 lines (159 loc) · 4.79 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
184
185
186
187
188
189
190
#!/usr/bin/env bash
#
# embodi - EMBODIOS build and management tool
#
# Usage:
# embodi build [--debug] Build kernel
# embodi iso [--model PATH] [--arch ARCH] Create bootable ISO
# embodi run [--memory SIZE] Run in QEMU
# embodi clean Clean build artifacts
# embodi test Run tests
# embodi help Show this help
#
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
KERNEL_DIR="$SCRIPT_DIR/kernel"
BUILD_DIR="$SCRIPT_DIR/build"
MODELS_DIR="$SCRIPT_DIR/models"
# Colors (disable if not tty)
if [ -t 1 ]; then
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m'
else
RED='' GREEN='' YELLOW='' BLUE='' NC=''
fi
log() { echo -e "${GREEN}[embodi]${NC} $*"; }
warn() { echo -e "${YELLOW}[embodi]${NC} $*"; }
error() { echo -e "${RED}[embodi]${NC} $*" >&2; }
die() { error "$@"; exit 1; }
usage() {
cat <<EOF
EMBODIOS Build Tool
Usage: embodi <command> [options]
Commands:
build Build the kernel
iso Create bootable ISO
run Run in QEMU
clean Clean build artifacts
test Run kernel tests
help Show this help
Build Options:
embodi build [--debug]
--debug Build with debug symbols
ISO Options:
embodi iso [--model PATH] [--arch ARCH]
--model PATH Path to GGUF model file (optional)
--arch ARCH Target architecture: x86_64 (default), arm64
Run Options:
embodi run [--memory SIZE] [--iso]
--memory SIZE Memory size (default: 512M)
--iso Boot from ISO instead of kernel
Examples:
embodi build # Quick kernel build
embodi build --debug # Debug build
embodi iso # ISO without model
embodi iso --model models/smollm.gguf # ISO with embedded model
embodi run # Run kernel in QEMU
embodi run --memory 2G --iso # Run ISO with 2GB RAM
EOF
}
cmd_build() {
local debug=0
while [[ $# -gt 0 ]]; do
case "$1" in
--debug|-d) debug=1; shift ;;
*) die "Unknown option: $1" ;;
esac
done
log "Building kernel..."
cd "$KERNEL_DIR"
if [[ $debug -eq 1 ]]; then
make DEBUG=1
else
make
fi
log "Build complete: $KERNEL_DIR/embodios.elf"
}
cmd_iso() {
local model=""
local arch="x86_64"
while [[ $# -gt 0 ]]; do
case "$1" in
--model|-m) model="$2"; shift 2 ;;
--arch|-a) arch="$2"; shift 2 ;;
*) die "Unknown option: $1" ;;
esac
done
# Validate arch
case "$arch" in
x86_64|arm64) ;;
*) die "Unsupported architecture: $arch (supported: x86_64, arm64)" ;;
esac
log "Creating ISO for $arch..."
local iso_args=""
if [[ -n "$model" ]]; then
if [[ ! -f "$model" ]]; then
die "Model file not found: $model"
fi
iso_args="-m $model"
log "Embedding model: $model"
fi
"$SCRIPT_DIR/scripts/create_iso.sh" $iso_args
log "ISO created: $BUILD_DIR/embodios.iso"
}
cmd_run() {
local memory="512M"
local use_iso=0
while [[ $# -gt 0 ]]; do
case "$1" in
--memory|-m) memory="$2"; shift 2 ;;
--iso|-i) use_iso=1; shift ;;
*) die "Unknown option: $1" ;;
esac
done
# Check for QEMU
if ! command -v qemu-system-x86_64 &>/dev/null; then
die "qemu-system-x86_64 not found. Install QEMU first."
fi
if [[ $use_iso -eq 1 ]]; then
local iso="$BUILD_DIR/embodios.iso"
if [[ ! -f "$iso" ]]; then
die "ISO not found: $iso (run 'embodi iso' first)"
fi
log "Running ISO with ${memory} RAM..."
log "Note: Large ISOs may not boot in QEMU (SeaBIOS limitation)"
qemu-system-x86_64 -cdrom "$iso" -m "$memory" -boot d -nographic
else
local kernel="$KERNEL_DIR/embodios.elf"
if [[ ! -f "$kernel" ]]; then
die "Kernel not found: $kernel (run 'embodi build' first)"
fi
log "Running kernel with ${memory} RAM..."
qemu-system-x86_64 -kernel "$kernel" -m "$memory" -nographic
fi
}
cmd_clean() {
log "Cleaning build artifacts..."
cd "$KERNEL_DIR"
make clean
rm -rf "$BUILD_DIR"
log "Clean complete"
}
cmd_test() {
log "Running tests..."
cd "$KERNEL_DIR"
make test
}
# Main
case "${1:-help}" in
build) shift; cmd_build "$@" ;;
iso) shift; cmd_iso "$@" ;;
run) shift; cmd_run "$@" ;;
clean) shift; cmd_clean "$@" ;;
test) shift; cmd_test "$@" ;;
help|-h|--help) usage ;;
*) die "Unknown command: $1 (try 'embodi help')" ;;
esac