From c3bcf438af2dc157641c8ca99e22c3d3a85294b9 Mon Sep 17 00:00:00 2001 From: p2r3 Date: Sat, 28 Sep 2024 02:57:24 +0300 Subject: [PATCH] streamline the dependency build process --- .gitignore | 3 +- CMakeLists.txt | 17 ++++--- deps.sh | 111 +++++++++++++++++++++++++++++++++++++--------- qt5setup.sh | 1 + tools/curl.cpp | 8 ++-- tools/curl.h | 6 +-- tools/install.cpp | 9 +++- tools/js.cpp | 8 ++-- windeps.sh | 33 -------------- 9 files changed, 120 insertions(+), 76 deletions(-) mode change 100644 => 100755 deps.sh delete mode 100755 windeps.sh diff --git a/.gitignore b/.gitignore index 8b8e739..32797b1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,4 @@ ui/*.h qt5 qt5build fonts -win -duktape +deps diff --git a/CMakeLists.txt b/CMakeLists.txt index f4b2e7c..9777e1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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} ) @@ -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" ) @@ -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() diff --git a/deps.sh b/deps.sh old mode 100644 new mode 100755 index baf292c..1391c85 --- a/deps.sh +++ b/deps.sh @@ -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 diff --git a/qt5setup.sh b/qt5setup.sh index d0b3da5..8743674 100755 --- a/qt5setup.sh +++ b/qt5setup.sh @@ -34,6 +34,7 @@ git checkout 5.15 mkdir build cd build +make clean function configure_linux { ../configure -release -opensource -confirm-license \ diff --git a/tools/curl.cpp b/tools/curl.cpp index 1e82b8b..158d95a 100644 --- a/tools/curl.cpp +++ b/tools/curl.cpp @@ -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 @@ -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 diff --git a/tools/curl.h b/tools/curl.h index fe510f8..b0c28a3 100644 --- a/tools/curl.h +++ b/tools/curl.h @@ -4,11 +4,9 @@ #include #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 { diff --git a/tools/install.cpp b/tools/install.cpp index b4d9189..c4cf239 100644 --- a/tools/install.cpp +++ b/tools/install.cpp @@ -8,20 +8,25 @@ #include #include #include -#include -#include + #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 #include #include #include #include #else + #include + #include + #include #include #endif diff --git a/tools/js.cpp b/tools/js.cpp index b0a639b..0aa0c96 100644 --- a/tools/js.cpp +++ b/tools/js.cpp @@ -4,14 +4,12 @@ #include #include #include -#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 diff --git a/windeps.sh b/windeps.sh deleted file mode 100755 index 5fcd1da..0000000 --- a/windeps.sh +++ /dev/null @@ -1,33 +0,0 @@ -rm -rf win -mkdir win -cd win - -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