win打包脚本。

This commit is contained in:
2026-03-30 16:39:34 +08:00
parent bac83f6cf8
commit 86034c71e0
4 changed files with 98 additions and 9 deletions

83
2022Build.bat Normal file
View File

@@ -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

View File

@@ -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)
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)

View File

@@ -1,10 +1,6 @@
# Tools
简易工具。
# strReplace
字符串替换。
工具。
# fileUpdater

View File

@@ -1,9 +1,9 @@
#include <CLI11.hpp>
#include <ToolBox.h>
#include <algorithm>
#include <boost/algorithm/string.hpp>
#include <boost/nowide/iostream.hpp>
#include <chrono>
#include <ToolBox.h>
#include <iomanip>
#include <iostream>
#include <spdlog/sinks/rotating_file_sink.h>
@@ -13,7 +13,7 @@
#include <string>
#include <tinyxml2.h>
#include <vector>
#include <zoost.h>
#include <zoost/zoost.h>
#ifdef _WIN32
#include <windows.h>
@@ -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;
}
}