forked from microsoft/vcpkg
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild_mumble_dependencies.sh
More file actions
executable file
·111 lines (92 loc) · 3.9 KB
/
build_mumble_dependencies.sh
File metadata and controls
executable file
·111 lines (92 loc) · 3.9 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
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
#!/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-md"; XCOMPILE_TRIPLET="x86-windows-static-md" ;;
linux-gnu*) TRIPLET="x64-linux" ;;
darwin*)
if [[ "$( uname -m )" = "x86_64" ]]; then
TRIPLET="x64-osx"
else
TRIPLET="arm64-osx"
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
OVERLAY_TRIPLETS="$SCRIPT_DIR/mumble_triplets/"
EXPORTED_NAME="mumble_env.$TRIPLET.$( 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 --overlay-triplets "$OVERLAY_TRIPLETS" --triplet "$XCOMPILE_TRIPLET" --host-triplet "$TRIPLET" boost-optional --clean-after-build --recurse
"$SCRIPT_DIR/vcpkg" upgrade --overlay-triplets "$OVERLAY_TRIPLETS" --triplet "$XCOMPILE_TRIPLET" --host-triplet "$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 --overlay-triplets "$OVERLAY_TRIPLETS" --triplet "$TRIPLET" --host-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 --overlay-triplets "$OVERLAY_TRIPLETS" --triplet "$TRIPLET" --host-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[@]}"
if [[ "$OSTYPE" = darwin* ]]; then
# Check if we ended up depending on a versioned SDK directory which might cause trouble
# when using the env on a different machine (that uses a different SDK version)
problematic_files="$( find "$EXPORTED_NAME" -iname '*.cmake' -exec grep -ni 'MacOSX[[:digit:]]\+\(.[[:digit:]]\+\)\?.sdk' {} /dev/null \; | grep --invert-match '#' || true )"
if [[ -n "$problematic_files" ]]; then
1>&2 echo "[Warning]: The following files depend on an explicitly versioned MacOSX SDK path (consider manually changing that):"
1>&2 echo "$problematic_files"
fi
fi