-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·40 lines (32 loc) · 895 Bytes
/
build.sh
File metadata and controls
executable file
·40 lines (32 loc) · 895 Bytes
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
#!/bin/zsh
kernel=$(uname -s)
BIN=bin
BUILD=build
MAIN=$1
DIRNAME=$(dirname "$MAIN")
FILENAME=${$(basename "$MAIN")%.*}
echo "Compiling $FILENAME..."
mkdir -p bin
cp $BUILD/dd $BIN/$FILENAME
echo "Building $FILENAME"
./$BIN/$FILENAME $MAIN
mv $BUILD/$FILENAME.asm $BIN/$FILENAME.asm
# mv dd.asm $BIN/$FILENAME.asm
# echo $kernel
if [ "$kernel" = "Darwin" ]; then
# macOS (M1 Mac)
echo "linking and loading in m1"
as $BIN/$FILENAME.asm -o $BIN/$FILENAME.o
ld $BIN/$FILENAME.o -o $BIN/$FILENAME -lSystem -syslibroot `xcrun -sdk macosx --show-sdk-path`
elif [ "$kernel" = "Linux" ]; then
# Linux (Raspberry Pi)
echo "linking and loading with Pi"
as $BIN/$FILENAME.asm -o $BIN/$FILENAME.o-gdwaef64 -g3
ld $BIN/$FILENAME.o -o $BIN/$FILENAME -arch -arm64
else
echo "Unsupported system"
exit 1
fi
echo "Running binary $FILENAME"
./$BIN/$FILENAME
echo $?