Skip to content

Commit 74bbac5

Browse files
committed
feat: Let CMake create the dll instead of doing so ourselves
We used to make the dll manually as we previously had 3 dlls: libtoxcore.dll, libtoxav.dll and libtoxencryptsave.dll, but for Windows we wanted them to be all combined into libtox.dll with all the dependencies included: libsodium, libopus, libvpx, pthreads, etc, to reduce the overall dll size and simplify linking. However, since CMake now produces a single libtoxcore.dll with toxcore, toxav and toxencryptsave included, we don't have to do this manually anymore. This results in the dll being named libtoxcore.dll instead of the libtox.dll that it previously was, matching the static libtoxcore.a's name.
1 parent 246642e commit 74bbac5

1 file changed

Lines changed: 6 additions & 41 deletions

File tree

other/docker/windows/build_toxcore.sh

100644100755
Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ build() {
2323

2424
rm -rf /tmp/*
2525

26-
# where to install static/shared toxcores before deciding whether they should be copied over to the user
27-
STATIC_TOXCORE_PREFIX_DIR="/tmp/static_prefix"
28-
SHARED_TOXCORE_PREFIX_DIR="/tmp/shared_prefix"
29-
mkdir -p "$STATIC_TOXCORE_PREFIX_DIR" "$SHARED_TOXCORE_PREFIX_DIR"
30-
3126
export MAKEFLAGS=j"$(nproc)"
3227
export CFLAGS="-D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS -ftrivial-auto-var-init=zero -fPIE -pie -fstack-protector-strong -fstack-clash-protection -fcf-protection=full"
3328

@@ -76,11 +71,12 @@ build() {
7671
CFLAGS="$CFLAGS $TOXCORE_CFLAGS" \
7772
cmake \
7873
-DCMAKE_TOOLCHAIN_FILE=windows_toolchain.cmake \
79-
-DCMAKE_INSTALL_PREFIX="$STATIC_TOXCORE_PREFIX_DIR" \
74+
-DCMAKE_INSTALL_PREFIX="$RESULT_PREFIX_DIR" \
8075
-DCMAKE_BUILD_TYPE="Release" \
81-
-DENABLE_SHARED=OFF \
76+
-DENABLE_SHARED=ON \
8277
-DENABLE_STATIC=ON \
8378
-DCMAKE_EXE_LINKER_FLAGS="-static" \
79+
-DCMAKE_SHARED_LINKER_FLAGS="-static" \
8480
"${EXTRA_CMAKE_FLAGS_ARRAY[@]}" \
8581
-S ..
8682
cmake --build . --target install --parallel "$(nproc)"
@@ -97,10 +93,12 @@ build() {
9793

9894
winecfg
9995
export CTEST_OUTPUT_ON_FAILURE=1
100-
# add libgcc_s_sjlj-1.dll libwinpthread-1.dll into PATH env var of wine
96+
# we don't have to do this since autotests are statically compiled now,
97+
# but just in case add MinGW-w64 dll locations to the PATH anyway
10198
export WINEPATH="$(
10299
cd /usr/lib/gcc/"$WINDOWS_TOOLCHAIN"/*win32/
103100
winepath -w "$PWD"
101+
cd -
104102
)"\;"$(winepath -w /usr/"$WINDOWS_TOOLCHAIN"/lib/)"
105103

106104
if [ "$ALLOW_TEST_FAILURE" = "true" ]; then
@@ -113,41 +111,8 @@ build() {
113111
fi
114112

115113
# move static dependencies
116-
cp -a "$STATIC_TOXCORE_PREFIX_DIR"/* "$RESULT_PREFIX_DIR"
117114
cp -a "$DEP_PREFIX_DIR"/* "$RESULT_PREFIX_DIR"
118115

119-
# make libtox.dll
120-
cd "$SHARED_TOXCORE_PREFIX_DIR"
121-
for archive in "$STATIC_TOXCORE_PREFIX_DIR"/lib/libtox*.a; do
122-
"$WINDOWS_TOOLCHAIN"-ar xv "$archive"
123-
done
124-
125-
if [ "$CROSS_COMPILE" = "true" ]; then
126-
LIBWINPTHREAD="/usr/$WINDOWS_TOOLCHAIN/lib/libwinpthread.a"
127-
cd "/usr/lib/gcc/$WINDOWS_TOOLCHAIN"/*win32/
128-
LIBSSP="$PWD/libssp.a"
129-
cd -
130-
else
131-
LIBWINPTHREAD="/usr/$WINDOWS_TOOLCHAIN/sys-root/mingw/lib/libwinpthread.a"
132-
LIBSSP="/usr/$WINDOWS_TOOLCHAIN/sys-root/mingw/lib/libssp.a"
133-
fi
134-
135-
"$WINDOWS_TOOLCHAIN"-gcc -Wl,--export-all-symbols \
136-
-Wl,--out-implib=libtox.dll.a \
137-
-shared \
138-
-o libtox.dll \
139-
*.obj \
140-
"$STATIC_TOXCORE_PREFIX_DIR"/lib/*.a \
141-
"$DEP_PREFIX_DIR"/lib/*.a \
142-
"$LIBWINPTHREAD" \
143-
-liphlpapi \
144-
-lws2_32 \
145-
-static-libgcc \
146-
"$LIBSSP"
147-
cp libtox.dll.a "$RESULT_PREFIX_DIR"/lib
148-
mkdir -p "$RESULT_PREFIX_DIR"/bin
149-
cp libtox.dll "$RESULT_PREFIX_DIR"/bin
150-
151116
rm -rf /tmp/*
152117

153118
# remove everything from include directory except tox headers

0 commit comments

Comments
 (0)