chore(M0): 建立 CLion/CMake 工程骨架与测试框架
- CMake 多目标工程:shs_core 静态库 + smart_home 可执行 + shs_tests 测试 - CMakePresets.json:debug/release/asan/coverage 四个预设(debug 告警即错误) - 自研零依赖测试框架 tests/framework/test_framework.h + 运行器(套件过滤、CTest 集成) - 工具:tools/header_check.sh 头文件独立编译检查(接口冻结门) - 已实现公共层:errors / string_utils / num_utils,main 启动自检 - 实测:debug 预设 0 告警、ctest 3/3 通过(45 项断言)
This commit is contained in:
commit
578a770737
36 files changed
+2914
No files matched your search
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @file app.h
|
||||
* @brief 应用入口层:CLI 交互、网页服务、脚本回放
|
||||
*
|
||||
* 教材对应:项目十「项目集成与部署」·项目一(程序结构)。
|
||||
*/
|
||||
#ifndef SHS_APP_H
|
||||
#define SHS_APP_H
|
||||
|
||||
#include "shs/common.h"
|
||||
#include "shs/errors.h"
|
||||
#include "shs/system.h"
|
||||
|
||||
/** 解析命令行参数(--cli / --web / --replay FILE / --port N / --data DIR) */
|
||||
typedef struct {
|
||||
shs_run_mode_t mode; /**< 运行模式 */
|
||||
uint16_t port; /**< 网页端口(0 表示用配置值) */
|
||||
const char *replay; /**< 回放脚本路径 */
|
||||
const char *data_dir; /**< 数据目录覆盖 */
|
||||
bool help; /**< 是否请求帮助 */
|
||||
} AppOptions;
|
||||
|
||||
/** 参数解析:成功返回 SHS_OK;非法参数返回负错误码 */
|
||||
shs_err_t app_parse_args(int argc, char **argv, AppOptions *opts);
|
||||
/** 打印使用说明 */
|
||||
void app_print_usage(const char *program);
|
||||
/** 运行 CLI 交互模式(菜单主循环) */
|
||||
shs_err_t app_run_cli(SmartHomeSystem *sys);
|
||||
/** 运行网页模式(启动 HTTP 服务并阻塞,直到 app_request_stop) */
|
||||
shs_err_t app_run_web(SmartHomeSystem *sys, uint16_t port);
|
||||
/** 脚本回放:从文件逐行读取命令并执行(无人值守演示) */
|
||||
shs_err_t app_replay_script(SmartHomeSystem *sys, const char *script_path);
|
||||
/** 执行一条文本命令(CLI 与回放共用),结果写入 out */
|
||||
shs_err_t app_execute_command(SmartHomeSystem *sys, const char *line, char *out, size_t out_size);
|
||||
/** 请求主循环退出(信号处理或测试调用) */
|
||||
void app_request_stop(void);
|
||||
bool app_stop_requested(void);
|
||||
|
||||
#endif /* SHS_APP_H */
|
||||
Reference in new issue
Block a user