forked from stuartcaunt/isgl3d
-
Notifications
You must be signed in to change notification settings - Fork 2
/
installTemplatesXcode4.sh
executable file
·100 lines (78 loc) · 2.21 KB
/
installTemplatesXcode4.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/sh
if [[ $EUID -ne 0 ]]; then
echo "[EUID:$EUID]This script must be run as root (man sudo)" 1>&2
exit 1
fi
ISGL3D_VERSION="iSGL3D v`cat Version`"
BASE_DIR=isgl3d
POWERVR_DIR=external/PowerVR_SDK-2.0.9
LIBS_DIR=libs
TEMPLATES_DIR_SRC=templates/xcode4
TEMPLATES_DIR_DEST=~/Library/Developer/Xcode/Templates/$ISGL3D_VERSION
BASE_TEMPLATE_DIR=iSGL3D\ Base.xctemplate
APPLICATION_TEMPLATE_DIR=iSGL3D\ Application.xctemplate
LIBRARY_TEMPLATE_DIR=iSGL3D\ Library.xctemplate
force=
usage(){
cat << EOF
usage: $0 [options]
Install / update templates for ${ISGL3D_VERSION}
OPTIONS:
-f force overwrite if directories exist
-h this help
EOF
}
while getopts "fh" OPTION; do
case "$OPTION" in
f)
force=1
;;
h)
usage
exit 0
;;
esac
done
copy_files() {
rsync -r --exclude=.svn "$1" "$2"
}
check_rm_dir() {
if [[ -d "$1" ]]; then
if [[ $force ]]; then
echo "deleting existing templates: $1" | sed "s|$HOME|~|"
rm -rf "$1"
else
echo "templates already installed. To force a re-install use the '-f' parameter"
exit 1
fi
fi
}
echo ""
echo ""
echo "Installing ${ISGL3D_VERSION} templates for Xcode 4"
echo "----------------------------------------------"
echo ""
#verify that Templates directory exists
if [[ ! -d "$TEMPLATES_DIR_DEST" ]]; then
echo ...creating templates folder
mkdir -p "$TEMPLATES_DIR_DEST"
fi
# Delete all previous iSGL3D templates
check_rm_dir "$TEMPLATES_DIR_DEST/$BASE_TEMPLATE_DIR"
check_rm_dir "$TEMPLATES_DIR_DEST/$APPLICATION_TEMPLATE_DIR"
check_rm_dir "$TEMPLATES_DIR_DEST/$LIBRARY_TEMPLATE_DIR"
# copy templates
echo ...copying template files
copy_files "$TEMPLATES_DIR_SRC/$BASE_TEMPLATE_DIR" "$TEMPLATES_DIR_DEST"
copy_files "$TEMPLATES_DIR_SRC/$APPLICATION_TEMPLATE_DIR" "$TEMPLATES_DIR_DEST"
copy_files "$TEMPLATES_DIR_SRC/$LIBRARY_TEMPLATE_DIR" "$TEMPLATES_DIR_DEST"
# copy shader files
echo ...copying shader files
copy_files Resources/Shaders "$TEMPLATES_DIR_DEST/$BASE_TEMPLATE_DIR/Resources"
# copy library files
echo ...copying library files
copy_files $BASE_DIR "$TEMPLATES_DIR_DEST/$LIBRARY_TEMPLATE_DIR/$LIBS_DIR"
# copy library files
echo ...copying external files
copy_files $POWERVR_DIR "$TEMPLATES_DIR_DEST/$LIBRARY_TEMPLATE_DIR"/external
echo done!