1.Add clang-tidy in CMakeList.txt.
2.Add clang-tidy tools.
This commit is contained in:
parent
2d3074454f
commit
a80a8f7cee
|
@ -3,6 +3,9 @@ include(build/global_config.cmake)
|
||||||
|
|
||||||
project(app)
|
project(app)
|
||||||
|
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
|
||||||
|
|
||||||
message("platform = ${TARGET_PLATFORM}")
|
message("platform = ${TARGET_PLATFORM}")
|
||||||
message("platform PATH = ${PLATFORM_PATH}")
|
message("platform PATH = ${PLATFORM_PATH}")
|
||||||
|
|
||||||
|
|
|
@ -11,3 +11,33 @@ set(UTILS_SOURCE_PATH "${CMAKE_SOURCE_DIR_IPCSDK}/utils")
|
||||||
set(HAL_SOURCE_PATH "${CMAKE_SOURCE_DIR_IPCSDK}/hal")
|
set(HAL_SOURCE_PATH "${CMAKE_SOURCE_DIR_IPCSDK}/hal")
|
||||||
set(TEST_SOURCE_PATH "${CMAKE_SOURCE_DIR_IPCSDK}/test")
|
set(TEST_SOURCE_PATH "${CMAKE_SOURCE_DIR_IPCSDK}/test")
|
||||||
set(EXTERNAL_SOURCE_PATH "${CMAKE_SOURCE_DIR_IPCSDK}/external")
|
set(EXTERNAL_SOURCE_PATH "${CMAKE_SOURCE_DIR_IPCSDK}/external")
|
||||||
|
|
||||||
|
set(CLANG_TIDY_CHECKS "-*\
|
||||||
|
llvm-else-after-return,\
|
||||||
|
llvm-header-guard,\
|
||||||
|
llvm-include-order,\
|
||||||
|
llvm-namespace-comment,\
|
||||||
|
llvm-prefer-isa-or-dyn-cast-in-conditionals,\
|
||||||
|
llvm-prefer-register-over-unsigned,\
|
||||||
|
llvm-qualified-auto,\
|
||||||
|
llvm-twine-local,\
|
||||||
|
misc-confusable-identifiers,\
|
||||||
|
misc-definitions-in-headers,\
|
||||||
|
misc-header-include-cycle,\
|
||||||
|
misc-include-cleaner,\
|
||||||
|
misc-misleading-bidirectional,\
|
||||||
|
misc-misleading-identifier,\
|
||||||
|
misc-misplaced-const,\
|
||||||
|
misc-new-delete-overloads,\
|
||||||
|
misc-non-copyable-objects,\
|
||||||
|
misc-redundant-expression,\
|
||||||
|
misc-static-assert,\
|
||||||
|
misc-throw-by-value-catch-by-reference,\
|
||||||
|
misc-unconventional-assign-operator,\
|
||||||
|
misc-uniqueptr-reset-release,\
|
||||||
|
misc-unused-alias-decls,\
|
||||||
|
misc-unused-using-decls,\
|
||||||
|
readability-identifier-naming")
|
||||||
|
|
||||||
|
set(CLANG_TIDY_CONFIG "-header-filter=\'.*\'")
|
||||||
|
set(CLANG_TIDY_CONFIG "${CLANG_TIDY_CONFIG} -p ${CMAKE_SOURCE_DIR_IPCSDK}/cmake-shell-linux")
|
|
@ -121,13 +121,49 @@ sequenceDiagram
|
||||||
participant MCU
|
participant MCU
|
||||||
participant 小核
|
participant 小核
|
||||||
participant 大核
|
participant 大核
|
||||||
|
MCU ->> MCU:待机
|
||||||
|
MCU ->> MCU:检测到PIR信号
|
||||||
MCU ->> +小核:上电
|
MCU ->> +小核:上电
|
||||||
小核 ->> 小核:抓拍 / 录像
|
小核 ->> 小核:抓拍 / 录像
|
||||||
小核 ->> 小核:保存到sd卡
|
小核 ->> 小核:保存到sd卡
|
||||||
小核 -->> -MCU:关机
|
小核 -->> -MCU:关机
|
||||||
|
MCU ->> 小核:断电
|
||||||
```
|
```
|
||||||
|
|
||||||
##### 1.4.2.1.1. 定时触发启动
|
#### 1.4.2.2. 定时触发状态启动
|
||||||
|
|
||||||
|
#### 1.4.2.3. 设置状态启动
|
||||||
|
|
||||||
|
   特殊的启动状态,可以长时间通电完成其它功能,此时功耗较高。
|
||||||
|
|
||||||
|
1. 如果没有设置状态按键,在物理电源上电时,首先进入设置状态启动,5分钟后自动切换到工作状态。
|
||||||
|
|
||||||
|
**设置状态启动时序图**
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
sequenceDiagram
|
||||||
|
participant MCU
|
||||||
|
participant 小核
|
||||||
|
participant 大核
|
||||||
|
MCU ->> MCU:物理上电
|
||||||
|
MCU ->> 小核:上电
|
||||||
|
小核 ->> 小核:?
|
||||||
|
小核 ->> 大核:设置状态启动
|
||||||
|
大核 ->> 大核:设置状态任务
|
||||||
|
大核 ->> MCU:关机
|
||||||
|
MCU ->> 小核:断电
|
||||||
|
```
|
||||||
|
|
||||||
|
**大核设置状态启动时序图**
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
sequenceDiagram
|
||||||
|
participant 大核
|
||||||
|
participant app
|
||||||
|
大核 ->> 大核:物理上电
|
||||||
|
大核 ->> app:启动脚本启动app
|
||||||
|
大核 ->> 大核:断电
|
||||||
|
```
|
||||||
|
|
||||||
### 1.4.3. 根据软件模块作用域分层
|
### 1.4.3. 根据软件模块作用域分层
|
||||||
|
|
||||||
|
|
|
@ -26,4 +26,24 @@ set(IMPL_TARGET Hal)
|
||||||
add_library(${ABSTRACT_TARGET} STATIC ${ABSTRACT_SRC_FILES})
|
add_library(${ABSTRACT_TARGET} STATIC ${ABSTRACT_SRC_FILES})
|
||||||
target_link_libraries(${ABSTRACT_TARGET} StatusCode Log)
|
target_link_libraries(${ABSTRACT_TARGET} StatusCode Log)
|
||||||
add_library(${IMPL_TARGET} STATIC ${IMPL_SRC_FILES})
|
add_library(${IMPL_TARGET} STATIC ${IMPL_SRC_FILES})
|
||||||
target_link_libraries(${IMPL_TARGET} ${ABSTRACT_TARGET} Log)
|
target_link_libraries(${IMPL_TARGET} ${ABSTRACT_TARGET} Log)
|
||||||
|
|
||||||
|
add_custom_target(
|
||||||
|
hal_code_check
|
||||||
|
COMMAND ${CMAKE_SOURCE_DIR_IPCSDK}/tools/clang-tidy/clang-tidy
|
||||||
|
-checks='${CLANG_TIDY_CHECKS}'
|
||||||
|
-header-filter=.*
|
||||||
|
-system-headers
|
||||||
|
${ABSTRACT_SRC_FILES}
|
||||||
|
${CLANG_TIDY_CONFIG}
|
||||||
|
-p ${CMAKE_SOURCE_DIR_IPCSDK}/cmake-shell-linux
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR_IPCSDK}/hal
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
TARGET ${IMPL_TARGET}
|
||||||
|
TARGET ${ABSTRACT_TARGET}
|
||||||
|
PRE_BUILD
|
||||||
|
COMMAND make hal_code_check
|
||||||
|
WORKING_DIRECTORY ${PROJECT_ROOT_PATH}/cmake-shell-linux/
|
||||||
|
)
|
|
@ -1,6 +1,7 @@
|
||||||
#include "IHal.h"
|
#include "IHal.h"
|
||||||
#include "IHalCpp.h"
|
#include "IHalCpp.h"
|
||||||
#include <stddef.h>
|
#include "StatusCode.h"
|
||||||
|
// #include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
static StatusCode IHalInit(IHal *object)
|
static StatusCode IHalInit(IHal *object)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "IHalCpp.h"
|
#include "IHalCpp.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include <thread>
|
// #include <thread>
|
||||||
|
#include <memory>
|
||||||
std::shared_ptr<IHalCpp> &IHalCpp::GetInstance(std::shared_ptr<IHalCpp> *impl)
|
std::shared_ptr<IHalCpp> &IHalCpp::GetInstance(std::shared_ptr<IHalCpp> *impl)
|
||||||
{
|
{
|
||||||
static std::shared_ptr<IHalCpp> instance = std::make_shared<IHalCpp>();
|
static std::shared_ptr<IHalCpp> instance = std::make_shared<IHalCpp>();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef I_HAL_H
|
#ifndef IHAL_H
|
||||||
#define I_HAL_H
|
#define IHAL_H
|
||||||
#include "StatusCode.h"
|
#include "StatusCode.h"
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef IHAL_CPP_H
|
#ifndef IHALCPP_H
|
||||||
#define IHAL_CPP_H
|
#define IHALCPP_H
|
||||||
#include "StatusCode.h"
|
#include "StatusCode.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
class IHalCpp
|
class IHalCpp
|
||||||
|
|
6
hal/result.txt
Normal file
6
hal/result.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
/home/xiaojiazhu/project/ipc/hal/abstract/IHal.cpp:1:10: error: 'IHal.h' file not found [clang-diagnostic-error]
|
||||||
|
1 | #include "IHal.h"
|
||||||
|
| ^~~~~~~~
|
||||||
|
/home/xiaojiazhu/project/ipc/hal/abstract/IHalCpp.cpp:1:10: error: 'IHalCpp.h' file not found [clang-diagnostic-error]
|
||||||
|
1 | #include "IHalCpp.h"
|
||||||
|
| ^~~~~~~~~~~
|
BIN
tools/clang-tidy/clang-tidy
Executable file
BIN
tools/clang-tidy/clang-tidy
Executable file
Binary file not shown.
|
@ -1,5 +1,5 @@
|
||||||
#ifndef STATUS_CODE_H
|
#ifndef STATUSCODE_H
|
||||||
#define STATUS_CODE_H
|
#define STATUSCODE_H
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user