Skip to content

Commit

Permalink
Tidy build script
Browse files Browse the repository at this point in the history
  • Loading branch information
lajohnston committed Apr 21, 2021
1 parent f38746d commit 1448409
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions examples/build.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,49 @@
#!/bin/bash

###
# Build examples on Linux
###

set -e # exit on errors

# cd to script directory
DIRECTORY=$(cd `dirname $0` && pwd)
cd $DIRECTORY
EXAMPLES_DIRECTORY=$(cd `dirname $0` && pwd)
cd $EXAMPLES_DIRECTORY

# Prep build directory
rm -r ./build
mkdir -p ./build/tmp
BUILD_DIR=$(realpath build)
TEMP_DIR=$BUILD_DIR/tmp

rm -rf $BUILD_DIR
mkdir $BUILD_DIR
mkdir $TEMP_DIR

# Build examples

EXAMPLES=( $(ls -d [0-9][0-9]-*) )
for i in "${EXAMPLES[@]}"
do
BUILD_DIR=../build
TEMP_DIR=$BUILD_DIR/tmp

cd ./$i
PROJECT_NAME=$i
for EXAMPLE in "${EXAMPLES[@]}"
do
cd $EXAMPLES_DIRECTORY/$EXAMPLE

printf "\nBuilding example ${PROJECT_NAME}:\n\n"
printf "\nBuilding example ${EXAMPLE}:\n\n"

# Create simple linkfile
LINKFILE=$TEMP_DIR/linkfile
echo [objects] > $LINKFILE
echo $PROJECT_NAME.o >> $LINKFILE
echo $EXAMPLE.o >> $LINKFILE

# Assemble objects
wla-z80 -o $TEMP_DIR/$PROJECT_NAME.o main.asm
wla-z80 -o $TEMP_DIR/$EXAMPLE.o main.asm

# Link objects
cd $TEMP_DIR
wlalink -d -v -S -A linkfile $PROJECT_NAME.sms
wlalink -d -v -S -A linkfile $EXAMPLE.sms
cd - # return to former directory

# Place output in build directory
mv $TEMP_DIR/$PROJECT_NAME.sms $BUILD_DIR
mv $TEMP_DIR/$PROJECT_NAME.sym $BUILD_DIR
mv $TEMP_DIR/$EXAMPLE.sms $BUILD_DIR
mv $TEMP_DIR/$EXAMPLE.sym $BUILD_DIR

cd ../
cd $EXAMPLES_DIRECTORY
done

0 comments on commit 1448409

Please sign in to comment.