Compare commits
No commits in common. "bc9a783b7a391fe5b0ebf3b6f8838d1821db0028" and "ed88102d19150baad4fb6a7b1349e1a7656e7605" have entirely different histories.
bc9a783b7a
...
ed88102d19
137
.clang-format
137
.clang-format
|
@ -1,137 +0,0 @@
|
||||||
---
|
|
||||||
Language: Cpp
|
|
||||||
# BasedOnStyle: LLVM
|
|
||||||
AccessModifierOffset: -4
|
|
||||||
AlignAfterOpenBracket: Align
|
|
||||||
AlignConsecutiveMacros: false
|
|
||||||
AlignConsecutiveAssignments: false
|
|
||||||
AlignConsecutiveDeclarations: false
|
|
||||||
AlignEscapedNewlines: Right
|
|
||||||
AlignOperands: true
|
|
||||||
AlignTrailingComments: true
|
|
||||||
AllowAllArgumentsOnNextLine: true
|
|
||||||
AllowAllConstructorInitializersOnNextLine: true
|
|
||||||
AllowAllParametersOfDeclarationOnNextLine: true
|
|
||||||
AllowShortBlocksOnASingleLine: Never
|
|
||||||
AllowShortCaseLabelsOnASingleLine: false
|
|
||||||
AllowShortFunctionsOnASingleLine: false
|
|
||||||
AllowShortLambdasOnASingleLine: false
|
|
||||||
AllowShortIfStatementsOnASingleLine: Never
|
|
||||||
AllowShortLoopsOnASingleLine: false
|
|
||||||
AlwaysBreakAfterDefinitionReturnType: None
|
|
||||||
AlwaysBreakAfterReturnType: None
|
|
||||||
AlwaysBreakBeforeMultilineStrings: false
|
|
||||||
AlwaysBreakTemplateDeclarations: true
|
|
||||||
BinPackArguments: false
|
|
||||||
BinPackParameters: true
|
|
||||||
BraceWrapping:
|
|
||||||
AfterCaseLabel: false
|
|
||||||
AfterClass: true
|
|
||||||
AfterControlStatement: false
|
|
||||||
AfterEnum: true
|
|
||||||
AfterFunction: true
|
|
||||||
AfterNamespace: true
|
|
||||||
AfterObjCDeclaration: true
|
|
||||||
AfterStruct: true
|
|
||||||
AfterUnion: false
|
|
||||||
AfterExternBlock: false
|
|
||||||
BeforeCatch: false
|
|
||||||
BeforeElse: true
|
|
||||||
IndentBraces: false
|
|
||||||
SplitEmptyFunction: true
|
|
||||||
SplitEmptyRecord: true
|
|
||||||
SplitEmptyNamespace: true
|
|
||||||
BreakBeforeBinaryOperators: None
|
|
||||||
BreakBeforeBraces: Custom
|
|
||||||
BreakBeforeInheritanceComma: false
|
|
||||||
BreakInheritanceList: BeforeColon
|
|
||||||
BreakBeforeTernaryOperators: true
|
|
||||||
BreakConstructorInitializersBeforeComma: false
|
|
||||||
BreakConstructorInitializers: BeforeColon
|
|
||||||
BreakAfterJavaFieldAnnotations: false
|
|
||||||
BreakStringLiterals: true
|
|
||||||
ColumnLimit: 120
|
|
||||||
CommentPragmas: '^ IWYU pragma:'
|
|
||||||
CompactNamespaces: false
|
|
||||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
|
||||||
ConstructorInitializerIndentWidth: 4
|
|
||||||
ContinuationIndentWidth: 4
|
|
||||||
Cpp11BracedListStyle: true
|
|
||||||
DeriveLineEnding: true
|
|
||||||
DerivePointerAlignment: false
|
|
||||||
DisableFormat: false
|
|
||||||
ExperimentalAutoDetectBinPacking: false
|
|
||||||
FixNamespaceComments: true
|
|
||||||
ForEachMacros:
|
|
||||||
- foreach
|
|
||||||
- Q_FOREACH
|
|
||||||
- BOOST_FOREACH
|
|
||||||
IncludeBlocks: Preserve
|
|
||||||
IncludeCategories:
|
|
||||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
|
||||||
Priority: 2
|
|
||||||
SortPriority: 0
|
|
||||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
|
||||||
Priority: 3
|
|
||||||
SortPriority: 0
|
|
||||||
- Regex: '.*'
|
|
||||||
Priority: 1
|
|
||||||
SortPriority: 0
|
|
||||||
IncludeIsMainRegex: '(Test)?$'
|
|
||||||
IncludeIsMainSourceRegex: ''
|
|
||||||
IndentCaseLabels: false
|
|
||||||
IndentGotoLabels: true
|
|
||||||
IndentPPDirectives: BeforeHash
|
|
||||||
IndentWidth: 4
|
|
||||||
IndentWrappedFunctionNames: false
|
|
||||||
JavaScriptQuotes: Leave
|
|
||||||
JavaScriptWrapImports: true
|
|
||||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
|
||||||
MacroBlockBegin: ''
|
|
||||||
MacroBlockEnd: ''
|
|
||||||
MaxEmptyLinesToKeep: 1
|
|
||||||
NamespaceIndentation: None
|
|
||||||
ObjCBinPackProtocolList: Auto
|
|
||||||
ObjCBlockIndentWidth: 2
|
|
||||||
ObjCSpaceAfterProperty: false
|
|
||||||
ObjCSpaceBeforeProtocolList: true
|
|
||||||
PenaltyBreakAssignment: 2
|
|
||||||
PenaltyBreakBeforeFirstCallParameter: 19
|
|
||||||
PenaltyBreakComment: 300
|
|
||||||
PenaltyBreakFirstLessLess: 120
|
|
||||||
PenaltyBreakString: 1000
|
|
||||||
PenaltyBreakTemplateDeclaration: 10
|
|
||||||
PenaltyExcessCharacter: 1000000
|
|
||||||
PenaltyReturnTypeOnItsOwnLine: 60
|
|
||||||
PointerAlignment: Right
|
|
||||||
ReflowComments: true
|
|
||||||
SortIncludes: true
|
|
||||||
SortUsingDeclarations: true
|
|
||||||
SpaceAfterCStyleCast: false
|
|
||||||
SpaceAfterLogicalNot: false
|
|
||||||
SpaceAfterTemplateKeyword: true
|
|
||||||
SpaceBeforeAssignmentOperators: true
|
|
||||||
SpaceBeforeCpp11BracedList: false
|
|
||||||
SpaceBeforeCtorInitializerColon: true
|
|
||||||
SpaceBeforeInheritanceColon: true
|
|
||||||
SpaceBeforeParens: ControlStatements
|
|
||||||
SpaceBeforeRangeBasedForLoopColon: true
|
|
||||||
SpaceInEmptyBlock: false
|
|
||||||
SpaceInEmptyParentheses: false
|
|
||||||
SpacesBeforeTrailingComments: 1
|
|
||||||
SpacesInAngles: false
|
|
||||||
SpacesInConditionalStatement: false
|
|
||||||
SpacesInContainerLiterals: true
|
|
||||||
SpacesInCStyleCastParentheses: false
|
|
||||||
SpacesInParentheses: false
|
|
||||||
SpacesInSquareBrackets: false
|
|
||||||
SpaceBeforeSquareBrackets: false
|
|
||||||
Standard: Latest
|
|
||||||
StatementMacros:
|
|
||||||
- Q_UNUSED
|
|
||||||
- QT_REQUIRE_VERSION
|
|
||||||
TabWidth: 8
|
|
||||||
UseCRLF: false
|
|
||||||
UseTab: Never
|
|
||||||
...
|
|
||||||
|
|
16
.gitignore
vendored
16
.gitignore
vendored
|
@ -1,16 +0,0 @@
|
||||||
.vscode
|
|
||||||
Doxygen
|
|
||||||
cmake-shell/
|
|
||||||
external/gtest/googletest-release-1.11.0/
|
|
||||||
external/libconfig/libconfig-1.7.3/
|
|
||||||
output_files/bin/
|
|
||||||
output_files/libs/*a*
|
|
||||||
output_files/libs/*so*
|
|
||||||
output_files/libs/external
|
|
||||||
output_files/test/
|
|
||||||
# !output_files/libs/test_tools/
|
|
||||||
# !output_files/libs/test_tools/*
|
|
||||||
external/openssl/openssl-1.1.1s/
|
|
||||||
external/openssl/openssl-3.1.0/
|
|
||||||
external/openssl/build/
|
|
||||||
external/curl/curl-8.1.2/
|
|
209
CMakeLists.txt
209
CMakeLists.txt
|
@ -1,209 +0,0 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
|
||||||
|
|
||||||
unset(CLANG_TIDY_EXE CACHE)
|
|
||||||
set(CMAKE_SOURCE_DIR_IPCSDK "${CMAKE_CURRENT_SOURCE_DIR}" CACHE STRING INTERNAL)
|
|
||||||
include(build/global_config.cmake)
|
|
||||||
|
|
||||||
project(fancycode)
|
|
||||||
|
|
||||||
# set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
||||||
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
|
|
||||||
|
|
||||||
message("platform = ${TARGET_PLATFORM}")
|
|
||||||
message("platform PATH = ${PLATFORM_PATH}")
|
|
||||||
|
|
||||||
add_custom_target(
|
|
||||||
sdk_clean
|
|
||||||
COMMAND echo "sdk clean finished."
|
|
||||||
WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
|
|
||||||
)
|
|
||||||
|
|
||||||
# Gdb debug
|
|
||||||
include(build/sdk_config.cmake)
|
|
||||||
|
|
||||||
# 查看是工具链支持情况
|
|
||||||
include(CheckCXXCompilerFlag)
|
|
||||||
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
|
||||||
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
|
||||||
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
|
|
||||||
|
|
||||||
# 获取所有修改过的文件
|
|
||||||
execute_process(
|
|
||||||
COMMAND git diff --name-only --diff-filter=ACMRT
|
|
||||||
OUTPUT_VARIABLE MODIFIED_FILES
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
|
||||||
)
|
|
||||||
set(ALL_MODEFIED_FILES "")
|
|
||||||
string(LENGTH "${MODIFIED_FILES}" GIT_RESULT_STRING_LENGTH)
|
|
||||||
if(GIT_RESULT_STRING_LENGTH EQUAL 0)
|
|
||||||
message("Nothing changed.")
|
|
||||||
else()
|
|
||||||
string(REPLACE "\n" ";" MODIFIED_FILES_LIST ${MODIFIED_FILES})
|
|
||||||
endif()
|
|
||||||
# 遍历每个文件
|
|
||||||
foreach(FILE ${MODIFIED_FILES_LIST})
|
|
||||||
# 检查文件扩展名,只格式化.cpp和.h文件
|
|
||||||
get_filename_component(FILE_EXT ${FILE} EXT)
|
|
||||||
if(FILE_EXT MATCHES "\\.(c|cpp|h)$")
|
|
||||||
set(ALL_MODEFIED_FILES "${ALL_MODEFIED_FILES};${FILE}")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
# 获取未跟踪的文件
|
|
||||||
execute_process(
|
|
||||||
COMMAND git ls-files --others --exclude-standard
|
|
||||||
OUTPUT_VARIABLE UNTRACKED_FILES
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
|
||||||
)
|
|
||||||
string(LENGTH "${UNTRACKED_FILES}" GIT_RESULT_STRING_LENGTH)
|
|
||||||
if(GIT_RESULT_STRING_LENGTH EQUAL 0)
|
|
||||||
else()
|
|
||||||
string(REPLACE "\n" ";" UNTRACKED_FILES_LIST ${UNTRACKED_FILES})
|
|
||||||
endif()
|
|
||||||
# 遍历每个文件
|
|
||||||
foreach(FILE ${UNTRACKED_FILES_LIST})
|
|
||||||
# 检查文件扩展名,只格式化.cpp和.h文件
|
|
||||||
get_filename_component(FILE_EXT ${FILE} EXT)
|
|
||||||
if(FILE_EXT MATCHES "\\.(c|cpp|h)$")
|
|
||||||
set(ALL_MODEFIED_FILES "${ALL_MODEFIED_FILES};${FILE}")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
string(LENGTH "${ALL_MODEFIED_FILES}" MODIFIED_STRING_LENGTH)
|
|
||||||
# find the clang-tidy tools
|
|
||||||
unset(CLANG_TIDY_EXE CACHE)
|
|
||||||
unset(CLANG_TIDY_FIND CACHE)
|
|
||||||
if ("${CLANG_TIDY_SUPPORT}" MATCHES "true")
|
|
||||||
find_program(CLANG_TIDY_FIND NAMES clang-tidy PATHS ${LLVM_PATH}/build/bin)
|
|
||||||
if(CLANG_TIDY_FIND)
|
|
||||||
message(STATUS "clang-tidy found: ${CLANG_TIDY_FIND}")
|
|
||||||
# set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}" "-header-filter=no.h -system-headers=no.h -checks=modernize-use-override")
|
|
||||||
set(CLANG_TIDY_EXE ${CLANG_TIDY_FIND} CACHE STRING INTERNAL)
|
|
||||||
message("CLANG_TIDY_EXE = ${CLANG_TIDY_EXE}")
|
|
||||||
|
|
||||||
if(MODIFIED_STRING_LENGTH GREATER 0)
|
|
||||||
add_custom_target(
|
|
||||||
check_modified_code
|
|
||||||
COMMAND ${CLANG_TIDY_EXE}
|
|
||||||
-checks='${CLANG_TIDY_CHECKS}'
|
|
||||||
--header-filter=.*
|
|
||||||
--system-headers=false
|
|
||||||
${ALL_MODEFIED_FILES}
|
|
||||||
${CLANG_TIDY_CONFIG}
|
|
||||||
--line-filter='[{\"name\":\"${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include/getest/*.h\"}]'
|
|
||||||
-p ${PLATFORM_PATH}/cmake-shell
|
|
||||||
WORKING_DIRECTORY ${PLATFORM_PATH}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
else()
|
|
||||||
# message(FATAL_ERROR "See ${CMAKE_SOURCE_DIR_IPCSDK}/doc.")
|
|
||||||
message(FATAL_ERROR "You set support clang-tidy, but clang-tidy not found.
|
|
||||||
Check path ${LLVM_PATH}/build/bin, weather clang-tidy exist.
|
|
||||||
How to install tools?
|
|
||||||
See ${IPC_SDK_PATH}/doc/clang-tidy_user_guide.md
|
|
||||||
How to disable clang-tidy tool?
|
|
||||||
Modify: set(CLANG_TIDY_SUPPORT \"false\")
|
|
||||||
See:${IPC_SDK_PATH}/builde/global_config.cmake")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
# find the clang-format tools
|
|
||||||
unset(CLANG_FORMAT_EXE CACHE)
|
|
||||||
unset(CLANG_FORMAT_FIND CACHE)
|
|
||||||
if ("${CLANG_FORMAT_SUPPORT}" MATCHES "true")
|
|
||||||
find_program(CLANG_FORMAT_FIND NAMES clang-format PATHS ${LLVM_PATH}/build/bin)
|
|
||||||
if(CLANG_FORMAT_FIND)
|
|
||||||
message(STATUS "clang-format found: ${CLANG_FORMAT_FIND}")
|
|
||||||
set(CLANG_FORMAT_EXE ${CLANG_FORMAT_FIND} CACHE STRING INTERNAL)
|
|
||||||
message("CLANG_FORMAT_EXE = ${CLANG_FORMAT_EXE}")
|
|
||||||
|
|
||||||
if(MODIFIED_STRING_LENGTH GREATER 0)
|
|
||||||
add_custom_target(
|
|
||||||
format_modified_code
|
|
||||||
COMMAND ${CLANG_FORMAT_EXE}
|
|
||||||
-style=file
|
|
||||||
-i ${ALL_MODEFIED_FILES}
|
|
||||||
WORKING_DIRECTORY ${PLATFORM_PATH}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "You set support clang-format, but clang-format not found.
|
|
||||||
Check path ${LLVM_PATH}/build/bin, weather clang-format exist.
|
|
||||||
How to install tools?
|
|
||||||
See ${IPC_SDK_PATH}/doc/clang-tidy_user_guide.md
|
|
||||||
How to disable clang-format tool?
|
|
||||||
Modify: set(CLANG_FORMAT_SUPPORT \"false\")
|
|
||||||
See:${IPC_SDK_PATH}/builde/global_config.cmake")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(MODIFIED_STRING_LENGTH GREATER 0)
|
|
||||||
if ("${CLANG_TIDY_SUPPORT}" MATCHES "true" AND "${CLANG_FORMAT_SUPPORT}" MATCHES "true")
|
|
||||||
add_custom_target(
|
|
||||||
improve_modified_code
|
|
||||||
DEPENDS format_modified_code check_modified_code
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(${TARGET_PLATFORM} MATCHES ${DEFINE_LINUX})
|
|
||||||
# execute_process(COMMAND sh build_lvgl_for_cmakelist.sh ${TARGET_PLATFORM} ${CMAKE_SOURCE_DIR_IPCSDK} WORKING_DIRECTORY ${EXTERNAL_SOURCE_PATH}/lvglLinux-x86/)
|
|
||||||
# add_subdirectory(external/lvglLinux-x86)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#Add macro definition
|
|
||||||
# add_definitions(-DCONFIG_FILE_PATH=\"${CONFIG_FILE_PATH}\")
|
|
||||||
|
|
||||||
# Config message of main thread
|
|
||||||
unset(MAIN_INCLUDE_PATH CACHE)
|
|
||||||
set(MAIN_INCLUDE_PATH "" CACHE STRING INTERNAL)
|
|
||||||
unset(MAIN_SRC_FILE CACHE)
|
|
||||||
set(MAIN_SRC_FILE "" CACHE STRING INTERNAL)
|
|
||||||
unset(MAIN_LINK_LIB CACHE)
|
|
||||||
set(MAIN_LINK_LIB "" CACHE STRING INTERNAL)
|
|
||||||
|
|
||||||
# Config message for test code.
|
|
||||||
unset(TEST_LINK_LIB CACHE)
|
|
||||||
set(TEST_LINK_LIB "" CACHE STRING INTERNAL)
|
|
||||||
unset(TEST_LINUX_MOCK CACHE)
|
|
||||||
set(TEST_LINUX_MOCK "" CACHE STRING INTERNAL)
|
|
||||||
# if(${TARGET_PLATFORM} MATCHES ${DEFINE_LINUX})
|
|
||||||
set(TEST_LINK_LIB "testUtils" CACHE STRING INTERNAL FORCE)
|
|
||||||
# endif()
|
|
||||||
|
|
||||||
# 添加编译目录
|
|
||||||
add_subdirectory(external)
|
|
||||||
# 检查子目录 application 是否存在,存在再添加
|
|
||||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
|
||||||
message(STATUS "application exists, add application to project.")
|
|
||||||
add_subdirectory(application)
|
|
||||||
else()
|
|
||||||
message(STATUS "application not exists.")
|
|
||||||
endif()
|
|
||||||
add_subdirectory(middleware)
|
|
||||||
add_subdirectory(utils)
|
|
||||||
add_subdirectory(hal)
|
|
||||||
# add_subdirectory(customization)
|
|
||||||
|
|
||||||
string(COMPARE EQUAL "${PLATFORM_PATH}" "" value)
|
|
||||||
message("The platform path is \"${PLATFORM_PATH}\".")
|
|
||||||
if (value EQUAL 0) #变量被设置了
|
|
||||||
message("build chip board code.")
|
|
||||||
# add_subdirectory(${PLATFORM_PATH})
|
|
||||||
# aux_source_directory(${PLATFORM_PATH})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
message("MAIN_INCLUDE_PATH = ${MAIN_INCLUDE_PATH}")
|
|
||||||
message("MAIN_SRC_FILE = ${MAIN_SRC_FILE}")
|
|
||||||
message("MAIN_LINK_LIB = ${MAIN_LINK_LIB}")
|
|
||||||
# 检查子目录 test 是否存在,存在再添加
|
|
||||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
|
||||||
message(STATUS "test exists, add test to project.")
|
|
||||||
add_subdirectory(test)
|
|
||||||
else()
|
|
||||||
message(STATUS "test not exists.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# include(build/global_config.cmake)
|
|
39
Makefile
39
Makefile
|
@ -1,39 +0,0 @@
|
||||||
gmock:
|
|
||||||
$(MAKE) -C external/gtest all
|
|
||||||
|
|
||||||
gmock_clean:
|
|
||||||
$(MAKE) -C external/gtest clean
|
|
||||||
|
|
||||||
cmake:
|
|
||||||
$(MAKE) -C build/cmake all
|
|
||||||
|
|
||||||
cmake_clean:
|
|
||||||
$(MAKE) -C build/cmake clean
|
|
||||||
|
|
||||||
clean_code:
|
|
||||||
@rm -rf !(Makefile)
|
|
||||||
|
|
||||||
install_cmake:
|
|
||||||
$(MAKE) -C tools/cmake all
|
|
||||||
|
|
||||||
compile_llvm:
|
|
||||||
$(MAKE) -C tools/clang-tidy all
|
|
||||||
|
|
||||||
all:cmake
|
|
||||||
$(MAKE) -C cmake-shell all
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@if [ -d "cmake-shell" ]; then \
|
|
||||||
echo "cmake-shell exist"; \
|
|
||||||
make -C cmake-shell clean; \
|
|
||||||
fi
|
|
||||||
@echo "IPC clean."
|
|
||||||
@rm -rf external/gtest/googletest-release-1.11.0 \
|
|
||||||
external/lvglLinux-x86/lv_sim_vscode_sdl \
|
|
||||||
external/openssl/openssl-1.1.1s \
|
|
||||||
external/openssl/build \
|
|
||||||
external/curl/curl-8.1.2 \
|
|
||||||
external/libconfig/libconfig-1.7.3 \
|
|
||||||
external/goahead-5.2.0/GoAhead \
|
|
||||||
output_files \
|
|
||||||
cmake-shell
|
|
57
README.md
57
README.md
|
@ -1,57 +0,0 @@
|
||||||
# 1. README
|
|
||||||
|
|
||||||
## 1.1. 概述
|
|
||||||
|
|
||||||
  基于IPC领域产品的SDK工程。
|
|
||||||
|
|
||||||
阅读小技巧:
|
|
||||||
|
|
||||||
* SDK工程所有开发文档均使用markdown语法编写,需要使用markdown语法解析器进行解析,方便阅读,如:Typora;开发工程师建议使用vscode安装markdownlint插件进行阅读;
|
|
||||||
* SDK工程所有文档描述路径时,"//"双斜杠表示工程根目录;
|
|
||||||
|
|
||||||
## 1.2. 编译
|
|
||||||
|
|
||||||
  架构设计上支持去平台编译和运行,本仓库源码可仿真运行在ubuntu系统。
|
|
||||||
|
|
||||||
### 1.2.1. Ubuntu系统
|
|
||||||
|
|
||||||
在项目根目录下执行命令:
|
|
||||||
|
|
||||||
```code
|
|
||||||
make clean // 如果之前有跨平台编译过,需要先make clean
|
|
||||||
make cmake // 构建源码,生成Makefile文件
|
|
||||||
cd cmake-shell/ // 在中间文件目录进行编译,把所有中间文件创建在此目录
|
|
||||||
make // 编译全部输出构建文件
|
|
||||||
```
|
|
||||||
|
|
||||||
### 1.2.2. 交叉编译
|
|
||||||
|
|
||||||
参考:
|
|
||||||
|
|
||||||
```code
|
|
||||||
//build/cmake/toolchain/linux.toolchain.cmake
|
|
||||||
//Makefile
|
|
||||||
```
|
|
||||||
|
|
||||||
  参考上述文件新建一份配置文件,建议不要修改原文档,新建一个交叉编译工程,把IPC SDK工程作为子仓库进行git管理,维护SDK的绝对跨平台属性。
|
|
||||||
|
|
||||||
  交叉编译请参考基于IPC SDK作为子仓库的工程配置,此处忽略。
|
|
||||||
|
|
||||||
### 1.2.3. 小技巧
|
|
||||||
|
|
||||||
#### 1.2.3.1. 代码阅读辅助工具(基于vscode)
|
|
||||||
|
|
||||||
  为了方便代码跳转阅读,除了安装基本的c++插件外,结合cmake构建工具生成的compile_commands.json文件可实现代码之间的精准跳转。
|
|
||||||
|
|
||||||
**compile_commands.json文件生成路径:**
|
|
||||||
|
|
||||||
```code
|
|
||||||
//cmake-shell/compile_commands.json
|
|
||||||
```
|
|
||||||
|
|
||||||
**compile_commands.json文件配置方法:**
|
|
||||||
|
|
||||||
```code
|
|
||||||
在//.vscode/settings.json配置文件中添加:
|
|
||||||
"C_Cpp.default.compileCommands": "/home/xiaojiazhu/project/ipc-sdk/ipc/cmake-shell/compile_commands.json",
|
|
||||||
```
|
|
|
@ -1,66 +0,0 @@
|
||||||
# 1. 客制化目录
|
|
||||||
|
|
||||||
## 1.1. 概述
|
|
||||||
   客制化目录,依赖整个项目源码(含各层目录),继承并重载接口实现客制化功能,用于管理定制化版本 / Debug版本 / 生产版本等,使特殊功能代码与公版代码解耦合,保持公版版本功能稳定性和一致性。
|
|
||||||
|
|
||||||
## 1.2. Debug版本
|
|
||||||
|
|
||||||
### 1.2.1. Debug版本概述
|
|
||||||
   Debug版本用于满足测试需求,例如:开启log / 特殊的功能。
|
|
||||||
|
|
||||||
### 1.2.2. 生产测试版本
|
|
||||||
   生产时使用的验证产品功能的版本。
|
|
||||||
|
|
||||||
### 1.2.3. 其它定制版本
|
|
||||||
|
|
||||||
   基于公版,继承派生出来的特殊功能的商业化版本。
|
|
||||||
|
|
||||||
```
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
int is_mounted(const char *dirpath) {
|
|
||||||
FILE *fp;
|
|
||||||
char line[1024];
|
|
||||||
char mount_point[1024];
|
|
||||||
|
|
||||||
// 尝试打开 /proc/mounts 文件
|
|
||||||
fp = fopen("/proc/mounts", "r");
|
|
||||||
if (fp == NULL) {
|
|
||||||
perror("Error opening /proc/mounts");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 逐行读取并查找挂载点
|
|
||||||
while (fgets(line, sizeof(line), fp) != NULL) {
|
|
||||||
if (sscanf(line, "%*s %1023s %*s %*s %*d %*d\n", mount_point) == 1) {
|
|
||||||
// 检查当前行中的挂载点是否与所查找的目录匹配
|
|
||||||
if (strcmp(dirpath, mount_point) == 0) {
|
|
||||||
fclose(fp);
|
|
||||||
return 1; // 已挂载
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
return 0; // 未挂载
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
|
||||||
if (argc != 2) {
|
|
||||||
fprintf(stderr, "Usage: %s <directory>\n", argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *dirpath = argv[1];
|
|
||||||
|
|
||||||
if (is_mounted(dirpath)) {
|
|
||||||
printf("Directory '%s' is mounted.\n", dirpath);
|
|
||||||
} else {
|
|
||||||
printf("Directory '%s' is not mounted.\n", dirpath);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
```
|
|
Loading…
Reference in New Issue
Block a user