Skip to content

Commit cd75192

Browse files
committed
Updated scripts
1 parent 6019691 commit cd75192

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

scripts/build.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
set -e
33
source "$(dirname $0)/common.sh"
44

5-
SOURCE=${1?"path to source.asm is missing: \$1"}
6-
SOURCE_DIR="$(dirname $SOURCE)"
7-
BINARY=${2?"path for output binary is missing: \$2"}
5+
SOURCE_DIR=${1?"path to source dir is missing: \$1"}
6+
BUILD_DIR=${2?"path to build dir is missing: \$2"}
87
MAX_SIZE=446
98

109
echo "[Build] Starting..."
11-
nasm -f bin "${SOURCE:?}" -o "${BINARY:?}" -i "${SOURCE_DIR}"
12-
binary_size="$(stat -c '%s' ${BINARY:?})"
10+
nasm "${SOURCE_DIR:?}/main_low.asm" -o "${BUILD_DIR:?}/main_low.o" -f elf64
11+
gcc -c "${SOURCE_DIR:?}/main.c" -o "${BUILD_DIR:?}/main.o"
12+
nasm -f bin "${SOURCE_DIR:?}/init.asm" -o "${BUILD_DIR:?}/init" -i "${SOURCE_DIR}"
13+
14+
binary_size="$(stat -c '%s' ${BUILD_DIR:?}/init )"
1315
(( ${binary_size:?} <= ${MAX_SIZE:?})) || raise "Binary size exceeds ${MAX_SIZE:?} bytes, got ${binary_size:?}"
1416
echo "[Build] done. BinarySize: ${binary_size} bytes. MaxSize: ${MAX_SIZE} bytes."

scripts/run.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,26 @@ set -e
33

44
# TODO: Fix dirs
55
SCRIPTS_DIR="/home/scopeinfinity/OS/scripts"
6+
SOURCE_DIR="/home/scopeinfinity/OS/bootloader"
67
BUILD_DIR="/home/scopeinfinity/OS/build"
78

8-
SOURCE="$(realpath main.asm)"
9-
BINARY="${BUILD_DIR:?}/main"
9+
BINARY="${BUILD_DIR:?}/init"
1010
DISK="$(realpath ../disk.vmdk)"
1111

1212
mkdir -p ${BUILD_DIR:?}
1313

14-
bash "${SCRIPTS_DIR}/build.sh" "${SOURCE}" "${BINARY}"
15-
bash "${SCRIPTS_DIR}/burn.sh" "${BINARY}" "${DISK}"
14+
function gethash {
15+
local hash=$(md5sum "$1" 2> /dev/null | cut -d ' ' -f1 )
16+
echo "$hash"
17+
}
18+
init_lm_s=$(gethash "${BINARY}")
19+
bash "${SCRIPTS_DIR}/build.sh" "${SOURCE_DIR}" "${BUILD_DIR}"
20+
init_lm_d=$(gethash "${BINARY}")
21+
if [[ "$1" = "--alsoburn" ]]; then
22+
if [[ "$init_lm_s" != "$init_lm_d" ]]; then
23+
bash "${SCRIPTS_DIR}/burn.sh" "${BINARY}" "${DISK}"
24+
else
25+
echo "Binary unchanged, ignoring burn."
26+
fi
27+
fi
1628
echo "Run Completed!"

0 commit comments

Comments
 (0)