forked from microsoft/vcpkg
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_mumble_dependencies.sh
executable file
·103 lines (87 loc) · 3.41 KB
/
build_mumble_dependencies.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
#!/bin/bash
# On failed command (error code) exit the whole script
set -e
# Treat using unset variables as errors
set -u
# For piped commands on command failure fail entire pipe instead of only the last command being significant
set -o pipefail
function error_msg {
>&2 echo "[ERROR] $@"
}
SCRIPT_DIR="$( dirname "$0" )"
TRIPLET=""
AUTO=false
while [[ -n "${1-}" ]]; do
case "$1" in
-t|--triplet) shift; TRIPLET="$1" ;;
--auto) AUTO=true ;;
--) shift; break ;;
*) error_msg "Invalid argument '$1'" ;;
esac
shift
done
if [[ "$AUTO" = "false" ]]; then
# Make sure the command-prompt stays open if an error is encountered so that the user can read
# the error message before the console closes.
# If you run call this script as part of some automation, you'll want to pass --auto
# to make sure you don't get stuck.
trap "printf '\n\n'; read -p 'ERROR encountered... Press Enter to exit'" ERR
fi
# Note: We can't use readarray as that doesn't work on macOS
# Taken from https://unix.stackexchange.com/a/628576
DEPS_CONTENT="$(cat "$SCRIPT_DIR/mumble_dependencies.txt" )"
set -o noglob
IFS=$'\n' MUMBLE_DEPS=($DEPS_CONTENT)
set +o noglob
if [[ -z "$TRIPLET" ]]; then
# Determine vcpkg triplet from OS
# Available triplets can be printed with `vcpkg help triplet`
case "$OSTYPE" in
msys*) TRIPLET="x64-windows-static-release-md-release"; XCOMPILE_TRIPLET="x86-windows-static-md-release" ;;
linux-gnu*) TRIPLET="x64-linux-release" ;;
darwin*)
# This must be <= the value that is used for compiling Mumble itself
# Otherwise, compiling the vcpkg libs could produce instructions that older Mac hardware
# doesn't understand but that Mumble is still supposed to run on.
# This initializes CMAKE_OSX_DEPLOYMENT_TARGET
export MACOSX_DEPLOYMENT_TARGET="10.15"
if [[ "$( uname -m )" = "x86_64" ]]; then
TRIPLET="x64-osx-release"
else
TRIPLET="arm64-osx-release"
fi
;;
*) error_msg "The OSTYPE is either not defined or unsupported. Aborting..."; exit 1;;
esac
fi
# Always bootstrap vcpkg to ensure we have the latest
case "$OSTYPE" in
msys*) "$SCRIPT_DIR/bootstrap-vcpkg.bat" -disableMetrics ;;
*) bash "$SCRIPT_DIR/bootstrap-vcpkg.sh" -disableMetrics ;;
esac
echo "Building for triplet $TRIPLET"
if [[ -z "$TRIPLET" ]]; then
error_msg "Triplet type is not defined! Aborting..."
exit 2
fi
EXPORTED_NAME="mumble_env.$TRIPLET.$( date +"%Y-%m-%d" ).$( git -C "$SCRIPT_DIR" rev-parse --short --verify HEAD )"
ALL_DEPS=()
if [[ $OSTYPE == msys ]]; then
# install dns-sd provider
MUMBLE_DEPS+=("mdnsresponder")
MUMBLE_DEPS+=("icu")
echo "Building xcompile dependencies..."
"$SCRIPT_DIR/vcpkg" install --triplet "$XCOMPILE_TRIPLET" boost-optional --clean-after-build --recurse
"$SCRIPT_DIR/vcpkg" upgrade --triplet "$XCOMPILE_TRIPLET" boost-optional --no-dry-run
ALL_DEPS+=("boost-optional:$XCOMPILE_TRIPLET")
fi
for dep in "${MUMBLE_DEPS[@]}"; do
echo "Building dependency '$dep'..."
"$SCRIPT_DIR/vcpkg" install --triplet "$TRIPLET" "$dep" --clean-after-build --recurse
# In case the dependency is already installed, but not up-to-date
# Unfortunately there is no clean-after-build for this one
depName="$( echo "$dep" | sed 's/\[.*\]//g' )"
"$SCRIPT_DIR/vcpkg" upgrade --triplet "$TRIPLET" "$depName" --no-dry-run
ALL_DEPS+=("$depName:$TRIPLET")
done
"$SCRIPT_DIR/vcpkg" export --raw --output "$EXPORTED_NAME" --output-dir "$SCRIPT_DIR" "${ALL_DEPS[@]}"