This repository has been archived by the owner on Jun 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
version-gen
executable file
·62 lines (52 loc) · 2.13 KB
/
version-gen
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
#!/bin/sh
#
# Updates the version code
cd "$(dirname "$0")"
cd "$(git rev-parse --show-toplevel)"
git_desc=$(git describe --tags --long --match "v*")
version=$(echo "$git_desc" | sed 's:v\(.*\)-\(.*\)-.*:\1.\2:')
short_version=$(echo "$git_desc" | sed 's:v\([^-]*\).*:\1:')
major=$(echo "$git_desc" | sed 's:v\(.*\)\.\(.*\)\..*:\1:')
minor=$(echo "$git_desc" | sed 's:v\(.*\)\.\(.*\)\..*:\2:')
version_tag=`echo $version | tr . _`
gen_tagged_addon() {
classname=$1
echo " [KSPAddonFixed(KSPAddon.Startup.Instantly, false, typeof(${classname}_${version_tag}))]"
}
gen_tagged_class() {
classname=$1
echo " internal class ${classname}_${version_tag} : ${classname} { }"
}
gen_tagged_class_wrappers() {
echo "using System;"
echo "using System.Collections.Generic;"
echo "using System.Linq;"
echo "using System.Reflection;"
echo "using DeftTech.DuckTyping;"
echo "using UnityEngine;"
echo "namespace KSPAPIExtensions {"
echo " [KSPAddon(KSPAddon.Startup.Instantly, true)]"
gen_tagged_class UIPartActionsExtendedRegistration
gen_tagged_class UIPartActionResourceEditorImproved
gen_tagged_class UIPartActionLabelImproved
gen_tagged_class UIPartActionFloatEdit
gen_tagged_class UIPartActionChooseOption
echo " [KSPAddon(KSPAddon.Startup.Instantly, true)]"
gen_tagged_class CompatibilityChecker
gen_tagged_class OnEditorUpdateUtility
echo "}"
echo "namespace KSPAPIExtensions.PartMessage {"
gen_tagged_class ServiceImpl
gen_tagged_addon PartMessageServiceInitializer
gen_tagged_class PartMessageServiceInitializer
gen_tagged_class KnownPartMarker
gen_tagged_class ListenerFerramAerospaceResearch
echo "}"
}
sed -e "s/@VERSION@/$version/;s/@MAJOR/$major/;s/@MINOR/$minor/" Source/Properties/AssemblyInfo.in > tmp
cmp -s Source/Properties/AssemblyInfo.cs tmp || cp tmp Source/Properties/AssemblyInfo.cs
#sed -e "s/@VERSION@/$short_version/" ProceduralParts.version.in > tmp
#cmp -s ProceduralParts.version tmp || cp tmp ProceduralParts.version
gen_tagged_class_wrappers > tmp
cmp -s Source/tagged_classes.cs tmp || cp tmp Source/tagged_classes.cs
rm tmp