-
Notifications
You must be signed in to change notification settings - Fork 1
/
genproject
executable file
·440 lines (399 loc) · 21.1 KB
/
genproject
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
#!/bin/bash
#Helper script for generating my gungeon mod's .csproj file
# Generate texture atlas: https://github.com/scriptum/Cheetah-Texture-Packer?tab=readme-ov-file
# ~/downloads/texture-packer/Cheetah-Texture-Packer/src/cheetah-texture-packer -s 1024x1024 --square --disable-merge --disable-crop --border-size 2 -o ~/workspace/gungy-cwaffing/Resources/Atlases/atlas ~/workspace/gungy-cwaffing/RawResources/
#Important top level variables
namespace="CwaffingTheGungy" #namespace used throughout source code; need to change for my own mod eventually
projectname="GungeonCraft" #name of the DLL to create
projfile="./CwaffingItems.csproj" #the name of the csproj file to generate
sourcechecksums="./obj/_${namespace}-checksums-src" #file containing checksums of all source files to determine recompilation
gfxchecksums="./obj/_${namespace}-checksums-gfx" #file containing checksums of all graphics to determine rebuilding atlases
audiochecksums="./obj/_${namespace}-checksums-audio" #file containing checksums of all audio files to determine rebuilding audio bank
externalupdate="./obj/_${namespace}-externalupdate" #file containing the last time an external resource was added
audioupdate="./obj/_${namespace}-audioupdate" #file containing the last time an audio resource / csv was added / updated
USEXTERNALASSEMBLY=0 #Whether to use the external or bundled Assembly-Csharp.dll -- couldn't get external working ):
UPDATEDLLS=0 #Set to 1 if any new DLLS are added to make sure they're copied correctly to bin/Debug
#Easy colors (condensed)
BLN="\e[0m" ; UND="\e[1;4m" ; INV="\e[1;7m" ; CRT="\e[1;41m";
BLK="\e[1;30m"; RED="\e[1;31m"; GRN="\e[1;32m"; YLW="\e[1;33m";
BLU="\e[1;34m"; MGN="\e[1;35m"; CYN="\e[1;36m"; WHT="\e[1;37m";
debugbuild="$( [ "false" == "$(cat 'src/Common.cs' | grep -m1 'DEBUG_BUILD' | cut -f 2 -d '=' | cut -f 1 -d ';' | tr -d ' ')" ]; echo "$?" )"
if [ "$debugbuild" == "1" ]; then
buildType="Debug"
buildColor="$YLW"
else
buildType="Release"
buildColor="$GRN"
fi
dllname="./bin/${buildType}/${projectname}.dll" #Release DLL name
dotnet35path="$(pwd)/_dotNETFramework/v3.5" #Path to .NET 3.5 developer assemblies (from NUGet)
shaderfile="cwaffshaders"
windowsshaderassetpath="/home/pretzel/workspace/gungeon-projects/gungy-shaders/Gungy Shaders/Assets/AssetBundles/Windows/${shaderfile}"
macosshaderassetpath="/home/pretzel/workspace/gungeon-projects/gungy-shaders/Gungy Shaders/Assets/AssetBundles/OSX/${shaderfile}"
linuxshaderassetpath="/home/pretzel/workspace/gungeon-projects/gungy-shaders/Gungy Shaders/Assets/AssetBundles/Linux/${shaderfile}"
projectversion="$(cat 'src/Common.cs' | grep 'MOD_VERSION' | cut -f 2 -d '"')"
manifesttemplate=`cat <<HERE
{
"name": "$projectname",
"version_number": "$projectversion",
"website_url": "https://github.com/pcrain/GungeonCraft",
"description": "A mechanics-focused mod for Enter the Gungeon O:",
"dependencies": [
"MtG_API-Mod_the_Gungeon_API-1.8.2",
"Alexandria-Alexandria-0.4.15",
"CaptainPretzel-Gunfig-1.0.3"
]
}
HERE`
thunderstore=0
if [ $# -gt 0 ] && [ "$1" == "-t" ]; then
thunderstore=1 #prepare for publishing on Thunderstore
# dllname="./bin/Release/${projectname}.dll" #Release DLL name
fi
if [ $thunderstore -eq 1 ]; then
if [ "$(task count proj:release status:pending)" -gt 0 ]; then
echo -e "[${YLW}#${BLN}] Trying to build Thunderstore package with release tasks pending, refusing\n"
task proj:release rc.report.next.columns=id,description rc.report.next.labels=ID,description | tail +3
exit
elif [ $debugbuild -gt 0 ]; then
echo -e "[${RED}@${BLN}] Trying to build Thunderstore package from debug build, refusing"
exit
fi
fi
#Base directory we're copying our plugin to
plugindir="/xmedia/pretzel/Steam/steamapps/common/Enter the Gungeon/BepInEx/plugins"
pluginspritesdir="${plugindir}/sprites" #plugin sprite directory
#Variable tracking if anything actually needs to be rebuilt
rebuild=0
sources=() #Array of source files
includes=() #Array of items to include in the base project file
externs=() #Array of external resource to copy over to the EtG plugins/sprites directory
#Manually populated includes
includes+=('<None Include="packages.config" />')
includes+=('<Reference Include="System" />') #needed for LinkedList
# includes+=('<Folder Include="Characters\Acolyte\newspritesetup\custom\" />')
# includes+=('<Folder Include="Characters\Shade\newspritesetup\custom\" />')
# includes+=('<Reference Include="Ionic.Zip, Version=1.9.1.8"/>')
#Regenerate atlases if necessary
echo -e "[${GRN}>${BLN}] Checking for changes to sprites"
updategfx=0
# gfxdata="$(/bin/ls -RAl "RawResources/" | grep -vE "(^total|.json$|.wav$|.bnk$|.csv$)")"
gfxdata="$(/bin/ls -RAl "RawResources/" | grep -E "(\.png$)")"
if [ ! -e "${gfxchecksums}" ]; then
echo -e "[${GRN}>${BLN}] Graphics checksum file does not exist, rebuilding sprite atlases"
updategfx=1
else
oldgfxdata="$(cat "${gfxchecksums}")"
if [[ "${gfxdata}" != "${oldgfxdata}" ]]; then
echo -e "[${GRN}>${BLN}] At least one image file was changed, rebuilding sprite atlases and project"
updategfx=1
else
echo -e "[${GRN}>${BLN}] No image files changed, skipping sprite atlas rebuild"
fi
fi
if [ $updategfx -eq 1 ]; then
rebuild=1
echo -e "[${GRN}>${BLN}] Regenerating sprite atlases"
/bin/rm -r "./Resources/Atlases"
mkdir -p "./Resources/Atlases"
# WARNING: all sprites need to be on the same texture, particularly those that are part of the same animation, or graphical glitches occur
# sort orders: 1 == width, 2 == height (fastest for our purposes), 3 == area, 4 == max(width, height)
~/bin/cheetah-texture-packer --sort-order 2 -s 2048x2048 --square --border-size 3 -o "./Resources/Atlases/atlas" "./RawResources/"
# cheetah-texture-packer -s 2048x2048 --square --border-size 3 -o "./Resources/Atlases/atlas" "./RawResources/"
# cheetah-texture-packer -s 1024x1024 --square --border-size 3 -o "./Resources/Atlases/atlas" "./RawResources/"
# cheetah-texture-packer -s 1024x1024 --square --disable-crop --border-size 2 -o "./Resources/Atlases/atlas" "./RawResources/"
# cheetah-texture-packer -s 1024x1024 --square --disable-merge --disable-crop --border-size 2 -o "./Resources/Atlases/atlas" "./RawResources/"
[ -e "./Resources/Atlases/atlas.atlas" ] && /bin/mv ./Resources/Atlases/atlas{,_1}.atlas
[ -e "./Resources/Atlases/atlas.png" ] && /bin/mv ./Resources/Atlases/atlas{,_1}.png
echo -e "[${GRN}>${BLN}] Regenerating checksums for sprites"
echo "$gfxdata" > "${gfxchecksums}"
fi
#Regenerate audio sources if necessary
echo -e "[${GRN}>${BLN}] Checking for changes to audio files"
lastmodifiedaudio="$(find "RawResources/Sounds" -type f -path "*.wav" -o -path "*.csv" -printf "%T+\n" | sort -nr | head -n 1)"
# lastmodifiedaudio="$(find "Resources" -type f -path "*.wav" -o -type f -path "*.ogg" -o -path "*.csv" -printf "%T+\n" | sort -nr | head -n 1)"
updateaudio=0
audiodata="$(/bin/ls -Al "RawResources/Sounds/" | grep -vE "(^total|.bnk$)")"
if [ ! -e "./Resources/${namespace}.bnk" ]; then
echo -e "[${GRN}>${BLN}] Audio bank does not exist, regenerating sound bank"
updateaudio=1
elif [ ! -e "${audiochecksums}" ]; then
echo -e "[${GRN}>${BLN}] Audio checksum file does not exist, regenerating sound bank"
updateaudio=1
# elif [ "${lastmodifiedaudio}" == "$(cat "$audioupdate")" ]; then
# updateaudio=0 #todo: this doesn't work for newly-added files with old modification times
else
oldaudiodata="$(cat "${audiochecksums}")"
if [[ "${audiodata}" != "${oldaudiodata}" ]]; then
echo -e "[${GRN}>${BLN}] At least one audio file was changed, rebuilding sound bank and project"
updateaudio=1
else
echo -e "[${GRN}>${BLN}] No audio files changed, skipping sound bank generation"
fi
echo "${lastmodifiedaudio}" > "$audioupdate";
fi
if [ $updateaudio -eq 1 ]; then
rebuild=1
echo -e "[${GRN}>${BLN}] Regenerating audio bank"
#BUG: gen-gungeon-audio-bank.py thinks paths beginning with . aren't absolute and prepend the current working directory
./gen-gungeon-audio-bank.py -qOr -s "./RawResources/Sounds/sound_info.csv" "./RawResources/Sounds" "$(pwd)/Resources/${namespace}.bnk"
# ./gen-gungeon-audio-bank.py -Ovr -s "./RawResources/Sounds/sound_info.csv" "./RawResources/Sounds" "$(pwd)/Resources/${namespace}.bnk"
echo -e "[${GRN}>${BLN}] Regenerating checksums for audio files"
echo "$audiodata" > "${audiochecksums}"
fi
# The below magic reads in each JSON, grabs the attachPoints array, flattens it to a sequence of (name, x, y) triplets, prepends the filename to each array,
# joins it into a larger array of arrays, and maps it to a TSV file
echo -e "[${GRN}>${BLN}] Regenerating attach point data"
jq -r -n \
'reduce inputs as $s (.; . += [($s.attachPoints[1:] | [(input_filename | split("/")[-1] | sub("\\.json$";"") ), (.[] | .name, .position.x, .position.y)])]) | map(@tsv)[]' \
./RawResources/WeaponCollection/*.json > ./Resources/Atlases/attach_points.tsv
#Check for shader updates
echo -e "[${GRN}>${BLN}] Checking for shader updates"
if [ -e "${linuxshaderassetpath}" ]; then
m1="$(md5sum "./Resources/${shaderfile}-linux" | cut -f 1 -d ' ')"
m2="$(md5sum "${linuxshaderassetpath}" | cut -f 1 -d ' ')"
if [ "${m1}" != "${m2}" ]; then
rebuild=1
echo -e "[${GRN}>${BLN}] Linux shader asset bundle changed, re-copying"
/bin/cp "${linuxshaderassetpath}" "./Resources/${shaderfile}-linux"
fi
fi
if [ -e "${macosshaderassetpath}" ]; then
m1="$(md5sum "./Resources/${shaderfile}-macos" | cut -f 1 -d ' ')"
m2="$(md5sum "${macosshaderassetpath}" | cut -f 1 -d ' ')"
if [ "${m1}" != "${m2}" ]; then
rebuild=1
echo -e "[${GRN}>${BLN}] MacOS shader asset bundle changed, re-copying"
/bin/cp "${macosshaderassetpath}" "./Resources/${shaderfile}-macos"
fi
fi
if [ -e "${windowsshaderassetpath}" ]; then
m1="$(md5sum "./Resources/${shaderfile}-windows" | cut -f 1 -d ' ')"
m2="$(md5sum "${windowsshaderassetpath}" | cut -f 1 -d ' ')"
if [ "${m1}" != "${m2}" ]; then
rebuild=1
echo -e "[${GRN}>${BLN}] Windows shader asset bundle changed, re-copying"
/bin/cp "${windowsshaderassetpath}" "./Resources/${shaderfile}-windows"
fi
fi
#Source files
echo -e "[${GRN}>${BLN}] Scanning for source files"
while read -r line; do
[[ "$line" =~ \\_ ]] && continue; # skip any filename beginning with an underscore
includes+=("<Compile Include=\"${line}\" />")
sources+=("${line}")
done <<< $(find "src" -type f -not -path "src/StandardAPI/ItemAPI/Examples/*" -not -path "src/StandardAPI/ItemAPI/FakePrefab/*" -not -path "src/SpriteBuilder.cs" | sed -r 's@/@\\@g')
#Custom Character Embedded resources (none for now)
# echo -e "[${GRN}>${BLN}] Scanning for custom characters"
# while read -r line; do
# includes+=("<EmbeddedResource Include=\"${line}\" />")
# done <<< $(find "Characters" -type f | sed -r 's@/@\\@g')
#Normal Embedded resources
echo -e "[${GRN}>${BLN}] Scanning for resources"
while read -r line; do
includes+=("<EmbeddedResource Include=\"${line}\" />")
done <<< $(find "Resources" -type f -not -path "*.wav" -not -path "*.ogg" -not -path "*.csv" | sed -r 's@/@\\@g')
#Unversioned EtG Unity Packages (skipping version numbers because there's no way to tell just by looking and it was causing problems)
echo -e "[${GRN}>${BLN}] Scanning for EtG DLLs"
unitydllpath="packages/EtG.UnityEngine.1.0.0/lib"
while read -r line; do
if [ $UPDATEDLLS -eq 1 ]; then
newpath="./bin/${buildType}/${line}.dll"
if [ ! -e "$newpath" ]; then
/bin/cp "${unitydllpath}/${line}.dll" "${newpath}"
fi
fi
includes+=("<Reference Include=\"${line}\"/>")
done <<< $(find "${unitydllpath}" -path "*.dll" | sed -r 's@^.*(UnityEngine(\..+)?).dll@\1@g')
#Versioned packages, net35
echo -e "[${GRN}>${BLN}] Scanning for net35 DLLs"
while read -r line; do
if [ $USEXTERNALASSEMBLY -eq 1 ] && [[ "$line" =~ Assembly-CSharp ]]; then
continue
fi
if [ $UPDATEDLLS -eq 1 ]; then
basename="$(echo "${line}" | rev | cut -f1 -d $'\\' | rev)"
separated="$(echo "${line}" | sed -re 's@\\@/@g')"
newpath="./bin/${buildType}/${basename}"
if [ ! -e "$newpath" ]; then
/bin/cp "${separated}" "${newpath}"
fi
fi
includes+=("<Reference Include=\"$(echo "$line" | rev | cut -f 1 -d '\' | cut -f 2- -d '.' | rev)\"/>")
done <<< $(find "packages" -path "*net35*.dll" | sed -r 's@/@\\@g')
#Manually add Assembly-CSharp.dll from base Gungeon path
# maindll=$(echo -e "<Reference Include=\"Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL\">\n <SpecificVersion>False</SpecificVersion>\n <HintPath>./packages/EtG.GameLibs.2.1.9.1/lib/net35/Assembly-CSharp.dll</HintPath>\n</Reference>")
# maindll=$(echo -e "<Reference Include=\"Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL\">\n <SpecificVersion>False</SpecificVersion>\n <HintPath>/home/pretzel/workspace/gungy-cwaffing/packages/EtG.GameLibs.2.1.9.1/lib/net35/Assembly-CSharp.dll</HintPath>\n</Reference>")
if [ $USEXTERNALASSEMBLY -eq 1 ]; then
maindll=$(echo -e "<Reference Include=\"Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL\">\n <SpecificVersion>False</SpecificVersion>\n <HintPath>/xmedia/pretzel/Steam/steamapps/common/Enter the Gungeon/EtG_Data/Managed/Assembly-CSharp.dll</HintPath>\n</Reference>")
includes+=("${maindll}")
else
: # unsuccessful hacks to get lsp working
# maindll=$(echo -e "<Reference Include=\"Assembly-CSharp-Full, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL\"><SpecificVersion>False</SpecificVersion><HintPath>/xmedia/pretzel/Steam/steamapps/common/Enter the Gungeon/EtG_Data/Managed/Assembly-CSharp.dll</HintPath></Reference>")
# includes+=("${maindll}")
fi
#Generate the template .csproj file (FrameworkPathOverride points to the .NET 3.5 development packages)
echo -e "[${GRN}>${BLN}] Generating .csproj template"
template=`cat <<'HERE'
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{52A82040-5BED-4ACB-9894-41A595F284CB}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>%s</RootNamespace>
<AssemblyName>%s</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<FrameworkPathOverride>%s</FrameworkPathOverride>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<LangVersion>latest</LangVersion>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<LangVersion>latest</LangVersion>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<FrameworkPathOverride>%s</FrameworkPathOverride>
<Deterministic>true</Deterministic>
</PropertyGroup>
<ItemGroup>
%s
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project=".\packages\BepInEx.Core.5.4.21\build\BepInEx.Core.targets" Condition="Exists('.\packages\BepInEx.Core.5.4.21\build\BepInEx.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('.\packages\BepInEx.Core.5.4.21\build\BepInEx.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '.\packages\BepInEx.Core.5.4.21\build\BepInEx.Core.targets'))" />
</Target>
</Project>
HERE`
#Escape all of the backslashes for printf
template="$(echo "$template" | sed -r 's@\\@\\\\@g')"
#Generate our substitution from our includes array
replace="$(printf "%s\n" "${includes[@]}")"
echo -e "[${GRN}>${BLN}] Substituting .csproj template"
#Get old checksum of generated csproj file
oldchecksum="$(md5sum "$projfile" | cut -f 1 -d ' ')"
#Invoke the substitution and create our projects file
printf "$template" "$namespace" "$projectname" "$dotnet35path" "$dotnet35path" "$replace" | xmllint --format - > "${projfile}.new"
#Get new checksum of generated csproj file
newchecksum="$(md5sum "${projfile}.new" | cut -f 1 -d ' ')"
#Compare .csproj checksums and clobber the old .csproj file as necessary
if [ "$oldchecksum" == "$newchecksum" ]; then
echo -e "[${GRN}>${BLN}] No changes to .csproj file!"
/bin/rm "${projfile}.new"
else
echo -e "[${GRN}>${BLN}] New .csproj file generated, rebuilding project"
/bin/rm "${projfile}"
/bin/mv "${projfile}.new" "${projfile}"
rebuild=1
fi
#Compare source file checksums to see if we need to rebuild
if [ $rebuild -eq 0 ]; then
echo -e "[${GRN}>${BLN}] Checking if any source files were changed"
if [ ! -e "${sourcechecksums}" ]; then
echo -e "[${GRN}>${BLN}] Source checksum file does not exist, rebuilding project"
rebuild=1
else
md5sum --status -c "${sourcechecksums}"
if [ $? -gt 0 ]; then
echo -e "[${GRN}>${BLN}] At least one source file was changed, rebuilding project"
rebuild=1
else
echo -e "[${GRN}>${BLN}] No source files changed"
fi
fi
fi
#Check if our dll has actually been built
if [ ! -e "${dllname}" ]; then
echo -e "[${GRN}>${BLN}] ${dllname} does not exist, forcing rebuild"
rebuild=1
fi
if [ $rebuild -eq 1 ]; then
#Remove old DLL file
/bin/rm -f "${dllname}"
#Recompute checksums for source file
echo -e "[${GRN}>${BLN}] Recomputing source file checksums"
/bin/rm -f "${sourcechecksums}"
for source in "${sources[@]}"; do
s="$(echo "${source}" | sed -re 's@\\@/@g')"
echo "$(md5sum "${s}")" >> "${sourcechecksums}"
done
#Don't warn about unused variables
# (list is semicolon delimited))
nowarn="CS0414"
if [ $USEXTERNALASSEMBLY -eq 1 ]; then
nowarn="${nowarn};CS0109" #CustomShopController issues warnings about unnecessary new with the real game's assembly
fi
#Actually rebuild the project
echo -e "[${GRN}>${BLN}] Building $buildColor$buildType$BLN project"
# cat "${projfile}" | sed '/Assembly-CSharp-Full/,+3d' > "${projfile}.fixed"
# if [ $thunderstore -eq 1 ]; then
dotnet build --no-restore -m -noLogo -warnAsMessage:"${nowarn}" -v:minimal -clp:"Summary" -property:Configuration="$buildType"
# else
# dotnet build --no-restore -m -noLogo -warnAsMessage:"${nowarn}" -v:minimal -clp:"Summary"
# fi
error="$?"
killall dotnet >/dev/null 2>&1 # fixes a dumb bug where the child process doesn't terminate...thanks microsoft D:
# dotnet build -m -noLogo -warnAsMessage:"${nowarn}" -v:minimal -clp:"Summary;Verbosity=minimal"
# msbuild -m -noLogo -warnAsMessage:"${nowarn}" -v:minimal -clp:"Summary;Verbosity=minimal"
if [ $error -gt 0 ]; then
echo -e "[${RED}@${BLN}] Build failed! D: Check errors above"
exit
else
echo -e "[${GRN}>${BLN}] Build succeeded! :D"
fi
#Import the mod into the plugins folder
echo -e "[${GRN}>${BLN}] Importing ${dllname} to EtG plugins directory"
/bin/cp "$dllname" "$plugindir"
fi
#Generate new Thunderstore Package
if [ $thunderstore -eq 1 ]; then
echo -e "[${GRN}>${BLN}] Regenerating item tips"
./gen-itemtips.py
echo -e "[${GRN}>${BLN}] Assembling Thunderstore package"
tdir="./_thunderstore_package"
/bin/mkdir -p "${tdir}"
cat "./readme.md" | sed -re 's@\(previews/@\(https://raw.githubusercontent.com/pcrain/GungeonCraft/master/previews/@g' > "${tdir}/README.md" # change images to absolute github links so Thunderstore can display inline images
/bin/cp -f "./changelog.md" "${tdir}/CHANGELOG.md"
/bin/cp -f "./previews/icon.png" "${tdir}/icon.png"
echo "${manifesttemplate}" > "${tdir}/manifest.json"
/bin/cp "${dllname}" "${tdir}"
cd "${tdir}"
/bin/rm -f "${projectname}.zip"
zip -q "${projectname}.zip" ./*
cd ..
/bin/rm -f ./bin/*.zip
zippath="./bin/${projectname}_${projectversion}_$(date +%F_%H-%M-%S).zip"
/bin/mv "${tdir}/${projectname}.zip" "${zippath}"
echo -e "[${GRN}>${BLN}] Created package ${CYN}${zippath}${BLN}"
fi
#Launch the game if "-g" flag was passed
if [ $# -gt 0 ] && [ "$1" == "-g" ]; then
echo -e "[${GRN}>${BLN}] Launching!"
gungy-modded
fi