forked from facebookarchive/xctool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xctool.sh
executable file
·48 lines (36 loc) · 1.29 KB
/
xctool.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
#!/bin/bash
#
# Compile xctool on-demand so we don't have to check-in binaries.
#
set -e
XCTOOL_DIR=$(cd $(dirname $0); pwd)
TEMP_PATH=$(/usr/bin/mktemp -t xctool-build)
trap "rm -f $TEMP_PATH" EXIT
BUILD_NEEDED_TOOL_PATH="$XCTOOL_DIR"/build_needed.sh
BUILD_NEEDED=$($BUILD_NEEDED_TOOL_PATH $*)
COLOR_BRIGHT_WHITE="\033[1;97m"
COLOR_BOLD_RED="\033[1;31m"
COLOR_GREEN="\033[0;32m"
COLOR_NORMAL="\033[0m"
CHECK_MARK="\xe2\x9c\x93"
if [ "$BUILD_NEEDED" -eq 1 ]; then
echo -e "${COLOR_BRIGHT_WHITE}=== BUILDING XCTOOL ===${COLOR_NORMAL}"
echo
echo -e " $XCTOOL_DIR/build.sh"
# Alas, date on Mac OS X has no %N, so we can't get milliseconds here.
BUILD_TIME_START=$SECONDS
if ! "$XCTOOL_DIR"/build.sh > $TEMP_PATH 2>&1; then
echo
echo -e "${COLOR_BOLD_RED}ERROR${COLOR_NORMAL}: Failed to build xctool:"
cat $TEMP_PATH
exit 1
fi
BUILD_TIME_END=$SECONDS
BUILD_DURATION_MS=$(((${BUILD_TIME_END}-${BUILD_TIME_START}) * 1000))
echo -ne " ${COLOR_GREEN}${CHECK_MARK}${COLOR_NORMAL} Built xctool "
echo -e "${COLOR_GREEN}(${BUILD_DURATION_MS} ms)${COLOR_NORMAL}"
echo
fi
# Will be a short git hash or just '.' if we're not in a git repo.
REVISION=$((git log -n 1 --format=%h "$XCTOOL_DIR" 2> /dev/null) || echo ".")
"$XCTOOL_DIR"/build/$REVISION/Products/Release/xctool "$@"