summaryrefslogtreecommitdiffstats
path: root/win32_build.sh
diff options
context:
space:
mode:
authorLucian Petrut <lpetrut@cloudbasesolutions.com>2020-08-07 14:11:02 +0200
committerLucian Petrut <lpetrut@cloudbasesolutions.com>2020-12-09 19:01:02 +0100
commit61999ec168c6568b71a87c066a0d59b363a39d28 (patch)
treedb2fe1864fc9576a0386fdd9630378bd106790e5 /win32_build.sh
parentMerge pull request #37971 from lixiaoy1/rwl_plugin (diff)
downloadceph-61999ec168c6568b71a87c066a0d59b363a39d28.tar.xz
ceph-61999ec168c6568b71a87c066a0d59b363a39d28.zip
win32*.sh: update Windows build scripts and readme
We're going to allow building a zip containing stripped binaries and skipping the ceph tests. We'll use a separate option rather than changing the build type so that may generate binaries containing debug symbols as well as stripped binaries in one shot. While at it, we're updating the Windows readme. Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com> Signed-off-by: Mike Latimer <mlatimer@suse.com>
Diffstat (limited to 'win32_build.sh')
-rwxr-xr-xwin32_build.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/win32_build.sh b/win32_build.sh
index 0b9b888baef..5d8fd22f5d2 100755
--- a/win32_build.sh
+++ b/win32_build.sh
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -e
+set -o pipefail
SCRIPT_DIR="$(dirname "$BASH_SOURCE")"
SCRIPT_DIR="$(realpath "$SCRIPT_DIR")"
@@ -10,11 +11,23 @@ num_vcpus=$(( $(lscpu -p | tail -1 | cut -d "," -f 1) + 1 ))
CEPH_DIR="${CEPH_DIR:-$SCRIPT_DIR}"
BUILD_DIR="${BUILD_DIR:-${CEPH_DIR}/build}"
DEPS_DIR="${DEPS_DIR:-$CEPH_DIR/build.deps}"
+ZIP_DEST="${ZIP_DEST:-$BUILD_DIR/ceph.zip}"
CLEAN_BUILD=${CLEAN_BUILD:-}
SKIP_BUILD=${SKIP_BUILD:-}
+# Usefull when packaging existing binaries.
+SKIP_CMAKE=${SKIP_CMAKE:-}
+SKIP_DLL_COPY=${SKIP_DLL_COPY:-}
+SKIP_TESTS=${SKIP_TESTS:-}
NUM_WORKERS=${NUM_WORKERS:-$num_vcpus}
DEV_BUILD=${DEV_BUILD:-}
+BUILD_ZIP=${BUILD_ZIP:-}
+# By default, we'll build release binaries with debug symbols attached.
+# If BUILD_ZIP and STRIP_ZIPPED are enabled, we'll strip the binaries
+# that we're going to archive.
+# Unfortunately we cannot use pdb symbols when cross compiling. cv2pdb
+# well as llvm rely on mspdb*.dll in order to support this proprietary format.
+STRIP_ZIPPED=${STRIP_ZIPPED:-}
# We'll have to be explicit here since auto-detecting doesn't work
# properly when cross compiling.
@@ -24,6 +37,8 @@ ALLOCATOR=${ALLOCATOR:-libc}
# -Wa,-mbig-obj does not help.
CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-RelWithDebInfo}
+binDir="$BUILD_DIR/bin"
+strippedBinDir="$BUILD_DIR/bin_stripped"
depsSrcDir="$DEPS_DIR/src"
depsToolsetDir="$DEPS_DIR/mingw"
@@ -62,6 +77,7 @@ fi
mkdir -p $BUILD_DIR
cd $BUILD_DIR
+if [[ -z $SKIP_CMAKE ]]; then
# We'll need to cross compile Boost.Python before enabling
# "WITH_MGR".
echo "Generating solution. Log: ${BUILD_DIR}/cmake.log"
@@ -103,6 +119,7 @@ cmake -D CMAKE_PREFIX_PATH=$depsDirs \
-D WNBD_LIBRARIES="$wnbdLibDir/libwnbd.a" \
-G "$generatorUsed" \
$CEPH_DIR 2>&1 | tee "${BUILD_DIR}/cmake.log"
+fi # [[ -z $SKIP_CMAKE ]]
if [[ -z $SKIP_BUILD ]]; then
echo "Building using $NUM_WORKERS workers. Log: ${BUILD_DIR}/build.log"
@@ -122,3 +139,31 @@ if [[ -z $SKIP_BUILD ]]; then
make -j $NUM_WORKERS -C $target_subdir ${make_targets[$target_subdir]} 2>&1 | tee -a "${BUILD_DIR}/build.log"
done
fi
+
+if [[ -z $SKIP_DLL_COPY ]]; then
+ # Hopefully this path will be the same across distros.
+ # This depends on the thread library, we're currently using posix.
+ mingwVersion=`x86_64-w64-mingw32-c++-posix -dumpversion`
+ mingwTargetLibDir="/usr/lib/gcc/x86_64-w64-mingw32/$mingwVersion"
+ required_dlls=(
+ $zlibDir/zlib1.dll
+ $sslDir/bin/libcrypto-1_1-x64.dll
+ $sslDir/bin/libssl-1_1-x64.dll
+ $mingwTargetLibDir/libstdc++-6.dll
+ $mingwTargetLibDir/libgcc_s_seh-1.dll
+ /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll)
+ echo "Copying required dlls to $binDir."
+ cp ${required_dlls[@]} $binDir
+fi
+
+if [[ -n $BUILD_ZIP ]]; then
+ if [[ -n $STRIP_ZIPPED ]]; then
+ rm -rf $strippedBinDir
+ cp -r $binDir $strippedBinDir
+ echo "Stripping debug symbols from $strippedBinDir binaries."
+ x86_64-w64-mingw32-strip $strippedBinDir/*.exe \
+ $strippedBinDir/*.dll
+ fi
+ echo "Building zip archive $ZIP_DEST."
+ zip -r $ZIP_DEST $strippedBinDir
+fi