From d6cbf5a3e34b54e38b3bfa4a7d8964f475f35a1e Mon Sep 17 00:00:00 2001 From: xfy911 Date: Wed, 3 Jun 2026 17:44:52 +0800 Subject: [PATCH] deps: add xfy911/coco as git submodule (fork with fixes) --- .gitmodules | 2 +- Makefile | 21 +++++++++++++++++---- coco | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.gitmodules b/.gitmodules index aee224b..417097d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "coco"] path = coco - url = https://github.com/DefectingCat/coco.git + url = https://github.com/xfy911/coco.git diff --git a/Makefile b/Makefile index df3c9ae..2aeb017 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,9 @@ # Cocoon - 基于 coco 协程库的静态资源 Web 服务器 -# coco 库路径(可覆盖) -COCO_INCLUDE ?= ../coco/include -COCO_LIB ?= ../coco/build +# 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) @@ -30,6 +31,18 @@ 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) + # 编译规则 %.o: %.c $(CC) $(CFLAGS) -c $< -o $@ @@ -50,4 +63,4 @@ clean: # 重新构建 rebuild: clean all -.PHONY: all clean install uninstall rebuild +.PHONY: all clean install uninstall rebuild deps build-all diff --git a/coco b/coco index 8c16830..7d6e23e 160000 --- a/coco +++ b/coco @@ -1 +1 @@ -Subproject commit 8c16830f9be849f579fc12719ed108739faf563d +Subproject commit 7d6e23ef4b2a52f83a670a04280839a645384161