forked from barry-ran/QtScrcpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_for_win.bat
98 lines (79 loc) · 2.03 KB
/
build_for_win.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
@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%