-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·61 lines (46 loc) · 1.82 KB
/
build.sh
File metadata and controls
executable file
·61 lines (46 loc) · 1.82 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
#!/bin/bash
# ZX Spectrum Basic Build Script
# Compiles .bas files using Boriel Basic compiler
set -e
BUILD_DIR="build"
SRC_DIR="src"
ASM_SRC_DIR="src/asm"
# Create build directory if it doesn't exist
mkdir -p "$BUILD_DIR"
echo "Building ZX Spectrum Basic projects..."
# Compile all .bas files in src directory
for basfile in "$SRC_DIR"/*.bas; do
if [ -f "$basfile" ]; then
filename=$(basename "$basfile" .bas)
echo "Compiling $basfile..."
# Compile to TAP format (ZX Spectrum tape format)
zxbc "$basfile" -o "$BUILD_DIR/$filename.tap" -O 2
# Also compile to binary
zxbc "$basfile" -o "$BUILD_DIR/$filename.bin" -O 2 --output-file-type=bin
echo "Created: $BUILD_DIR/$filename.tap and $BUILD_DIR/$filename.bin"
fi
done
echo "Build complete! Output files are in the $BUILD_DIR directory."
# Compile assembly files if they exist
if [ -d "$ASM_SRC_DIR" ] && [ "$(ls -A "$ASM_SRC_DIR"/*.asm 2>/dev/null)" ]; then
echo ""
echo "Building Z80 Assembly projects..."
mkdir -p "$BUILD_DIR/asm"
for asmfile in "$ASM_SRC_DIR"/*.asm; do
if [ -f "$asmfile" ]; then
filename=$(basename "$asmfile" .asm)
echo "Assembling $asmfile..."
# Try SjASMPlus first, fallback to z80asm
if command -v sjasmplus >/dev/null 2>&1; then
sjasmplus --raw="$BUILD_DIR/asm/$filename.bin" "$asmfile"
elif command -v z80asm >/dev/null 2>&1; then
z80asm -o "$BUILD_DIR/asm/$filename.bin" "$asmfile"
else
echo "Warning: No Z80 assembler found. Skipping assembly files."
break
fi
echo "Created: $BUILD_DIR/asm/$filename.bin"
fi
done
echo "Assembly build complete!"
fi