mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-21 20:15:04 +00:00
window action (#85)
This commit is contained in:
parent
2dc13a262f
commit
0d8bf0cc97
4 changed files with 315 additions and 123 deletions
152
.github/workflows/windows.yml
vendored
Normal file
152
.github/workflows/windows.yml
vendored
Normal file
|
@ -0,0 +1,152 @@
|
|||
name: Windows
|
||||
on:
|
||||
# push代码时触发workflow
|
||||
push:
|
||||
# 忽略部分文件
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'README_zh.md'
|
||||
- 'LICENSE'
|
||||
# pull_request时触发workflow
|
||||
pull_request:
|
||||
# 忽略部分文件
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'README_zh.md'
|
||||
- 'LICENSE'
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
# 运行平台, windows-latest目前是windows server 2019,选择2016是2016安装的是vs2017
|
||||
# https://github.com/actions/virtual-environments/blob/master/images/win/Windows2019-Readme.md
|
||||
# https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
|
||||
runs-on: windows-2016
|
||||
strategy:
|
||||
# 矩阵配置
|
||||
matrix:
|
||||
qt_ver: [5.12.6]
|
||||
qt_target: [desktop]
|
||||
# mingw用不了
|
||||
# qt_arch: [win64_msvc2017_64, win32_msvc2017, win32_mingw53,win32_mingw73]
|
||||
qt_arch: [win64_msvc2017_64, win32_msvc2017]
|
||||
# 额外设置msvc_arch
|
||||
include:
|
||||
- qt_arch: win64_msvc2017_64
|
||||
msvc_arch: x64
|
||||
qt_arch_install: msvc2017_64
|
||||
- qt_arch: win32_msvc2017
|
||||
msvc_arch: x86
|
||||
qt_arch_install: msvc2017
|
||||
env:
|
||||
targetName: QtScrcpy.exe
|
||||
# 步骤
|
||||
steps:
|
||||
- name: Cache Qt
|
||||
id: WindowsCacheQt
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ../../Qt5/${{matrix.qt_ver}}/${{matrix.qt_arch_install}}
|
||||
key: ${{ runner.os }}-Qt5.12.6/${{matrix.qt_ver}}/${{matrix.qt_arch}}
|
||||
- name: Setup Qt
|
||||
if: steps.WindowsCacheQt.outputs.cache-hit == 'true'
|
||||
shell: pwsh
|
||||
env:
|
||||
QtPath: ../../Qt5/${{matrix.qt_ver}}/${{matrix.qt_arch_install}}
|
||||
run: |
|
||||
$qt_Path=${env:QtPath}
|
||||
echo "::set-env name=Qt5_Dir::$qt_Path"
|
||||
echo "::add-path::$qt_Path/bin"
|
||||
# 安装Qt
|
||||
- name: Install Qt
|
||||
if: steps.WindowsCacheQt.outputs.cache-hit != 'true'
|
||||
# 使用外部action。这个action专门用来安装Qt
|
||||
uses: jurplel/install-qt-action@v2.0.0
|
||||
with:
|
||||
# Version of Qt to install
|
||||
version: ${{ matrix.qt_ver }}
|
||||
# Target platform for build
|
||||
target: ${{ matrix.qt_target }}
|
||||
# Architecture for Windows/Android
|
||||
arch: ${{ matrix.qt_arch }}
|
||||
# 拉取代码
|
||||
- uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 1
|
||||
# 编译msvc
|
||||
- name: Build MSVC
|
||||
shell: cmd
|
||||
env:
|
||||
ENV_VCVARSALL: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvarsall.bat'
|
||||
ENV_QT_MSVC: 'd:\a\Qt5\5.12.6'
|
||||
run: |
|
||||
call "ci\win\build_for_win.bat" release ${{ matrix.msvc_arch }}
|
||||
# tag 打包
|
||||
- name: Package
|
||||
if: startsWith(github.event.ref, 'refs/tags/')
|
||||
env:
|
||||
publish_dir: QtScrcpy-win-${{matrix.msvc_arch}}
|
||||
ref: ${{ github.event.ref }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
[string]$tag = ${env:ref}.Substring(${env:ref}.LastIndexOf('/') + 1)
|
||||
[string]$full_publish_dir = ${env:publish_dir} + '-' + ${tag}
|
||||
cmd.exe /c ci\win\publish_for_win.bat ${{matrix.msvc_arch}} ..\build\$full_publish_dir
|
||||
# 打包zip
|
||||
Compress-Archive -Path ci\build\$full_publish_dir ci\build\${full_publish_dir}.zip
|
||||
# 记录环境变量packageName给后续step
|
||||
$name = $full_publish_dir
|
||||
echo "::set-env name=packageName::$name"
|
||||
# 打印环境变量packageName
|
||||
Write-Host 'packageName:'${env:packageName}
|
||||
# 查询Release
|
||||
- name: Query Release
|
||||
if: startsWith(github.event.ref, 'refs/tags/')
|
||||
shell: pwsh
|
||||
env:
|
||||
githubFullName: ${{ github.event.repository.full_name }}
|
||||
ref: ${{ github.event.ref }}
|
||||
run: |
|
||||
[string]$tag = ${env:ref}.Substring(${env:ref}.LastIndexOf('/') + 1)
|
||||
[string]$url = 'https://api.github.com/repos/' + ${env:githubFullName} + '/releases/tags/' + ${tag}
|
||||
$response={}
|
||||
try {
|
||||
$response = Invoke-RestMethod -Uri $url -Method Get
|
||||
} catch {
|
||||
Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__
|
||||
Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
|
||||
# 没查到
|
||||
return 1
|
||||
}
|
||||
[string]$latestUpUrl = $response.upload_url
|
||||
Write-Host 'latestUpUrl:'$latestUpUrl
|
||||
if ($latestUpUrl.Length -eq 0) {
|
||||
# 没查到
|
||||
return 1
|
||||
}
|
||||
# 获取上传url
|
||||
- name: Get Release Url
|
||||
if: startsWith(github.event.ref, 'refs/tags/')
|
||||
shell: pwsh
|
||||
env:
|
||||
githubFullName: ${{ github.event.repository.full_name }}
|
||||
ref: ${{ github.event.ref }}
|
||||
run: |
|
||||
[string]$tag = ${env:ref}.Substring(${env:ref}.LastIndexOf('/') + 1)
|
||||
[string]$url = 'https://api.github.com/repos/' + ${env:githubFullName} + '/releases/tags/' + ${tag}
|
||||
$response = Invoke-RestMethod -Uri $url -Method Get
|
||||
[string]$latestUpUrl = $response.upload_url
|
||||
Write-Host 'latestUpUrl:'$latestUpUrl
|
||||
echo "::set-env name=uploadUrl::$latestUpUrl"
|
||||
Write-Host 'env uploadUrl:'${env:uploadUrl}
|
||||
# tag 上传Release
|
||||
- name: Upload Release
|
||||
id: uploadRelease
|
||||
if: startsWith(github.event.ref, 'refs/tags/')
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
with:
|
||||
upload_url: ${{ env.uploadUrl }}
|
||||
asset_path: ci\build\${{ env.packageName }}.zip
|
||||
asset_name: ${{ env.packageName }}.zip
|
||||
asset_content_type: application/zip
|
|
@ -1,102 +0,0 @@
|
|||
@echo off
|
||||
set vcvarsall="D:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat"
|
||||
set qt_msvc_path="D:\Qt\Qt5.12.5\5.12.5\"
|
||||
|
||||
:: 获取脚本绝对路径
|
||||
set script_path=%~dp0
|
||||
:: 进入脚本所在目录,因为这会影响脚本中执行的程序的工作目录
|
||||
set old_cd=%cd%
|
||||
cd /d %~dp0
|
||||
|
||||
:: 启动参数声明
|
||||
set debug_mode="false"
|
||||
set cpu_mode=x86
|
||||
|
||||
echo=
|
||||
echo=
|
||||
echo ---------------------------------------------------------------
|
||||
echo 检查编译参数[debug/release x86/x64]
|
||||
echo ---------------------------------------------------------------
|
||||
|
||||
:: 编译参数检查 /i忽略大小写
|
||||
if /i "%1"=="debug" (
|
||||
set debug_mode="true"
|
||||
)
|
||||
if /i "%1"=="release" (
|
||||
set debug_mode="false"
|
||||
)
|
||||
|
||||
if /i "%2"=="x86" (
|
||||
set cpu_mode=x86
|
||||
)
|
||||
if /i "%2"=="x64" (
|
||||
set cpu_mode=x64
|
||||
)
|
||||
|
||||
:: 提示
|
||||
if /i %debug_mode% == "true" (
|
||||
echo 当前编译模式为 debug %cpu_mode%
|
||||
) else (
|
||||
echo 当前编译模式为debug release %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%
|
||||
|
||||
:: 注册vc环境
|
||||
if /i %cpu_mode% == x86 (
|
||||
call %vcvarsall% %cpu_mode%
|
||||
) else (
|
||||
call %vcvarsall% %cpu_mode%
|
||||
)
|
||||
|
||||
if not %errorlevel%==0 (
|
||||
echo "vcvarsall not find"
|
||||
goto return
|
||||
)
|
||||
|
||||
echo=
|
||||
echo=
|
||||
echo ---------------------------------------------------------------
|
||||
echo 开始qmake编译
|
||||
echo ---------------------------------------------------------------
|
||||
|
||||
if exist %build_path% (
|
||||
rmdir /q /s %build_path%
|
||||
)
|
||||
md %build_path%
|
||||
cd %build_path%
|
||||
|
||||
set qmake_params=-spec win32-msvc
|
||||
|
||||
if /i %debug_mode% == "true" (
|
||||
set qmake_params=%qmake_params% "CONFIG+=debug" "CONFIG+=qml_debug"
|
||||
) else (
|
||||
set qmake_params=%qmake_params% "CONFIG+=qtquickcompiler"
|
||||
)
|
||||
|
||||
:: qmake ../all.pro -spec win32-msvc "CONFIG+=debug" "CONFIG+=qml_debug"
|
||||
qmake ../all.pro %qmake_params%
|
||||
|
||||
nmake
|
||||
|
||||
if not %errorlevel%==0 (
|
||||
echo "qmake build failed"
|
||||
goto return
|
||||
)
|
||||
|
||||
echo=
|
||||
echo=
|
||||
echo ---------------------------------------------------------------
|
||||
echo 完成!
|
||||
echo ---------------------------------------------------------------
|
||||
|
||||
:return
|
||||
cd %old_cd%
|
123
ci/win/build_for_win.bat
Normal file
123
ci/win/build_for_win.bat
Normal file
|
@ -0,0 +1,123 @@
|
|||
@echo off
|
||||
:: 从环境变量获取必要参数
|
||||
:: 例如 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat
|
||||
set vcvarsall="%ENV_VCVARSALL%"
|
||||
:: 例如 d:\a\QtScrcpy\Qt\5.12.7
|
||||
set qt_msvc_path="%ENV_QT_MSVC%"
|
||||
|
||||
echo=
|
||||
echo=
|
||||
echo ---------------------------------------------------------------
|
||||
echo check ENV
|
||||
echo ---------------------------------------------------------------
|
||||
|
||||
echo ENV_VCVARSALL %ENV_VCVARSALL%
|
||||
echo ENV_QT_MSVC %ENV_QT_MSVC%
|
||||
|
||||
:: 获取脚本绝对路径
|
||||
set script_path=%~dp0
|
||||
:: 进入脚本所在目录,因为这会影响脚本中执行的程序的工作目录
|
||||
set old_cd=%cd%
|
||||
cd /d %~dp0
|
||||
|
||||
:: 临时文件目录
|
||||
set temp_path=%script_path%..\temp
|
||||
|
||||
:: 启动参数声明
|
||||
set debug_mode="false"
|
||||
set cpu_mode=x86
|
||||
set errno=1
|
||||
|
||||
echo=
|
||||
echo=
|
||||
echo ---------------------------------------------------------------
|
||||
echo check build param[debug/release x86/x64]
|
||||
echo ---------------------------------------------------------------
|
||||
|
||||
:: 编译参数检查 /i忽略大小写
|
||||
if /i "%1"=="debug" (
|
||||
set debug_mode="true"
|
||||
)
|
||||
if /i "%1"=="release" (
|
||||
set debug_mode="false"
|
||||
)
|
||||
|
||||
if /i "%2"=="x86" (
|
||||
set cpu_mode=x86
|
||||
)
|
||||
if /i "%2"=="x64" (
|
||||
set cpu_mode=x64
|
||||
)
|
||||
|
||||
:: 提示
|
||||
if /i %debug_mode% == "true" (
|
||||
echo current build mode: debug %cpu_mode%
|
||||
) else (
|
||||
echo current build mode: release %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 PATH=%qt_msvc_path%;%PATH%
|
||||
|
||||
:: 注册vc环境
|
||||
if /i %cpu_mode% == x86 (
|
||||
call %vcvarsall% %cpu_mode%
|
||||
) else (
|
||||
call %vcvarsall% %cpu_mode%
|
||||
)
|
||||
|
||||
if not %errorlevel%==0 (
|
||||
echo "vcvarsall not find"
|
||||
goto return
|
||||
)
|
||||
|
||||
echo=
|
||||
echo=
|
||||
echo ---------------------------------------------------------------
|
||||
echo begin qmake build
|
||||
echo ---------------------------------------------------------------
|
||||
|
||||
if exist %temp_path% (
|
||||
rmdir /q /s %temp_path%
|
||||
)
|
||||
md %temp_path%
|
||||
cd %temp_path%
|
||||
|
||||
set qmake_params=-spec win32-msvc
|
||||
|
||||
if /i %debug_mode% == "true" (
|
||||
set qmake_params=%qmake_params% "CONFIG+=debug" "CONFIG+=qml_debug"
|
||||
) else (
|
||||
set qmake_params=%qmake_params% "CONFIG+=qtquickcompiler"
|
||||
)
|
||||
|
||||
:: qmake ../../all.pro -spec win32-msvc "CONFIG+=debug" "CONFIG+=qml_debug"
|
||||
qmake ../../all.pro %qmake_params%
|
||||
if not %errorlevel%==0 (
|
||||
echo "qmake failed"
|
||||
goto return
|
||||
)
|
||||
|
||||
nmake
|
||||
if not %errorlevel%==0 (
|
||||
echo "nmake build failed"
|
||||
goto return
|
||||
)
|
||||
|
||||
echo=
|
||||
echo=
|
||||
echo ---------------------------------------------------------------
|
||||
echo finish!!!
|
||||
echo ---------------------------------------------------------------
|
||||
|
||||
set errno=0
|
||||
|
||||
:return
|
||||
cd %old_cd%
|
||||
exit /B %errno%
|
|
@ -1,13 +1,23 @@
|
|||
@echo off
|
||||
set qt_msvc_path="D:\Qt\Qt5.12.4\5.12.4\"
|
||||
:: 从环境变量获取必要参数
|
||||
:: 例如 d:\a\QtScrcpy\Qt\5.12.7
|
||||
set qt_msvc_path="%ENV_QT_MSVC%"
|
||||
|
||||
:: 获取脚本绝对路径
|
||||
echo=
|
||||
echo=
|
||||
echo ---------------------------------------------------------------
|
||||
echo check ENV
|
||||
echo ---------------------------------------------------------------
|
||||
|
||||
echo ENV_QT_MSVC %ENV_QT_MSVC%
|
||||
|
||||
:: 获取脚本绝对路径
|
||||
set script_path=%~dp0
|
||||
:: 进入脚本所在目录,因为这会影响脚本中执行的程序的工作目录
|
||||
:: 进入脚本所在目录,因为这会影响脚本中执行的程序的工作目录
|
||||
set old_cd=%cd%
|
||||
cd /d %~dp0
|
||||
|
||||
:: 启动参数声明
|
||||
:: 启动参数声明
|
||||
set cpu_mode=x86
|
||||
if /i "%1"=="x86" (
|
||||
set cpu_mode=x86
|
||||
|
@ -16,21 +26,27 @@ if /i "%1"=="x64" (
|
|||
set cpu_mode=x64
|
||||
)
|
||||
|
||||
:: 环境变量设置
|
||||
set publish_dir=%2
|
||||
set errno=1
|
||||
|
||||
set adb_path=%script_path%third_party\adb\win\*.*
|
||||
set jar_path=%script_path%third_party\scrcpy-server
|
||||
set keymap_path=%script_path%keymap
|
||||
set config_path=%script_path%config
|
||||
:: 提示
|
||||
echo current build mode: %cpu_mode%
|
||||
echo current publish dir: %publish_dir%
|
||||
|
||||
:: 环境变量设置
|
||||
set adb_path=%script_path%..\..\third_party\adb\win\*.*
|
||||
set jar_path=%script_path%..\..\third_party\scrcpy-server
|
||||
set keymap_path=%script_path%..\..\keymap
|
||||
set config_path=%script_path%..\..\config
|
||||
|
||||
if /i %cpu_mode% == x86 (
|
||||
set publish_path=%script_path%QtScrcpy-win32\
|
||||
set release_path=%script_path%output\win\x86\release
|
||||
set qt_msvc_path=%qt_msvc_path%msvc2017\bin
|
||||
set publish_path=%script_path%%publish_dir%\
|
||||
set release_path=%script_path%..\..\output\win\x86\release
|
||||
set qt_msvc_path=%qt_msvc_path%\msvc2017\bin
|
||||
) else (
|
||||
set publish_path=%script_path%QtScrcpy-win64\
|
||||
set release_path=%script_path%output\win\x64\release
|
||||
set qt_msvc_path=%qt_msvc_path%msvc2017_64\bin
|
||||
set publish_path=%script_path%%publish_dir%\
|
||||
set release_path=%script_path%..\..\output\win\x64\release
|
||||
set qt_msvc_path=%qt_msvc_path%\msvc2017_64\bin
|
||||
)
|
||||
set PATH=%qt_msvc_path%;%PATH%
|
||||
|
||||
|
@ -38,21 +54,21 @@ if exist %publish_path% (
|
|||
rmdir /s/q %publish_path%
|
||||
)
|
||||
|
||||
:: 复制要发布的包
|
||||
:: 复制要发布的包
|
||||
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
|
||||
xcopy %config_path% %publish_path%config\ /E /Y
|
||||
|
||||
:: 添加qt依赖包
|
||||
:: 添加qt依赖包
|
||||
windeployqt %publish_path%\QtScrcpy.exe
|
||||
|
||||
:: 删除多余qt依赖包
|
||||
:: 删除多余qt依赖包
|
||||
rmdir /s/q %publish_path%\iconengines
|
||||
rmdir /s/q %publish_path%\translations
|
||||
|
||||
:: 截图功能需要qjpeg.dll
|
||||
:: 截图功能需要qjpeg.dll
|
||||
del %publish_path%\imageformats\qgif.dll
|
||||
del %publish_path%\imageformats\qicns.dll
|
||||
del %publish_path%\imageformats\qico.dll
|
||||
|
@ -72,8 +88,11 @@ if /i %cpu_mode% == x86 (
|
|||
echo=
|
||||
echo=
|
||||
echo ---------------------------------------------------------------
|
||||
echo 完成!
|
||||
echo finish!!!
|
||||
echo ---------------------------------------------------------------
|
||||
|
||||
set errno=0
|
||||
|
||||
:return
|
||||
cd %old_cd%
|
||||
cd %old_cd%
|
||||
exit /B %errno%
|
Loading…
Add table
Reference in a new issue