feat: mac action (#86)

This commit is contained in:
Barry 2020-02-22 19:35:27 +08:00 committed by GitHub
commit a6f516ef1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 816 additions and 189 deletions

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%