-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathautobuild.sh
More file actions
executable file
·137 lines (111 loc) · 4 KB
/
autobuild.sh
File metadata and controls
executable file
·137 lines (111 loc) · 4 KB
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
#!/usr/bin/env bash
set -e
build_root=${BUILD_ROOT:-"$PWD"}
target_windows=false
target_linux=false
for arg in "$@"; do
if [ "$arg" == "--win" ] || [ "$arg" == "--windows" ]; then
echo "Building Qt5 for Windows..."
target_windows=true
elif [ "$arg" == "--both" ]; then
echo "Building Qt5 for Linux and Windows..."
target_windows=true
target_linux=true
elif [ "$arg" == "--linux" ]; then
echo "Building Qt5 for Linux..."
target_linux=true
fi
done
if [ "$#" -eq 0 ]; then
echo "No arguments provided. Assuming Linux build..."
target_linux=true
fi
# Pull, configure, and statically build Qt5.
# Doing this, of course, assumes you agree to comply with the Qt open source licence.
if [ ! -d "$build_root/qt5build" ]; then
cd $build_root/scripts
if [ "$target_both" == true ]; then
./qt5setup.sh --both
elif [ "$target_windows" == true ]; then
./qt5setup.sh --win
else
./qt5setup.sh
fi
cd $build_root
fi
echo "Using build root: $build_root"
cd $build_root
# Compile UI files into headers.
echo "Compiling UI files..."
cd $build_root/ui
ui_path="win32";
if [ "$target_linux" == true ]; then
ui_path="linux";
fi
$build_root/qt5build/$ui_path/bin/uic -o mainwindow.h MainWindow.ui
$build_root/qt5build/$ui_path/bin/uic -o packageitem.h PackageItem.ui
$build_root/qt5build/$ui_path/bin/uic -o errordialog.h ErrorDialog.ui
$build_root/qt5build/$ui_path/bin/uic -o packageinfo.h PackageInfo.ui
$build_root/qt5build/$ui_path/bin/uic -o repositories.h Repositories.ui
$build_root/qt5build/$ui_path/bin/uic -o settings.h Settings.ui
cd $build_root
# Build application dependencies if not present
if [ ! -d "./deps" ]; then
echo "Building dependencies..."
cd scripts
./deps.sh
cd $build_root
fi
# Create a directory for the distributable files.
mkdir -p dist
# Build for the specified platform(s) using CMake.
if [ "$target_windows" == true ]; then
rm -rf build; mkdir build; cd build
rm -rf $build_root/dist/win32; mkdir $build_root/dist/win32
sed -i "s|^// #define TARGET_WINDOWS|#define TARGET_WINDOWS|" $build_root/globals.h
cmake -DCMAKE_TOOLCHAIN_FILE="$build_root/scripts/windows.cmake" $build_root/scripts
make -j$(nproc)
mv ./SppliceCPP.exe $build_root/dist/win32/SppliceCPP.exe
cd $build_root
fi
if [ "$target_linux" == true ]; then
rm -rf build; mkdir build; cd build
rm -rf $build_root/dist/linux; mkdir $build_root/dist/linux
sed -i "s|^#define TARGET_WINDOWS|// #define TARGET_WINDOWS|" $build_root/globals.h
cmake $build_root/scripts
make -j$(nproc)
mv ./SppliceCPP $build_root/dist/linux/SppliceCPP
cd $build_root
fi
cd dist
# Prepare the Windows binary for distribution.
if [ "$target_windows" == true ]; then
# Copy project dependencies
cp $build_root/deps/win32/lib/libcurl-4.dll ./win32
cp $build_root/deps/win32/lib/archive.dll ./win32
cp $build_root/deps/win32/lib/liblzma.dll ./win32
cp $build_root/deps/win32/lib/libcrypto-1_1-x64.dll ./win32
# Copy Qt5 dependencies
cp $build_root/qt5build/win32/bin/Qt5Core.dll ./win32
cp $build_root/qt5build/win32/bin/Qt5Gui.dll ./win32
cp $build_root/qt5build/win32/bin/Qt5Widgets.dll ./win32
# Copy Qt5 plugins
mkdir ./win32/platforms
cp -r $build_root/qt5build/win32/plugins/platforms/qwindows.dll ./win32/platforms
cp -r $build_root/qt5build/win32/plugins/imageformats ./win32
# Copy C++ dependencies
cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll ./win32
cp /usr/lib/gcc/x86_64-w64-mingw32/12-posix/libgcc_s_seh-1.dll ./win32
cp /usr/lib/gcc/x86_64-w64-mingw32/12-posix/libstdc++-6.dll ./win32
# Strip debug symbols
strip ./win32/SppliceCPP.exe
strip ./win32/*.dll
strip ./win32/platforms/*.dll
strip ./win32/imageformats/*.dll
fi
if [ "$target_linux" == true ]; then
# Strip debug symbols
strip ./linux/SppliceCPP
# Pack with UPX
$build_root/deps/shared/upx/upx --best --lzma ./linux/SppliceCPP
fi