282 lines
9.2 KiB
Bash
282 lines
9.2 KiB
Bash
#!/bin/bash
|
|
|
|
###
|
|
### Constants
|
|
###
|
|
|
|
TRUE=0 # Map the shell's idea of truth to a variable for better documentation
|
|
FALSE=1
|
|
|
|
# If you have some other version of python installed other than 26, do not edit this file.
|
|
# Add a line like this to ~/.bashrc:
|
|
# export WINPYTHON="/cygdrive/c/path_to_your_python.exe"
|
|
# And then close and restart cygwin
|
|
if [ -z $WINPYTHON ] ; then
|
|
WINPYTHON="/cygdrive/c/Python26/python.exe"
|
|
fi
|
|
LOG="`pwd`/logs/build_win32.log"
|
|
|
|
###
|
|
### Global Variables
|
|
###
|
|
|
|
WANTS_CLEAN=$FALSE
|
|
WANTS_CONFIG=$FALSE
|
|
WANTS_LAA=$TRUE
|
|
WANTS_BUILD=$FALSE
|
|
WANTS_PACKAGE=$FALSE
|
|
WANTS_VERSION=$FALSE
|
|
WANTS_KDU=$FALSE
|
|
BTYPE="Release"
|
|
CHANNEL="private-`hostname`"
|
|
|
|
###
|
|
### Helper Functions
|
|
###
|
|
|
|
showUsage()
|
|
{
|
|
echo
|
|
echo "Usage: "
|
|
echo "========================"
|
|
echo
|
|
echo " --clean : Remove past builds & configuration"
|
|
echo " --config : General a new architecture-specific config"
|
|
echo " --version : Update version number"
|
|
echo " --rebuild : Build, reusing unchanged projects to save time"
|
|
echo " --kdu : Build with KDU"
|
|
echo " --chan [Release|Beta|Private] : Private is the default, sets channel"
|
|
echo " --btype [Release|RelWithDebInfo] : Release is default, whether to use symbols"
|
|
echo " --laa [on|off] : Default is on, enables the viewer to use more than 2 GB ram"
|
|
}
|
|
|
|
getArgs()
|
|
# $* = the options passed in from main
|
|
{
|
|
|
|
if [ $# -gt 0 ]; then
|
|
while getoptex "clean config version kdu fmod rebuild help chan: btype: laa:" "$@" ; do
|
|
|
|
#insure options are valid
|
|
if [ -z "$OPTOPT" ] ; then
|
|
showUsage
|
|
exit 1
|
|
fi
|
|
|
|
case "$OPTOPT" in
|
|
clean) WANTS_CLEAN=$TRUE;;
|
|
config) WANTS_CONFIG=$TRUE;;
|
|
version) WANTS_VERSION=$TRUE;;
|
|
rebuild) WANTS_BUILD=$TRUE
|
|
WANTS_VERSION=$TRUE
|
|
WANTS_PACKAGE=$TRUE;;
|
|
chan) CHANNEL="$OPTARG";;
|
|
btype) BTYPE="$OPTARG";;
|
|
fmod) WANTS_FMOD=$TRUE;;
|
|
kdu) WANTS_KDU=$TRUE;;
|
|
laa) if [ "$OPTARG" == "on" ] ; then
|
|
WANTS_LAA=$TRUE
|
|
elif [ "$OPTARG" == "off" ] ; then
|
|
WANTS_LAA=$FALSE
|
|
else
|
|
showUsage && exit 1
|
|
fi;;
|
|
|
|
|
|
help) showUsage && exit 0;;
|
|
|
|
-*) showUsage && exit 1;;
|
|
*) showUsage && exit 1;;
|
|
esac
|
|
done
|
|
shift $[OPTIND-1]
|
|
if [ $OPTIND -le 1 ] ; then
|
|
showUsage && exit 1
|
|
fi
|
|
fi
|
|
|
|
if [ $WANTS_CLEAN -ne $TRUE ] && [ $WANTS_CONFIG -ne $TRUE ] && \
|
|
[ $WANTS_BUILD -ne $TRUE ] && [ $WANTS_VERSION -ne $TRUE ] && \
|
|
[ $WANTS_PACKAGE -ne $TRUE ] ; then
|
|
# the user didn't say what to do, so assume he wants to do everything
|
|
WANTS_CLEAN=$TRUE
|
|
WANTS_CONFIG=$TRUE
|
|
WANTS_BUILD=$TRUE
|
|
WANTS_VERSION=$TRUE
|
|
WANTS_PACKAGE=$TRUE
|
|
fi
|
|
}
|
|
|
|
|
|
function getoptex()
|
|
{
|
|
let $# || return 1
|
|
local optlist="${1#;}"
|
|
let OPTIND || OPTIND=1
|
|
[ $OPTIND -lt $# ] || return 1
|
|
shift $OPTIND
|
|
if [ "$1" != "-" -a "$1" != "${1#-}" ]
|
|
then OPTIND=$[OPTIND+1]; if [ "$1" != "--" ]
|
|
then
|
|
local o
|
|
o="-${1#-$OPTOFS}"
|
|
for opt in ${optlist#;}
|
|
do
|
|
OPTOPT="${opt%[;.:]}"
|
|
unset OPTARG
|
|
local opttype="${opt##*[^;:.]}"
|
|
[ -z "$opttype" ] && opttype=";"
|
|
if [ ${#OPTOPT} -gt 1 ]
|
|
then # long-named option
|
|
case $o in
|
|
"--$OPTOPT")
|
|
if [ "$opttype" != ":" ]; then return 0; fi
|
|
OPTARG="$2"
|
|
if [ -z "$OPTARG" ];
|
|
then # error: must have an agrument
|
|
let OPTERR && echo "$0: error: $OPTOPT must have an argument" >&2
|
|
OPTARG="$OPTOPT";
|
|
OPTOPT="?"
|
|
return 1;
|
|
fi
|
|
OPTIND=$[OPTIND+1] # skip option's argument
|
|
return 0
|
|
;;
|
|
"--$OPTOPT="*)
|
|
if [ "$opttype" = ";" ];
|
|
then # error: must not have arguments
|
|
let OPTERR && echo "$0: error: $OPTOPT must not have arguments" >&2
|
|
OPTARG="$OPTOPT"
|
|
OPTOPT="?"
|
|
return 1
|
|
fi
|
|
OPTARG=${o#"--$OPTOPT="}
|
|
return 0
|
|
;;
|
|
esac
|
|
else # short-named option
|
|
case "$o" in
|
|
"-$OPTOPT")
|
|
unset OPTOFS
|
|
[ "$opttype" != ":" ] && return 0
|
|
OPTARG="$2"
|
|
if [ -z "$OPTARG" ]
|
|
then
|
|
echo "$0: error: -$OPTOPT must have an argument" >&2
|
|
OPTARG="$OPTOPT"
|
|
OPTOPT="?"
|
|
return 1
|
|
fi
|
|
OPTIND=$[OPTIND+1] # skip option's argument
|
|
return 0
|
|
;;
|
|
"-$OPTOPT"*)
|
|
if [ $opttype = ";" ]
|
|
then # an option with no argument is in a chain of options
|
|
OPTOFS="$OPTOFS?" # move to the next option in the chain
|
|
OPTIND=$[OPTIND-1] # the chain still has other options
|
|
return 0
|
|
else
|
|
unset OPTOFS
|
|
OPTARG="${o#-$OPTOPT}"
|
|
return 0
|
|
fi
|
|
;;
|
|
esac
|
|
fi
|
|
done
|
|
echo "$0: error: invalid option: $o"
|
|
showUsage
|
|
exit 1
|
|
fi; fi
|
|
OPTOPT="?"
|
|
unset OPTARG
|
|
return 1
|
|
}
|
|
|
|
function optlistex
|
|
{
|
|
local l="$1"
|
|
local m # mask
|
|
local r # to store result
|
|
while [ ${#m} -lt $[${#l}-1] ]; do m="$m?"; done # create a "???..." mask
|
|
while [ -n "$l" ]
|
|
do
|
|
r="${r:+"$r "}${l%$m}" # append the first character of $l to $r
|
|
l="${l#?}" # cut the first charecter from $l
|
|
m="${m#?}" # cut one "?" sign from m
|
|
if [ -n "${l%%[^:.;]*}" ]
|
|
then # a special character (";", ".", or ":") was found
|
|
r="$r${l%$m}" # append it to $r
|
|
l="${l#?}" # cut the special character from l
|
|
m="${m#?}" # cut one more "?" sign
|
|
fi
|
|
done
|
|
echo $r
|
|
}
|
|
|
|
function getopt()
|
|
{
|
|
local optlist=`optlistex "$1"`
|
|
shift
|
|
getoptex "$optlist" "$@"
|
|
return $?
|
|
}
|
|
|
|
|
|
###
|
|
### Main Logic
|
|
###
|
|
|
|
MAIN_START_TIME=`date +%s`
|
|
getArgs $*
|
|
|
|
path=$WINPATH:/usr/local/bin:/usr/bin:/bin
|
|
if [ ! -f "$WINPYTHON" ] ; then
|
|
echo "ERROR: You need to edit .bashrc and set WINPYTHON at the top to point at the path of your windows python executable."
|
|
exit 1
|
|
fi
|
|
|
|
pushd indra > /dev/null
|
|
if [ $WANTS_CLEAN -eq $TRUE ] ; then
|
|
$WINPYTHON develop.py clean
|
|
find . -name "*.pyc" -exec rm {} \;
|
|
fi
|
|
|
|
if [ $WANTS_VERSION -eq $TRUE ] ; then
|
|
buildVer=`hg summary | head -1 | cut -d " " -f 2 | cut -d : -f 1`
|
|
majorVer=`cat Version | cut -d "=" -f 2 | cut -d "." -f 1`
|
|
minorVer=`cat Version | cut -d "=" -f 2 | cut -d "." -f 2`
|
|
patchVer=`cat Version | cut -d "=" -f 2 | cut -d "." -f 3`
|
|
echo "Building $CHANN- ${majorVer}.${minorVer}.${patchVer}.${buildVer}"
|
|
sed -e "s#LL_VERSION_BUILD = .*\$#LL_VERSION_BUILD = ${buildVer};#" \
|
|
-e "s#LL_VERSION_MAJOR = .*\$#LL_VERSION_MAJOR = ${majorVer};#" \
|
|
-e "s#LL_VERSION_MINOR = .*\$#LL_VERSION_MINOR = ${minorVer};#" \
|
|
-e "s#LL_VERSION_PATCH = .*\$#LL_VERSION_PATCH = ${patchVer};#" \
|
|
-e "s#LL_CHANNEL = .*\$#LL_CHANNEL = \"Firestorm-$CHANNEL\";#" llcommon/llversionviewer.cpp.in > llcommon/llversionviewer.cpp
|
|
fi
|
|
|
|
if [ $WANTS_CONFIG -eq $TRUE ] ; then
|
|
mkdir -p ../logs > /dev/null 2>&1
|
|
if [ $WANTS_LAA -eq $TRUE ] ; then LAA=ON ; else LAA=OFF ; fi
|
|
if [ $WANTS_KDU -eq $TRUE ] ; then KDU=ON ; else KDU=OFF ; fi
|
|
$WINPYTHON develop.py -G vc80 -t $BTYPE configure -DFIRECYG:BOOL=ON -DPACKAGE:BOOL=ON -DLL_TESTS:BOOL=OFF -DVIEWER_CHANNEL:STRING=Firestorm-$CHANNEL -DVIEWER_LOGIN_CHANNEL:STRING=Firestorm-$CHANNEL -DLAA:BOOL=$LAA -DUSE_KDU:BOOL=$KDU 2>&1 | tee $LOG
|
|
mkdir -p build-vc80/sharedlibs/RelWithDebInfo
|
|
mkdir -p build-vc80/sharedlibs/Release
|
|
cp -f ../libraries/i686-win32/lib/release/fmod.dll .
|
|
cp fmod.dll ./build-vc80/sharedlibs/RelWithDebInfo
|
|
cp fmod.dll ./build-vc80/sharedlibs/Release
|
|
fi
|
|
|
|
if [ $WANTS_BUILD -eq $TRUE ] ; then
|
|
echo "Building in progress. Check $LOG for verbose status."
|
|
$WINPYTHON develop.py -G vc80 -t $BTYPE build 2>&1 | tee -a $LOG | grep Build
|
|
trap - INT TERM EXIT
|
|
# Save the .h file we built with in case of errors in compile.
|
|
# Except during the build process, the .h file should ALWAYS be the
|
|
# same as existed in the source repository to avoid merge conflicts
|
|
# during updates.
|
|
echo "Complete"
|
|
fi
|
|
popd > /dev/null
|