-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·147 lines (122 loc) · 4.52 KB
/
setup.sh
File metadata and controls
executable file
·147 lines (122 loc) · 4.52 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
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
140
141
142
143
144
145
146
147
#!/bin/bash
set -Eeuo pipefail
#
# Wire
# Copyright (C) 2026 Wire Swiss GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# USAGE:
# This scripts checks that the necessary tools are installed on the local machine
# and sets up the project so that it can be built with Xcode.
#
# Pass --test-only to skip steps not required for running unit tests (codegen,
# licenses, AWS CLI, submodules, build-tool Swift packages).
#
function die { ( >&2 echo "$*"); exit 1; }
# Parse flags, filtering out --test-only before forwarding remaining args to sub-scripts
TEST_ONLY=false
REMAINING_ARGS=()
for arg in "$@"; do
case $arg in
--test-only)
TEST_ONLY=true
;;
*)
REMAINING_ARGS+=("$arg")
;;
esac
done
# CHECK PREREQUISITES
## Xcode
hash xcodebuild 2>/dev/null || die "Can't find Xcode, please install from the App Store"
local_xcode_version=`xcodebuild -version | sed -n "s/Xcode //p"`
LOCAL_XCODE_VERSION=( ${local_xcode_version//./ } )
repository_xcode_version=`cat .xcode-version`
REPOSITORY_XCODE_VERSION=( ${repository_xcode_version//./ } )
[[ ${LOCAL_XCODE_VERSION[0]} -gt ${REPOSITORY_XCODE_VERSION[0]} ||
( ${LOCAL_XCODE_VERSION[0]} -eq ${REPOSITORY_XCODE_VERSION[0]} && ${LOCAL_XCODE_VERSION[1]} -ge ${REPOSITORY_XCODE_VERSION[1]} ) ]] ||
die "Xcode version for the repository should be at least ${repository_xcode_version}. The current local version is ${local_xcode_version}. If you have multiple versions of Xcode installed, please run: sudo xcode-select --switch /Applications/Xcode_${repository_xcode_version}.app"
# SETUP
REPO_ROOT=$(git rev-parse --show-toplevel)
if [[ "$TEST_ONLY" == "false" ]]; then
echo "ℹ️ Installing Homebrew dependencies from Brewfile..."
# Install dependencies from Brewfile (respects CI environment variable)
brew bundle install
echo ""
fi
if [[ -n "${CI-}" ]]; then
echo "Running on CI, skipping git lfs install"
elif command -v git-lfs > /dev/null 2>&1; then
echo "ℹ️ Running git lfs install..."
git lfs install
else
die "git-lfs is not installed."
fi
echo ""
# Workaround for carthage "The file couldn't be saved." error
rm -rf ${TMPDIR}/TemporaryItems/*carthage*
echo "ℹ️ Carthage bootstrap. This might take a while..."
if [[ -n "${CI-}" ]]; then
echo "Skipping Carthage bootstrap from setup.sh script since CI is defined"
else
"$REPO_ROOT/scripts/carthage.sh" bootstrap --cache-builds --platform ios --use-xcframeworks
fi
echo ""
if [[ "$TEST_ONLY" == "false" ]]; then
echo "ℹ️ Resolve Swift Packages for Scripts..."
xcrun --sdk macosx swift package --package-path scripts resolve
xcrun --sdk macosx swift package --package-path WirePlugins resolve
echo ""
echo "ℹ️ Installing AWS CLI..."
if [[ -n "${CI-}" ]]; then
which aws || (curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg" && sudo installer -pkg AWSCLIV2.pkg -target /)
else
echo "Skipping AWS CLI install because not running on CI"
fi
echo ""
echo "ℹ️ Fetching submodules..."
git submodule update --init --recursive || true
git submodule sync --recursive || true
echo ""
fi
echo "ℹ️ Installing bundler and Ruby dependencies..."
if [[ -n "${CI-}" ]]; then
# CI
echo "Skipping install since CI is defined"
else
# Local machine
which bundle || gem install bundler
bundle check || bundle install
fi
echo ""
echo "ℹ️ Overriding configuration if specified..."
scripts/override-configuration_if_needed.sh "${REMAINING_ARGS[@]+"${REMAINING_ARGS[@]}"}"
echo ""
if [[ "$TEST_ONLY" == "false" ]]; then
echo "ℹ️ Generate Licenses"
if [[ -n "${CI-}" ]]; then
scripts/generate-licenses.sh
else
echo "Skipping as CI is not is defined"
fi
echo ""
fi
(
cd "$REPO_ROOT/wire-ios"
echo "ℹ️ [CodeGen] Update StyleKit Icons..."
swift run --package-path ./Scripts/updateStylekit
echo ""
)
echo "✅ Wire project was set up, you can now open wire-ios-mono.xcworkspace"