Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- GAMESPATH=/home/ondra/games/inform # The basic path to your projects
- GAME="Murder Most Foul" # Name of the project
- DIRSCHEME="$GAME"/"$GAME".inform # The scheme under $GAMESPATH
- FULLPATH=$GAMESPATH/"$DIRSCHEME" # The path to the .inform directory itself.
- # Change here if you don't use the $GAME/$GAME.inform hierarchy
- SOURCEPATH="$FULLPATH"/Source # And the path to the Source dir
- TARGET=c # Without any options, the script will compile only
- BLORB=1 # Blorb a release version
- ZCODE=g # By default, compile to Glulx
- PLAY=no # Don't play after compiling
- INTERPRETER=gargoyle # Select an interpreter of our choice
- COMPILE=yes # Do we want to compile the source?
- ORDERFILE=order # Filename of the order file
- if [[ $1 ]]
- then
- GAME="$1"
- if [[ ! -d "$FULLPATH" ]] # Check if the directory exists
- then
- echo "You need to supply a valid game directory name withouth the .inform extension, enclosed in quotes."
- exit 3
- fi
- fi
- while getopts crpbBz:C opt # Here we have the arguments to the script
- do
- case $opt in
- c) # Just compile
- TARGET=c
- ;;
- r) # Release
- TARGET=r
- ;;
- p) # Play
- PLAY=yes
- ;;
- b) # Blorb the release
- BLORB=1
- ;;
- B) # Don't blorb the release
- BLORB=0 # WARNING! Non-blorbed releases are not in Materials/Release directory
- ;;
- z) # Compile into following format: 5 = z5, 6 = z6, 8 = z8, g = glulx
- ZCODE=$OPTARG
- ;;
- C)
- COMPILE=no # Don't even compile, just cat the files into story.ni
- ;;
- esac
- done
- shift $OPTIND
- cd "$SOURCEPATH"
- function newline () # Add a new line
- {
- echo " " | tr " " "\r" | sed "s/\r//" - >> story.txt
- }
- if [[ -f $ORDERFILE ]] # Must have a file with ordered list of sourcing files
- then
- while read line
- do
- ISHEADING=`echo "$line" | sed "s/^\(.\).*/\1/" -` # Check if the line contains headings
- # Line with headings have to start with + sign
- if [[ $ISHEADING = + ]]
- then
- echo "$line" | sed "s/^+//" - >> story.txt # Add the heading into the source file
- newline
- else
- echo "[$line]" | cat - >> story.txt # Add the file name for easier debugging
- newline
- cat "$line" >> story.txt # Add the contents of the file to the end of the temp source file
- newline
- fi
- done < $ORDERFILE
- cp story.ni story.ni.bck # Back up our original source file
- mv story.txt story.ni # Replace the old source with the new
- fi
- if [[ $COMPILE = no ]] # Stop here if we don't need to compile the source
- then
- exit 2
- fi
- i7 -s blorb=$BLORB,zcode=$ZCODE -$TARGET "$FULLPATH" # Compile
- if [[ $TARGET = -r ]] # If we want to release, let's stop here
- then
- exit 1
- fi
- if [[ $PLAY = yes ]] # If we want to play
- then
- case $ZCODE in # Decide on an appropriate file extension
- 5)
- EXT=z5
- ;;
- 6)
- EXT=z6
- ;;
- 8)
- EXT=z8
- ;;
- g|256)
- EXT=ulx
- ;;
- esac
- cd "$FULLPATH"/Build/ # Move to the Build dir
- if [[ -f output.$EXT ]] # If the file exists
- then
- $INTERPRETER output.$EXT # Play the file
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement