Advertisement
Guest User

Untitled

a guest
Jul 10th, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
BOO 3.16 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. GAMESPATH=/home/ondra/games/inform                  # The basic path to your projects
  4. GAME="Murder Most Foul"                         # Name of the project
  5. DIRSCHEME="$GAME"/"$GAME".inform                    # The scheme under $GAMESPATH
  6. FULLPATH=$GAMESPATH/"$DIRSCHEME"                    # The path to the .inform directory itself.
  7.                                     # Change here if you don't use the $GAME/$GAME.inform hierarchy
  8. SOURCEPATH="$FULLPATH"/Source                       # And the path to the Source dir
  9. TARGET=c                                # Without any options, the script will compile only
  10. BLORB=1                                 # Blorb a release version
  11. ZCODE=g                                 # By default, compile to Glulx
  12. PLAY=no                                 # Don't play after compiling
  13. INTERPRETER=gargoyle                            # Select an interpreter of our choice
  14. COMPILE=yes                             # Do we want to compile the source?
  15. ORDERFILE=order                             # Filename of the order file
  16.  
  17. if [[ $1 ]]
  18. then
  19.     GAME="$1"
  20.     if [[ ! -d "$FULLPATH" ]]                   # Check if the directory exists
  21.     then
  22.         echo "You need to supply a valid game directory name withouth the .inform extension, enclosed in quotes."
  23.         exit 3
  24.     fi
  25. fi
  26.  
  27. while getopts crpbBz:C opt                      # Here we have the arguments to the script
  28. do
  29.     case $opt in
  30.         c)                          # Just compile
  31.             TARGET=c
  32.             ;;
  33.         r)                          # Release
  34.             TARGET=r
  35.             ;;
  36.         p)                          # Play
  37.             PLAY=yes
  38.             ;;
  39.         b)                          # Blorb the release
  40.             BLORB=1
  41.             ;;
  42.         B)                          # Don't blorb the release
  43.             BLORB=0                     # WARNING! Non-blorbed releases are not in Materials/Release directory
  44.             ;;
  45.         z)                          # Compile into following format: 5 = z5, 6 = z6, 8 = z8, g = glulx
  46.             ZCODE=$OPTARG
  47.             ;;
  48.         C)
  49.             COMPILE=no                  # Don't even compile, just cat the files into story.ni
  50.             ;;
  51.     esac
  52. done
  53. shift $OPTIND
  54.  
  55. cd "$SOURCEPATH"
  56.  
  57. function newline ()                         # Add a new line
  58. {
  59.     echo " " | tr " " "\r" | sed "s/\r//" - >> story.txt
  60. }
  61.  
  62. if [[ -f $ORDERFILE ]]                          # Must have a file with ordered list of sourcing files
  63. then
  64.     while read line
  65.     do
  66.         ISHEADING=`echo "$line" | sed "s/^\(.\).*/\1/" -`   # Check if the line contains headings
  67.                                     # Line with headings have to start with + sign
  68.         if [[ $ISHEADING = + ]]
  69.         then
  70.             echo "$line" | sed "s/^+//" - >> story.txt  # Add the heading into the source file
  71.             newline
  72.         else
  73.             echo "[$line]" | cat - >> story.txt     # Add the file name for easier debugging
  74.             newline
  75.             cat "$line" >> story.txt            # Add the contents of the file to the end of the temp source file
  76.             newline
  77.         fi
  78.     done < $ORDERFILE
  79.     cp story.ni story.ni.bck                    # Back up our original source file
  80.     mv story.txt story.ni                       # Replace the old source with the new
  81. fi
  82.  
  83. if [[ $COMPILE = no ]]                          # Stop here if we don't need to compile the source
  84. then
  85.     exit 2
  86. fi
  87.  
  88. i7 -s blorb=$BLORB,zcode=$ZCODE -$TARGET "$FULLPATH"            # Compile
  89.  
  90. if [[ $TARGET = -r ]]                           # If we want to release, let's stop here
  91. then
  92.     exit 1
  93. fi
  94.  
  95. if [[ $PLAY = yes ]]                            # If we want to play
  96. then
  97.     case $ZCODE in                          # Decide on an appropriate file extension
  98.         5)
  99.             EXT=z5
  100.             ;;
  101.         6)
  102.             EXT=z6
  103.             ;;
  104.         8)
  105.             EXT=z8
  106.             ;;
  107.         g|256)
  108.             EXT=ulx
  109.             ;;
  110.     esac
  111.     cd "$FULLPATH"/Build/                       # Move to the Build dir
  112.     if [[ -f output.$EXT ]]                     # If the file exists
  113.     then
  114.         $INTERPRETER output.$EXT                # Play the file
  115.     fi
  116. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement