-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync-rider-run-settings.sh
83 lines (60 loc) · 3.26 KB
/
sync-rider-run-settings.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
#!/bin/sh
BASEDIR=$(dirname "$0")
echo "$BASEDIR"
TargetEngine="$1"
# For unity, this defaults to /client, but can be overridable
PathToWorkingDirectory="$2"
if [[ $TargetEngine == "UNITY" && $PathToWorkingDirectory == "" ]]; then
PathToWorkingDirectory="$BASEDIR/client"
fi
PathToWorkingDirectory="${PathToWorkingDirectory//\\/\/}"
# For unreal
PathToRestoreDirectory="$3"
if [[ $TargetEngine == "UNREAL" && $PathToRestoreDirectory == "" ]]; then
PathToRestoreDirectory="$PathToWorkingDirectory"Microservices
fi
# This argument is the path to GitBash 99% of the time. If not given, assumes C:/Program Files/Git/bin/bash.exe
PathToUnixShell="$3"
if [[ $PathToUnixShell == "" ]]; then
case "$OSTYPE" in
solaris*) echo "/bin/bash" ;;
darwin*) echo "/bin/bash" ;;
linux*) echo "/usr/bin/bash" ;;
bsd*) echo "/usr/bin/bash" ;;
msys*) PathToUnixShell="C:\Program Files\Git\bin\bash.exe" ;;
cygwin*) PathToUnixShell="C:\Program Files\Git\bin\bash.exe" ;;
*) echo "Should never see this!!" ;;
esac
fi
PathToUnixShell="${PathToUnixShell//\\/\/}"
# Path to the CLI .run folder.
CliRunPath="$BASEDIR/cli/.run"
if [ -d "$CliRunPath" ]; then
echo "Copying all TEMPLATE- configurations into $TargetEngine- configurations."
for i in $(find "$CliRunPath" -name 'TEMPLATE-*.run.xml'); do # Not recommended, will break on whitespace
TargetFile="${i/TEMPLATE-/"$TargetEngine"-}"
echo "cp -u $i $TargetFile"
cp -u "$i" "$TargetFile"
echo sed -i 's/TEMPLATE-/'"$TargetEngine"'-/g' "$TargetFile"
sed -i 's/TEMPLATE-/'"$TargetEngine"'-/g' "$TargetFile"
# If there is an INTERPRETER_PATH in the xml, replace it with the given $PathToUnixShell
echo sed -i '\@="INTERPRETER_PATH"@s@value=".*"@value="'"$PathToUnixShell"'"@g' "$TargetFile"
sed -i '\@="INTERPRETER_PATH"@s@value=".*"@value="'"$PathToUnixShell"'"@g' "$TargetFile"
# For the local packages script we also change the SCRIPT_OPTIONS to point to the $PathToWorkingDirectory
# For every other script, we set the WORKING_DIRECTORY path in the xml, replace it with the given $PathToWorkingDirectory
if [[ $TargetFile == *$TargetEngine-Set-Local-Packages* || $TargetFile == *$TargetEngine-Set-Install-* ]]; then
echo sed -i '\@="SCRIPT_OPTIONS"@s@\$PROJECT_DIR\$\/\.\.\/client@'"$PathToWorkingDirectory"'@g' "$TargetFile"
sed -i '\@="SCRIPT_OPTIONS"@s@\$PROJECT_DIR\$\/\.\.\/client@'"$PathToWorkingDirectory"'@g' "$TargetFile"
echo sed -i '\@="SCRIPT_OPTIONS"@s@BeamableNugetSource@'"$TargetEngine"'_NugetSource@g' "$TargetFile"
sed -i '\@="SCRIPT_OPTIONS"@s@BeamableNugetSource@'"$TargetEngine"'_NugetSource@g' "$TargetFile"
echo sed -i '\@="SCRIPT_OPTIONS"@s@PathToRestore@'"$PathToRestoreDirectory"'@g' "$TargetFile"
sed -i '\@="SCRIPT_OPTIONS"@s@PathToRestore@'"$PathToRestoreDirectory"'@g' "$TargetFile"
continue
else
echo sed -i '\@="WORKING_DIRECTORY"@s@value=".*"@value="'"$PathToWorkingDirectory"'"@g' "$TargetFile"
sed -i '\@="WORKING_DIRECTORY"@s@value=".*"@value="'"$PathToWorkingDirectory"'"@g' "$TargetFile"
fi
done
else
echo "Invalid path to a .run folder. Given Path: $CliRunPath"
fi