chore: add linux build script

This commit is contained in:
Unknown 2020-02-27 22:39:47 +08:00
parent c0ffd960d4
commit 3e0f67236b
4 changed files with 181 additions and 5 deletions

91
ci/linux/build_for_linux.sh Executable file
View file

@ -0,0 +1,91 @@
echo
echo
echo ---------------------------------------------------------------
echo check ENV
echo ---------------------------------------------------------------
# 从环境变量获取必要参数
# 例如 /home/barry/Qt5.9.6/5.9.6/gcc_64
echo ENV_QT_GCC $ENV_QT_GCC
# 获取绝对路径,保证其他目录执行此脚本依然正确
{
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=$ENV_QT_GCC/bin:$PATH
echo
echo
echo ---------------------------------------------------------------
echo begin qmake build
echo ---------------------------------------------------------------
# 删除输出目录
output_path=$script_path../../output/linux/$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 linux-g++"
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 linux-g++ 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/linux/publish_for_linux.sh Executable file
View file

@ -0,0 +1,85 @@
echo
echo
echo ---------------------------------------------------------------
echo check ENV
echo ---------------------------------------------------------------
# 从环境变量获取必要参数
# 例如 /home/barry/Qt5.9.6/5.9.6/gcc_64
echo ENV_QT_GCC $ENV_QT_GCC
# 获取绝对路径,保证其他目录执行此脚本依然正确
{
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/linux/release
export PATH=$ENV_QT_GCC/bin:$PATH
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

View file

@ -6,7 +6,7 @@ echo check ENV
echo ---------------------------------------------------------------
# 从环境变量获取必要参数
# 例如 /Users/barry/Qt5.12.5/5.12.5
# 例如 /Users/barry/Qt5.12.5/5.12.5/clang_64
echo ENV_QT_CLANG $ENV_QT_CLANG
# 获取绝对路径,保证其他目录执行此脚本依然正确
@ -39,7 +39,7 @@ fi
echo current build mode: $build_mode
# 环境变量设置
export PATH=$PATH:$ENV_QT_CLANG/bin
export PATH=$ENV_QT_CLANG/bin:$PATH
echo
echo
@ -88,4 +88,4 @@ echo ---------------------------------------------------------------
# 恢复当前目录
cd $old_cd
exit 0
exit 0

View file

@ -31,7 +31,7 @@ keymap_path=$script_path/../../keymap
publish_path=$script_path/$publish_dir
release_path=$script_path/../../output/mac/release
export PATH=$PATH:$ENV_QT_CLANG/bin
export PATH=$ENV_QT_CLANG/bin:$PATH
if [ -d "$publish_path" ]; then
rm -rf $publish_path
@ -82,4 +82,4 @@ echo ---------------------------------------------------------------
# 恢复当前目录
cd $old_cd
exit 0
exit 0