-
Notifications
You must be signed in to change notification settings - Fork 16
/
carthage-developer-checkouts
executable file
·65 lines (49 loc) · 1.98 KB
/
carthage-developer-checkouts
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
#!/bin/bash
#
# This script replaces Carthage checkouts with symlinks pointed inside the
# parent directory (..), useful for developing dependencies in coordination with
# the parent project, while avoiding the need for submodules.
#
# Usage:
# cd ProjectFolder && /path/to/carthage-developer-checkouts
mkdir -p "Carthage/Checkouts/"
project_dir=$PWD
parent_dir=$(dirname "$PWD")
sed -E 's/(github|git|binary) \"([^\"]+)\" \"([^\"]+)\"/\2 \3/g' Cartfile.resolved | while read line
do
read -a array <<< "$line"
# Handles:
# - ReactiveCocoa/ReactiveSwift > ReactiveSwift
# - https://github.com/Carthage/Carthage.git > Carthage
# - https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json > Mapbox-iOS-SDK
dependency=`basename ${array[0]} | awk -F'.' '{ print $1 }'`
version=${array[1]}
echo -e "Cartfile.resolved[$dependency] at $version"
dependency_dir="$parent_dir/$dependency"
checkout_dir="Carthage/Checkouts/$dependency"
echo "*** Setting up $dependency"
if [ -d "$dependency_dir/.git" ]
then
pushd "$dependency_dir" >/dev/null
git rev-parse "$version^{commit}" >/dev/null 2>&1
if [ $? -ne 0 ]
then
echo -e "\tFetching"
git fetch --prune --quiet || exit $?
fi
echo -e "\tChecking out $version"
git checkout --quiet "$version" || exit $?
# TODO: Update submodules
popd >/dev/null
echo -e "\tSymlinking $dependency/Carthage/Build -> $project_dir/Carthage/Build"
mkdir -p "$dependency_dir/Carthage" || exit $?
rm -rf "$dependency_dir/Carthage/Build" || exit $?
ln -s "$project_dir/Carthage/Build" "$dependency_dir/Carthage/Build" || exit $?
echo -e "\tSymlinking $checkout_dir -> $dependency_dir"
rm -rf "$checkout_dir" || exit $?
ln -s "$dependency_dir" "$checkout_dir" || exit $?
else
echo -e "\tWarning: $dependency has not yet been cloned to $dependency_dir, skipping symlink."
fi
echo
done