From 77d8def8f848420036c41aec76925cf24446e19e Mon Sep 17 00:00:00 2001 From: xeleh Date: Sun, 13 Feb 2022 14:08:38 +0100 Subject: [PATCH] Added build script --- README.md | 2 +- build.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100755 build.sh diff --git a/README.md b/README.md index 6570f5c..b5e4f5f 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ Demoscene-ish tiny intros and other sizecoding experiments. -Assemble with [nasm](https://www.nasm.us/). \ No newline at end of file +Assemble with [nasm](https://www.nasm.us/) or use the provided `build.sh` bash script. \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..fd7132d --- /dev/null +++ b/build.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# $1 : name of the folder to build +# Make sure that nasm is on the PATH! + +# fail if no folder name is specified +if [[ "$#" -eq 0 ]] ; then + exit 1 +fi + +# try to find the main .asm file +file="$1" +[ ! -f "$1/$file.asm" ] && file="main" +[ ! -f "$1/$file.asm" ] && file="test" +[ ! -f "$1/$file.asm" ] && exit 1 + +# assemble it +if command -v nasm &> /dev/null ; then + nasm -w+error -f bin -o "$1/$file.com" "$1/$file.asm" || exit 1 +else + echo "nasm not on path?" + exit 1 +fi + +# show .com file size +if [[ -f "$1/$file.com" ]] ; then + size=$(stat -f%z "$1/$file.com") + echo "$1/$file.com" : "$size" bytes +fi