|
| 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" |
0 commit comments