@@ -30,15 +30,14 @@ ${PROGNAME} [options]
30
30
31
31
--symbols-dir <DIR> Path to the directory to install the .dSYM bundle to.
32
32
33
- --sdk <SDK> SDK used for building the library. This represents
34
- the target platform that the library will run on.
35
- You can get a list of SDKs with \` xcodebuild -showsdks\` .
36
-
37
33
--architectures "<arch>..." A whitespace separated list of architectures to build for.
38
34
The library will be built for each architecture independently,
39
35
and a universal binary containing all architectures will be
40
36
created from that.
41
37
38
+ --headers-only Only install the header part of the library -- don't actually
39
+ build the full library.
40
+
42
41
--version X[.Y[.Z]] The version of the library to encode in the dylib.
43
42
EOF
44
43
}
@@ -65,14 +64,14 @@ while [[ $# -gt 0 ]]; do
65
64
install_dir=" ${2} "
66
65
shift ; shift
67
66
;;
68
- --sdk)
69
- sdk=" ${2} "
70
- shift ; shift
71
- ;;
72
67
--architectures)
73
68
architectures=" ${2} "
74
69
shift ; shift
75
70
;;
71
+ --headers-only)
72
+ headers_only=true
73
+ shift
74
+ ;;
76
75
--version)
77
76
version=" ${2} "
78
77
shift ; shift
@@ -83,7 +82,7 @@ while [[ $# -gt 0 ]]; do
83
82
esac
84
83
done
85
84
86
- for arg in llvm_root build_dir symbols_dir install_dir sdk architectures version; do
85
+ for arg in llvm_root build_dir symbols_dir install_dir architectures version; do
87
86
if [ -z ${! arg+x} ]; then
88
87
error " Missing required argument '--${arg// _/ -} '"
89
88
elif [ " ${! arg} " == " " ]; then
@@ -111,22 +110,22 @@ function step() {
111
110
for arch in ${architectures} ; do
112
111
step " Building libc++.dylib and libc++abi.dylib for architecture ${arch} "
113
112
mkdir -p " ${build_dir} /${arch} "
114
- (cd " ${build_dir} / ${arch} " &&
115
- xcrun --sdk " ${sdk} " cmake " ${llvm_root} /runtimes " \
116
- -GNinja \
117
- -DCMAKE_MAKE_PROGRAM=" $( xcrun --sdk " ${sdk} " --find ninja) " \
118
- -DLLVM_ENABLE_RUNTIMES= " libcxx;libcxxabi " \
119
- -C " ${llvm_root} / libcxx/cmake/caches/Apple.cmake " \
120
- -DCMAKE_INSTALL_PREFIX=" ${build_dir} /${arch} -install" \
121
- -DCMAKE_INSTALL_NAME_DIR=" /usr/lib" \
122
- -DCMAKE_OSX_ARCHITECTURES=" ${arch} " \
123
- -DLIBCXXABI_LIBRARY_VERSION=" ${version} " \
124
- -DLIBCXX_INCLUDE_BENCHMARKS=OFF \
125
- -DLIBCXX_TEST_CONFIG= " apple-libc++-shared.cfg.in " \
126
- -DLIBCXXABI_TEST_CONFIG= " apple-libc++abi-shared.cfg.in "
127
- )
128
-
129
- xcrun --sdk " ${sdk} " cmake --build " ${build_dir} / ${arch} " --target install-cxx install-cxxabi -- -v
113
+ xcrun cmake -S " ${llvm_root} /runtimes " \
114
+ -B " ${build_dir} / ${arch} " \
115
+ -GNinja \
116
+ -DCMAKE_MAKE_PROGRAM=" $( xcrun --find ninja) " \
117
+ -C " ${llvm_root} / libcxx/cmake/caches/Apple.cmake " \
118
+ -DLLVM_ENABLE_RUNTIMES= " libcxx;libcxxabi " \
119
+ -DCMAKE_INSTALL_PREFIX=" ${build_dir} /${arch} -install" \
120
+ -DCMAKE_INSTALL_NAME_DIR=" /usr/lib" \
121
+ -DCMAKE_OSX_ARCHITECTURES=" ${arch} " \
122
+ -DLIBCXXABI_LIBRARY_VERSION=" ${version} "
123
+
124
+ if [ " $headers_only " = true ] ; then
125
+ xcrun cmake --build " ${build_dir} / ${arch} " --target install-cxx-headers -- -v
126
+ else
127
+ xcrun cmake --build " ${build_dir} / ${arch} " --target install-cxx install-cxxabi -- -v
128
+ fi
130
129
done
131
130
132
131
function universal_dylib() {
@@ -135,21 +134,23 @@ function universal_dylib() {
135
134
inputs=$( for arch in ${architectures} ; do echo " ${build_dir} /${arch} -install/lib/${dylib} " ; done)
136
135
137
136
step " Creating a universal dylib ${dylib} from the dylibs for all architectures"
138
- xcrun --sdk " ${sdk} " lipo -create ${inputs} -output " ${build_dir} /${dylib} "
137
+ xcrun lipo -create ${inputs} -output " ${build_dir} /${dylib} "
139
138
140
139
step " Installing the (stripped) universal dylib to ${install_dir} /usr/lib"
141
140
mkdir -p " ${install_dir} /usr/lib"
142
141
cp " ${build_dir} /${dylib} " " ${install_dir} /usr/lib/${dylib} "
143
- xcrun --sdk " ${sdk} " strip -S " ${install_dir} /usr/lib/${dylib} "
142
+ xcrun strip -S " ${install_dir} /usr/lib/${dylib} "
144
143
145
144
step " Installing the unstripped dylib and the dSYM bundle to ${symbols_dir} "
146
- xcrun --sdk " ${sdk} " dsymutil " ${build_dir} /${dylib} " -o " ${symbols_dir} /${dylib} .dSYM"
145
+ xcrun dsymutil " ${build_dir} /${dylib} " -o " ${symbols_dir} /${dylib} .dSYM"
147
146
cp " ${build_dir} /${dylib} " " ${symbols_dir} /${dylib} "
148
147
}
149
148
150
- universal_dylib libc++.1.dylib
151
- universal_dylib libc++abi.dylib
152
- (cd " ${install_dir} /usr/lib" && ln -s " libc++.1.dylib" libc++.dylib)
149
+ if [ " $headers_only " != true ]; then
150
+ universal_dylib libc++.1.dylib
151
+ universal_dylib libc++abi.dylib
152
+ (cd " ${install_dir} /usr/lib" && ln -s " libc++.1.dylib" libc++.dylib)
153
+ fi
153
154
154
155
# Install the headers by copying the headers from one of the built architectures
155
156
# into the install directory. Headers from all architectures should be the same.
@@ -162,15 +163,17 @@ if [[ $EUID -eq 0 ]]; then # Only chown if we're running as root
162
163
chown -R root:wheel " ${install_dir} /usr/include"
163
164
fi
164
165
165
- step " Installing the libc++ and libc++abi licenses"
166
- mkdir -p " ${install_dir} /usr/local/OpenSourceLicenses"
167
- cp " ${llvm_root} /libcxx/LICENSE.TXT" " ${install_dir} /usr/local/OpenSourceLicenses/libcxx.txt"
168
- cp " ${llvm_root} /libcxxabi/LICENSE.TXT" " ${install_dir} /usr/local/OpenSourceLicenses/libcxxabi.txt"
169
-
170
- # Also install universal static archives for libc++ and libc++abi
171
- libcxx_archives=$( for arch in ${architectures} ; do echo " ${build_dir} /${arch} -install/lib/libc++.a" ; done)
172
- libcxxabi_archives=$( for arch in ${architectures} ; do echo " ${build_dir} /${arch} -install/lib/libc++abi.a" ; done)
173
- step " Creating universal static archives for libc++ and libc++abi from the static archives for each architecture"
174
- mkdir -p " ${install_dir} /usr/local/lib/libcxx"
175
- xcrun --sdk " ${sdk} " libtool -static ${libcxx_archives} -o " ${install_dir} /usr/local/lib/libcxx/libc++-static.a"
176
- xcrun --sdk " ${sdk} " libtool -static ${libcxxabi_archives} -o " ${install_dir} /usr/local/lib/libcxx/libc++abi-static.a"
166
+ if [ " $headers_only " != true ]; then
167
+ step " Installing the libc++ and libc++abi licenses"
168
+ mkdir -p " ${install_dir} /usr/local/OpenSourceLicenses"
169
+ cp " ${llvm_root} /libcxx/LICENSE.TXT" " ${install_dir} /usr/local/OpenSourceLicenses/libcxx.txt"
170
+ cp " ${llvm_root} /libcxxabi/LICENSE.TXT" " ${install_dir} /usr/local/OpenSourceLicenses/libcxxabi.txt"
171
+
172
+ # Also install universal static archives for libc++ and libc++abi
173
+ libcxx_archives=$( for arch in ${architectures} ; do echo " ${build_dir} /${arch} -install/lib/libc++.a" ; done)
174
+ libcxxabi_archives=$( for arch in ${architectures} ; do echo " ${build_dir} /${arch} -install/lib/libc++abi.a" ; done)
175
+ step " Creating universal static archives for libc++ and libc++abi from the static archives for each architecture"
176
+ mkdir -p " ${install_dir} /usr/local/lib/libcxx"
177
+ xcrun libtool -static ${libcxx_archives} -o " ${install_dir} /usr/local/lib/libcxx/libc++-static.a"
178
+ xcrun libtool -static ${libcxxabi_archives} -o " ${install_dir} /usr/local/lib/libcxx/libc++abi-static.a"
179
+ fi
0 commit comments