forked from TouchScript/TouchScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_package.sh
More file actions
executable file
·60 lines (49 loc) · 1.47 KB
/
Copy pathbuild_package.sh
File metadata and controls
executable file
·60 lines (49 loc) · 1.47 KB
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
#!/bin/bash
# Assumes that Unity is located either in /Applications/Unity/ or c:\Program Files\Unity\.
if [[ $# -lt 3 ]] ; then
printf "\e[31mUsage: build_package.sh <project folder> <package path> <folders>\e[39m\n"
exit 0
fi
if [ ! -d "${1}" ]; then
printf "\e[31mError! Folder '${1}' does not exist.\e[39m\n"
exit 0
fi
printf "\n\e[32mBuilding a package from project '$1' to '$2'.\e[39m\n"
LOG="__log.txt"
# ".*" -> .*
TEMP="${3%\"}"
TEMP="${TEMP#\"}"
EXPORTFOLDERS="$TEMP"
if [ -f "$2" ]; then
rm $2
fi
cd $1
# Mac
if [ "$(uname)" == "Darwin" ]; then
UNITYPATH="/Applications/Unity/Unity.app/Contents/MacOS/Unity"
if [ ! -f "$UNITYPATH" ]; then
printf "\e[31mCouldn't find Unity at $UNITYPATH!\e[39m\n"
exit 0;
fi
PROJECTFOLDER=$(pwd)
SEPARATOR="/"
# Windows
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ] || [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then
UNITYPATH="/c/Program Files/Unity/Editor/Unity.exe"
if [ ! -f "$UNITYPATH" ]; then
printf "\e[31mCouldn't find Unity at $UNITYPATH!\e[39m\n"
exit 0;
fi
# Windows path
PROJECTFOLDER=$(pwd | sed -e 's/^\/\([a-z]\)/\1:/g' -e 's/\//\\/g')
SEPARATOR="\\"
fi
LOG="${PROJECTFOLDER}${SEPARATOR}${LOG}"
"$UNITYPATH" -batchmode -logFile $LOG -projectPath "$PROJECTFOLDER" -exportPackage $EXPORTFOLDERS $2 -quit
if [ ! -f $2 ]; then
cat "$LOG"
printf "\e[31mFailed to build $2!\e[39m\n"
rm "$LOG"
exit 0
fi
rm "$LOG"