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:
parent
a0158a6cbf
commit
d1569c92bb
|
|
@ -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/)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
|
@ -0,0 +1,47 @@
|
|||
/**
|
||||
* @file myMongoose.h
|
||||
* @brief Mongoose 适配层 — 嵌入式 HTTP/WebSocket 网络库
|
||||
* @details 封装 mongoose v7.22 开源库(MIT 许可),提供:
|
||||
* - HTTP 服务器(REST API)
|
||||
* - WebSocket 双向通信
|
||||
* - 事件驱动异步 IO(epoll)
|
||||
* 本头文件是对外公开接口,模块内部直接使用 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
Loading…
Reference in New Issue