chore: update build script_path

1. update windows build script
2. add mac build script
This commit is contained in:
rankun 2020-02-22 02:03:49 +08:00
commit eed62a668c
4 changed files with 220 additions and 123 deletions

View file

@ -77,7 +77,7 @@ jobs:
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'
ENV_QT_PATH: 'd:\a\Qt5\5.12.6'
run: |
call "ci\win\build_for_win.bat" release ${{ matrix.msvc_arch }}
# tag 打包

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_PATH $ENV_QT_PATH
# 获取绝对路径,保证其他目录执行此脚本依然正确
{
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_PATH/clang_64/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

View file

@ -1,9 +1,4 @@
@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=
@ -11,8 +6,14 @@ 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_MSVC %ENV_QT_MSVC%
echo ENV_QT_PATH %ENV_QT_PATH%
:: 获取脚本绝对路径
set script_path=%~dp0
@ -20,12 +21,9 @@ 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 build_mode=debug
set errno=1
echo=
@ -36,11 +34,16 @@ echo ---------------------------------------------------------------
:: 编译参数检查 /i忽略大小写
if /i "%1"=="debug" (
set debug_mode="true"
set build_mode=debug
goto build_mode_ok
)
if /i "%1"=="release" (
set debug_mode="false"
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
@ -50,11 +53,7 @@ if /i "%2"=="x64" (
)
:: 提示
if /i %debug_mode% == "true" (
echo current build mode: debug %cpu_mode%
) else (
echo current build mode: release %cpu_mode%
)
echo current build mode: %build_mode% %cpu_mode%
:: 环境变量设置
if /i %cpu_mode% == x86 (
@ -62,7 +61,6 @@ if /i %cpu_mode% == x86 (
) else (
set qt_msvc_path=%qt_msvc_path%\msvc2017_64\bin
)
set PATH=%qt_msvc_path%;%PATH%
:: 注册vc环境
@ -83,6 +81,13 @@ 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%
)
@ -90,8 +95,7 @@ md %temp_path%
cd %temp_path%
set qmake_params=-spec win32-msvc
if /i %debug_mode% == "true" (
if /i %build_mode% == debug (
set qmake_params=%qmake_params% "CONFIG+=debug" "CONFIG+=qml_debug"
) else (
set qmake_params=%qmake_params% "CONFIG+=qtquickcompiler"
@ -104,9 +108,11 @@ if not %errorlevel%==0 (
goto return
)
nmake
:: nmake
:: jom是qt的多进程nmake工具
..\win\jom -j8
if not %errorlevel%==0 (
echo "nmake build failed"
echo "nmake failed"
goto return
)

BIN
ci/win/jom.exe Executable file

Binary file not shown.