cocoon/Makefile
xfy911 b6beb8bb9c feat(tests): 添加集成测试套件 + 性能基准 + 更新文档
- 新增 tests/ 目录:
  - integration_test.sh: 27 项 curl/bash 集成测试(GET/HEAD/404/Range/304/gzip/MIME/目录浏览/路径防护)
  - benchmark.sh: wrk 压测脚本,支持单线程和多线程模式
  - fixtures/: 测试用静态资源(HTML/CSS/JS/JSON/PNG)
- Makefile 新增 test / bench 快捷目标
- README 全面更新:
  - 补充 Gzip/缓存/超时/日志等已实现特性
  - 更新命令行参数(-m/-o/-l/-v)
  - 添加性能基准表格(~16K RPS / ~60μs 延迟)
  - 路线图标记已完成项
- .cocoon-plan.md 更新 Phase 2 进度
2026-06-03 21:15:05 +08:00

77 lines
1.5 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Cocoon - 基于 coco 协程库的静态资源 Web 服务器
# coco 库路径(默认使用 submodule可覆盖
COCO_DIR ?= coco
COCO_INCLUDE ?= $(COCO_DIR)/include
COCO_LIB ?= $(COCO_DIR)/build
CC = gcc
CFLAGS = -Wall -Wextra -O2 -std=c11 -I$(COCO_INCLUDE)
LDFLAGS = -L$(COCO_LIB) -lcoco -lpthread -lm -luring -lz
# 调试模式
DEBUG ?= 0
ifeq ($(DEBUG),1)
CFLAGS += -g -O0 -DCOCOON_DEBUG
endif
# 安装路径
PREFIX ?= /usr/local
BINDIR = $(PREFIX)/bin
# 源文件
SRCS = main.c server.c http.c static.c log.c
OBJS = $(SRCS:.c=.o)
TARGET = cocoon
# 默认目标
all: $(TARGET)
# 链接
$(TARGET): $(OBJS)
$(CC) $(OBJS) -o $@ $(LDFLAGS)
# 构建 coco 依赖(如果 submodule 已初始化)
deps:
@if [ ! -d "$(COCO_DIR)/build" ]; then \
echo "[Cocoon] 构建 coco 依赖..."; \
cd $(COCO_DIR) && mkdir -p build && cd build && cmake .. && $(MAKE); \
else \
echo "[Cocoon] coco 已构建,跳过"; \
fi
# 完整构建(先构建依赖,再构建项目)
build-all: deps $(TARGET)
# 集成测试
test: $(TARGET)
@echo "[Cocoon] 运行集成测试..."
@./tests/integration_test.sh
# 性能基准
bench: $(TARGET)
@echo "[Cocoon] 运行性能基准..."
@./tests/benchmark.sh
# 编译规则
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
# 安装
install: $(TARGET)
install -d $(BINDIR)
install -m 755 $(TARGET) $(BINDIR)/
# 卸载
uninstall:
rm -f $(BINDIR)/$(TARGET)
# 清理
clean:
rm -f $(OBJS) $(TARGET)
# 重新构建
rebuild: clean all
.PHONY: all clean install uninstall rebuild deps build-all