Skip to content

Commit 350b782

Browse files
committed
Simplify the project
1 parent f4a59bf commit 350b782

42 files changed

Lines changed: 2578 additions & 1452 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/codecov.yml

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

.github/workflows/lints.yml

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,4 @@ poetry.lock
9595
# Additional files and directories to ignore (put below)
9696
docs/api/
9797
*_output.txt
98+
POST.md

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ would like to work on or if it has already been resolved.
2020

2121
### Submitting Pull Requests
2222

23-
- Ensure all tests pass before submitting a pull request.
23+
- Make sure all tests pass before submitting a pull request.
2424
- Write a clear description of the changes you made and the reasons behind them.
2525

2626
> [!IMPORTANT]

Makefile

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
1-
# Generic Makefile for Zig projects
2-
3-
# Load environment variables from .env file
4-
ifneq (,$(wildcard ./.env))
5-
include .env
6-
export $(shell sed 's/=.*//' .env)
7-
else
8-
$(warning `.env` file not found. Environment variables not loaded.)
9-
endif
10-
111
################################################################################
122
# Configuration and Variables
133
################################################################################
14-
ZIG ?= zig
4+
ZIG ?= $(shell which zig || echo ~/.local/share/zig/0.15.2/zig)
155
ZIG_VERSION := $(shell $(ZIG) version)
166
BUILD_TYPE ?= Debug
177
BUILD_OPTS = -Doptimize=$(BUILD_TYPE)
@@ -20,43 +10,55 @@ SRC_DIR := src
2010
TEST_DIR := tests
2111
BUILD_DIR := zig-out
2212
CACHE_DIR := .zig-cache
23-
DOC_SRC := src/root.zig
13+
DOC_SRC := src/lib.zig
2414
DOC_OUT := docs/api/
2515
COVERAGE_DIR := coverage
26-
BINARY_NAME := template-zig-project
16+
BINARY_NAME := zodd
2717
BINARY_PATH := $(BUILD_DIR)/bin/$(BINARY_NAME)
2818
TEST_EXECUTABLE := $(BUILD_DIR)/bin/test
2919
PREFIX ?= /usr/local
3020
RELEASE_MODE := ReleaseSmall
3121

22+
# Get all .zig files in the examples directory and extract their stem names
23+
EXAMPLES := $(patsubst %.zig,%,$(notdir $(wildcard examples/*.zig)))
24+
EXAMPLE ?= all
25+
3226
SHELL := /usr/bin/env bash
3327
.SHELLFLAGS := -eu -o pipefail -c
3428

3529
################################################################################
3630
# Targets
3731
################################################################################
3832

39-
.PHONY: all build rebuild run test cov lint format docs clean install-deps release help coverage setup-hooks test-hooks
33+
.PHONY: all build rebuild example test cov lint format docs docs-serve clean install-deps release help coverage \
34+
setup-hooks test-hooks
4035
.DEFAULT_GOAL := help
4136

4237
help: ## Show the help messages for all targets
4338
@grep -E '^[a-zA-Z0-9_-]+:.*?## ' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf " %-10s %s\n", $$1, $$2}'
4439

45-
all: build test lint docs ## build, test, lint, and doc
40+
all: build test lint docs ## build, test, lint, and docs
4641

4742
build: ## Build project (Mode=$(BUILD_TYPE))
4843
@echo "Building project in $(BUILD_TYPE) mode with $(JOBS) concurrent jobs..."
4944
$(ZIG) build $(BUILD_OPTS) -j$(JOBS)
5045

5146
rebuild: clean build ## clean and build
5247

53-
run: build ## Run the main application
54-
@echo "Running $(BINARY_NAME)..."
55-
$(ZIG) build run $(BUILD_OPTS) --
48+
example: ## Run examples (default: all tests, or 'make example EXAMPLE=e1_transitive_closure')
49+
ifeq ($(EXAMPLE),all)
50+
@for ex in $(EXAMPLES); do \
51+
echo "--> Running example: $$ex"; \
52+
$(ZIG) build run-$$ex $(BUILD_OPTS); \
53+
done
54+
else
55+
@echo "--> Running example: $(EXAMPLE)"
56+
$(ZIG) build run-$(EXAMPLE) $(BUILD_OPTS)
57+
endif
5658

57-
test: ## Run tests and generate coverage data
58-
@echo "Running tests with coverage enabled..."
59-
$(ZIG) build test $(BUILD_OPTS) -Denable-coverage=true -j$(JOBS)
59+
test: ## Run tests
60+
@echo "Running tests..."
61+
$(ZIG) build test $(BUILD_OPTS) -j$(JOBS) --summary all
6062

6163
release: ## Build in Release mode
6264
@echo "Building the project in Release mode..."
@@ -90,18 +92,16 @@ docs: ## Generate API documentation
9092
done; \
9193
fi
9294

95+
docs-serve: ## Serve API documentation locally
96+
@echo "Serving documentation at http://localhost:8000/..."
97+
cd $(DOC_OUT) && python3 -m http.server 8000
98+
9399
install-deps: ## Install system dependencies (for Debian-based systems)
94100
@echo "Installing system dependencies..."
95101
sudo apt-get update
96102
sudo apt-get install -y make llvm snapd
97103
sudo snap install zig --beta --classic # Use `--edge --classic` to install the latest version
98104

99-
coverage: ## Generate code coverage report
100-
@echo "Building tests with coverage instrumentation..."
101-
@zig build test -Denable-coverage=true
102-
@echo "Generating coverage report..."
103-
@kcov --include-pattern=src --verify coverage-out zig-out/bin/test-root
104-
105105
setup-hooks: ## Install Git hooks (pre-commit and pre-push)
106106
@echo "Installing Git hooks..."
107107
@pre-commit install --hook-type pre-commit

0 commit comments

Comments
 (0)