-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
67 lines (57 loc) · 1.56 KB
/
Copy pathbuild.sh
File metadata and controls
67 lines (57 loc) · 1.56 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
#!/bin/bash
# ============================================================================
# AK CODE Bootstrap Compiler - Linux Build Script
# Builds the entire bootstrap compiler using NASM and LD
# ============================================================================
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR="$SCRIPT_DIR/build"
echo "=== AK CODE Bootstrap Compiler Build ==="
echo ""
# Create build directory
mkdir -p "$BUILD_DIR"
# Functions for build steps
assemble() {
echo " Assembling $1..."
nasm -f elf64 -g -F dwarf "$SCRIPT_DIR/asm/$1" -o "$BUILD_DIR/${1%.asm}.o"
}
link() {
echo " Linking..."
ld -o "$BUILD_DIR/akc" \
"$BUILD_DIR/entry_linux.o" \
"$BUILD_DIR/lexer.o" \
"$BUILD_DIR/parser.o" \
"$BUILD_DIR/codegen.o" \
"$BUILD_DIR/runtime.o" \
"$BUILD_DIR/linker_glue.o" \
-e _start \
--gc-sections \
-z noexecstack
}
echo "Step 1: Assembling all source files..."
assemble "runtime.asm"
assemble "entry_linux.asm"
assemble "lexer.asm"
assemble "parser.asm"
assemble "codegen.asm"
assemble "linker_glue.asm"
echo ""
echo "Step 2: Linking..."
link
echo ""
echo "Step 3: Setting permissions..."
chmod +x "$BUILD_DIR/akc"
echo ""
echo "=== Build Complete ==="
echo " Output: $BUILD_DIR/akc"
echo ""
echo "Usage:"
echo " ./build/akc source.ak [-o output]"
echo ""
# Test if NASM is available
if command -v nasm &> /dev/null; then
NASM_VER=$(nasm --version 2>&1 | head -n1)
echo " NASM: $NASM_VER"
else
echo " WARNING: NASM not found in PATH"
fi