-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·79 lines (62 loc) · 2.16 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·79 lines (62 loc) · 2.16 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# ==== build.sh ====
# Check if inotifywait is installed
if [ -z "$(which inotifywait)" ]; then
echo "inotifywait not installed."
echo "Install the inotify-tools package and try again."
exit 1
fi
# Directory to monitor for changes
dir="./Source"
MOD=$(basename $PWD)
# Define the path to your project file
projectPath="Source/${MOD}.csproj"
# Define an array of configurations
configurations=("v1.2" "v1.3" "v1.4" "v1.5" "v1.6")
dotnet restore "$projectPath"
function sync_mod() {
# Copy over the mod directory.
rsync -a ${MOD} /rimworld/1.2/Mods/
# Copy over and reformat the README.
cp README.md /rimworld/1.2/Mods/${MOD}
unix2dos /rimworld/1.2/Mods/${MOD}/README.md
rm -rf /rimworld/1.3/Mods/${MOD}
rm -rf /rimworld/1.4/Mods/${MOD}
rm -rf /rimworld/1.5/Mods/${MOD}
rm -rf /rimworld/1.6/Mods/${MOD}
rm -rf /rimworld/1.6-steam/Mods/${MOD}
cp -af /rimworld/1.2/Mods/${MOD} /rimworld/1.3/Mods
cp -af /rimford/1.2/Mods/${MOD} /rimworld/1.4/Mods
cp -af /rimworld/1.2/Mods/${MOD} /rimworld/1.5/Mods
cp -af /rimworld/1.2/Mods/${MOD} /rimworld/1.6/Mods
cp -af /rimworld/1.2/Mods/${MOD} /rimworld/1.6-steam/Mods
}
function build() {
rm -rf /rimworld/1.2/Mods/${MOD}
# Loop through each configuration and build it
for config in "${configurations[@]}"; do
echo "Building for configuration: $config"
dotnet build --no-restore "$projectPath" --configuration "Release $config" &
done
wait # Blocks until all background jobs finish
sync_mod
echo "All builds completed!"
}
build
if [ "$1" == "1" ]; then
echo "Done"
exit
fi
# Watch for changes to .cs and XML files in the directory and subdirectories
inotifywait --recursive --monitor --format "%e %w%f" \
--exclude '/\.idea($|/)' \
--event modify,move,create,delete "$dir" "$MOD" |
while read event fullpath; do
if [[ "$fullpath" == "$dir"* && "$fullpath" == *.cs ]]; then
echo "Running build for $fullpath"
build
elif [[ "$fullpath" == "$MOD"* && "$fullpath" == *.xml ]]; then
echo "Running sync_mod for $fullpath"
sync_mod
fi
done