-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
common.sh
executable file
·139 lines (113 loc) · 4.12 KB
/
common.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/sh
#
# Copyright 2012 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This script sets up a consistent environment for the other scripts in this directory.
# Set up paths for a specific clone of the SDK source
if [ -z "$FB_SDK_SCRIPT" ]; then
# ---------------------------------------------------------------------------
# Versioning for the SDK
#
FB_SDK_VERSION_MAJOR=0
FB_SDK_VERSION_MINOR=1
test -n "$FB_SDK_VERSION_BUILD" || FB_SDK_VERSION_BUILD=$(date '+%Y%m%d')
FB_SDK_VERSION=${FB_SDK_VERSION_MAJOR}.${FB_SDK_VERSION_MINOR}
FB_SDK_VERSION_FULL=${FB_SDK_VERSION}.${FB_SDK_VERSION_BUILD}
# ---------------------------------------------------------------------------
# Set up paths
#
# The directory containing this script
# We need to go there and use pwd so these are all absolute paths
pushd $(dirname $0) >/dev/null
FB_SDK_SCRIPT=$(pwd)
popd >/dev/null
# The root directory where the Facebook iOS SDK is cloned
FB_SDK_ROOT=$(dirname $FB_SDK_SCRIPT)
# Path to source files for Facebook SDK
FB_SDK_SRC=$FB_SDK_ROOT/src
# Path to sample files for Facebook SDK
FB_SDK_SAMPLES=$FB_SDK_ROOT/samples
# The directory where the target is built
FB_SDK_BUILD=$FB_SDK_ROOT/build
FB_SDK_BUILD_LOG=$FB_SDK_BUILD/build.log
# The name of the Facebook iOS SDK
FB_SDK_BINARY_NAME=FBiOSSDK
# The name of the Facebook iOS SDK framework
FB_SDK_FRAMEWORK_NAME=${FB_SDK_BINARY_NAME}.framework
# The path to the built Facebook iOS SDK .framework
FB_SDK_FRAMEWORK=$FB_SDK_BUILD/$FB_SDK_FRAMEWORK_NAME
# The path to the framework docs
FB_SDK_FRAMEWORK_DOCS=$FB_SDK_BUILD/docs
fi
# Set up one-time variables
if [ -z $FB_SDK_ENV ]; then
FB_SDK_ENV=env1
FB_SDK_BUILD_DEPTH=0
# Explains where the log is if this is the outermost build or if
# we hit a fatal error.
function show_summary() {
test -r $FB_SDK_BUILD_LOG && echo "Build log is at $FB_SDK_BUILD_LOG"
}
# Determines whether this is out the outermost build.
function is_outermost_build() {
test 1 -eq $FB_SDK_BUILD_DEPTH
}
# Calls show_summary if this is the outermost build.
# Do not call outside common.sh.
function pop_common() {
FB_SDK_BUILD_DEPTH=$(($FB_SDK_BUILD_DEPTH - 1))
test 0 -eq $FB_SDK_BUILD_DEPTH && show_summary
}
# Deletes any previous build log if this is the outermost build.
# Do not call outside common.sh.
function push_common() {
test 0 -eq $FB_SDK_BUILD_DEPTH && \rm -f $FB_SDK_BUILD_LOG
FB_SDK_BUILD_DEPTH=$(($FB_SDK_BUILD_DEPTH + 1))
}
# Echoes a progress message to stderr
function progress_message() {
echo "$@" >&2
}
# Any script that includes common.sh must call this once if it finishes
# successfully.
function common_success() {
pop_common
return 0
}
# Call this when there is an error. This does not return.
function die() {
echo ""
echo "FATAL: $*" >&2
show_summary
exit 1
}
test -n "$XCODEBUILD" || XCODEBUILD=$(which xcodebuild)
test -n "$LIPO" || LIPO=$(which lipo)
test -n "$PACKAGEMAKER" || PACKAGEMAKER=$(which PackageMaker)
# < XCode 4.3.1
if [ ! -x "$XCODEBUILD" ]; then
# XCode from app store
XCODEBUILD=/Applications/XCode.app/Contents/Developer/usr/bin/xcodebuild
fi
if [ ! -x "$PACKAGEMAKER" ]; then
PACKAGEMAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker
fi
if [ ! -x "$PACKAGEMAKER" ]; then
PACKAGEMAKER=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
fi
fi
# Increment depth every time we . this file. At the end of any script
# that .'s this file, there should be a call to common_finish to decrement.
push_common