[messages] [Developers] Compiling Vassal from the Command Line on MacOS

trevelyan david at wesecretary.com
Tue Dec 27 00:07:35 CET 2016


I wanted to share the following script/Makefile that compiles VASSAL
from the command-line on MacOS. It uses basic Unix utilities to parse
through the directories in the distribution recursively, and finds all
of the necessary .java files and bundles them into a lengthy
command-line file that compiles the software from scratch without the
need for an IDE. A second file is also created that can be used to run
the software.

Sharing in case it will be of use to those familiar with command-line
editing but not Java experts. The script requires that people already
have java/javac installed on their machines, but doesn't need any
messing around with Netbeans, etc.



Code:

#
# Clean up any legacy files from the last 
# time we ran this script if necessary
#
if [ -e mac.make.temp1 ]
then
  rm mac.make.temp1
fi
if [ -e mac.make.temp2 ]
then
  rm mac.make.temp2
fi
if [ -e mac.make.temp3 ]
then
  rm mac.make.temp3
fi
if [ -e mac.make.java_files ]
then
  rm mac.make.java_files
fi
if [ -e mac.make.class_files ]
then
  rm mac.make.class_files
fi
if [ -e mac.make.compile ]
then
  rm mac.make.compile
fi
if [ -e src/mac.make.run ]
then
  rm src/mac.make.run
fi




#
# Print Reassuring Message
#
echo '
Generating Makefile....'



#
# Create file containing all sub-directories
# found within this folder
#
ls -R -1 ./* > mac.make.temp1



#
# Parse that file for only the directory
# entries. We will subsequently search 
# directory by directory for files in 
# these folders
#
grep ":" mac.make.temp1 > mac.make.temp2



#
# Loop through folders and rename them to
# absolute file paths, so that we can search
# them for ava files
#
# Generate a file containing nothing but
# the directories in which we want to 
# find our *.class and *.java files.
while read p; do
  len=${#p}
  echo $PWD${p:1:len-2} >> mac.make.temp3
done < mac.make.temp2



#
# generate separate files containing only
# our java files
#
while read p; do
  ls ${p}/*.java 2>/dev/null >> mac.make.java_files
done < mac.make.temp3



#
# create the javac command 
#
echo 'javac -classpath "lib/*:lib-eth/*:lib-nondist/*"
@mac.make.java_files ' >> mac.make.compile



#
# Print Reassuring Message
#
echo '
Compiling VASSAL from the command-line means going through
all of the directories included in this software package
to find all of the .java files that need to be compiled. 
We have just done this and generated a script that will 
automate the compilation process using the default Java
compiler on your system:

  ./mac.make.compile

The default VASSAL code triggers a few error messages, but
nothing critical. If you need to recompile the software you
can simply re-execute this script from this directory.

Compiling....

';



#
# compile
#
chmod +x mac.make.compile
./mac.make.compile


#
# generate separate files containing only
# our class files
#
while read p; do
  ls ${p}/*.class 2>/dev/null >> mac.make.class_files
done < mac.make.temp3



#
# create the java runtime 
#
echo -n 'java -classpath "../lib/*:../lib-nondist/*:' >>
src/mac.make.run
while read p; do
  echo -n ${p} >> src/mac.make.run
  echo -n ":" >> src/mac.make.run
done < mac.make.class_files
echo '" VASSAL/launch/EthereumModuleManager' >> src/mac.make.run
chmod +x src/mac.make.run



#
# Print Reassuring Message
#
echo '


Now that the software has compiled we have created
another command-line file you can use to start running
it. Enter the /src directory and run:

 ./mac.make.run

Remember that if you need to make any changes to the 
code base you will need to recompile from scratch.

';





_______________________________________________
Read this topic online here:
http://www.vassalengine.org/forum/viewtopic.php?p=52780#p52780


More information about the messages mailing list