Skip to content

Commit 9069591

Browse files
committed
Support Debug build and upload debug binaries
(cherry picked from commit 4e2dd62)
1 parent e3eefce commit 9069591

File tree

4 files changed

+62
-10
lines changed

4 files changed

+62
-10
lines changed

.github/workflows/ci-build-binary-artifacts.yaml

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,35 @@ jobs:
163163
shell: bash
164164
run: 7z a -tzip pulsar-client-cpp-${{ matrix.triplet }}.zip ${{ env.INSTALL_DIR }}/*
165165

166-
- name: Upload binaries to release
167-
uses: svenstaro/upload-release-action@v2
166+
- name: Upload artifacts
167+
uses: actions/upload-artifact@v3
168168
with:
169-
repo_token: ${{ secrets.GITHUB_TOKEN }}
170-
file: pulsar-client-cpp-${{ matrix.triplet }}.zip
171-
asset_name: pulsar-client-cpp-${{ matrix.triplet }}.zip
172-
tag: ${{ github.ref }}
173-
overwrite: true
169+
name: ${{ matrix.triplet }}
170+
path: ${{ env.INSTALL_DIR }}
171+
172+
- name: Build and package (Debug)
173+
shell: bash
174+
run: |
175+
BUILD_DIR=./build-debug
176+
INSTALL_DIR_DEBUG={{ env.INSTALL_DIR }}-Debug
177+
mkdir -p $BUILD_DIR
178+
cmake -B $BUILD_DIR \
179+
-G "${{ matrix.generator }}" ${{ matrix.arch }} \
180+
-DBUILD_TESTS=OFF \
181+
-DVCPKG_TRIPLET=${{ matrix.triplet }} \
182+
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR_DEBUG \
183+
-DCMAKE_BUILD_TYPE=Debug \
184+
-S .
185+
cmake --build $BUILD_DIR --parallel --config Debug
186+
cmake --install $BUILD_DIR --config Debug
187+
cp dependencies.txt $INSTALL_DIR_DEBUG
188+
189+
- name: Zip artifact (Debug)
190+
shell: bash
191+
run: 7z a -tzip pulsar-client-cpp-${{ matrix.triplet }}-Debug.zip ${{ env.INSTALL_DIR }}-Debug/*
192+
193+
- name: Upload artifacts (Debug)
194+
uses: actions/upload-artifact@v3
195+
with:
196+
name: ${{ matrix.triplet }}-Debug
197+
path: ${{ env.INSTALL_DIR }}-Debug

.github/workflows/ci-pr-validation.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,21 @@ jobs:
200200
./build-static/Release/win-example.exe
201201
fi
202202
203+
- name: Build (Debug with LINK_STATIC=ON)
204+
shell: bash
205+
run: |
206+
if [ "$RUNNER_OS" == "Windows" ]; then
207+
cmake \
208+
-B ./build-2 \
209+
-G "${{ matrix.generator }}" ${{ matrix.arch }} \
210+
-DBUILD_TESTS=OFF \
211+
-DVCPKG_TRIPLET="${{ matrix.triplet }}-static" \
212+
-DCMAKE_INSTALL_PREFIX="${{ env.INSTALL_DIR }}" \
213+
-DCMAKE_BUILD_TYPE=Debug \
214+
-S .
215+
cmake --build ./build-2 --parallel --config Debug
216+
fi
217+
203218
package:
204219
name: Build ${{matrix.pkg.name}} ${{matrix.cpu.platform}}
205220
runs-on: ubuntu-22.04

CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ if (VCPKG_TRIPLET)
4444
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
4545
set(ZLIB_ROOT ${VCPKG_DEBUG_ROOT})
4646
set(OPENSSL_ROOT_DIR ${VCPKG_DEBUG_ROOT})
47+
set(CMAKE_PREFIX_PATH ${VCPKG_DEBUG_ROOT} ${CMAKE_PREFIX_PATH})
4748
endif ()
4849
if (VCPKG_TRIPLET MATCHES ".*-static")
4950
set(LINK_STATIC ON)
@@ -202,13 +203,21 @@ if (LINK_STATIC AND NOT VCPKG_TRIPLET)
202203
elseif (LINK_STATIC AND VCPKG_TRIPLET)
203204
find_package(protobuf REQUIRED)
204205
message(STATUS "Found protobuf static library: " ${Protobuf_LIBRARIES})
205-
find_library(ZLIB_LIBRARIES NAMES zlib z)
206+
if (MSVC AND (${CMAKE_BUILD_TYPE} STREQUAL Debug))
207+
find_library(ZLIB_LIBRARIES NAMES zlibd)
208+
else ()
209+
find_library(ZLIB_LIBRARIES NAMES zlib z)
210+
endif ()
206211
if (ZLIB_LIBRARIES)
207212
message(STATUS "Found zlib static library: " ${ZLIB_LIBRARIES})
208213
else ()
209214
message(FATAL_ERROR "Failed to find zlib static library")
210215
endif ()
211-
find_library(CURL_LIBRARIES NAMES libcurl)
216+
if (MSVC AND (${CMAKE_BUILD_TYPE} STREQUAL Debug))
217+
find_library(CURL_LIBRARIES NAMES libcurl-d)
218+
else ()
219+
find_library(CURL_LIBRARIES NAMES libcurl)
220+
endif ()
212221
if (CURL_LIBRARIES)
213222
message(STATUS "Found libcurl: ${CURL_LIBRARIES}")
214223
else ()

lib/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ endif(NOT LIBRARY_VERSION)
4646
if (MSVC)
4747
find_package(dlfcn-win32 REQUIRED)
4848
set(CMAKE_DL_LIBS dlfcn-win32::dl psapi.lib)
49-
get_target_property(dlfcn-win32_LIBRARY dlfcn-win32::dl IMPORTED_LOCATION_RELEASE)
49+
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
50+
get_target_property(dlfcn-win32_LIBRARY dlfcn-win32::dl IMPORTED_LOCATION_DEBUG)
51+
else ()
52+
get_target_property(dlfcn-win32_LIBRARY dlfcn-win32::dl IMPORTED_LOCATION_RELEASE)
53+
endif ()
5054
message(STATUS "dlfcn-win32_LIBRARY: " ${dlfcn-win32_LIBRARY})
5155
endif(MSVC)
5256

0 commit comments

Comments
 (0)