#!/bin/bash

# releaseadl
# this assumes you have a complete ArchProj directory hierarchy installed, with then
# archTools folders containing correct source etc code
# it gets rid of stuff not wanted in an uploadable release, in particular
#	- any .o files
#	- any DerivedData folders in the various projects

echo "releaseadl 0.1v0"
echo

#first find the path to the current directory
archpath="${PWD}"
#echo "We're in directory $archpath"

#################### clean up the tools ######################

echo "cleaning up tools:"

# no need to loop through the tools - we know what they are
# simpleADL
cd "$archpath/archTools/simpleADL/"
      
make clean
rm -rf simpleADL/DerivedData

cd ..

cd "$archpath/archTools/simpleAsm/"

echo "cleaning up simpleAsm..."

make clean
rm -rf simpleAsm/DerivedData

cd ..

cd "$archpath/archTools/simpleModel/"
echo "cleaning up simpleModel..."
make clean
rm -rf simpleModel/DerivedData

cd ..

#################### clean up all the architectures ######################

echo 
echo
echo "listing architectures:"
cd "$archpath/archModels"

# loop through the list of directories
for f in *; do
    if [[ -d $f ]]; then
        # $f is a directory
        # need to tidy stuff in the 'projects/asm' folder
        echo
        echo "Working on $f..."
        cd "$archpath/archModels/$f/projects/asm/"
        
 		make clean
 		rm -rf DerivedData

        # into the model directory
        cd "$archpath/archModels"
        cd "$archpath/archModels/$f/projects/model/"
        make clean
 		rm -rf DerivedData
 		
        cd "$archpath/archModels"

    fi
done

cd ..


echo
echo "All done."
echo

