-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
153 lines (131 loc) · 6.22 KB
/
Makefile
File metadata and controls
153 lines (131 loc) · 6.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# ==============================================================================
# Variables
# ==============================================================================
PROJ_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
EXT_NAME := infera
RUST_LIB := infera/target/release/$(EXT_NAME).a
DUCKDB_SRCDIR := ./external/duckdb/
EXT_CONFIG := ${PROJ_DIR}extension_config.cmake
EXAMPLES_DIR := docs/examples
SHELL := /bin/bash
PYTHON := python3
# ==============================================================================
# DuckDB Extension Build Configuration
# ==============================================================================
include external/extension-ci-tools/makefiles/duckdb_extension.Makefile
set_duckdb_version:
cd external/duckdb && git checkout $(DUCKDB_GIT_VERSION)
# ==============================================================================
# Help Target
# ==============================================================================
.DEFAULT_GOAL := help
.PHONY: help
help: ## Show the help messages for all targets
@echo "Usage: make <target>"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*## .*$$' Makefile | \
awk 'BEGIN {FS = ":.*## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
# ==============================================================================
# Rust Targets
# ==============================================================================
.PHONY: rust-build
rust-build: ## Build Infera in release mode
@echo "Building Infera in release mode..."
@cd infera && cargo build --release --features "duckdb_extension,tract"
.PHONY: rust-build-debug
rust-build-debug: ## Build Infera in debug mode
@echo "Building Infera in debug mode..."
@cd infera && cargo build --features "duckdb_extension,tract"
.PHONY: rust-format
rust-format: ## Format Rust files
@echo "Formatting Rust files..."
@cargo fmt --manifest-path infera/Cargo.toml
.PHONY: rust-test
rust-test: rust-format ## Run tests
@echo "Running the unit tests for Infera..."
@cargo test --manifest-path infera/Cargo.toml --features "tract" --all-targets -- --nocapture
.PHONY: rust-coverage
rust-coverage: ## Generate code coverage report for Infera crate
@echo "Generating coverage report..."
@cargo tarpaulin --manifest-path infera/Cargo.toml --features "tract" --all-targets --out Xml
.PHONY: rust-lint
rust-lint: rust-format ## Run linter checks on Rust files
@echo "Linting Rust files..."
@cargo clippy --manifest-path infera/Cargo.toml --features "tract" -- -D warnings -D clippy::unwrap_used -D clippy::expect_used
.PHONY: rust-fix-lint
rust-fix-lint: ## Fix Rust linter warnings
@echo "Fixing linter warnings..."
@cargo clippy --fix --allow-dirty --allow-staged --manifest-path infera/Cargo.toml --features "tract" -- -D warnings -D clippy::unwrap_used -D clippy::expect_used
.PHONY: rust-careful
careful: ## Run security checks on Rust code
@echo "Running security checks..."
@cargo careful
.PHONY: rust-clean
rust-clean: ## Clean Rust build artifacts
@echo "Cleaning Rust build artifacts..."
@cd infera && cargo clean
.PHONY: create-bindings
create-bindings: ## Generate C bindings from Rust code
@echo "Generating C bindings for Infera..."
@cd infera && cbindgen --config cbindgen.toml --crate infera --output bindings/include/rust.h
@echo "C bindings generated at infera/bindings/include/rust.h"
# ==============================================================================
# Targets for Building the Extension
# ==============================================================================
# We need to build the DuckDB first, so we can link against it
# when building the Infera as a DuckDB extension.
# We normally need to build the DuckDB once only.
# The `build/{release,debug}` directories will contain the DuckDB build that is staticly linked
# with the Infera extension. That is used for testing the extension.
.PHONY: release
release: rust-build ## Build the extension in release mode (DuckDB + extension)
@echo "Building the extension in release mode..."
@mkdir -p build/release
@cmake $(GENERATOR) $(BUILD_FLAGS) $(EXT_RELEASE_FLAGS) $(VCPKG_MANIFEST_FLAGS) -DBUILD_SHELL=TRUE -DBUILD_MAIN_DUCKDB_LIBRARY=TRUE -DCMAKE_BUILD_TYPE=Release -S $(DUCKDB_SRCDIR) -B build/release
@cmake --build build/release --config Release
.PHONY: debug
debug: rust-build-debug ## Build the extension in debug mode (DuckDB + extension)
@echo "Building the extension in debug mode..."
@mkdir -p build/debug
@cmake $(GENERATOR) $(BUILD_FLAGS) $(EXT_DEBUG_FLAGS) $(VCPKG_MANIFEST_FLAGS) -DBUILD_SHELL=TRUE -DBUILD_MAIN_DUCKDB_LIBRARY=TRUE -DCMAKE_BUILD_TYPE=Debug -S $(DUCKDB_SRCDIR) -B build/debug
@cmake --build build/debug --config Debug
# ==============================================================================
# Development Targets
# ==============================================================================
.PHONY: install-deps
install-deps: ## Set up development environment (for Debian-based systems)
@echo "Setting up development environment..."
@sudo apt-get install -y cmake clang-format snap python3-pip
@sudo snap install rustup --classic
@cargo install cargo-tarpaulin cbindgen cargo-edit cargo-audit cargo-outdated cargo-careful
@cd infera && cargo check --features "tract"
@git submodule update --init --recursive
@pip install --user --upgrade pip uv
@uv sync --extra dev
@pre-commit install-hooks
@echo "Development environment ready"
.PHONY: setup-hooks
setup-hooks: ## Install Git hooks (pre-commit and pre-push)
@echo "Installing Git hooks..."
@pre-commit install --hook-type pre-commit
@pre-commit install --hook-type pre-push
@pre-commit install-hooks
.PHONY: test-hooks
test-hooks: ## Run Git hooks on all files manually
@echo "Running Git hooks..."
@pre-commit run --all-files
.PHONY: clean-all
clean-all: clean rust-clean ## Clean everything
@echo "All clean!"
.PHONY: check
check: rust-lint rust-test ## Run all checks (linting and tests)
@echo "All checks passed!"
.PHONY: examples
examples: ## Run SQL examples for Infera extension
@echo "Running the examples in the ${EXAMPLES_DIR} directory..."
@for sql_file in $(EXAMPLES_DIR)/*.sql; do \
echo "Running example: $$sql_file"; \
./build/release/duckdb < $$sql_file; \
echo "============================================================================"; \
done