This commit is contained in:
Barry 2020-02-22 19:49:50 +08:00 committed by GitHub
parent 5ff64da1fb
commit 3acc7a8ae6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 816 additions and 189 deletions

124
.github/workflows/macos.yml vendored Normal file
View file

@ -0,0 +1,124 @@
name: MacOS
on:
push:
paths:
- 'QtScrcpy/**'
- '!QtScrcpy/res/**'
- '.github/workflows/**'
pull_request:
paths:
- 'QtScrcpy/**'
- '!QtScrcpy/res/**'
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
qt_ver: [5.12.6]
qt_arch: [clang_64]
env:
targetName: QtScrcpy
steps:
- name: Cache Qt
id: MacosCacheQt
uses: actions/cache@v1
with:
path: ../Qt/${{matrix.qt_ver}}/${{matrix.qt_arch}}
key: ${{ runner.os }}-Qt/${{matrix.qt_ver}}/${{matrix.qt_arch}}
- name: Setup Qt
if: steps.MacosCacheQt.outputs.cache-hit == 'true'
shell: pwsh
env:
QtPath: ../Qt/${{matrix.qt_ver}}/${{matrix.qt_arch}}
run: |
$qt_Path=${env:QtPath}
echo "::set-env name=Qt5_Dir::$qt_Path"
echo "::add-path::$qt_Path/bin"
- name: Install Qt
if: steps.MacosCacheQt.outputs.cache-hit != 'true'
uses: jurplel/install-qt-action@v2.0.0
with:
version: ${{ matrix.qt_ver }}
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Build MacOS
run: |
export ENV_QT_CLANG=$(pwd)/${{env.Qt5_Dir}}
ci/mac/build_for_mac.sh release
- name: Publish
if: startsWith(github.event.ref, 'refs/tags/')
run: |
export ENV_QT_CLANG=$(pwd)/${{env.Qt5_Dir}}
ci/mac/publish_for_mac.sh ../build
# tag 打包
- name: Package
id: package
if: startsWith(github.event.ref, 'refs/tags/')
shell: pwsh
env:
ref: ${{ github.event.ref }}
run: |
[string]$tag = ${env:ref}.Substring(${env:ref}.LastIndexOf('/') + 1)
[string]$name = 'QtScrcpy-mac-x64-' + ${tag}
# 打包zip
Compress-Archive -Path ci\build\QtScrcpy.app ci\build\${name}.zip
# 记录环境变量packageName给后续step
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\${{ steps.package.env.packageName }}.zip
asset_name: ${{ steps.package.env.packageName }}.zip
asset_content_type: application/zip

149
.github/workflows/windows.yml vendored Normal file
View file

@ -0,0 +1,149 @@
name: Windows
on:
# push代码时触发workflow
push:
paths:
- 'QtScrcpy/**'
- '!QtScrcpy/res/**'
- '.github/workflows/**'
# pull_request时触发workflow
pull_request:
paths:
- 'QtScrcpy/**'
- '!QtScrcpy/res/**'
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_PATH: '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
.gitignore vendored
View file

@ -12,3 +12,4 @@
/build/
build-*
*.DS_Store
userdata.ini

View file

@ -153,7 +153,7 @@ macos {
QMAKE_BUNDLE_DATA += APP_FFMPEG
APP_CONFIG.files = $$files($$PWD/../config/config.ini)
APP_CONFIG.path = Contents/MacOS
APP_CONFIG.path = Contents/MacOS/config
QMAKE_BUNDLE_DATA += APP_CONFIG
# mac application icon

View file

@ -83,7 +83,7 @@ void Dialog::initUI()
ui->bitRateBox->addItem("6000000");
ui->bitRateBox->addItem("8000000");
ui->bitRateBox->addItem("10000000");
ui->bitRateBox->setCurrentIndex(2);
ui->bitRateBox->setCurrentIndex(Config::getInstance().getBitRateIndex());
ui->maxSizeBox->addItem("640");
ui->maxSizeBox->addItem("720");
@ -91,13 +91,14 @@ void Dialog::initUI()
ui->maxSizeBox->addItem("1280");
ui->maxSizeBox->addItem("1920");
ui->maxSizeBox->addItem(tr("original"));
ui->maxSizeBox->setCurrentIndex(2);
ui->maxSizeBox->setCurrentIndex(Config::getInstance().getMaxSizeIndex());
ui->formatBox->addItem("mp4");
ui->formatBox->addItem("mkv");
ui->formatBox->setCurrentIndex(Config::getInstance().getRecordFormatIndex());
ui->recordPathEdt->setText(Config::getInstance().getRecordPath());
}
}
void Dialog::execAdbCmd()
{
@ -358,3 +359,18 @@ void Dialog::on_recordScreenCheck_clicked(bool checked)
ui->recordScreenCheck->setChecked(false);
}
}
void Dialog::on_bitRateBox_activated(int index)
{
Config::getInstance().setBitRateIndex(index);
}
void Dialog::on_maxSizeBox_activated(int index)
{
Config::getInstance().setMaxSizeIndex(index);
}
void Dialog::on_formatBox_activated(int index)
{
Config::getInstance().setRecordFormatIndex(index);
}

View file

@ -56,6 +56,12 @@ private slots:
void on_recordScreenCheck_clicked(bool checked);
void on_bitRateBox_activated(int index);
void on_maxSizeBox_activated(int index);
void on_formatBox_activated(int index);
private:
bool checkAdbRun();
void initUI();

View file

@ -45,13 +45,13 @@ int main(int argc, char *argv[])
qputenv("QTSCRCPY_ADB_PATH", "../../../../third_party/adb/win/adb.exe");
qputenv("QTSCRCPY_SERVER_PATH", "../../../../third_party/scrcpy-server");
qputenv("QTSCRCPY_KEYMAP_PATH", "../../../../keymap");
qputenv("QTSCRCPY_CONFIG_PATH", "../../../../config/config.ini");
qputenv("QTSCRCPY_CONFIG_PATH", "../../../../config");
#endif
#ifdef Q_OS_LINUX
qputenv("QTSCRCPY_ADB_PATH", "../../../third_party/adb/linux/adb");
qputenv("QTSCRCPY_SERVER_PATH", "../../../third_party/scrcpy-server");
qputenv("QTSCRCPY_CONFIG_PATH", "../../../config/config.ini");
qputenv("QTSCRCPY_CONFIG_PATH", "../../../config");
#endif
//加载样式表
@ -77,6 +77,7 @@ int main(int argc, char *argv[])
g_mainDlg->setWindowTitle(Config::getInstance().getTitle());
g_mainDlg->show();
qInfo(QObject::tr("This software is completely open source and free, you can download it at the following address:").toUtf8());
qInfo(QString("QtScrcpy %1 <https://github.com/barry-ran/QtScrcpy>").arg(QCoreApplication::applicationVersion()).toUtf8());
int ret = a.exec();

Binary file not shown.

View file

@ -75,7 +75,7 @@
</message>
<message>
<location filename="../../dialog.ui" line="144"/>
<location filename="../../dialog.cpp" line="293"/>
<location filename="../../dialog.cpp" line="294"/>
<source>select path</source>
<translation>select path</translation>
</message>
@ -203,6 +203,14 @@
<translation>original</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../../main.cpp" line="80"/>
<source>This software is completely open source and free, you can download it at the following address:</source>
<translation>This software is completely open source and free, you can download it at the following address:</translation>
</message>
</context>
<context>
<name>ToolForm</name>
<message>

Binary file not shown.

View file

@ -75,7 +75,7 @@
</message>
<message>
<location filename="../../dialog.ui" line="144"/>
<location filename="../../dialog.cpp" line="293"/>
<location filename="../../dialog.cpp" line="294"/>
<source>select path</source>
<translation></translation>
</message>
@ -203,6 +203,14 @@
<translation></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../../main.cpp" line="80"/>
<source>This software is completely open source and free, you can download it at the following address:</source>
<translation></translation>
</message>
</context>
<context>
<name>ToolForm</name>
<message>

View file

@ -6,12 +6,10 @@
#define GROUP_COMMON "common"
// config
#define COMMON_TITLE_KEY "WindowTitle"
#define COMMON_TITLE_DEF QCoreApplication::applicationName()
#define COMMON_RECORD_KEY "RecordPath"
#define COMMON_RECORD_DEF ""
#define COMMON_PUSHFILE_KEY "PushFilePath"
#define COMMON_PUSHFILE_DEF "/sdcard/"
@ -33,12 +31,30 @@
#define COMMON_RENDER_EXPIRED_FRAMES_KEY "RenderExpiredFrames"
#define COMMON_RENDER_EXPIRED_FRAMES_DEF 0
// user data
#define COMMON_RECORD_KEY "RecordPath"
#define COMMON_RECORD_DEF ""
#define COMMON_BITRATE_INDEX_KEY "BitRateIndex"
#define COMMON_BITRATE_INDEX_DEF 2
#define COMMON_MAX_SIZE_INDEX_KEY "MaxSizeIndex"
#define COMMON_MAX_SIZE_INDEX_DEF 2
#define COMMON_RECORD_FORMAT_INDEX_KEY "RecordFormatIndex"
#define COMMON_RECORD_FORMAT_INDEX_DEF 0
// 最大尺寸 录制格式
QString Config::s_configPath = "";
Config::Config(QObject *parent) : QObject(parent)
{
m_settings = new QSettings(getConfigPath(), QSettings::IniFormat);
m_settings = new QSettings(getConfigPath() + "/config.ini", QSettings::IniFormat);
m_settings->setIniCodec("UTF-8");
m_userData = new QSettings(getConfigPath() + "/userdata.ini", QSettings::IniFormat);
m_userData->setIniCodec("UTF-8");
}
Config &Config::getInstance()
@ -52,8 +68,8 @@ const QString& Config::getConfigPath()
if (s_configPath.isEmpty()) {
s_configPath = QString::fromLocal8Bit(qgetenv("QTSCRCPY_CONFIG_PATH"));
QFileInfo fileInfo(s_configPath);
if (s_configPath.isEmpty() || !fileInfo.isFile()) {
s_configPath = QCoreApplication::applicationDirPath() + "/config/config.ini";
if (s_configPath.isEmpty() || !fileInfo.isDir()) {
s_configPath = QCoreApplication::applicationDirPath() + "/config";
}
}
return s_configPath;
@ -62,17 +78,65 @@ const QString& Config::getConfigPath()
QString Config::getRecordPath()
{
QString record;
m_settings->beginGroup(GROUP_COMMON);
record = m_settings->value(COMMON_RECORD_KEY, COMMON_RECORD_DEF).toString();
m_settings->endGroup();
m_userData->beginGroup(GROUP_COMMON);
record = m_userData->value(COMMON_RECORD_KEY, COMMON_RECORD_DEF).toString();
m_userData->endGroup();
return record;
}
void Config::setRecordPath(const QString &path)
{
m_settings->beginGroup(GROUP_COMMON);
m_settings->setValue(COMMON_RECORD_KEY, path);
m_settings->endGroup();
m_userData->beginGroup(GROUP_COMMON);
m_userData->setValue(COMMON_RECORD_KEY, path);
m_userData->endGroup();
}
int Config::getBitRateIndex()
{
int bitRateIndex;
m_userData->beginGroup(GROUP_COMMON);
bitRateIndex = m_userData->value(COMMON_BITRATE_INDEX_KEY, COMMON_BITRATE_INDEX_DEF).toInt();
m_userData->endGroup();
return bitRateIndex;
}
void Config::setBitRateIndex(int bitRateIndex)
{
m_userData->beginGroup(GROUP_COMMON);
m_userData->setValue(COMMON_BITRATE_INDEX_KEY, bitRateIndex);
m_userData->endGroup();
}
int Config::getMaxSizeIndex()
{
int maxSizeIndex;
m_userData->beginGroup(GROUP_COMMON);
maxSizeIndex = m_userData->value(COMMON_MAX_SIZE_INDEX_KEY, COMMON_MAX_SIZE_INDEX_DEF).toInt();
m_userData->endGroup();
return maxSizeIndex;
}
void Config::setMaxSizeIndex(int maxSizeIndex)
{
m_userData->beginGroup(GROUP_COMMON);
m_userData->setValue(COMMON_MAX_SIZE_INDEX_KEY, maxSizeIndex);
m_userData->endGroup();
}
int Config::getRecordFormatIndex()
{
int recordFormatIndex;
m_userData->beginGroup(GROUP_COMMON);
recordFormatIndex = m_userData->value(COMMON_RECORD_FORMAT_INDEX_KEY, COMMON_RECORD_FORMAT_INDEX_DEF).toInt();
m_userData->endGroup();
return recordFormatIndex;
}
void Config::setRecordFormatIndex(int recordFormatIndex)
{
m_userData->beginGroup(GROUP_COMMON);
m_userData->setValue(COMMON_RECORD_FORMAT_INDEX_KEY, recordFormatIndex);
m_userData->endGroup();
}
QString Config::getServerVersion()

View file

@ -10,9 +10,8 @@ class Config : public QObject
Q_OBJECT
public:
static Config& getInstance();
// config
QString getTitle();
QString getRecordPath();
void setRecordPath(const QString& path);
QString getServerVersion();
int getMaxFps();
int getDesktopOpenGL();
@ -21,6 +20,16 @@ public:
QString getPushFilePath();
QString getServerPath();
// user data
QString getRecordPath();
void setRecordPath(const QString& path);
int getBitRateIndex();
void setBitRateIndex(int bitRateIndex);
int getMaxSizeIndex();
void setMaxSizeIndex(int maxSizeIndex);
int getRecordFormatIndex();
void setRecordFormatIndex(int recordFormatIndex);
private:
explicit Config(QObject *parent = nullptr);
const QString& getConfigPath();
@ -28,6 +37,7 @@ private:
private:
static QString s_configPath;
QPointer<QSettings> m_settings;
QPointer<QSettings> m_userData;
};
#endif // CONFIG_H

View file

@ -1,98 +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
)
:: 提示
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%
:: 注册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%

91
ci/mac/build_for_mac.sh Executable file
View file

@ -0,0 +1,91 @@
echo
echo
echo ---------------------------------------------------------------
echo check ENV
echo ---------------------------------------------------------------
# 从环境变量获取必要参数
# 例如 /Users/barry/Qt5.12.5/5.12.5
echo ENV_QT_CLANG $ENV_QT_CLANG
# 获取绝对路径,保证其他目录执行此脚本依然正确
{
cd $(dirname "$0")
script_path=$(pwd)
cd -
} &> /dev/null # disable output
# 设置当前目录cd的目录影响接下来执行程序的工作目录
old_cd=$(pwd)
cd $(dirname "$0")
# 启动参数声明
build_mode=debug
echo
echo
echo ---------------------------------------------------------------
echo check build param[debug/release]
echo ---------------------------------------------------------------
# 编译参数检查
build_mode=$(echo $1 | tr '[:upper:]' '[:lower:]')
if [[ $build_mode != "release" && $build_mode != "debug" ]]; then
echo "error: unkonow build mode -- $1"
exit 1
fi
# 提示
echo current build mode: $build_mode
# 环境变量设置
export PATH=$PATH:$ENV_QT_CLANG/bin
echo
echo
echo ---------------------------------------------------------------
echo begin qmake build
echo ---------------------------------------------------------------
# 删除输出目录
output_path=$script_path../../output/mac/$build_mode
if [ -d "$output_path" ]; then
rm -rf $output_path
fi
# 删除临时目录
temp_path=$script_path/../temp
if [ -d "$temp_path" ]; then
rm -rf $temp_path
fi
mkdir $temp_path
cd $temp_path
qmake_params="-spec macx-clang"
if [ $build_mode == "debug" ]; then
qmake_params="$qmake_params CONFIG+=debug CONFIG+=x86_64 CONFIG+=qml_debug"
else
qmake_params="$qmake_params CONFIG+=x86_64 CONFIG+=qtquickcompiler"
fi
# qmake ../../all.pro -spec macx-clang CONFIG+=debug CONFIG+=x86_64 CONFIG+=qml_debug
qmake ../../all.pro $qmake_params
if [ $? -ne 0 ] ;then
echo "qmake failed"
exit 1
fi
make -j8
if [ $? -ne 0 ] ;then
echo "make failed"
exit 1
fi
echo
echo
echo ---------------------------------------------------------------
echo finish!!!
echo ---------------------------------------------------------------
# 恢复当前目录
cd $old_cd
exit 0

85
ci/mac/publish_for_mac.sh Executable file
View file

@ -0,0 +1,85 @@
echo
echo
echo ---------------------------------------------------------------
echo check ENV
echo ---------------------------------------------------------------
# 从环境变量获取必要参数
# 例如 /Users/barry/Qt5.12.5/5.12.5
echo ENV_QT_CLANG $ENV_QT_CLANG
# 获取绝对路径,保证其他目录执行此脚本依然正确
{
cd $(dirname "$0")
script_path=$(pwd)
cd -
} &> /dev/null # disable output
# 设置当前目录cd的目录影响接下来执行程序的工作目录
old_cd=$(pwd)
cd $(dirname "$0")
# 启动参数声明
publish_dir=$1
# 提示
echo current publish dir: $publish_dir
# 环境变量设置
keymap_path=$script_path/../../keymap
# config_path=$script_path/../../config
publish_path=$script_path/$publish_dir
release_path=$script_path/../../output/mac/release
export PATH=$PATH:$ENV_QT_CLANG/bin
if [ -d "$publish_path" ]; then
rm -rf $publish_path
fi
# 复制要发布的包
cp -r $release_path $publish_path
cp -r $keymap_path $publish_path/QtScrcpy.app/Contents/MacOS
# cp -r $config_path $publish_path/QtScrcpy.app/Contents/MacOS
# 添加qt依赖包
macdeployqt $publish_path/QtScrcpy.app
# 删除多余qt依赖包
# PlugIns
rm -rf $publish_path/QtScrcpy.app/Contents/PlugIns/iconengines
# 截图功能需要libqjpeg.dylib
rm -f $publish_path/QtScrcpy.app/Contents/PlugIns/imageformats/libqgif.dylib
rm -f $publish_path/QtScrcpy.app/Contents/PlugIns/imageformats/libqicns.dylib
rm -f $publish_path/QtScrcpy.app/Contents/PlugIns/imageformats/libqico.dylib
# rm -f $publish_path/QtScrcpy.app/Contents/PlugIns/imageformats/libqjpeg.dylib
rm -f $publish_path/QtScrcpy.app/Contents/PlugIns/imageformats/libqmacheif.dylib
rm -f $publish_path/QtScrcpy.app/Contents/PlugIns/imageformats/libqmacjp2.dylib
rm -f $publish_path/QtScrcpy.app/Contents/PlugIns/imageformats/libqtga.dylib
rm -f $publish_path/QtScrcpy.app/Contents/PlugIns/imageformats/libqtiff.dylib
rm -f $publish_path/QtScrcpy.app/Contents/PlugIns/imageformats/libqwbmp.dylib
rm -f $publish_path/QtScrcpy.app/Contents/PlugIns/imageformats/libqwebp.dylib
rm -rf $publish_path/QtScrcpy.app/Contents/PlugIns/virtualkeyboard
rm -rf $publish_path/QtScrcpy.app/Contents/PlugIns/printsupport
rm -rf $publish_path/QtScrcpy.app/Contents/PlugIns/platforminputcontexts
rm -rf $publish_path/QtScrcpy.app/Contents/PlugIns/iconengines
rm -rf $publish_path/QtScrcpy.app/Contents/PlugIns/bearer
# Frameworks
rm -rf $publish_path/QtScrcpy.app/Contents/Frameworks/QtVirtualKeyboard.framework
rm -rf $publish_path/Contents/Frameworks/QtSvg.framework
# qml
rm -rf $publish_path/QtScrcpy.app/Contents/Frameworks/QtQml.framework
rm -rf $publish_path/QtScrcpy.app/Contents/Frameworks/QtQuick.framework
echo
echo
echo ---------------------------------------------------------------
echo finish!!!
echo ---------------------------------------------------------------
# 恢复当前目录
cd $old_cd
exit 0

129
ci/win/build_for_win.bat Normal file
View file

@ -0,0 +1,129 @@
@echo off
echo=
echo=
echo ---------------------------------------------------------------
echo check ENV
echo ---------------------------------------------------------------
:: 从环境变量获取必要参数
:: example: D:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat
set vcvarsall="%ENV_VCVARSALL%"
:: example: D:\Qt\Qt5.12.5\5.12.5
set qt_msvc_path="%ENV_QT_PATH%"
echo ENV_VCVARSALL %ENV_VCVARSALL%
echo ENV_QT_PATH %ENV_QT_PATH%
:: 获取脚本绝对路径
set script_path=%~dp0
:: 进入脚本所在目录,因为这会影响脚本中执行的程序的工作目录
set old_cd=%cd%
cd /d %~dp0
:: 启动参数声明
set cpu_mode=x86
set build_mode=debug
set errno=1
echo=
echo=
echo ---------------------------------------------------------------
echo check build param[debug/release x86/x64]
echo ---------------------------------------------------------------
:: 编译参数检查 /i忽略大小写
if /i "%1"=="debug" (
set build_mode=debug
goto build_mode_ok
)
if /i "%1"=="release" (
set build_mode=release
goto build_mode_ok
)
echo error: unkonow build mode -- %1
goto return
:build_mode_ok
if /i "%2"=="x86" (
set cpu_mode=x86
)
if /i "%2"=="x64" (
set cpu_mode=x64
)
:: 提示
echo current build mode: %build_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 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 ---------------------------------------------------------------
:: 删除输出目录
set output_path=%script_path%..\..\output\win\%cpu_mode%\%build_mode%
if exist %output_path% (
rmdir /q /s %output_path%
)
:: 删除临时目录
set temp_path=%script_path%..\temp
if exist %temp_path% (
rmdir /q /s %temp_path%
)
md %temp_path%
cd %temp_path%
set qmake_params=-spec win32-msvc
if /i %build_mode% == debug (
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
:: jom是qt的多进程nmake工具
..\win\jom -j8
if not %errorlevel%==0 (
echo "nmake failed"
goto return
)
echo=
echo=
echo ---------------------------------------------------------------
echo finish!!!
echo ---------------------------------------------------------------
set errno=0
:return
cd %old_cd%
exit /B %errno%

BIN
ci/win/jom.exe Executable file

Binary file not shown.

View file

@ -0,0 +1,99 @@
@echo off
echo=
echo=
echo ---------------------------------------------------------------
echo check ENV
echo ---------------------------------------------------------------
:: 从环境变量获取必要参数
:: 例如 d:\a\QtScrcpy\Qt\5.12.7
set qt_msvc_path="%ENV_QT_PATH%"
echo ENV_QT_PATH %ENV_QT_PATH%
:: 获取脚本绝对路径
set script_path=%~dp0
:: 进入脚本所在目录,因为这会影响脚本中执行的程序的工作目录
set old_cd=%cd%
cd /d %~dp0
:: 启动参数声明
set cpu_mode=x86
set publish_dir=%2
set errno=1
if /i "%1"=="x86" (
set cpu_mode=x86
)
if /i "%1"=="x64" (
set cpu_mode=x64
)
:: 提示
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%%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%%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%
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依赖包
windeployqt %publish_path%\QtScrcpy.exe
:: 删除多余qt依赖包
rmdir /s/q %publish_path%\iconengines
rmdir /s/q %publish_path%\translations
:: 截图功能需要qjpeg.dll
del %publish_path%\imageformats\qgif.dll
del %publish_path%\imageformats\qicns.dll
del %publish_path%\imageformats\qico.dll
::del %publish_path%\imageformats\qjpeg.dll
del %publish_path%\imageformats\qsvg.dll
del %publish_path%\imageformats\qtga.dll
del %publish_path%\imageformats\qtiff.dll
del %publish_path%\imageformats\qwbmp.dll
del %publish_path%\imageformats\qwebp.dll
if /i %cpu_mode% == x86 (
del %publish_path%\vc_redist.x86.exe
) else (
del %publish_path%\vc_redist.x64.exe
)
echo=
echo=
echo ---------------------------------------------------------------
echo finish!!!
echo ---------------------------------------------------------------
set errno=0
:return
cd %old_cd%
exit /B %errno%

View file

@ -7,12 +7,14 @@
- text转换 https://github.com/Genymobile/scrcpy/commit/c916af0984f72a60301d13fa8ef9a85112f54202?tdsourcetag=s_pctim_aiomsg
## 中优先级
- 自动打包脚本
- mac自动打包脚本
- 脚本
- 群控
- 竖屏全屏不拉伸画面
- 软解
- opengles 3.0
- github action
- 打包版本截图无效?
## 高优先级
- linux打包以及版本号

View file

@ -1,68 +0,0 @@
@echo off
set qt_msvc_path="D:\Qt\Qt5.12.4\5.12.4\"
:: 获取脚本绝对路径
set script_path=%~dp0
:: 进入脚本所在目录,因为这会影响脚本中执行的程序的工作目录
set old_cd=%cd%
cd /d %~dp0
:: 启动参数声明
set cpu_mode=x86
if /i "%1"=="x86" (
set cpu_mode=x86
)
if /i "%1"=="x64" (
set cpu_mode=x64
)
:: 环境变量设置
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
) 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 PATH=%qt_msvc_path%;%PATH%
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依赖包
windeployqt %publish_path%\QtScrcpy.exe
:: 删除多余qt依赖包
rmdir /s/q %publish_path%\iconengines
rmdir /s/q %publish_path%\imageformats
rmdir /s/q %publish_path%\translations
if /i %cpu_mode% == x86 (
del %publish_path%\vc_redist.x86.exe
) else (
del %publish_path%\vc_redist.x64.exe
)
echo=
echo=
echo ---------------------------------------------------------------
echo 完成!
echo ---------------------------------------------------------------
:return
cd %old_cd%