-
Notifications
You must be signed in to change notification settings - Fork 1
/
MAC_build_RELEASE.sh
159 lines (121 loc) · 3 KB
/
MAC_build_RELEASE.sh
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
QT_DIR=/usr/local/Cellar/qt@5/
QT_DIR="$QT_DIR""$(ls $QT_DIR)"
QMAKE=$QT_DIR/bin/qmake
MAC_DEPLOY_TOOL=$QT_DIR/bin/macdeployqt
appget="$(cat *.pro |grep 'TARGET ='|awk -F\= '{print $2;}'| tr -d ' ')"
BIN_DIR="./build-$appget-Release/"
APP_NAME=$appget
BUNDLE_NAME=$APP_NAME.app
VOL_NAME="$appget"
#DMG_DIR=${APP_NAME}_dmg
#DMG_PATH=./$APP_NAME.dmg
PROJECT_FILE=$(basename -- "*.pro")
main(){
cd "${0/*}";
compileProject
RESULT=$?
if [ $RESULT -ne 0 ] ; then
echo Failed to CompileProject
return $RESULT
fi
prepareBundle
RESULT=$?
if [ $RESULT -ne 0 ] ; then
echo Failed to Prepare bundle
return $RESULT
fi
app_ver=$(cat main.cpp |grep 'const QString APP'|awk -F\" '{print $2;}')
makeDMG
RESULT=$?
if [ $RESULT -ne 0 ] ; then
echo Failed to Make DMG file
return $RESULT
fi
makeZIP
RESULT=$?
if [ $RESULT -ne 0 ] ; then
echo Failed to Make ZIP file
return $RESULT
fi
return 0
}
compileProject(){
echo Compiling...
$QMAKE $PROJECT_FILE -config release
RESULT=$?
if [ $RESULT -ne 0 ] ; then
echo qmake failed, error code $RESULT
return $RESULT
fi
make CXX="g++"
RESULT=$?
if [ $RESULT -ne 0 ] ; then
echo make failed, error code $RESULT
return $RESULT
fi
echo Done.
return 0
}
prepareBundle(){
CURRENT_DIR=$PWD
echo Preparing Bundle...
cd $BIN_DIR
if [ ! -d $BUNDLE_NAME ]
then
echo "$BUNDLE_NAME bundle doesn't exist."
return 1
fi
# cd to Resources folder
cd $BUNDLE_NAME
cd Contents
cd MacOS
# copy appconfig to resources
mkdir ./lang
cp ../../../*.qm ./lang/
cp ../../../chart_rules.json .
#cp ../../../exec_history .
#cp ../../../filters_list .
#path to adb in my case installed by: $ brew install android-platform-tools
#cp /usr/local/Cellar/android-platform-tools/25.0.3/bin/adb .
#cd ..
#cd Contents
#cd Resources
cd ../../../
# Add QtFramework libraries and required plugins into .app bundle. Update dependencies of binary files.
$MAC_DEPLOY_TOOL $BUNDLE_NAME -verbose=3
RESULT=$?
if [ $RESULT -ne 0 ] ; then
echo macdeployqt failed, error code $RESULT
return $RESULT
fi
cd $CURRENT_DIR
echo Done.
return 0
}
makeDMG(){
echo Making DMG File...
if [ ! -d "$BUNDLE_NAME" ]
then
echo "$BUNDLE_NAME bundle doesn't exist."
return 1
fi
rm -f "$APP_NAME"_"$app_ver".dmg
hdiutil create -format UDZO -srcfolder "$BUNDLE_NAME" "$APP_NAME"_"$app_ver".dmg
echo Done.
return 0
}
makeZIP(){
echo Making ZIP File...
if [ ! -d "$BUNDLE_NAME" ]
then
echo "$BUNDLE_NAME bundle doesn't exist."
return 1
fi
rm -f "$APP_NAME"_"$app_ver".zip
zip -r -X "$APP_NAME"_"$app_ver".zip "$BUNDLE_NAME"
echo Done.
return 0
}
main
exit $?