-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
158 lines (125 loc) · 4.13 KB
/
Makefile
File metadata and controls
158 lines (125 loc) · 4.13 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
# SseNimHttpClient Makefile
# Pure Nim SSE HTTP client — built from scratch over TCP + TLS
# Compiler settings
NIM = nim
NIMC = $(NIM) c
SSL_FLAG = -d:ssl
RELEASE = -d:release
DEBUG =
# Directories
SRC_DIR = src
TEST_DIR = tests
EX_DIR = examples
# Source files
MAIN_SRC = $(SRC_DIR)/sse_nim_http_client.nim
TEST_SRCS = $(wildcard $(TEST_DIR)/test_*.nim)
EX_SRCS = $(wildcard $(EX_DIR)/*.nim)
# Test binaries (strip .nim extension)
TEST_BINS = $(TEST_SRCS:.nim=)
EX_BINS = $(EX_SRCS:.nim=)
# Default target
.PHONY: all build test examples clean install publish help
## Build the main library (verification compile)
build:
$(NIMC) $(SSL_FLAG) $(MAIN_SRC)
## Build with release optimizations
release:
$(NIMC) $(SSL_FLAG) $(RELEASE) $(MAIN_SRC)
## Run all tests
test: $(TEST_BINS)
@echo "========================================"
@echo " Running all tests..."
@echo "========================================"
@for bin in $(TEST_BINS); do \
echo ""; \
echo ">>> $$bin"; \
"$$bin" || exit 1; \
done
@echo ""
@echo "========================================"
@echo " All tests passed!"
@echo "========================================"
## Compile all test binaries
$(TEST_DIR)/test_%: $(TEST_DIR)/test_%.nim
$(NIMC) $(SSL_FLAG) $@
## Run a specific test (usage: make test-basic)
test-basic:
$(NIMC) -r $(SSL_FLAG) $(TEST_DIR)/test_basic.nim
test-url:
$(NIMC) -r $(SSL_FLAG) $(TEST_DIR)/test_url.nim
test-request:
$(NIMC) -r $(SSL_FLAG) $(TEST_DIR)/test_request.nim
test-http11:
$(NIMC) -r $(SSL_FLAG) $(TEST_DIR)/test_http11.nim
test-sse:
$(NIMC) -r $(SSL_FLAG) $(TEST_DIR)/test_sse.nim
test-sse-ext:
$(NIMC) -r $(SSL_FLAG) $(TEST_DIR)/test_sse_extended.nim
test-https:
$(NIMC) -r $(SSL_FLAG) $(TEST_DIR)/test_https.nim
test-errors:
$(NIMC) -r $(SSL_FLAG) $(TEST_DIR)/test_errors.nim
## Build all examples
examples: $(EX_BINS)
@echo "Examples built: $(EX_BINS)"
$(EX_DIR)/%: $(EX_DIR)/%.nim
$(NIMC) $(SSL_FLAG) $@
## Run individual examples
run-basic-get: $(EX_DIR)/basic_get
$(EX_DIR)/basic_get
run-post-json: $(EX_DIR)/post_json
$(EX_DIR)/post_json
run-sse: $(EX_DIR)/sse_listen
$(EX_DIR)/sse_listen
run-async-https: $(EX_DIR)/async_https
$(EX_DIR)/async_https
run-openai-sse: $(EX_DIR)/openai_sse
$(EX_DIR)/openai_sse
run-anthropic-sse: $(EX_DIR)/anthropic_sse
$(EX_DIR)/anthropic_sse
## Clean all build artifacts
clean:
@echo "Cleaning build artifacts..."
rm -f $(TEST_BINS) $(EX_BINS) $(SRC_DIR)/sse_nim_http_client
rm -rf nimcache/
## Deep clean (including nimble cache)
distclean: clean
rm -rf nimblecache/
## Install locally via nimble
install:
nimble install
## Publish to Nimble package registry
publish:
nimble publish
## Check code style / syntax (compile-only, no link)
check:
$(NIM) check $(MAIN_SRC)
## Format all Nim source files (requires nph or nimpretty)
format:
$(NIM) pretty $(SRC_DIR)/*.nim $(SRC_DIR)/**/*.nim
## Show project info
info:
@echo "Project: sse_nim_http_client"
@echo "Version: $$(grep 'version' sse_nim_http_client.nimble | cut -d= -f2 | xargs)"
@echo "License: MIT"
@echo "Author: zhenruyan <admin@pkold.com>"
@echo "Nim req: >= 2.0.0"
@echo "Tests: $(words $(TEST_SRCS)) files"
@echo "Examples: $(words $(EX_SRCS)) files"
## Show help
help:
@echo "SseNimHttpClient — Makefile targets"
@echo ""
@echo " make build — Compile main library (debug)"
@echo " make release — Compile with release optimizations"
@echo " make test — Run all tests"
@echo " make test-<name> — Run specific test (basic, url, request, http11, sse, sse-ext, https, errors)"
@echo " make examples — Build all examples"
@echo " make run-<example> — Build and run example (basic-get, post-json, sse, async-https, openai-sse, anthropic-sse)"
@echo " make clean — Remove build artifacts"
@echo " make distclean — Remove all caches"
@echo " make install — Install via nimble"
@echo " make publish — Publish to nimble registry"
@echo " make check — Syntax check main source"
@echo " make info — Show project info"
@echo " make help — Show this message"