-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMakefile
More file actions
184 lines (155 loc) · 7.59 KB
/
Copy pathMakefile
File metadata and controls
184 lines (155 loc) · 7.59 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# ==============================================================================
# Variables
# ==============================================================================
PROJ_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
EXT_NAME := onager
RUST_LIB := onager/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
PY_DEP_MNGR := uv
# ==============================================================================
# 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 Onager in release mode
@echo "Building Onager in release mode..."
@cd onager && cargo build --release --features "duckdb_extension"
.PHONY: rust-build-debug
rust-build-debug: ## Build Onager in debug mode
@echo "Building Onager in debug mode..."
@cd onager && cargo build --features "duckdb_extension"
# The wasm extension is linked as an Emscripten side module, which requires
# position-independent code, so the Rust library is built with relocation-model=pic.
# Only the static library is built: the cdylib crate type does not link for
# wasm32-unknown-emscripten and is not needed there.
.PHONY: rust-build-wasm
rust-build-wasm: ## Build Onager for wasm32-unknown-emscripten in release mode
@echo "Building Onager for WASM in release mode..."
@cd onager && RUSTFLAGS="-C relocation-model=pic" cargo rustc --release --target wasm32-unknown-emscripten --features "duckdb_extension" --crate-type staticlib
# extension-ci-tools runs this hook before the wasm_mvp, wasm_eh, and wasm_threads builds.
wasm_pre_build_step: rust-build-wasm
.PHONY: rust-format
rust-format: ## Format Rust files
@echo "Formatting Rust files..."
@cargo fmt --manifest-path onager/Cargo.toml
.PHONY: rust-test
rust-test: rust-format ## Run tests
@echo "Running the unit tests for Onager..."
@cargo test --manifest-path onager/Cargo.toml --all-targets -- --nocapture
.PHONY: rust-coverage
rust-coverage: ## Generate code coverage report for Onager crate
@echo "Generating coverage report..."
@cargo tarpaulin --manifest-path onager/Cargo.toml --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 onager/Cargo.toml -- -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 onager/Cargo.toml -- -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 onager && cargo clean
.PHONY: create-bindings
create-bindings: ## Generate C bindings from Rust code
@echo "Generating C bindings for Onager..."
@cd onager && cbindgen --config cbindgen.toml --crate onager --output bindings/include/rust.h
@echo "C bindings generated at onager/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 Onager 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 Onager 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 liblzma-dev
@sudo snap install rustup --classic
@rustup toolchain install stable --profile minimal
@cargo +stable install cargo-tarpaulin cbindgen cargo-edit cargo-audit cargo-outdated cargo-careful
@cd onager && cargo check
@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: test-oracle
test-oracle: release ## Run Python-based differential tests with NetworkX
@echo "Running Python-based differential tests..."
@source .venv/bin/activate && pytest test/test_differential.py
.PHONY: bench-onager
bench-onager: release ## Run Python-based benchmark comparisons against NetworkX
@echo "Running benchmark comparisons..."
@$(PY_DEP_MNGR) run --with networkx python3 benchmarks/compare.py
.PHONY: check
check: rust-lint rust-test test-oracle ## Run all checks (linting, tests, and differential tests)
@echo "All checks passed!"
.PHONY: docs
docs: ## Generate Onager MkDocs documentation
@echo "Generating MkDocs documentation..."
@source .venv/bin/activate && $(PY_DEP_MNGR) run mkdocs build --config-file mkdocs.yml
.PHONY: docs-serve
docs-serve: ## Serve Onager MkDocs documentation locally
@echo "Serving MkDocs documentation locally..."
@source .venv/bin/activate && $(PY_DEP_MNGR) run mkdocs serve --config-file mkdocs.yml
.PHONY: playground-serve
playground-serve: ## Serve the playground app locally
@echo "Starting local server for Onager Playground..."
@python3 -m http.server --directory web 8000