-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathbuild.sh
executable file
·120 lines (108 loc) · 2.75 KB
/
build.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
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
#!/usr/bin/env bash
orig_pwd=$(pwd)
config="Release"
framework="net6.0"
output="./build"
declare -a extra_options
dry_run="false"
plugins=("Binding/ScriptRunner" "Filter/MeL" "Filter/PrecisionControl" "Filter/Reconstructor" "OutputMode/TouchEmu" "OutputMode/VMultiMode" "OutputMode/WindowsInk")
generate_zip="true"
generate_sha256="true"
clean_builds="true"
sources="./src"
contains_space() { [[ "$1" =~ " " ]]; return $?; }
wrap_exec() {
if [ "$dry_run" == "true" ]; then
eval echo "Would execute: \"$@\""
else
eval "$@"
fi
}
clean_output() {
if [ -d "$output" ]; then
wrap_exec rm -rf "$output"
fi
}
build_plugin() {
echo "Building $1"
echo
local plugin="$1"
local plugin_output="$2"
wrap_exec dotnet publish "$sources/$plugin" -c $config -f $framework -o "$plugin_output" "${extra_options[@]}"
wrap_exec rm "$plugin_output/${plugin##*/}.deps.json"
wrap_exec rm "$plugin_output/OpenTabletDriver.Plugin.dll"
wrap_exec rm "$plugin_output/OpenTabletDriver.Plugin.pdb"
}
generate_zip() {
local files="$1"
local zip_file="$2"
local zip_name=${zip_file##*/}
wrap_exec zip -rj "$zip_file" "$files"
if [ "$generate_sha256" = "true" ]; then
local abs_output="$(readlink -f $output)"
cd $(dirname "$zip_file")
wrap_exec 'sha256sum "$zip_name" >> "$abs_output/zip_hashes.sha256"'
cd "$orig_pwd"
fi
if [ "$clean_builds" = "true" ]; then
wrap_exec rm -rf "$files"
fi
}
while [ $# -gt 0 ]; do
case $1 in
--sources)
sources="$2"
shift
;;
-c=*|--config=*)
config="${1#*=}"
;;
-c|--config)
config="$2"
shift
;;
-f=*|--framework=*)
framework="${1#*=}"
;;
-f|--framework)
framework="$2"
shift
;;
-o=*|--output=*)
output="${1#*=}"
;;
-o|--output)
output="$2"
shift
;;
--dry-run)
dry_run="true"
;;
--no-zip)
generate_zip="false"
;;
--no-sha256)
generate_sha256="false"
;;
--no-clean)
clean_builds="false"
;;
*)
if contains_space "$1"; then
extra_options+=("\"$1\"")
else
extra_options+=("$1")
fi
;;
esac
shift
done
clean_output
for plugin in "${plugins[@]}"; do
plugin_output="$output/${plugin##*/}"
build_plugin "$plugin" "$plugin_output"
if [ "$generate_zip" = "true" ]; then
generate_zip "$plugin_output" "$plugin_output.zip"
fi
echo
done