[Mac] Use scripts to copy resources

...instead of needing to update Xcode project each time.

These scripts are pickier than what's currently used on GNUstep
systems, mostly to keep out .DS_Store and similar.
This commit is contained in:
Jens Ayton 2013-11-05 16:38:28 +01:00
parent 1ea963b3ba
commit 50ec08dfb6
3 changed files with 141 additions and 881 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,49 @@
#! /bin/sh
if [ $# -lt 2 ]; then
echo "error: usage: copy_game_resources <source directory> <destination directory>"
exit 1
fi
SOURCE_DIR=$1
DESTINATION_DIR=$2
if [ ! $COPY_HELPER ]; then
COPY_HELPER="$(dirname $0)/copy-resources"
fi
function perform_copy_base {
"$COPY_HELPER" "$SOURCE_DIR/$1" "$DESTINATION_DIR/$2" "$3"
if [ $? -ne 0 ]; then
exit $?
fi
}
# Usage: perform_copy <directory name> <file suffix>
# Copies modified files from src/<directory name> to dst/<directory name>
function perform_copy {
perform_copy_base "$1" "$1" "$2"
}
# Usage: perform_copy_binary <directory name> <file suffix>
# Copies modified files from src/Binary/<directory name> to dst/<directory name>
function perform_copy_binary {
perform_copy_base "Binary/$1" "$1" "$2"
}
perform_copy AIs .plist
perform_copy AIs .js
perform_copy Config .plist
perform_copy Scripts .js
perform_copy Shaders .vertex
perform_copy Shaders .fragment
perform_copy_binary Images .png
# N.b.: Images .bmp deliberately excluded, being Windows-specific
perform_copy_binary Models .dat
perform_copy_binary Music .ogg
perform_copy_binary Sounds .ogg
perform_copy_binary Textures .png

View File

@ -0,0 +1,74 @@
#! /bin/sh
function fail {
# Print an error and bail. error: prefix is used for the benefit of build tools.
echo "error: $1" 1>&2
exit 1
}
function verbose {
# echo "$1"
:
}
function debug {
# Uncomment for debugging.
# echo " DEBUG: $1"
:
}
if [ $# -lt 3 ]; then
fail "usage: copy_resources <source directory> <destination directory> <file extension>"
fi
pushd "$1" > /dev/null
SOURCE_DIR=$(pwd)
popd > /dev/null
mkdir -p "$2"
pushd "$2" > /dev/null
DESTINATION_DIR=$(pwd)
popd > /dev/null
FILE_EXTENSION=$3
cd "$SOURCE_DIR"
FILES=`ls *$FILE_EXTENSION 2> /dev/null`
if [ "$FILES" = "" ]; then
echo "warning: no files matching *$FILE_EXTENSION found in $SOURCE_DIR"
exit 0
fi
for FILE in $FILES; do
DESTINATION_FILE="$DESTINATION_DIR/$FILE"
SOURCE_FILE="$SOURCE_DIR/$FILE"
# If the destination file exists, don't copy if it has the same timestamp
COPY_THIS_FILE=1
if [ -e "$DESTINATION_FILE" ]; then
SOURCE_MOD_DATE=$(stat -f "%m" "$SOURCE_FILE")
DESTINATION_MOD_DATE=$(stat -f "%m" "$DESTINATION_FILE")
if [ $SOURCE_MOD_DATE -eq $DESTINATION_MOD_DATE ]; then
verbose "$FILE is up to date"
COPY_THIS_FILE=""
else
debug "$FILE is out of date (src: $SOURCE_MOD_DATE dst: $DESTINATION_MOD_DATE)"
fi
else
debug "$DESTINATION_FILE does not exist"
fi
if [ $COPY_THIS_FILE ]; then
echo "Copying $FILE"
cp -p "$SOURCE_FILE" "$DESTINATION_FILE"
if [ $? -ne 0 ]; then
fail "Failed to copy $FILE"
fi
else
debug "Not copying $FILE"
fi
done