diff --git a/test/application/CMakeLists.txt b/test/application/CMakeLists.txt index 9a2fbdb..0127207 100644 --- a/test/application/CMakeLists.txt +++ b/test/application/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory(HuntingCamera) -add_subdirectory(MissionManager) \ No newline at end of file +add_subdirectory(MissionManager) +add_subdirectory(VersionReleaseTool) \ No newline at end of file diff --git a/test/application/HuntingCamera/CMakeLists.txt b/test/application/HuntingCamera/CMakeLists.txt index 07de680..fadba1b 100644 --- a/test/application/HuntingCamera/CMakeLists.txt +++ b/test/application/HuntingCamera/CMakeLists.txt @@ -45,7 +45,7 @@ endif() if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true") add_custom_target( - HunttingCameraTest_code_check + HuntingCameraTest_code_check COMMAND ${CLANG_TIDY_EXE} -checks='${CLANG_TIDY_CHECKS}' --header-filter=.* @@ -61,13 +61,13 @@ add_custom_target( add_custom_command( TARGET ${TARGET_NAME} PRE_BUILD - COMMAND make HunttingCameraTest_code_check + COMMAND make HuntingCameraTest_code_check WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ ) file(GLOB_RECURSE HEADER_FILES *.h) add_custom_target( - HunttingCameraTest_code_format + HuntingCameraTest_code_format COMMAND ${CLANG_FORMAT_EXE} -style=file -i ${SRC_FILES} ${SRC_FILES_MAIN} ${HEADER_FILES} @@ -76,8 +76,8 @@ add_custom_target( add_custom_command( TARGET ${TARGET_NAME} PRE_BUILD - COMMAND make HunttingCameraTest_code_check - COMMAND make HunttingCameraTest_code_format + COMMAND make HuntingCameraTest_code_check + COMMAND make HuntingCameraTest_code_format WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ ) endif() diff --git a/test/application/VersionReleaseTool/CMakeLists.txt b/test/application/VersionReleaseTool/CMakeLists.txt new file mode 100644 index 0000000..11dfe15 --- /dev/null +++ b/test/application/VersionReleaseTool/CMakeLists.txt @@ -0,0 +1,84 @@ +# include(${CMAKE_SOURCE_DIR}/build/independent_source.cmake) +include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake) +# include(${APPLICATION_SOURCE_PATH}/VersionRelease/build/hunting_camera.cmake) +set(EXECUTABLE_OUTPUT_PATH ${TEST_OUTPUT_PATH}/bin) + +include_directories( + ./src + # ${HUNTTING_MAIN_INCLUDE_PATH} + # ${MIDDLEWARE_SOURCE_PATH}/McuManager/include + # ${MIDDLEWARE_SOURCE_PATH}/McuManager/src + ${UTILS_SOURCE_PATH}/UpgradeTool/include + ${UTILS_SOURCE_PATH}/StatusCode/include + ${UTILS_SOURCE_PATH}/Log/include + ${TEST_SOURCE_PATH} + # ${TEST_SOURCE_PATH}/application/MissionManager/tool/include + # ${TEST_SOURCE_PATH}/middleware/McuManager/tool/include + # ${TEST_SOURCE_PATH}/middleware/AppManager/tool/include + # ${TEST_SOURCE_PATH}/utils/LinuxApiMock/include + # ${TEST_SOURCE_PATH}/utils/TestManager/include + # ${TEST_SOURCE_PATH}/utils/McuProtocol/tool/include + # ${TEST_SOURCE_PATH}/utils/UartDevice/tool/include + # ${TEST_SOURCE_PATH}/hal/tool/include + ${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include + ${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googlemock/include +) + +link_directories( + ${LIBS_OUTPUT_PATH} + ${EXTERNAL_LIBS_OUTPUT_PATH} +) + +aux_source_directory(. SRC_FILES_MAIN) +aux_source_directory(./src SRC_FILES) +if(${TARGET_PLATFORM} MATCHES ${DEFINE_LINUX}) + aux_source_directory(./src_mock SRC_FILES) +endif() + +set(TARGET_NAME VersionReleaseTool) +add_executable(${TARGET_NAME} ${SRC_FILES_MAIN} ${SRC_FILES}) +target_link_libraries(${TARGET_NAME} UpgradeTool StatusCode Log gtest gmock pthread) +if(${TEST_COVERAGE} MATCHES "true") + target_link_libraries(${TARGET_NAME} gcov) +endif() + +if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true") +add_custom_target( + VersionReleaseTool_code_check + COMMAND ${CLANG_TIDY_EXE} + -checks='${CLANG_TIDY_CHECKS}' + --header-filter=.* + --system-headers=false + ${SRC_FILES} + ${SRC_FILES_MAIN} + ${CLANG_TIDY_CONFIG} + # --line-filter='[{\"name\":\"${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include/getest/gtest.h\"}]' + --line-filter='[{\"name\":\"${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include/getest/*.h\"}]' + -p ${PLATFORM_PATH}/cmake-shell + WORKING_DIRECTORY ${TEST_SOURCE_PATH}/application/VersionRelease +) +add_custom_command( + TARGET ${TARGET_NAME} + PRE_BUILD + COMMAND make VersionReleaseTool_code_check + WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ +) + +file(GLOB_RECURSE HEADER_FILES *.h) +add_custom_target( + VersionReleaseTool_code_format + COMMAND ${CLANG_FORMAT_EXE} + -style=file + -i ${SRC_FILES} ${SRC_FILES_MAIN} ${HEADER_FILES} + WORKING_DIRECTORY ${TEST_SOURCE_PATH}/application/VersionRelease +) +add_custom_command( + TARGET ${TARGET_NAME} + PRE_BUILD + COMMAND make VersionReleaseTool_code_check + COMMAND make VersionReleaseTool_code_format + WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ +) +endif() + +define_file_name(${TARGET_NAME}) \ No newline at end of file diff --git a/test/application/VersionReleaseTool/mainTest.cpp b/test/application/VersionReleaseTool/mainTest.cpp new file mode 100644 index 0000000..71aa4a0 --- /dev/null +++ b/test/application/VersionReleaseTool/mainTest.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Fancy Code. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ArgvAnalysis.h" +#include "ILog.h" +#include +#include +#include +#include +int main(int argc, char *argv[]) +{ + CreateLogModule(); + ILogInit(LOG_INSTANCE_TYPE_END); + ArgvAnalysis::GetInstance()->Analyze(argc, argv); + testing::InitGoogleTest(&argc, argv); + RUN_ALL_TESTS(); + ILogUnInit(); + DestroyLogModule(); + return 0; +} \ No newline at end of file diff --git a/test/application/VersionReleaseTool/src/ArgvAnalysis.cpp b/test/application/VersionReleaseTool/src/ArgvAnalysis.cpp new file mode 100644 index 0000000..103f456 --- /dev/null +++ b/test/application/VersionReleaseTool/src/ArgvAnalysis.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Fancy Code. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "ArgvAnalysis.h" +#include "ILog.h" +std::shared_ptr &ArgvAnalysis::GetInstance(std::shared_ptr *impl) +{ + static auto instance = std::make_shared(); + if (impl) { + if (instance.use_count() == 1) { + LogInfo("Instance changed succeed.\n"); + instance = *impl; + } + else { + LogError("Can't changing the instance becase of using by some one.\n"); + } + } + return instance; +} +void ArgvAnalysis::Analyze(int argc, char *argv[]) +{ + LogInfo("argc: %d\n", argc); + for (int i = 1; i < argc; ++i) { + std::string arg = argv[i]; + size_t pos = arg.find('='); + + if (pos != std::string::npos) { + std::string key = arg.substr(0, pos); + std::string value = arg.substr(pos + 1); + + // remove'--' + if (key.substr(0, 2) == "--") { + key = key.substr(2); + } + + mOptions[key] = value; + } + else { + LogError("Invalid argument format: %s\n", arg.c_str()); + return; + } + } + + for (const auto &pair : mOptions) { + LogInfo("Key: %s, Value: %s\n", pair.first.c_str(), pair.second.c_str()); + } +} \ No newline at end of file diff --git a/test/application/VersionReleaseTool/src/ArgvAnalysis.h b/test/application/VersionReleaseTool/src/ArgvAnalysis.h new file mode 100644 index 0000000..82db6cc --- /dev/null +++ b/test/application/VersionReleaseTool/src/ArgvAnalysis.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 Fancy Code. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ARGV_ANALYSIS_H +#define ARGV_ANALYSIS_H +#include "StatusCode.h" +#include +#include +class ArgvAnalysis +{ +public: + ArgvAnalysis() = default; + virtual ~ArgvAnalysis() = default; + static std::shared_ptr &GetInstance(std::shared_ptr *impl = nullptr); + void Analyze(int argc, char *argv[]); + +private: + std::map mOptions; +}; +#endif \ No newline at end of file diff --git a/test/application/VersionReleaseTool/src/VersionReleaseTool.cpp b/test/application/VersionReleaseTool/src/VersionReleaseTool.cpp new file mode 100644 index 0000000..0539796 --- /dev/null +++ b/test/application/VersionReleaseTool/src/VersionReleaseTool.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023 Fancy Code. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "GtestUsing.h" +#include "ILog.h" +#include "UpgradeTool.h" +#include "VersionReleaseTool.h" +#include +namespace VersionReleaseTool +{ +TEST(VersionReleaseTool, Version) +{ + UpgradeTool::GetInstance()->PackFile("src", "output", "1.0.0", "product", "project", "upgradeType"); +} +} // namespace VersionReleaseTool \ No newline at end of file diff --git a/test/application/VersionReleaseTool/src/VersionReleaseTool.h b/test/application/VersionReleaseTool/src/VersionReleaseTool.h new file mode 100644 index 0000000..f1caf98 --- /dev/null +++ b/test/application/VersionReleaseTool/src/VersionReleaseTool.h @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2023 Fancy Code. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef VERSION_RELEASE_TOOL_H +#define VERSION_RELEASE_TOOL_H + +#endif \ No newline at end of file diff --git a/tools/README.md b/tools/README.md index f7be89b..550aa8c 100644 --- a/tools/README.md +++ b/tools/README.md @@ -9,5 +9,16 @@ 使用方法: ``` - ./delete_test_code.sh ../../test/ +$ cd //tools/shell +$ ./delete_test_code.sh ../../test/ +``` + +## 1.3. delete_sdk_code.sh + +  根据需要,删除SDK当中若干模块的src代码。 + +使用方法: +``` +$ cd //tools/shell +$ ./delete_sdk_code.sh ``` \ No newline at end of file diff --git a/tools/shell/delete_sdk_code.sh b/tools/shell/delete_sdk_code.sh new file mode 100755 index 0000000..93e2417 --- /dev/null +++ b/tools/shell/delete_sdk_code.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# 查找目录列表 +# search_dirs=("../../middleware" "../../application" "../../utils") +search_dirs=("../../test-utils") + +# 保留目录列表 +preserve_dirs=("../../test-utils/LinuxApi" "../../test-utils/ConfigBase") + +# 遍历查找目录 +for search_dir in "${search_dirs[@]}"; do + echo "正在处理目录: $search_dir" + + # 使用find命令遍历目录并删除文件 + find "$search_dir" -type d | while read -r dir; do + # 检查目录是否在保留列表中 + is_preserve=false + for preserve_dir in "${preserve_dirs[@]}"; do + if [[ "$dir" == *"$preserve_dir"* ]]; then + is_preserve=true + break + fi + done + + # 如果目录不在保留列表中,则删除src目录和CMakeLists.txt + if [[ $is_preserve == false ]]; then + src_dir="$dir/src" + cmake_file="$dir/CMakeLists.txt" + + # 如果src目录存在,则删除它 + if [[ -d "$src_dir" ]]; then + echo "删除目录: $src_dir" + rm -rf "$src_dir" + fi + + # 如果CMakeLists.txt文件存在,则删除它 + if [[ -f "$cmake_file" ]]; then + echo "删除文件: $cmake_file" + rm "$cmake_file" + fi + fi + done +done + +echo "处理完成" \ No newline at end of file