Skip to content

Commit

Permalink
cmake: allow building CLI tools on Windows
Browse files Browse the repository at this point in the history
For now, we'll only build some of the Ceph CLI binaries when
targeting Windows. In order to avoid over complicating the
cmake files, it was decided that the build script should pick
the targets that are to be compiled.

To keep the build script relatively simple, we'll stop supporting
Ninja, sticking to "make". Another reason for that is that some
targets cannot be compiled using Ninja:

http://paste.openstack.org/raw/796649/

Signed-off-by: Lucian Petrut <[email protected]>
  • Loading branch information
petrutlucian94 committed Aug 31, 2020
1 parent be15568 commit d024506
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
1 change: 0 additions & 1 deletion README.windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ DEPS_DIR The directory where the Ceph $CEPH_DIR/build.deps
dependencies will be built.
NUM_WORKERS The number of workers to use The number of vcpus
when building Ceph. available
NINJA_BUILD Use Ninja instead of make.
CLEAN_BUILD Clean the build directory.
SKIP_BUILD Run cmake without actually
performing the build.
Expand Down
2 changes: 1 addition & 1 deletion src/librbd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ if(ENABLE_SHARED)
SOVERSION 1
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON)
if(NOT APPLE)
if(NOT APPLE AND NOT WIN32)
set_property(TARGET librbd APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--exclude-libs,ALL")
endif()
Expand Down
35 changes: 16 additions & 19 deletions win32_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ DEPS_DIR="${DEPS_DIR:-$CEPH_DIR/build.deps}"
CLEAN_BUILD=${CLEAN_BUILD:-}
SKIP_BUILD=${SKIP_BUILD:-}
NUM_WORKERS=${NUM_WORKERS:-$num_vcpus}
NINJA_BUILD=${NINJA_BUILD:-}
DEV_BUILD=${DEV_BUILD:-}

# We'll have to be explicit here since auto-detecting doesn't work
Expand All @@ -36,11 +35,7 @@ zlibDir="${depsToolsetDir}/zlib"
backtraceDir="${depsToolsetDir}/backtrace"
snappyDir="${depsToolsetDir}/snappy"
winLibDir="${depsToolsetDir}/windows/lib"
if [[ -n $NINJA_BUILD ]]; then
generatorUsed="Ninja"
else
generatorUsed="Unix Makefiles"
fi
generatorUsed="Unix Makefiles"

pyVersion=`python -c "import sys; print('%d.%d' % (sys.version_info.major, sys.version_info.minor))"`

Expand Down Expand Up @@ -110,17 +105,19 @@ cmake -D CMAKE_PREFIX_PATH=$depsDirs \

if [[ -z $SKIP_BUILD ]]; then
echo "Building using $NUM_WORKERS workers. Log: ${BUILD_DIR}/build.log"
echo "NINJA_BUILD = $NINJA_BUILD"

# We're currently limitting the build scope to the rados/rbd binaries.
if [[ -n $NINJA_BUILD ]]; then
cd $BUILD_DIR
ninja -v rados.exe rbd.exe compressor | tee "${BUILD_DIR}/build.log"
else
cd $BUILD_DIR/src/tools
make -j $NUM_WORKERS 2>&1 | tee "${BUILD_DIR}/build.log"

cd $BUILD_DIR/src/compressor
make -j $NUM_WORKERS 2>&1 | tee -a "${BUILD_DIR}/build.log"
fi
echo "" > "${BUILD_DIR}/build.log"

# We're going to use an associative array having subdirectories as keys
# and targets as values.
declare -A make_targets
make_targets["src/tools"]="ceph-conf ceph_radosacl ceph_scratchtool rados"
make_targets["src/tools/immutable_object_cache"]="all"
make_targets["src/tools/rbd"]="all"
make_targets["src/tools/rbd_mirror"]="all"
make_targets["src/compressor"]="all"

for target_subdir in "${!make_targets[@]}"; do
echo "Building $target_subdir: ${make_targets[$target_subdir]}" | tee -a "${BUILD_DIR}/build.log"
make -j $NUM_WORKERS -C $target_subdir ${make_targets[$target_subdir]} 2>&1 | tee -a "${BUILD_DIR}/build.log"
done
fi

0 comments on commit d024506

Please sign in to comment.