From 31a7d23dce5e5f87501d2205f36d09f230f53aca Mon Sep 17 00:00:00 2001 From: Unknown <870709864@qq.com> Date: Thu, 27 Feb 2020 22:39:47 +0800 Subject: [PATCH] chore: add linux build script --- ci/linux/build_for_linux.sh | 91 +++++++++++++++++++++++++++++++++++ ci/linux/publish_for_linux.sh | 85 ++++++++++++++++++++++++++++++++ ci/mac/build_for_mac.sh | 6 +-- ci/mac/publish_for_mac.sh | 4 +- 4 files changed, 181 insertions(+), 5 deletions(-) create mode 100755 ci/linux/build_for_linux.sh create mode 100755 ci/linux/publish_for_linux.sh diff --git a/ci/linux/build_for_linux.sh b/ci/linux/build_for_linux.sh new file mode 100755 index 0000000..d30ac38 --- /dev/null +++ b/ci/linux/build_for_linux.sh @@ -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 diff --git a/ci/linux/publish_for_linux.sh b/ci/linux/publish_for_linux.sh new file mode 100755 index 0000000..7ced137 --- /dev/null +++ b/ci/linux/publish_for_linux.sh @@ -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 diff --git a/ci/mac/build_for_mac.sh b/ci/mac/build_for_mac.sh index 41ab2f6..d71b28a 100755 --- a/ci/mac/build_for_mac.sh +++ b/ci/mac/build_for_mac.sh @@ -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 \ No newline at end of file +exit 0 diff --git a/ci/mac/publish_for_mac.sh b/ci/mac/publish_for_mac.sh index 1d76173..e3d679d 100755 --- a/ci/mac/publish_for_mac.sh +++ b/ci/mac/publish_for_mac.sh @@ -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 \ No newline at end of file +exit 0