Skip to content

Commit

Permalink
streamline the dependency build process
Browse files Browse the repository at this point in the history
  • Loading branch information
p2r3 committed Sep 27, 2024
1 parent f8fb9d0 commit c3bcf43
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 76 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ ui/*.h
qt5
qt5build
fonts
win
duktape
deps
17 changes: 12 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ add_executable(SppliceCPP
tools/repo.cpp
tools/js.cpp
tools/netcon.cpp
duktape/duktape.c
deps/shared/duktape/duktape.c
${RESOURCES}
)

Expand All @@ -81,9 +81,9 @@ target_link_libraries(SppliceCPP Qt5::Widgets)
if (SPPLICE_TARGET_WINDOWS) # If building for Windows:

target_link_libraries(SppliceCPP
"${CMAKE_CURRENT_SOURCE_DIR}/win/lib/archive.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/win/lib/liblzma.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/win/lib/libcurl-x64.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/deps/win32/lib/archive.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/deps/win32/lib/liblzma.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/deps/win32/lib/libcurl-x64.dll"
"libwininet.a"
"libws2_32.a"
)
Expand All @@ -98,11 +98,18 @@ else() # If building for Linux:
# Then, link the libraries to our binary.
target_link_libraries(SppliceCPP
# Dynamically linked libraries
curl
nghttp2
idn2
psl
ssl
crypto
zstd
z
# Statically linked libraries
${libacl_STATIC}
${libarchive_STATIC}
${liblzma_STATIC}
"${CMAKE_CURRENT_SOURCE_DIR}/deps/linux/lib/libcurl.a"
)

endif()
111 changes: 91 additions & 20 deletions deps.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,20 +1,91 @@
#!/bin/bash

# Potential dependencies for building on Debian.
# I do not guarantee that these are accurate.

sudo apt install \
libcurl4-openssl-dev \
libarchive-dev \
libxml2-dev \
liblzma-dev \
rapidjson-dev \
libacl1-dev \
\
make \
g++ \
pkg-config \
libgl1-mesa-dev \
libxcb*-dev \
libfontconfig1-dev \
libxkbcommon-x11-dev
# Builds statically linkable dependencies for both supported platforms
# On the Windows side, most of this is just unzipping and sorting pre-built binaries
# On the Linux side, we're only compiling CURL and installing Debian packages

rm -rf ./deps
mkdir deps
cd deps

mkdir win32
mkdir linux
mkdir shared

# Build shared dependencies
cd shared

wget https://duktape.org/duktape-2.7.0.tar.xz
tar -xf ./duktape-2.7.0.tar.xz
rm ./duktape-2.7.0.tar.xz
mv ./duktape-2.7.0/src ./duktape
rm -rf duktape-2.7.0

cd ..

# Build Windows dependencies
cd win32

mkdir bin
mkdir lib
mkdir include

mkdir xz; cd xz
wget https://tukaani.org/xz/xz-5.2.9-windows.zip
unzip xz-5.2.9-windows.zip
mv ./bin_x86-64/*.exe ../bin
mv ./bin_x86-64/* ../lib
cd ..; rm -rf xz

mkdir archive; cd archive
wget https://libarchive.org/downloads/libarchive-v3.7.4-amd64.zip
unzip libarchive-v3.7.4-amd64.zip
mv ./libarchive/bin/*.exe ../bin
mv ./libarchive/bin/*.dll ../lib
mv ./libarchive/lib/* ../lib
mv ./libarchive/include/* ../include
cd ..; rm -rf archive

mkdir curl; cd curl
wget https://curl.se/windows/dl-8.10.1_2/curl-8.10.1_2-win64-mingw.zip
unzip curl-8.10.1_2-win64-mingw.zip
mv curl-8.10.1_2-win64-mingw curl
mv ./curl/bin/*.exe ../bin
mv ./curl/bin/*.dll ../lib
mv ./curl/lib/* ../lib
mv ./curl/include/* ../include
cd ..; rm -rf curl

cd ..

# Build Linux dependencies
cd linux

mkdir bin
mkdir lib
mkdir include

mkdir curl; cd curl
wget https://curl.se/download/curl-8.10.1.zip
unzip curl-8.10.1.zip
mv curl-8.10.1 curl; cd curl
./configure --enable-optimize --with-openssl --disable-dependency-tracking --disable-shared --disable-ftp --disable-file --disable-ldap --disable-ldaps --disable-rtsp --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-mqtt --disable-manual --disable-docs --disable-sspi --disable-aws --disable-ntlm --disable-unix-sockets --disable-socketpair --disable-dateparse --disable-progress-meter --enable-websockets --without-brotli --without-libssh2 --without-libssh --without-wolfssh --without-librtmp
make
cd ..
mv ./curl/src/curl ../bin
mv ./curl/lib/.libs/libcurl.a ../lib
mv ./curl/include/* ../include
cd ..; rm -rf curl

cd ..

if command -v apt > /dev/null; then
echo "Checking for necessary -dev packages..."
sudo apt install \
libarchive-dev \
libxml2-dev \
liblzma-dev \
libacl1-dev \
libgl1-mesa-dev \
libxcb*-dev \
libfontconfig1-dev \
libxkbcommon-x11-dev
fi
1 change: 1 addition & 0 deletions qt5setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ git checkout 5.15

mkdir build
cd build
make clean

function configure_linux {
../configure -release -opensource -confirm-license \
Expand Down
8 changes: 3 additions & 5 deletions tools/curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
#include "curl.h"

#ifndef TARGET_WINDOWS
// If on Linux, include the system's CURL
#include "curl/curl.h"
#include "../deps/linux/include/curl/curl.h"
#else
// If on Windows, include the CURL from windeps.sh
#include "../win/include/curl/curl.h"
#include "../deps/win32/include/curl/curl.h"
#endif

// Initializes CURL globally
Expand Down Expand Up @@ -192,7 +190,7 @@ std::string ToolsCURL::wsReceive (CURL *curl, size_t size) {
char buffer[size];

// Receive the message
struct curl_ws_frame *meta;
const struct curl_ws_frame *meta;
CURLcode response = curl_ws_recv(curl, buffer, sizeof(buffer), &rlen, &meta);

// If the socket is not ready, assume there's just no data to be read
Expand Down
6 changes: 2 additions & 4 deletions tools/curl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
#include <filesystem>

#ifndef TARGET_WINDOWS
// If on Linux, include the system's CURL
#include "curl/curl.h"
#include "../deps/linux/include/curl/curl.h"
#else
// If on Windows, include the CURL from windeps.sh
#include "../win/include/curl/curl.h"
#include "../deps/win32/include/curl/curl.h"
#endif

class ToolsCURL {
Expand Down
9 changes: 7 additions & 2 deletions tools/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,25 @@
#include <cstdlib>
#include <thread>
#include <chrono>
#include <archive.h>
#include <archive_entry.h>

#include "../globals.h" // Project globals
#include "curl.h" // ToolsCURL
#include "qt.h" // ToolsQT
#include "js.h" // ToolsJS

#ifdef TARGET_WINDOWS
#include "../deps/win32/include/archive.h"
#include "../deps/win32/include/archive_entry.h"

#include <windows.h>
#include <tlhelp32.h>
#include <psapi.h>
#include <locale>
#include <codecvt>
#else
#include <archive.h>
#include <archive_entry.h>

#include <sys/stat.h>
#include <unistd.h>
#endif
Expand Down
8 changes: 3 additions & 5 deletions tools/js.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
#include <filesystem>
#include <thread>
#include <chrono>
#include "../duktape/duktape.h"
#include "../deps/shared/duktape/duktape.h"

#ifndef TARGET_WINDOWS
// If on Linux, include the system's CURL
#include "curl/curl.h"
#include "../deps/linux/include/curl/curl.h"
#else
// If on Windows, include the CURL from windeps.sh
#include "../win/include/curl/curl.h"
#include "../deps/win32/include/curl/curl.h"
#endif

#include "../globals.h" // Project globals
Expand Down
33 changes: 0 additions & 33 deletions windeps.sh

This file was deleted.

0 comments on commit c3bcf43

Please sign in to comment.