-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvalidate.sh
More file actions
51 lines (42 loc) · 1.26 KB
/
validate.sh
File metadata and controls
51 lines (42 loc) · 1.26 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
#!/bin/bash
set -e
SOURCE=${BASH_SOURCE[0]}
while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
TARGET=$(readlink "$SOURCE")
if [[ $TARGET == /* ]]; then
echo "SOURCE '$SOURCE' is an absolute symlink to '$TARGET'"
SOURCE=$TARGET
else
DIR=$( dirname "$SOURCE" )
echo "SOURCE '$SOURCE' is a relative symlink to '$TARGET' (relative to '$DIR')"
SOURCE=$DIR/$TARGET # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
fi
done
echo "SOURCE is '$SOURCE'"
RDIR=$( dirname "$SOURCE" )
DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
HERE="$DIR"
containsElement () {
local e match="$1"
shift
for e; do [[ "$e" == "$match" ]] && return 0; done
return 1
}
TARGETS=(linux windows android osx)
BUILD_TYPES=(release debug rwd)
VALIDATE_TARGET()
{
containsElement "$BUILD_TARGET" "${TARGETS[@]}" || {
echo "Such target not implemented [$BUILD_TARGET]"
echo "Available targets are [${TARGETS[@]}]"
exit 255
}
}
VALIDATE_BUILD_TYPE()
{
containsElement "$BUILD_TYPE" "${BUILD_TYPES[@]}" || {
echo "Unknown build typed [$BUILD_TYPE]"
echo "Available types are [${BUILD_TYPES[@]}]"
exit 255
}
}