6 SCRIPT_DIR
="$(dirname "$BASH_SOURCE")"
7 SCRIPT_DIR
="$(realpath "$SCRIPT_DIR")"
11 CEPH_DIR
="${CEPH_DIR:-$SCRIPT_DIR}"
12 BUILD_DIR
="${BUILD_DIR:-${CEPH_DIR}/build}"
13 DEPS_DIR
="${DEPS_DIR:-$CEPH_DIR/build.deps}"
14 ZIP_DEST
="${ZIP_DEST:-$BUILD_DIR/ceph.zip}"
16 CLEAN_BUILD
=${CLEAN_BUILD:-}
17 SKIP_BUILD
=${SKIP_BUILD:-}
18 # Usefull when packaging existing binaries.
19 SKIP_CMAKE
=${SKIP_CMAKE:-}
20 SKIP_DLL_COPY
=${SKIP_DLL_COPY:-}
21 SKIP_TESTS
=${SKIP_TESTS:-}
22 SKIP_BINDIR_CLEAN
=${SKIP_BINDIR_CLEAN:-}
23 # Use Ninja's default, it might be useful when having few cores.
24 NUM_WORKERS_DEFAULT
=$
(( $num_vcpus + 2 ))
25 NUM_WORKERS
=${NUM_WORKERS:-$NUM_WORKERS_DEFAULT}
26 DEV_BUILD
=${DEV_BUILD:-}
27 # Unless SKIP_ZIP is set, we're preparing an archive that contains the Ceph
28 # binaries, debug symbols as well as the required DLLs.
29 SKIP_ZIP
=${SKIP_ZIP:-}
30 # By default, we'll move the debug symbols to separate files located in the
31 # ".debug" directory. If "EMBEDDED_DBG_SYM" is set, the debug symbols will
32 # remain embedded in the binaries.
34 # Unfortunately we cannot use pdb symbols when cross compiling. cv2pdb
35 # well as llvm rely on mspdb*.dll in order to support this proprietary format.
36 EMBEDDED_DBG_SYM
=${EMBEDDED_DBG_SYM:-}
37 # Allow for OS specific customizations through the OS flag.
38 # Valid options are currently "ubuntu", "suse", and "rhel".
42 source /etc
/os-release
54 echo "Unsupported Linux distro $ID."
55 echo "only SUSE, Ubuntu and RHEL are supported."
56 echo "Set the OS environment variable to override."
63 # We'll have to be explicit here since auto-detecting doesn't work
64 # properly when cross compiling.
65 ALLOCATOR
=${ALLOCATOR:-libc}
66 # Debug builds don't work with MINGW for the time being, failing with
67 # can't close <file>: File too big
68 # -Wa,-mbig-obj does not help.
69 CMAKE_BUILD_TYPE
=${CMAKE_BUILD_TYPE:-}
70 if [[ -z $CMAKE_BUILD_TYPE ]]; then
71 # By default, we're building release binaries with minimal debug information.
72 export CFLAGS
="$CFLAGS -g1"
73 export CXXFLAGS
="$CXXFLAGS -g1"
74 CMAKE_BUILD_TYPE
=Release
77 # Some tests can't use shared libraries yet due to unspecified dependencies.
78 # We'll do a static build by default for now.
79 ENABLE_SHARED
=${ENABLE_SHARED:-OFF}
81 binDir
="$BUILD_DIR/bin"
82 strippedBinDir
="$BUILD_DIR/bin_stripped"
83 # GDB will look for this directory by default.
85 dbgSymbolDir
="$strippedBinDir/${dbgDirname}"
86 depsSrcDir
="$DEPS_DIR/src"
87 depsToolsetDir
="$DEPS_DIR/mingw"
89 cmakeGenerator
="Ninja"
90 lz4Dir
="${depsToolsetDir}/lz4"
91 sslDir
="${depsToolsetDir}/openssl"
92 boostDir
="${depsToolsetDir}/boost"
93 zlibDir
="${depsToolsetDir}/zlib"
94 backtraceDir
="${depsToolsetDir}/libbacktrace"
95 snappyDir
="${depsToolsetDir}/snappy"
96 winLibDir
="${depsToolsetDir}/windows/lib"
97 wnbdSrcDir
="${depsSrcDir}/wnbd"
98 wnbdLibDir
="${depsToolsetDir}/wnbd/lib"
99 dokanSrcDir
="${depsSrcDir}/dokany"
100 dokanLibDir
="${depsToolsetDir}/dokany/lib"
102 depsDirs
="$lz4Dir;$sslDir;$boostDir;$zlibDir;$backtraceDir;$snappyDir"
103 depsDirs
+=";$winLibDir"
105 # Cmake recommends using CMAKE_PREFIX_PATH instead of link_directories.
106 # Still, some library dependencies may not include the full path (e.g. Boost
107 # sets the "-lz" flag through INTERFACE_LINK_LIBRARIES), which is why
108 # we have to ensure that the linker will be able to locate them.
109 linkDirs
="$zlibDir/lib"
111 lz4Lib
="${lz4Dir}/lib/dll/liblz4-1.dll"
112 lz4Include
="${lz4Dir}/lib"
114 if [[ -n $CLEAN_BUILD ]]; then
115 echo "Cleaning up build dir: $BUILD_DIR"
119 if [[ -z $SKIP_BINDIR_CLEAN ]]; then
120 echo "Cleaning up bin dir: $binDir"
127 if [[ ! -f ${depsToolsetDir}/completed
]]; then
128 echo "Preparing dependencies: $DEPS_DIR. Log: ${BUILD_DIR}/build_deps.log"
129 NUM_WORKERS
=$NUM_WORKERS DEPS_DIR
=$DEPS_DIR OS
="$OS"\
130 "$SCRIPT_DIR/win32_deps_build.sh" |
tee "${BUILD_DIR}/build_deps.log"
133 # Due to distribution specific mingw settings, the mingw.cmake file
134 # must be built prior to running cmake.
135 MINGW_CMAKE_FILE
="$BUILD_DIR/mingw32.cmake"
137 source "$SCRIPT_DIR/mingw_conf.sh"
139 if [[ -z $SKIP_CMAKE ]]; then
140 # We'll need to cross compile Boost.Python before enabling
142 echo "Generating solution. Log: ${BUILD_DIR}/cmake.log"
144 # This isn't propagated to some of the subprojects, we'll use an env variable
146 export CMAKE_PREFIX_PATH
=$depsDirs
148 if [[ -n $DEV_BUILD ]]; then
149 echo "Dev build enabled."
150 echo "Git versioning will be disabled."
151 ENABLE_GIT_VERSION
="OFF"
152 WITH_CEPH_DEBUG_MUTEX
="ON"
154 ENABLE_GIT_VERSION
="ON"
155 WITH_CEPH_DEBUG_MUTEX
="OFF"
158 # As opposed to Linux, Windows shared libraries can't have unresolved
159 # symbols. Until we fix the dependencies (which are either unspecified
160 # or circular), we'll have to stick to static linking.
161 cmake
-D CMAKE_PREFIX_PATH
=$depsDirs \
162 -D MINGW_LINK_DIRECTORIES
="$linkDirs" \
163 -D CMAKE_TOOLCHAIN_FILE
="$MINGW_CMAKE_FILE" \
164 -D WITH_LIBCEPHSQLITE
=OFF \
165 -D WITH_RDMA
=OFF
-D WITH_OPENLDAP
=OFF \
166 -D WITH_GSSAPI
=OFF
-D WITH_XFS
=OFF \
167 -D WITH_FUSE
=OFF
-D WITH_DOKAN
=ON \
168 -D WITH_BLUESTORE
=OFF
-D WITH_LEVELDB
=OFF \
169 -D WITH_LTTNG
=OFF
-D WITH_BABELTRACE
=OFF
-D WITH_JAEGER
=OFF \
170 -D WITH_SYSTEM_BOOST
=ON
-D WITH_MGR
=OFF
-D WITH_KVS
=OFF \
171 -D WITH_LIBCEPHFS
=ON
-D WITH_KRBD
=OFF
-D WITH_RADOSGW
=OFF \
172 -D ENABLE_SHARED
=$ENABLE_SHARED -D WITH_RBD
=ON
-D BUILD_GMOCK
=ON \
173 -D WITH_CEPHFS
=OFF
-D WITH_MANPAGE
=OFF \
174 -D WITH_MGR_DASHBOARD_FRONTEND
=OFF
-D WITH_SYSTEMD
=OFF
-D WITH_TESTS
=ON \
175 -D LZ4_INCLUDE_DIR
=$lz4Include -D LZ4_LIBRARY
=$lz4Lib \
176 -D Backtrace_INCLUDE_DIR
="$backtraceDir/include" \
177 -D Backtrace_LIBRARY
="$backtraceDir/lib/libbacktrace.a" \
178 -D ENABLE_GIT_VERSION
=$ENABLE_GIT_VERSION \
179 -D ALLOCATOR
="$ALLOCATOR" -D CMAKE_BUILD_TYPE
=$CMAKE_BUILD_TYPE \
180 -D WNBD_INCLUDE_DIRS
="$wnbdSrcDir/include" \
181 -D WNBD_LIBRARIES
="$wnbdLibDir/libwnbd.a" \
182 -D WITH_CEPH_DEBUG_MUTEX
=$WITH_CEPH_DEBUG_MUTEX \
183 -D DOKAN_INCLUDE_DIRS
="$dokanSrcDir/dokan" \
184 -D DOKAN_LIBRARIES
="$dokanLibDir/libdokan.a" \
185 -G "$cmakeGenerator" \
186 $CEPH_DIR 2>&1 |
tee "${BUILD_DIR}/cmake.log"
187 fi # [[ -z $SKIP_CMAKE ]]
189 if [[ -z $SKIP_BUILD ]]; then
190 echo "Building using $NUM_WORKERS workers. Log: ${BUILD_DIR}/build.log"
191 echo "" > "${BUILD_DIR}/build.log"
194 ninja_targets
="rados rbd rbd-wnbd "
195 ninja_targets
+=" ceph-conf ceph-immutable-object-cache"
196 ninja_targets
+=" cephfs ceph-dokan"
197 # TODO: do we actually need the ceph compression libs?
198 ninja_targets
+=" compressor ceph_lz4 ceph_snappy ceph_zlib ceph_zstd"
199 if [[ -z $SKIP_TESTS ]]; then
200 ninja_targets
+=" tests ceph_radosacl ceph_scratchtool "
201 ninja_targets
+=`ninja -t targets | grep ceph_test | cut -d ":" -f 1 | grep -v exe`
204 ninja
-v $ninja_targets 2>&1 |
tee "${BUILD_DIR}/build.log"
207 if [[ -z $SKIP_DLL_COPY ]]; then
208 # To adjust mingw paths, see 'mingw_conf.sh'.
211 $lz4Dir/lib
/dll
/liblz4-1.dll
212 $sslDir/bin
/libcrypto-1_1-x64.dll
213 $sslDir/bin
/libssl-1_1-x64.dll
214 $mingwTargetLibDir/libstdc
++-6.dll
215 $mingwTargetLibDir/libgcc_s_seh-1.dll
216 $mingwTargetLibDir/libssp
*.dll
217 $mingwLibpthreadDir/libwinpthread-1.dll
219 echo "Copying required dlls to $binDir."
220 cp ${required_dlls[@]} $binDir
223 if [[ -z $SKIP_ZIP ]]; then
224 # Use a temp directory, in order to create a clean zip file
225 ZIP_TMPDIR
=$
(mktemp
-d win_binaries.XXXXX
)
226 if [[ -z $EMBEDDED_DBG_SYM ]]; then
227 echo "Extracting debug symbols from binaries."
228 rm -rf $strippedBinDir; mkdir
$strippedBinDir
229 rm -rf $dbgSymbolDir; mkdir
$dbgSymbolDir
230 # Strip files individually, to save time and space
231 for file in $binDir/*.exe
$binDir/*.dll
; do
232 dbgFilename
=$
(basename $file).debug
233 dbgFile
="$dbgSymbolDir/$dbgFilename"
234 strippedFile
="$strippedBinDir/$(basename $file)"
236 echo "Copying debug symbols: $dbgFile"
237 $MINGW_OBJCOPY --only-keep-debug $file $dbgFile
238 $MINGW_STRIP --strip-debug --strip-unneeded -o $strippedFile $file
239 $MINGW_OBJCOPY --remove-section .gnu_debuglink
$strippedFile
240 $MINGW_OBJCOPY --add-gnu-debuglink=$dbgFile $strippedFile
242 # Copy any remaining files to the stripped directory
243 for file in $binDir/*; do
244 [[ ! -f $strippedBinDir/$
(basename $file) ]] && \
245 cp $file $strippedBinDir
247 ln -s $strippedBinDir $ZIP_TMPDIR/ceph
249 ln -s $binDir $ZIP_TMPDIR/ceph
251 echo "Building zip archive $ZIP_DEST."
252 # Include the README file in the archive
253 ln -s $CEPH_DIR/README.windows.rst
$ZIP_TMPDIR/ceph
/README.windows.rst
255 [[ -f $ZIP_DEST ]] && rm $ZIP_DEST
256 zip -r $ZIP_DEST ceph
258 rm -rf $ZIP_TMPDIR/ceph
/README.windows.rst
$ZIP_TMPDIR
259 echo -e '\n WIN32 files zipped to: '$ZIP_DEST'\n'