diff --git a/build_for_win.bat b/build_for_win.bat index 3c46e50..ece01a7 100644 --- a/build_for_win.bat +++ b/build_for_win.bat @@ -1,6 +1,6 @@ @echo off -set VsDevCmd="C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat" -set qt_msvc_path="D:\Qt\Qt5.12.4\5.12.4\msvc2017\bin" +set vcvarsall="C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat" +set qt_msvc_path="D:\Qt\Qt5.12.4\5.12.4\" :: 获取脚本绝对路径 set script_path=%~dp0 @@ -10,44 +10,51 @@ cd /d %~dp0 :: 启动参数声明 set debug_mode="false" +set cpu_mode=x86 echo= echo= echo --------------------------------------------------------------- -echo 检查编译参数[debug/release] +echo 检查编译参数[debug/release x86/x64] echo --------------------------------------------------------------- :: 编译参数检查 /i忽略大小写 if /i "%1"=="debug" ( set debug_mode="true" - goto param_ok ) if /i "%1"=="release" ( set debug_mode="false" - goto param_ok ) -echo "waring: unkonow build mode -- %1, default release" -set debug_mode="false" -goto param_ok - -:param_ok +if /i "%2"=="x86" ( + set cpu_mode=x86 +) +if /i "%2"=="x64" ( + set cpu_mode=x64 +) :: 提示 -if /i %debug_mode% == "true" ( - echo 当前编译版本为debug版本 -) else ( - echo 当前编译版本为release版本 -) +echo 当前编译模式为debug %debug_mode% %cpu_mode% :: 环境变量设置 +if /i %cpu_mode% == x86 ( + set qt_msvc_path=%qt_msvc_path%msvc2017\bin +) else ( + set qt_msvc_path=%qt_msvc_path%msvc2017_64\bin +) + set build_path=%script_path%build set PATH=%qt_msvc_path%;%PATH% -call %VsDevCmd% +:: 注册vc环境 +if /i %cpu_mode% == x86 ( + call %vcvarsall% %cpu_mode% +) else ( + call %vcvarsall% %cpu_mode% +) if not %errorlevel%==0 ( - echo "VsDevCmd not find" + echo "vcvarsall not find" goto return ) diff --git a/publish_for_win.bat b/publish_for_win.bat new file mode 100644 index 0000000..e729460 --- /dev/null +++ b/publish_for_win.bat @@ -0,0 +1,55 @@ +@echo off +set qt_msvc_path="D:\Qt\Qt5.12.4\5.12.4\msvc2017\bin" + +:: 获取脚本绝对路径 +set script_path=%~dp0 +:: 进入脚本所在目录,因为这会影响脚本中执行的程序的工作目录 +set old_cd=%cd% +cd /d %~dp0 + +:: 启动参数声明 +set cpu_mode=x86 +if /i "%2"=="x86" ( + set cpu_mode=x86 +) +if /i "%2"=="x64" ( + set cpu_mode=x64 +) + +:: 环境变量设置 +set PATH=%qt_msvc_path%;%PATH% + +set publish_path=%script_path%publish\ +set adb_path=%script_path%\third_party\adb\win\*.* +set jar_path=%script_path%\third_party\scrcpy-server.jar +set keymap_path=%script_path%\keymap + +if /i %cpu_mode% == x86 ( + set release_path=%script_path%output\win\release +) else ( + set release_path=%script_path%output\win-x64\release +) + +:: 复制要发布的包 +xcopy %release_path% %publish_path% /E /Y +xcopy %adb_path% %publish_path% /Y +xcopy %jar_path% %publish_path% /Y +xcopy %keymap_path% %publish_path%keymap\ /E /Y + +:: 添加qt依赖包 +windeployqt %publish_path%\QtScrcpy.exe + +:: 删除多余qt依赖包 +rmdir /s/q %publish_path%\iconengines +rmdir /s/q %publish_path%\imageformats +rmdir /s/q %publish_path%\translations +del %publish_path%\vc_redist.x86.exe + +echo= +echo= +echo --------------------------------------------------------------- +echo 完成! +echo --------------------------------------------------------------- + +:return +cd %old_cd% \ No newline at end of file