-
Notifications
You must be signed in to change notification settings - Fork 54
/
installXcodebuild
executable file
·138 lines (114 loc) · 3.4 KB
/
installXcodebuild
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
#!/bin/sh
FORCE="YES"
XCODEBUILD=/usr/bin/xcodebuild
BUILDROOT="$1"
EXTRACOPY=( \
/usr/lib/dyld \
# /usr/share/icu \
/System/Library/CoreServices/CharacterSets \
/Developer/Private \
/Developer/Tools \
/usr/bin/xcodebuild \
/Developer/Makefiles/pbx_jamfiles \
/Library/Application\ Support/Xcode)
if [ -z "$BUILDROOT" ]; then
echo "Usage: $0 /Volumes/DarwinBuild/BuildRoot" 1>&2
exit 1
fi
mkdir -p "$BUILDROOT"
###
### Recurse through frameworks and libraries looking for dependencies
###
RecurseLibs() {
echo $1 >> /tmp/installXcode.seen.$$
otool -L $1 | tail -n +2 | awk '{ print $1 }' > /tmp/installXcode.tmplibs.$$
cat /tmp/installXcode.tmplibs.$$ >> /tmp/installXcode.libs.$$
cat /tmp/installXcode.tmplibs.$$ | while read X; do
if ! grep -q "^$X\$" /tmp/installXcode.seen.$$ ; then
RecurseLibs $X
fi
done
}
RemoveTemps() {
rm -f /tmp/installXcode.libs.$$
rm -f /tmp/installXcode.seen.$$
rm -f /tmp/installXcode.tmplibs.$$
rm -f /tmp/installXcode.tmpfiles.$$
rm -f /tmp/installXcode.files.$$
}
AppendExtraFiles() {
for X in "${EXTRACOPY[@]}"; do
echo "$X" >> /tmp/installXcode.libs.$$
done
}
TransformLibs() {
# set -x
while read X; do
NEWX=$(echo $X | sed -n 's/\(.*\.framework\).*/\1/p')
if [ -n "$NEWX" ]; then
# if we're copying a framework binary, copy the entire bundle
echo "$NEWX"
continue
fi
NEWX=$(echo $X | sed -n 's/\([^.]*\)\..*dylib$/\1/p')
if [ -n "$NEWX" ]; then
# if we're copying a dylib, copy associate symlinks and stuff
for Y in "$NEWX"*.dylib; do
echo "$Y"
done
continue
fi
echo "$X"
done
# set +x
}
GenerateFileNames() {
cat /tmp/installXcode.libs.$$ | sort -u | TransformLibs | sort -u | while read X; do
# echo adding children for "$X"
# first mkdir parent directories
PARENT=$(dirname "$X")
while [ "$PARENT" != "/" -a "$PARENT" != "." ]; do
echo ".$PARENT" >> /tmp/installXcode.tmpfiles.$$
PARENT=$(dirname "$PARENT")
done
find ".$X" \! \( -name \*_debug\* -o -name \*_profile\* -o -path \*/Headers\* -o -path \*/PrivateHeaders\* -o -path \*.dict\* \) >> /tmp/installXcode.tmpfiles.$$
done
sort -u /tmp/installXcode.tmpfiles.$$ > /tmp/installXcode.files.$$
}
CopyFiles() {
VERBOSECPIO=""
echo -n "Copying Xcode and dependencies ..."
cpio -o -c < /tmp/installXcode.files.$$ | \
sed -e 's,/System,/XCD/SY,g' \
-e 's,/usr/lib,/XCD/lib,g' \
-e 's,/Developer,/XCD/loper,g' | \
(cd "$BUILDROOT"; cpio -im${VERBOSECPIO}d )
echo "done"
}
###
### Find all the framework and library dependencies of Xcode build
### For frameworks, copy over all supporting files.
###
pushd / > /dev/null
RemoveTemps
touch /tmp/installXcode.seen.$$
echo Analyzing Xcode dependencies ...
RecurseLibs $XCODEBUILD
AppendExtraFiles
GenerateFileNames
CopyFiles
popd > /dev/null
if [ ! -e "$BUILDROOT/Library/Application Support/Xcode/Specifications/GCC 3.5.xcspec" ];
then
echo "Generating GCC 3.5.xcspec"
sed \
-e 's/4\.0/3.5/g' \
-e 's/4_0/3_5/g' \
-e '/DashIFlagAcceptsHeadermaps/d' \
-e 's/SupportsHeadermaps = Yes/SupportsHeadermaps = No/' \
-e '/USE_HEADERMAP/,/}/ s/DefaultValue = YES/DefaultValue = NO/' \
-e '/USE_HEADER_SYMLINKS/,/}/ s/DefaultValue = NO/DefaultValue = YES/' \
< "$BUILDROOT/Library/Application Support/Xcode/Specifications/GCC 4.0.xcspec" \
> "$BUILDROOT/Library/Application Support/Xcode/Specifications/GCC 3.5.xcspec"
fi
RemoveTemps