From 86034c71e0ff181181986496a8688f65aa4c7748 Mon Sep 17 00:00:00 2001 From: taynpg Date: Mon, 30 Mar 2026 16:39:34 +0800 Subject: [PATCH] =?UTF-8?q?win=E6=89=93=E5=8C=85=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2022Build.bat | 83 ++++++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 11 +++++- README.md | 6 +--- fileUpdater/main.cpp | 7 ++-- 4 files changed, 98 insertions(+), 9 deletions(-) create mode 100644 2022Build.bat diff --git a/2022Build.bat b/2022Build.bat new file mode 100644 index 0000000..c04bbb9 --- /dev/null +++ b/2022Build.bat @@ -0,0 +1,83 @@ +@echo off +setlocal + +:: Configuration +set "CMAKE_ARGS=-DCMAKE_PREFIX_PATH=C:/local -G Ninja -DCMAKE_BUILD_TYPE=Release" +set "BUILD_DIR=build-release" +set "BUILD_CONFIG=Release" +set "ERROR_CODE=0" + +:: Clean up any existing build directory +if exist "%BUILD_DIR%" ( + echo Removing existing build directory: %BUILD_DIR% + rmdir /s /q "%BUILD_DIR%" + if errorlevel 1 ( + echo ERROR: Failed to remove build directory: %BUILD_DIR% + exit /b 1 + ) +) + +:: Create build directory +if not exist "%BUILD_DIR%" ( + echo Creating build directory: %BUILD_DIR% + mkdir "%BUILD_DIR%" + if errorlevel 1 ( + echo ERROR: Failed to create build directory: %BUILD_DIR% + exit /b 1 + ) +) + +call "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvars64.bat" + +:: Run CMake configuration +echo Running CMake configuration... +cmake -B"%BUILD_DIR%" %CMAKE_ARGS% +if errorlevel 1 ( + echo ERROR: CMake configuration failed + set "ERROR_CODE=1" + goto cleanup +) + +:: Build the project +echo Building project with configuration: %BUILD_CONFIG% +cmake --build "%BUILD_DIR%" --config %BUILD_CONFIG% +if errorlevel 1 ( + echo ERROR: Build failed + set "ERROR_CODE=1" + goto cleanup +) + +:: Change to build directory +echo Changing to build directory: %BUILD_DIR% +cd "%BUILD_DIR%" +if errorlevel 1 ( + echo ERROR: Failed to change to build directory: %BUILD_DIR% + set "ERROR_CODE=1" + goto cleanup +) + +:: Run CPack +echo Running CPack... +cpack +if errorlevel 1 ( + echo ERROR: CPack failed + set "ERROR_CODE=1" + goto cleanup +) + +echo. +echo ======================================== +echo Build and packaging completed successfully! +echo ======================================== +goto end + +:cleanup +if "%ERROR_CODE%"=="1" ( + echo. + echo ======================================== + echo Build process failed! + echo ======================================== +) + +:end +pause \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index bc11c24..c581933 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,4 +27,13 @@ configure_file(ToolBox.h.in ToolBox.h) message(STATUS "Version file config to: ${CMAKE_CURRENT_BINARY_DIR}") include_directories(${CMAKE_CURRENT_BINARY_DIR}) -add_subdirectory(fileUpdater) \ No newline at end of file +add_subdirectory(fileUpdater) + +if(WIN32) +set(CPACK_GENERATOR "ZIP") +else() +set(CPACK_GENERATOR "TGZ") +endif() + +set(CPACK_PACKAGE_FILE_NAME "ToolBox-${VERSION_GIT_HASH}-${VERSION_GIT_BRANCH}") +include(CPack) \ No newline at end of file diff --git a/README.md b/README.md index 3ca9efb..c122671 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,6 @@ # Tools -简易工具。 - -# strReplace - -字符串替换。 +工具。 # fileUpdater diff --git a/fileUpdater/main.cpp b/fileUpdater/main.cpp index eb8aa27..f32f7b9 100644 --- a/fileUpdater/main.cpp +++ b/fileUpdater/main.cpp @@ -1,9 +1,9 @@ #include +#include #include #include #include #include -#include #include #include #include @@ -13,7 +13,7 @@ #include #include #include -#include +#include #ifdef _WIN32 #include @@ -497,7 +497,8 @@ int main(int argc, char** argv) ofs.close(); } ifs.close(); - boost::nowide::cout << "已生成默认配置文件: fileUpdater.xml" << std::endl; + auto msg = fmt::format("{} on {} 已生成默认配置文件: fileUpdater.xml", VERSION_GIT_COMMIT, VERSION_GIT_BRANCH); + boost::nowide::cout << msg << std::endl; return 0; } }