-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
setup.sh
executable file
·255 lines (232 loc) · 7.47 KB
/
setup.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#!/bin/bash
#**************************************************************************
#
# QPrompt
# Copyright (C) 2024 Javier O. Cordero Pérez
#
# This file is part of QPrompt.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#**************************************************************************
ARCHITECTURE="$(uname -m)"
QT_VER=6.7.3
echo -e "\nArchitecture: $ARCHITECTURE"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
PLATFORM="linux"
CMAKE_INSTALL_PREFIX="/usr"
if [ "$ARCHITECTURE" == "aarch64" ]; then
COMPILER="gcc_arm64"
else
COMPILER="gcc_64"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
PLATFORM="macos"
CMAKE_INSTALL_PREFIX="/usr"
COMPILER="macos"
elif [[ "$OSTYPE" == "win32" || "$OSTYPE" == "msys" ]]; then
PLATFORM="windows"
CMAKE_INSTALL_PREFIX="install"
if [ "$ARCHITECTURE" == "aarch64" ]; then
COMPILER="msvc2019_arm64"
else
COMPILER="msvc2019_64"
fi
elif [[ "$OSTYPE" == "freebsd"* ]]; then
PLATFORM="freebsd"
CMAKE_INSTALL_PREFIX="/usr"
COMPILER="gcc"
else
PLATFORM="unix"
CMAKE_INSTALL_PREFIX="/usr"
COMPILER="gcc"
fi
CMAKE_CONFIGURATION_TYPES="Debug;Release;RelWithDebInfo;MinSizeRel"
CMAKE_BUILD_TYPE=$1
if [ "$CMAKE_BUILD_TYPE" == "" ]; then
if [[ "$PLATFORM" == "windows" ]]; then
CMAKE_BUILD_TYPE="Release"
else
CMAKE_BUILD_TYPE="RelWithDebInfo"
fi
fi
CMAKE_PREFIX_PATH=$2
if [ "$CMAKE_PREFIX_PATH" == "" ]; then
if [[ "$OSTYPE" == "win32" ]]; then
CMAKE_PREFIX_PATH="C:\\Qt\\$QT_VER\\$COMPILER\\"
elif [[ "$OSTYPE" == "msys" ]]; then
CMAKE_PREFIX_PATH=/c/Qt/$QT_VER/$COMPILER/
else
CMAKE_PREFIX_PATH=~/Qt/$QT_VER/$COMPILER/
fi
fi
cat << EOF
usage: $0 <CMAKE_BUILD_TYPE> <CMAKE_PREFIX_PATH> [CLEAR | CLEAR_ALL]
Settings:
* CMAKE_BUILD_TYPE: $CMAKE_BUILD_TYPE
* CMAKE_PREFIX_PATH: $CMAKE_PREFIX_PATH
Setup script for building QPrompt
This script assumes you've already installed the following dependencies:
For all platforms:
> Git
> Bash
> Python 3
> Qt 6 ($QT_VER used by default)
For Linux:
> build-essential
> cmake
> python3-venv
For macOS:
> CMake
> Homebrew
For Windows:
> Visual Studio (Community Edition)
>> Desktop Development with C++
>> C++ ATL
>> Windows SDK
EOF
QT_MAJOR_VERSION=6
CLEAR_ARG="${@: -1}"
if [ "$CLEAR_ARG" == "CLEAR" ]; then
CLEAR=true
CLEAR_ALL=false
elif [ "$CLEAR_ARG" == "CLEAR_ALL" ]; then
CLEAR=true
CLEAR_ALL=true
else
CLEAR=false
CLEAR_ALL=false
fi
# Constants
if [[ "$PLATFORM" == "windows" ]]; then
AppDir=""
AppDirUsr="install"
else
AppDir="install"
AppDirUsr="install/usr"
fi
mkdir -p $AppDirUsr
echo -e "\nBuild directory is ./build"
if $CLEAR_ALL # QPrompt and dependencies
then
rm -dRf ./build ./install
elif $CLEAR # QPrompt
then
rm -dRf ./build
fi
mkdir -p build install
if [[ "$PLATFORM" == "macos" ]]; then
brew install ninja
elif [[ "$PLATFORM" == "windows" ]]; then
winget install -e --id Kitware.CMake
winget install -e --id Ninja-build.Ninja
winget install -e --id JRSoftware.InnoSetup
fi
echo "Downloading git submodules"
git submodule update --init --recursive
python3 -m venv venv
if [[ "$PLATFORM" == "windows" ]]; then
source venv/Scripts/activate
else
source venv/bin/activate
fi
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
if [[ "$PLATFORM" == "windows" ]]; then
# Initialize MSVC environment variables
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
# Download and extract gettext binary
FILENAME="gettext0.21-iconv1.16-shared-64.zip"
curl -Lo build/$FILENAME "https://github.com/mlocati/gettext-iconv-windows/releases/download/v0.21-v1.16/$FILENAME"
unzip -o build/$FILENAME -d "$CMAKE_PREFIX_PATH"
fi
# VCPKG
# Setup VCPKG
./3rdparty/vcpkg/bootstrap-vcpkg.sh -disableMetrics
if [[ "$PLATFORM" == "windows" ]]; then
VCPKG=./3rdparty/vcpkg/vcpkg.exe
else
VCPKG=./3rdparty/vcpkg/vcpkg
fi
# Install VCPKG packages
$VCPKG install --x-install-root $CMAKE_PREFIX_PATH gettext gettext-libintl
# Copy installed packages into install prefix
for package in ./3rdparty/vcpkg/packages/*; do
echo $package
cp -rf $package/* $CMAKE_PREFIX_PATH
cp -rf $package/* ./install
done
# KDE Frameworks
tier_0="
./3rdparty/extra-cmake-modules
"
tier_1="
./3rdparty/kcoreaddons
./3rdparty/ki18n
./3rdparty/kcrash
./3rdparty/kirigami
"
tier_2="
"
tier_3="
"
for dependency in $tier_0 $tier_1 $tier_2 $tier_3; do
echo -e "\n\n~~~" $dependency "~~~\n"
if $CLEAR_ALL; then
rm -dRf $dependency/build
fi
cmake -DCMAKE_CONFIGURATION_TYPES=$CMAKE_CONFIGURATION_TYPES -DBUILD_TESTING=OFF -BUILD_QCH=OFF -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH -DCMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX -B ./$dependency/build ./$dependency/
cmake --build ./$dependency/build --config $CMAKE_BUILD_TYPE
DESTDIR=$AppDir cmake --install ./$dependency/build
cp -r $AppDirUsr/* $CMAKE_PREFIX_PATH
done
echo "QHotkey"
if $CLEAR_ALL; then
rm -dRf 3rdparty/QHotkey/build
fi
cmake -DCMAKE_CONFIGURATION_TYPES=$CMAKE_CONFIGURATION_TYPES -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH -DCMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX -DBUILD_SHARED_LIBS=ON -DQT_DEFAULT_MAJOR_VERSION=$QT_MAJOR_VERSION -B ./3rdparty/QHotkey/build ./3rdparty/QHotkey/
cmake --build ./3rdparty/QHotkey/build --config $CMAKE_BUILD_TYPE
DESTDIR=$AppDir cmake --install ./3rdparty/QHotkey/build
cp -r $AppDirUsr/* $CMAKE_PREFIX_PATH
echo "QPrompt"
cmake -DCMAKE_CONFIGURATION_TYPES=$CMAKE_CONFIGURATION_TYPES -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH -DCMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX -B ./build .
cmake --build ./build --config $CMAKE_BUILD_TYPE
DESTDIR=$AppDir cmake --install ./build
# Copy Qt libraries into install directory
if [[ "$PLATFORM" == "windows" ]]; then
PATH=$PATH:"C:\Program Files (x86)\NSIS"
$CMAKE_PREFIX_PATH/bin/windeployqt.exe ./install/bin/$CMAKE_BUILD_TYPE/QPrompt.exe
elif [[ "$PLATFORM" == "linux" ]]; then
if [ "$ARCHITECTURE" == "aarch64" ]; then
cp -r $AppDirUsr/lib/aarch64-linux-gnu/* $CMAKE_PREFIX_PATH/lib/
fi
mkdir -p ~/Applications/
wget -nc -P ~/Applications/ https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-$ARCHITECTURE.AppImage
# wget -nc -P ~/Applications/ https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-$ARCHITECTURE.AppImage
LINUX_DEPLOY=~/Applications/linuxdeploy-$ARCHITECTURE.AppImage
# LINUX_DEPLOY_QT=~/Applications/linuxdeploy-$ARCHITECTURE.AppImage
chmod +x $LINUX_DEPLOY
# chmod +x $LINUX_DEPLOY_QT
if ! command -v $LINUX_DEPLOY 2>&1 >/dev/null; then
echo "$LINUX_DEPLOY could not be found"
exit 1
fi
# if ! command -v $LINUX_DEPLOY_QT 2>&1 >/dev/null; then
# echo "$LINUX_DEPLOY could not be found"
# exit 1
# fi
$LINUX_DEPLOY --appdir $AppDir --output appimage # --plugin qt
fi
cd build
cpack
cd ..