forked from FirestormViewer/fs-build-variables
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convenience
57 lines (51 loc) · 1.6 KB
/
convenience
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
# Bring in the functions from the 'functions' script in the same directory as
# this script. Beware: since this script is itself sourced, its name is NOT in
# $0, but rather in $BASH_SOURCE!
d="$(dirname "$BASH_SOURCE")"
source "$d/functions"
# Now the 'variables' script
source "$d/variables"
# Enumerate the known universe of buildtypes and suffixes.
# Alternatively we could trawl the output of 'set' for variables whose name
# matches a regexp, but this way feels more predictable.
T=(BASE RELEASE RELWITHDEBINFO DEBUG)
X=(_MACROS _SWITCHES "")
case "$OSTYPE" in
cygwin)
p="WINDOWS"
;;
darwin*)
p="DARWIN"
;;
linux*)
p="LINUX"
;;
*)
echo "Unrecognized platform $OSTYPE" 1>&2
exit 2
;;
esac
# make aliases for all LL_BUILD_{platform}_{buildtype}{suffix}
# variables that eliminate the {platform} part:
# LL_BUILD_{buildtype}{suffix}
# e.g. LL_BUILD_RELEASE has Release switches for current platform
for t in "${T[@]}"
do for x in "${X[@]}"
do eval LL_BUILD_$t$x=\$LL_BUILD_${p}_$t$x
done
done
# further, if $1 is passed as a buildtype (Release, RelWithDebInfo, Debug),
# make aliases that eliminate the {buildtype} part: just
# LL_BUILD{suffix}
# e.g. if we assume 'source convenience Release', then
# LL_BUILD has Release switches for current platform
if [ -n "${1:-}" ]
then # uppercase the buildtype so that's not on our caller
t="$(toupper "$1")"
for x in "${X[@]}"
do eval LL_BUILD$x=\$LL_BUILD_$t$x
done
fi
# Since this script is designed to be sourced, explicitly delete temporary
# variables.
unset d p T X t x