-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunitybuild.sh
93 lines (71 loc) · 3.13 KB
/
unitybuild.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
#!/bin/bash
gamename="YourGame";
projpath=`pwd -P`;
projpath="`cygpath -w "${projpath}"`";
unitypath="/cygdrive/c/Program Files/Unity/Editor/Unity.exe";
buildname="$1";
temppath="${projpath}\\TempBuilds\\${buildname}\\";
basepath="${projpath}\\Builds\\${buildname}\\";
buildargs="";
exbuildargs="-s ASSERTIONS=1 -logFile \"${projpath}build-${gamename}-${buildname}.log\" -projectPath \"${projpath}\" -batchmode -quit";
UnityBuild_Prepare(){
if [ -d "${temppath}" ]; then
echo "Clearing temporary build directory.";
rm -rf "${temppath}";
fi
if [ -d "${basepath}" ]; then
echo "Clearing build artifact directory.";
rm -rf "${basepath}";
fi
mkdir -p "${temppath}" "${temppath}linux" "${temppath}mac" "${temppath}win32" "${temppath}win64" "${temppath}webgl";
mkdir -p "${basepath}" "${basepath}linux" "${basepath}mac" "${basepath}win32" "${basepath}win64" "${basepath}webgl";
}
UnityBuild_BuildAll(){
# linux
buildargs+=" -buildLinuxUniversalPlayer \"${temppath}linux\\${gamename}\"";
# mac
buildargs+=" -buildOSXUniversalPlayer \"${temppath}mac\\${gamename}.app\"";
# win32
buildargs+=" -buildWindowsPlayer \"${temppath}win32\\${gamename}.exe\"";
# win64
buildargs+=" -buildWindows64Player \"${temppath}win64\\${gamename}.exe\"";
# webgl
buildargs+=" -executeMethod UnityBuild.Build_WebGL \"${temppath}webgl\"";
echo -e "\"${unitypath}\" ${buildargs} ${exbuildargs}";
bash -c "\"${unitypath}\" ${buildargs} ${exbuildargs}";
}
UnityBuild_Archive(){
#linux
mv "${temppath}linux" "${temppath}${gamename}";
tar cvpzf "`cygpath -u \"${basepath}linux/${gamename}.tar.gz\"`" -C "${temppath}" "${gamename}";
mv "${temppath}${gamename}" "${temppath}linux";
#mac
# for some reason, if we don't provide pz, then it doesn't fully preserve file permissions.
# therefore, we need to do something stupid.
tar cvpzf "`cygpath -u \"${basepath}mac/${gamename}.tar.gz\"`" -C "${temppath}mac" "${gamename}.app";
gunzip "`cygpath -u \"${basepath}mac/${gamename}.tar.gz\"`";
tar --delete --file="`cygpath -u \"${basepath}mac/${gamename}.tar\"`" "${gamename}.app/Contents/MacOS/${gamename}";
tar -v --append --file="`cygpath -u \"${basepath}mac/${gamename}.tar\"`" -C "`cygpath -u \"${temppath}mac\"`" "`cygpath -u \"${gamename}.app/Contents/MacOS/${gamename}\"`" --mode='u+rwX,a+rX';
gzip "`cygpath -u \"${basepath}mac/${gamename}.tar\"`";
# win
rm -rf "${temppath}win32\\player_win_x86.pdb" "${temppath}win32\\player_win_x86_s.pdb";
rm -rf "${temppath}win64\\player_win_x64.pdb" "${temppath}win64\\player_win_x64_s.pdb";
cd "${temppath}win32";
zip -r "${basepath}win32\\${gamename}.zip" ".";
cd "${temppath}win64";
zip -r "${basepath}win64\\${gamename}.zip" ".";
cd "${projpath}";
#webgl
cp -R "${temppath}webgl" "${basepath}";
}
UnityBuild_Judges(){
cd "${temppath}..";
mv "${temppath}..\\${buildname}" "${temppath}..\\${gamename}";
zip -r "${basepath}${gamename}-judges.zip" "${gamename}";
mv "${temppath}..\\${gamename}" "${temppath}..\\${buildname}";
cd "${projpath}";
}
UnityBuild_Prepare;
UnityBuild_BuildAll;
UnityBuild_Archive;
UnityBuild_Judges;