-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
305 lines (258 loc) · 10.7 KB
/
Makefile
File metadata and controls
305 lines (258 loc) · 10.7 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# Makefile for CodeOSX
# A Claude CLI for Mac OS X 10.0+ (GNU C89 compatible)
# Note: Uses gnu89 instead of c89 for BearSSL's inline keyword support
CC = gcc
CFLAGS = -std=gnu89 -Wall -Wextra -pedantic -O2 -I./src -I./src/bearssl/inc
LDFLAGS = -L./build -lbearssl -lm
TARGET = codeosx
VERSION = 0.0.1
# Source files
SOURCES = src/main.c src/config.c src/util.c src/cJSON.c \
src/http.c src/tls.c src/certs.c src/http_client.c src/cli.c src/syntax.c \
src/agent.c src/terminal.c src/tool_approval.c src/tool_display.c \
src/tools/registry.c src/tools/filesystem.c src/tools/shell.c \
src/tools/search.c src/tools/todos.c src/tools/ask_user.c src/tools/ask_user_ui.c \
src/ui/ui_buffer.c src/ui/ui_style.c src/ui/ui_caps.c src/ui/ui_layout.c \
src/ui/ui_text.c src/ui/ui_terminal.c src/ui/ui_frame.c \
src/ui/widgets/ui_block.c src/ui/widgets/ui_list.c \
src/ui/widgets/ui_gauge.c src/ui/widgets/ui_spinner.c \
src/ui/widgets/ui_input.c src/ui/widgets/ui_confirm.c \
src/ui/widgets/ui_dropdown.c src/ui/widgets/ui_message.c \
src/ui/ui_viewport.c src/ui/ui_logo.c
OBJECTS = $(SOURCES:.c=.o)
# BearSSL configuration
BEARSSL_DIR = src/bearssl
BEARSSL_LIB = build/libbearssl.a
.PHONY: all bearssl clean distclean test version test-markdown test-unit test-memory \
visual-framework visual-tests test-visual test-visual-update-baselines ui-lib test-ui
all: version bearssl $(TARGET)
@echo ""
@echo "Build complete! Binary: build/$(TARGET)"
@echo "Version: $(VERSION)"
@echo ""
version:
@echo "Building CodeOSX $(VERSION)..."
bearssl: $(BEARSSL_LIB)
$(BEARSSL_LIB):
@echo "Building BearSSL..."
@if [ -d "$(BEARSSL_DIR)" ] && [ -f "$(BEARSSL_DIR)/Makefile" ]; then \
cd $(BEARSSL_DIR) && $(MAKE) clean && $(MAKE); \
if [ -f build/libbearssl.a ]; then \
cp build/libbearssl.a ../../build/; \
else \
echo "Error: BearSSL build failed"; \
exit 1; \
fi; \
else \
echo "BearSSL source not found in $(BEARSSL_DIR)"; \
echo "Please download BearSSL 0.6 from https://bearssl.org/"; \
exit 1; \
fi
$(TARGET): $(OBJECTS) $(BEARSSL_LIB)
@echo "Linking $(TARGET)..."
@$(CC) $(OBJECTS) $(LDFLAGS) -o build/$(TARGET)
@echo "Linked: build/$(TARGET)"
%.o: %.c
@echo "Compiling $<..."
@$(CC) $(CFLAGS) -c $< -o $@
clean:
@echo "Cleaning build artifacts..."
@rm -f build/*.o build/*.a build/$(TARGET) $(OBJECTS)
@if [ -d "$(BEARSSL_DIR)" ]; then \
cd $(BEARSSL_DIR) && $(MAKE) clean 2>/dev/null || true; \
fi
@echo "Clean complete"
distclean: clean
@echo "Removing all generated files..."
@rm -rf build/*
@if [ -d "$(BEARSSL_DIR)" ]; then \
cd $(BEARSSL_DIR) && $(MAKE) distclean 2>/dev/null || true; \
fi
@echo "Distclean complete"
test: $(TARGET)
@echo "Running basic tests..."
@./build/$(TARGET) --version
@echo "Basic tests complete"
test-markdown: src/cli.o src/syntax.o
@echo "Building markdown test..."
@$(CC) $(CFLAGS) tests/test_markdown_simple.c src/cli.o src/syntax.o -o build/test_markdown
@echo "Running markdown test..."
@./build/test_markdown tests/markdown_test.md
@echo "Markdown test complete"
# Unit test targets
TEST_OBJECTS = src/config.o src/util.o src/cJSON.o src/http.o src/tls.o \
src/certs.o src/http_client.o src/cli.o src/syntax.o src/agent.o \
src/terminal.o src/tool_approval.o src/tool_display.o \
src/tools/registry.o src/tools/filesystem.o \
src/tools/shell.o src/tools/search.o src/tools/todos.o src/tools/ask_user.o \
src/tools/ask_user_ui.o $(UI_OBJECTS)
build/test_agent_lifecycle: tests/test_agent_lifecycle.c $(TEST_OBJECTS) $(BEARSSL_LIB)
@echo "Building test_agent_lifecycle..."
@$(CC) $(CFLAGS) -o $@ $< $(TEST_OBJECTS) $(LDFLAGS)
build/test_cli_context: tests/test_cli_context.c $(TEST_OBJECTS) $(BEARSSL_LIB)
@echo "Building test_cli_context..."
@$(CC) $(CFLAGS) -o $@ $< $(TEST_OBJECTS) $(LDFLAGS)
build/test_session_boundaries: tests/test_session_boundaries.c $(TEST_OBJECTS) $(BEARSSL_LIB)
@echo "Building test_session_boundaries..."
@$(CC) $(CFLAGS) -o $@ $< $(TEST_OBJECTS) $(LDFLAGS)
# Build all unit tests
test-build: build/test_agent_lifecycle build/test_cli_context build/test_session_boundaries
@echo "All unit tests built"
# Run unit tests
test-unit: test-build
@echo ""
@echo "========================================="
@echo "Running Unit Tests"
@echo "========================================="
@echo ""
@./build/test_agent_lifecycle
@./build/test_cli_context
@./build/test_session_boundaries
@echo "========================================="
@echo "All unit tests passed!"
@echo "========================================="
@echo ""
# Run memory leak tests with valgrind (if available)
test-memory: test-build
@echo ""
@echo "========================================="
@echo "Running Memory Leak Tests"
@echo "========================================="
@echo ""
@if command -v valgrind >/dev/null 2>&1; then \
echo "Running test_agent_lifecycle with valgrind..."; \
valgrind --leak-check=full --error-exitcode=1 --show-leak-kinds=all \
./build/test_agent_lifecycle 2>&1 | grep -E "(ERROR SUMMARY|definitely lost|indirectly lost|possibly lost)" || true; \
echo ""; \
echo "Running test_cli_context with valgrind..."; \
valgrind --leak-check=full --error-exitcode=1 --show-leak-kinds=all \
./build/test_cli_context 2>&1 | grep -E "(ERROR SUMMARY|definitely lost|indirectly lost|possibly lost)" || true; \
echo ""; \
echo "Running test_session_boundaries with valgrind..."; \
valgrind --leak-check=full --error-exitcode=1 --show-leak-kinds=all \
./build/test_session_boundaries 2>&1 | grep -E "(ERROR SUMMARY|definitely lost|indirectly lost|possibly lost)" || true; \
echo ""; \
echo "========================================"; \
echo "Memory leak tests complete"; \
echo "========================================"; \
else \
echo "valgrind not found - skipping memory tests"; \
echo "Install valgrind to run memory leak detection"; \
fi
@echo ""
# ============================================================================
# Visual Testing Framework
# ============================================================================
# Visual testing framework sources
VT_FRAMEWORK_DIR = tests/visual/framework
VT_FRAMEWORK_SOURCES = $(VT_FRAMEWORK_DIR)/vt_ansi_parser.c \
$(VT_FRAMEWORK_DIR)/vt_capture.c \
$(VT_FRAMEWORK_DIR)/vt_diff.c \
$(VT_FRAMEWORK_DIR)/vt_report.c
VT_FRAMEWORK_OBJECTS = $(VT_FRAMEWORK_SOURCES:.c=.o)
# Visual testing tools
VT_TOOLS = build/vt_parse build/vt_compare build/vt_report
VT_TESTS = build/test_vt_simple
# Compile visual framework objects
$(VT_FRAMEWORK_DIR)/%.o: $(VT_FRAMEWORK_DIR)/%.c
@echo "Compiling $<..."
@$(CC) $(CFLAGS) -I$(VT_FRAMEWORK_DIR) -c $< -o $@
# Build visual testing tools
build/vt_parse: tests/visual/vt_parse_tool.c $(VT_FRAMEWORK_OBJECTS)
@echo "Building vt_parse tool..."
@$(CC) $(CFLAGS) -I$(VT_FRAMEWORK_DIR) -o $@ $^
build/vt_compare: tests/visual/vt_compare_tool.c $(VT_FRAMEWORK_OBJECTS)
@echo "Building vt_compare tool..."
@$(CC) $(CFLAGS) -I$(VT_FRAMEWORK_DIR) -o $@ $^
build/vt_report: tests/visual/vt_report_tool.c $(VT_FRAMEWORK_OBJECTS)
@echo "Building vt_report tool..."
@$(CC) $(CFLAGS) -I$(VT_FRAMEWORK_DIR) -o $@ $^
# Build visual test programs
build/test_vt_simple: tests/visual/tests/vt_simple.c
@echo "Building visual test: vt_simple..."
@$(CC) $(CFLAGS) -o $@ $<
# Build all visual testing infrastructure
visual-framework: $(VT_TOOLS)
@echo "Visual testing framework built"
# Build all visual test programs
visual-tests: $(VT_TESTS)
@echo "Visual test programs built"
# Run all visual tests
test-visual: visual-framework visual-tests
@echo ""
@echo "========================================="
@echo "Running Visual Tests"
@echo "========================================="
@./tests/visual/scripts/run_all_visual_tests.sh
@echo ""
# Update visual test baselines
test-visual-update-baselines: visual-framework visual-tests
@echo "Updating visual test baselines..."
@./tests/visual/scripts/capture_baseline.sh --all
@echo "Baselines updated"
# ============================================================================
# UI Component Library
# ============================================================================
# UI library sources
UI_DIR = src/ui
UI_SOURCES = $(UI_DIR)/ui_buffer.c $(UI_DIR)/ui_style.c $(UI_DIR)/ui_caps.c \
$(UI_DIR)/ui_layout.c $(UI_DIR)/ui_text.c \
$(UI_DIR)/ui_terminal.c $(UI_DIR)/ui_frame.c \
$(UI_DIR)/widgets/ui_block.c $(UI_DIR)/widgets/ui_list.c \
$(UI_DIR)/widgets/ui_gauge.c $(UI_DIR)/widgets/ui_spinner.c \
$(UI_DIR)/widgets/ui_input.c $(UI_DIR)/widgets/ui_confirm.c \
$(UI_DIR)/widgets/ui_dropdown.c $(UI_DIR)/widgets/ui_message.c \
$(UI_DIR)/ui_viewport.c $(UI_DIR)/ui_logo.c
UI_OBJECTS = $(UI_SOURCES:.c=.o)
# Compile UI library objects
$(UI_DIR)/%.o: $(UI_DIR)/%.c
@echo "Compiling $<..."
@$(CC) $(CFLAGS) -c $< -o $@
$(UI_DIR)/widgets/%.o: $(UI_DIR)/widgets/%.c
@echo "Compiling $<..."
@$(CC) $(CFLAGS) -c $< -o $@
# Build UI library objects
ui-lib: $(UI_OBJECTS)
@echo "UI library objects built"
# UI library tests
build/test_ui_buffer: tests/ui/test_ui_buffer.c $(UI_OBJECTS)
@echo "Building test_ui_buffer..."
@$(CC) $(CFLAGS) -o $@ $^
build/test_ui_layout: tests/ui/test_ui_layout.c $(UI_OBJECTS)
@echo "Building test_ui_layout..."
@$(CC) $(CFLAGS) -o $@ $^
build/test_ui_widgets: tests/ui/test_ui_widgets.c $(UI_OBJECTS)
@echo "Building test_ui_widgets..."
@$(CC) $(CFLAGS) -o $@ $^
build/test_ui_interactive: tests/ui/test_ui_interactive.c $(UI_OBJECTS)
@echo "Building test_ui_interactive..."
@$(CC) $(CFLAGS) -o $@ $^
# Run UI library tests
test-ui: build/test_ui_buffer build/test_ui_layout build/test_ui_widgets build/test_ui_interactive
@echo ""
@echo "========================================="
@echo "Running UI Library Tests"
@echo "========================================="
@echo ""
@./build/test_ui_buffer
@echo ""
@./build/test_ui_layout
@echo ""
@./build/test_ui_widgets
@echo ""
@./build/test_ui_interactive
@echo ""
# UI Terminal test (interactive resize testing)
build/test_ui_terminal: tests/test_ui_terminal.c $(UI_OBJECTS) src/terminal.o
@echo "Building test_ui_terminal..."
@$(CC) $(CFLAGS) -o $@ $^
test-terminal: build/test_ui_terminal
@echo "Running terminal resize test (press 'q' to quit)..."
@./build/test_ui_terminal
# CLI render test (logo preservation investigation)
build/test_cli_render: tests/test_cli_render.c $(UI_OBJECTS) src/terminal.o
@echo "Building test_cli_render..."
@$(CC) $(CFLAGS) -o $@ $^
test-cli-render: build/test_cli_render
@echo "Running CLI render test..."
@./build/test_cli_render