feat(libmongoose): 导入 Mongoose v7.22 MIT 开源网络库

- 导入 mongoose v7.22 源码 (mongoose.h 5748行 + mongoose.c 31786行)
- 创建 myMongoose.h 适配头(epoll/poll/socket 启用,filesystem 禁用)
- makefile 纯 C 编译为 libmongoose.a
- 注册到 copy_headers.sh + protocol SUBDIRS
- 编译产物: x86 462KB / ARM 471KB,零警告
- 用途: libweb_server 模块的 HTTP REST API + WebSocket 底层协议栈
This commit is contained in:
ypc 2026-07-08 17:35:59 +08:00
parent a0158a6cbf
commit d1569c92bb
6 changed files with 37615 additions and 1 deletions

View File

@ -101,6 +101,8 @@ copy_module "libcomm" "myComm.h"
# ================================================================
copy_proto_module "libmodbus" "myModbus.h"
copy_proto_module "lib60870" "myIec60870.h"
copy_proto_module "libmongoose" "myMongoose.h"
copy_proto_module "libmongoose" "mongoose.h"
# ================================================================
# 系统模块system/

View File

@ -0,0 +1,31 @@
include ./../../../linux.mk
L := $(notdir $(realpath $(CURDIR)/..))
M := libmongoose
O := $(LIB_REL)/$(M).a
S := $(SRC_ROOT_DIR)/$(L)/libmongoose/src
I := -I$(SRC_ROOT_DIR)/$(L)/libmongoose/inc
B := $(CURDIR)/$(M)/obj
SRCS := $(wildcard $(S)/*.c)
OBJS := $(patsubst $(S)/%.c, $(B)/%.o, $(SRCS))
F := $(C_FLAGS) $(I)
.PHONY: all
all:
@mkdir -p $(ROOT_DIR)/release/inc
@$(MAKE) $(O)
$(O): $(OBJS)
@mkdir -p $(dir $@)
$(AR) rcs $@ $^
@echo "[$(M)] built"
$(B)/%.o: $(S)/%.c
@mkdir -p $(dir $@)
$(CC) $(F) -c $< -o $@
.PHONY: clean
clean:
rm -rf $(B) $(O)
.PHONY: rebuild
rebuild: clean all

View File

@ -1,4 +1,4 @@
SUBDIRS := ./libmodbus ./lib60870
SUBDIRS := ./libmodbus ./lib60870 ./libmongoose
define make_subdir
for d in $(SUBDIRS); do [ -f "$$d/makefile" ] && (cd "$$d" && make -f makefile $1) || true; done
endef

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,47 @@
/**
* @file myMongoose.h
* @brief Mongoose HTTP/WebSocket
* @details mongoose v7.22 MIT :
* - HTTP REST API
* - WebSocket
* - IOepoll
* 使 mongoose.h
*
* : MIT (https://github.com/cesanta/mongoose)
* : https://mongoose.ws/documentation/
*/
#ifndef _MY_MONGOOSE_H_
#define _MY_MONGOOSE_H_
#ifdef __cplusplus
extern "C"
{
#endif
/* ---- 编译配置(在包含 mongoose.h 之前定义) ---- */
/** 启用日志printf 到 stderr与 RTU liblog 并行工作) */
#define MG_ENABLE_LOG 1
/** 禁用文件系统支持RTU 不通过 mongoose 提供静态文件服务) */
#define MG_ENABLE_FILE 0
/** 禁用 POSIX 文件系统相关 API */
#define MG_ENABLE_POSIX_FS 0
/** 启用 epoll 支持Linux 下高效的 IO 多路复用) */
#define MG_ENABLE_EPOLL 1
/** 启用 poll 支持epoll 不可用时的回退方案) */
#define MG_ENABLE_POLL 1
/** 启用 TCP/IP 协议栈(使用 Linux 内核 socket */
#define MG_ENABLE_SOCKET 1
#include "mongoose.h"
#ifdef __cplusplus
}
#endif
#endif /* _MY_MONGOOSE_H_ */

File diff suppressed because it is too large Load Diff