Skip to content

Commit 45bcc40

Browse files
committed
makefile: factor static build targets
Split the static driver build from the static integration-test build and share the configured build directory setup. This keeps the static integration target focused on building and probing the test binary.
1 parent 232f300 commit 45bcc40

2 files changed

Lines changed: 34 additions & 8 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.vscode/
22
.zed
33
build/
4+
build-static/
45
build-macos/
56
**/build/
67
**/build-macos/

Makefile

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,16 @@ build-integration-test-bin-if-missing:
276276
cmake -DCASS_BUILD_INTEGRATION_TESTS=ON -DCMAKE_BUILD_TYPE=Release .. && (make -j 4 || make)
277277

278278
STATIC_BUILD_DIR := $(CURRENT_DIR)build-static
279-
280-
build-static-integration-test-bin:
279+
STATIC_BUILD_CMAKE_FLAGS := -DCASS_BUILD_INTEGRATION_TESTS=ON -DCASS_USE_STATIC_LIBS=ON -DCMAKE_BUILD_TYPE=Release
280+
STATIC_INTEGRATION_TEST_TARGET := cassandra-integration-tests
281281
ifeq ($(OS_TYPE),windows)
282-
$(MAKE) .package-build-prepare-windows
283-
cmake -S . -B build-static -G "Visual Studio 17 2022" -A x64 -DCASS_BUILD_INTEGRATION_TESTS=ON -DCASS_USE_STATIC_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DOPENSSL_VERSION=$(OPENSSL_WIN_VERSION)
282+
STATIC_DRIVER_COPY_TARGET := scylla-cpp-driver_static.lib_copy
283+
else
284+
STATIC_DRIVER_COPY_TARGET := libscylla-cpp-driver_static.a_copy
285+
endif
286+
STATIC_DRIVER_BUILD_TARGETS := scylla_cpp_driver_target $(STATIC_DRIVER_COPY_TARGET)
287+
288+
define build-static-windows-targets
284289
@pwsh -NoProfile -Command "\
285290
$$useExternalOpenSSL = ((Select-String -Path 'build-static\\CMakeCache.txt' -Pattern '^SCYLLA_OPENSSL_EXTERNAL_PROJECT:BOOL=' -ErrorAction SilentlyContinue | Select-Object -First 1).Line -split '=', 2)[1]; \
286291
$$externalOpenSSLTarget = ((Select-String -Path 'build-static\\CMakeCache.txt' -Pattern '^SCYLLA_OPENSSL_EXTERNAL_TARGET:STRING=' -ErrorAction SilentlyContinue | Select-Object -First 1).Line -split '=', 2)[1]; \
@@ -312,15 +317,35 @@ ifeq ($(OS_TYPE),windows)
312317
$$env:OPENSSL_LIBS = [string]::Join(':', @($$opensslSslLibName, $$opensslCryptoLibName)); \
313318
} \
314319
}; \
315-
cmake --build build-static --config Release; \
320+
cmake --build build-static --config Release --target $(1); \
316321
if ($$LASTEXITCODE -ne 0) { exit $$LASTEXITCODE } \
317322
"
323+
endef
324+
325+
.configure-static-build-dir:
326+
ifeq ($(OS_TYPE),windows)
327+
$(MAKE) .package-build-prepare-windows
328+
cmake -S . -B build-static -G "Visual Studio 17 2022" -A x64 $(STATIC_BUILD_CMAKE_FLAGS) -DOPENSSL_VERSION=$(OPENSSL_WIN_VERSION)
329+
else
330+
@mkdir "${STATIC_BUILD_DIR}" >/dev/null 2>&1 || true
331+
cmake -S . -B "${STATIC_BUILD_DIR}" $(STATIC_BUILD_CMAKE_FLAGS)
332+
endif
333+
334+
build-static-driver: .configure-static-build-dir
335+
ifeq ($(OS_TYPE),windows)
336+
$(call build-static-windows-targets,$(STATIC_DRIVER_BUILD_TARGETS))
337+
else
338+
@echo "Building static driver artifacts in ${STATIC_BUILD_DIR}"
339+
cmake --build "${STATIC_BUILD_DIR}" --target $(STATIC_DRIVER_BUILD_TARGETS)
340+
endif
341+
342+
build-static-integration-test-bin: build-static-driver
343+
ifeq ($(OS_TYPE),windows)
344+
$(call build-static-windows-targets,$(STATIC_INTEGRATION_TEST_TARGET))
318345
build-static\Release\cassandra-integration-tests.exe --gtest_list_tests > NUL
319346
else
320347
@echo "Building integration test binary with STATIC linking to ${STATIC_BUILD_DIR}"
321-
@mkdir "${STATIC_BUILD_DIR}" >/dev/null 2>&1 || true
322-
@cd "${STATIC_BUILD_DIR}"
323-
cmake -DCASS_BUILD_INTEGRATION_TESTS=ON -DCASS_USE_STATIC_LIBS=ON -DCMAKE_BUILD_TYPE=Release .. && (make -j 4 || make)
348+
cmake --build "${STATIC_BUILD_DIR}" --target $(STATIC_INTEGRATION_TEST_TARGET)
324349
"${STATIC_BUILD_DIR}/cassandra-integration-tests" --gtest_list_tests > /dev/null
325350
endif
326351

0 commit comments

Comments
 (0)