Skip to content

Commit 503715a

Browse files
authored
Improved Error Handling (#11)
* Verbose Try/Catch Statements for Config and UC * Unit Tests for Error Handling * Versioning Automation
1 parent feb334c commit 503715a

File tree

13 files changed

+1279
-58
lines changed

13 files changed

+1279
-58
lines changed

.gitignore

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ build/
33
cmake-build-*/
44
out/
55

6+
# Generated files (auto-generated by CMake from .in templates)
7+
# Only commit the .in templates, not the generated files
8+
include/databricks/version.h
9+
Doxyfile
10+
vcpkg.json
11+
612
# Documentation
713
docs/html/
814
docs/latex/
@@ -26,14 +32,16 @@ docs/latex/
2632
*.dll
2733
*.exe
2834

29-
# CMake generated files
35+
# CMake generated files (in build directory)
3036
CMakeCache.txt
3137
CMakeFiles/
3238
cmake_install.cmake
33-
Makefile
39+
build/Makefile
3440
*.cmake
3541
!CMakeLists.txt
3642
!cmake/*.cmake.in
43+
# Keep root Makefile (it's a wrapper, not generated by CMake)
44+
!Makefile
3745

3846
# Testing
3947
Testing/

CMakeLists.txt

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.14)
22
project(databricks_sdk
3-
VERSION 0.2.3
3+
VERSION 0.2.4
44
DESCRIPTION "Databricks C++ SDK"
55
LANGUAGES CXX)
66

@@ -9,6 +9,35 @@ set(CMAKE_CXX_STANDARD 17)
99
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1010
set(CMAKE_CXX_EXTENSIONS OFF)
1111

12+
# ========================================================================
13+
# Generate version-dependent files from templates
14+
# This ensures ALL version references stay in sync with CMakeLists.txt
15+
# ========================================================================
16+
17+
# Generate version.h
18+
configure_file(
19+
"${CMAKE_CURRENT_SOURCE_DIR}/include/databricks/version.h.in"
20+
"${CMAKE_CURRENT_BINARY_DIR}/include/databricks/version.h"
21+
@ONLY
22+
)
23+
24+
# Generate Doxyfile
25+
configure_file(
26+
"${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in"
27+
"${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile"
28+
@ONLY
29+
)
30+
31+
# Generate vcpkg.json
32+
configure_file(
33+
"${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json.in"
34+
"${CMAKE_CURRENT_SOURCE_DIR}/vcpkg.json"
35+
@ONLY
36+
)
37+
38+
message(STATUS "Databricks C++ SDK Version: ${PROJECT_VERSION}")
39+
message(STATUS " Generated: version.h, Doxyfile, vcpkg.json")
40+
1241
# Options
1342
option(BUILD_EXAMPLES "Build example applications" ON)
1443
option(BUILD_TESTS "Build tests" OFF)
@@ -108,7 +137,8 @@ set(HEADERS
108137
include/databricks/core/client.h
109138
include/databricks/core/config.h
110139
include/databricks/connection_pool.h
111-
include/databricks/version.h
140+
# version.h is auto-generated in build directory
141+
${CMAKE_CURRENT_BINARY_DIR}/include/databricks/version.h
112142
include/databricks/jobs/jobs.h
113143
include/databricks/compute/compute.h
114144
include/databricks/compute/compute_types.h
@@ -129,7 +159,10 @@ add_library(databricks_sdk ${SOURCES} ${HEADERS})
129159
# Set include directories
130160
target_include_directories(databricks_sdk
131161
PUBLIC
162+
# Source includes (for headers like client.h, config.h)
132163
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
164+
# Build includes (for generated version.h)
165+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
133166
$<INSTALL_INTERFACE:include>
134167
PRIVATE
135168
${ODBC_INCLUDE_DIRS}

Doxyfile renamed to Doxyfile.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Doxyfile for Databricks C++ SDK
2+
# This file is AUTO-GENERATED by CMake from Doxyfile.in
3+
# DO NOT EDIT MANUALLY - Changes will be overwritten!
4+
# To update version, modify CMakeLists.txt VERSION
25

36
# Project information
47
PROJECT_NAME = "Databricks C++ SDK"
5-
PROJECT_NUMBER = "0.2.3"
8+
PROJECT_NUMBER = "@PROJECT_VERSION@"
69
PROJECT_BRIEF = "Interact with Databricks via an SDK"
710
OUTPUT_DIRECTORY = docs
811

Makefile

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
# Databricks C++ SDK Makefile
2+
# This Makefile provides convenient wrappers around CMake commands
3+
#
4+
# VERSION MANAGEMENT:
5+
# - Version is defined in CMakeLists.txt (line 3)
6+
# - The following files are AUTO-GENERATED from .in templates:
7+
# * Doxyfile (from Doxyfile.in)
8+
# * vcpkg.json (from vcpkg.json.in)
9+
# * include/databricks/version.h (from version.h.in)
10+
# - To update version: ./scripts/update_version.sh <version>
11+
# or manually edit CMakeLists.txt and run 'make configure'
12+
13+
# Build configuration
14+
BUILD_DIR := build
15+
CMAKE := cmake
16+
CMAKE_FLAGS := -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
17+
18+
# Default target
19+
.PHONY: all
20+
all: build
21+
22+
# Configure the build
23+
.PHONY: configure
24+
configure:
25+
@mkdir -p $(BUILD_DIR)
26+
cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_FLAGS) ..
27+
28+
# Build the project
29+
.PHONY: build
30+
build: configure
31+
cd $(BUILD_DIR) && $(CMAKE) --build .
32+
33+
# Build with examples
34+
.PHONY: build-examples
35+
build-examples:
36+
@mkdir -p $(BUILD_DIR)
37+
cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_FLAGS) -DBUILD_EXAMPLES=ON ..
38+
cd $(BUILD_DIR) && $(CMAKE) --build .
39+
40+
# Build with tests
41+
.PHONY: build-tests
42+
build-tests:
43+
@mkdir -p $(BUILD_DIR)
44+
cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_FLAGS) -DBUILD_TESTS=ON ..
45+
cd $(BUILD_DIR) && $(CMAKE) --build .
46+
47+
# Build everything (examples + tests)
48+
.PHONY: build-all
49+
build-all:
50+
@mkdir -p $(BUILD_DIR)
51+
cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_FLAGS) -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON ..
52+
cd $(BUILD_DIR) && $(CMAKE) --build .
53+
54+
# Run tests
55+
.PHONY: test
56+
test: build-tests
57+
cd $(BUILD_DIR) && ctest --output-on-failure
58+
59+
# Clean build artifacts
60+
.PHONY: clean
61+
clean:
62+
rm -rf $(BUILD_DIR)
63+
@echo "Note: Regenerating version-dependent files (Doxyfile, vcpkg.json, version.h)..."
64+
@echo "Run 'make configure' or 'make build' to regenerate them."
65+
66+
# Install the library
67+
.PHONY: install
68+
install: build
69+
cd $(BUILD_DIR) && $(CMAKE) --install .
70+
71+
# Uninstall (if supported)
72+
.PHONY: uninstall
73+
uninstall:
74+
cd $(BUILD_DIR) && $(CMAKE) --build . --target uninstall 2>/dev/null || \
75+
echo "Uninstall target not available"
76+
77+
# Build in release mode
78+
.PHONY: release
79+
release:
80+
@mkdir -p $(BUILD_DIR)
81+
cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_FLAGS) -DCMAKE_BUILD_TYPE=Release ..
82+
cd $(BUILD_DIR) && $(CMAKE) --build .
83+
84+
# Build in debug mode
85+
.PHONY: debug
86+
debug:
87+
@mkdir -p $(BUILD_DIR)
88+
cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_FLAGS) -DCMAKE_BUILD_TYPE=Debug ..
89+
cd $(BUILD_DIR) && $(CMAKE) --build .
90+
91+
# Rebuild from scratch
92+
.PHONY: rebuild
93+
rebuild: clean build
94+
95+
# Format code (if clang-format is available)
96+
.PHONY: format
97+
format:
98+
@if command -v clang-format >/dev/null 2>&1; then \
99+
find src include examples tests -type f \( -name "*.cpp" -o -name "*.h" \) \
100+
-exec clang-format -i {} +; \
101+
echo "Code formatted successfully"; \
102+
else \
103+
echo "clang-format not found. Please install it to use this target."; \
104+
fi
105+
106+
# Generate documentation with Doxygen
107+
.PHONY: docs
108+
docs:
109+
@if command -v doxygen >/dev/null 2>&1; then \
110+
if [ ! -f Doxyfile ]; then \
111+
echo "Doxyfile not found. Generating from template..."; \
112+
$(MAKE) configure; \
113+
fi; \
114+
doxygen Doxyfile; \
115+
echo "Documentation generated in docs/html/index.html"; \
116+
echo "Run 'make docs-open' to view in browser"; \
117+
else \
118+
echo "Doxygen not found. Install with: brew install doxygen"; \
119+
fi
120+
121+
# Open documentation in browser
122+
.PHONY: docs-open
123+
docs-open:
124+
@if [ -f docs/html/index.html ]; then \
125+
open docs/html/index.html; \
126+
else \
127+
echo "Documentation not found. Run 'make docs' first."; \
128+
fi
129+
130+
# Clean documentation
131+
.PHONY: clean-docs
132+
clean-docs:
133+
rm -rf docs/html docs/latex
134+
135+
# Update version (interactive)
136+
.PHONY: update-version
137+
update-version:
138+
@if [ -z "$(VERSION)" ]; then \
139+
echo "Usage: make update-version VERSION=x.y.z"; \
140+
echo "Example: make update-version VERSION=0.3.0"; \
141+
echo ""; \
142+
echo "Or use the interactive script:"; \
143+
echo " ./scripts/update_version.sh <version>"; \
144+
else \
145+
./scripts/update_version.sh $(VERSION); \
146+
fi
147+
148+
# Run pooling benchmark
149+
.PHONY: benchmark
150+
benchmark: build-examples
151+
@echo "Running connection pooling benchmark..."
152+
@cd $(BUILD_DIR) && ./examples/benchmark 10
153+
154+
# Help target
155+
.PHONY: help
156+
help:
157+
@echo "Databricks C++ SDK - Available targets:"
158+
@echo ""
159+
@echo "Building:"
160+
@echo " make - Build the project (default)"
161+
@echo " make build - Build the project"
162+
@echo " make configure - Run CMake configuration"
163+
@echo " make build-examples - Build with examples"
164+
@echo " make build-tests - Build with tests"
165+
@echo " make build-all - Build with examples and tests"
166+
@echo " make clean - Remove build artifacts"
167+
@echo ""
168+
@echo "Testing:"
169+
@echo " make test - Run tests"
170+
@echo " make benchmark - Run connection pooling benchmark"
171+
@echo ""
172+
@echo "Documentation:"
173+
@echo " make docs - Generate API documentation"
174+
@echo " make docs-open - Open documentation in browser"
175+
@echo " make clean-docs - Remove generated documentation"
176+
@echo ""
177+
@echo "Installation:"
178+
@echo " make install - Install the library"
179+
@echo " make uninstall - Uninstall the library"
180+
@echo ""
181+
@echo "Development:"
182+
@echo " make release - Build in release mode"
183+
@echo " make debug - Build in debug mode"
184+
@echo " make rebuild - Clean and rebuild"
185+
@echo " make format - Format code with clang-format"
186+
@echo ""
187+
@echo "Version Management:"
188+
@echo " make update-version VERSION=x.y.z - Update SDK version"
189+
@echo " ./scripts/update_version.sh <ver> - Interactive version update"
190+
@echo ""
191+
@echo "Other:"
192+
@echo " make help - Show this help message"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
A C++ SDK for Databricks, providing an interface for interacting with Databricks services.
88

9-
**Latest Release**: [v0.2.3](https://github.com/calvinjmin/databricks-sdk-cpp/releases/tag/v0.2.3)
9+
**Latest Release**: [v0.2.4](https://github.com/calvinjmin/databricks-sdk-cpp/releases/tag/v0.2.4)
1010

1111
**Author**: Calvin Min ([email protected])
1212

include/databricks/version.h

Lines changed: 0 additions & 19 deletions
This file was deleted.

include/databricks/version.h.in

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#pragma once
2+
3+
/**
4+
* @file version.h
5+
* @brief Version information for Databricks C++ SDK
6+
*
7+
* This file is AUTO-GENERATED by CMake from version.h.in
8+
* DO NOT EDIT MANUALLY - Changes will be overwritten!
9+
*
10+
* To update the version, modify the VERSION in CMakeLists.txt:
11+
* project(databricks_sdk VERSION x.y.z ...)
12+
*/
13+
14+
namespace databricks
15+
{
16+
17+
/**
18+
* @brief SDK version information
19+
*
20+
* Version is automatically synchronized with CMakeLists.txt project() VERSION
21+
*/
22+
constexpr const char *VERSION = "@PROJECT_VERSION@";
23+
constexpr int VERSION_MAJOR = @PROJECT_VERSION_MAJOR@;
24+
constexpr int VERSION_MINOR = @PROJECT_VERSION_MINOR@;
25+
constexpr int VERSION_PATCH = @PROJECT_VERSION_PATCH@;
26+
27+
/**
28+
* @brief Full version string with all components
29+
*/
30+
constexpr const char *VERSION_FULL = "@PROJECT_VERSION@";
31+
32+
/**
33+
* @brief Get a human-readable version string
34+
* @return Version string in format "Databricks C++ SDK v0.2.4"
35+
*/
36+
inline const char* get_version_string() {
37+
return "Databricks C++ SDK v" VERSION;
38+
}
39+
40+
} // namespace databricks

0 commit comments

Comments
 (0)