Add Windows deploy script and fix Windows build

This commit is contained in:
uncor3
2025-09-16 19:21:54 +00:00
parent b9bff056fd
commit 6812609d3f
6 changed files with 112 additions and 3 deletions
+15
View File
@@ -10,6 +10,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Platform-specific paths for libraries built from source
if(WIN32)
set(CUSTOM_LIB_PATH "C:/msys64/mingw64/lib")
set(CUSTOM_BIN_PATH "C:/msys64/mingw64/bin")
set(CUSTOM_INCLUDE_PATH "C:/msys64/mingw64/include")
set(CUSTOM_PKGCONFIG_PATH "C:/msys64/mingw64/lib/pkgconfig")
# Use Windows path separator for environment variables
@@ -228,3 +229,17 @@ install(TARGETS iDescriptor
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(iDescriptor)
endif()
# Copy runtime DLLs to build directory after building
if(WIN32)
add_custom_command(TARGET iDescriptor POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Starting Windows deployment..."
COMMAND ${CMAKE_COMMAND}
-DEXECUTABLE_PATH=${CMAKE_CURRENT_BINARY_DIR}/iDescriptor.exe
-DMSYS2_BIN_PATH=${CUSTOM_BIN_PATH}
-DOUTPUT_DIR=${CMAKE_CURRENT_BINARY_DIR}
-P ${CMAKE_CURRENT_LIST_DIR}/cmake/win-deploy.cmake
COMMENT "Deploying Windows application with all dependencies"
VERBATIM
)
endif()
+87
View File
@@ -0,0 +1,87 @@
# Windows deployment script for Qt applications with MinGW/MSYS2
# This script handles Qt deployment, runtime DLL copying, and GStreamer plugins
if(NOT EXISTS ${EXECUTABLE_PATH})
message(FATAL_ERROR "Executable not found: ${EXECUTABLE_PATH}")
endif()
message("=== Starting Windows deployment for: ${EXECUTABLE_PATH} ===")
# Step 1: Run windeployqt6 to copy Qt-related DLLs and plugins
message("Running windeployqt6 to deploy Qt dependencies...")
execute_process(
COMMAND ${MSYS2_BIN_PATH}/windeployqt6.exe --dir ${OUTPUT_DIR} --plugindir ${OUTPUT_DIR}/plugins ${EXECUTABLE_PATH}
RESULT_VARIABLE WINDEPLOYQT_RESULT
OUTPUT_VARIABLE WINDEPLOYQT_OUTPUT
ERROR_VARIABLE WINDEPLOYQT_ERROR
)
if(NOT WINDEPLOYQT_RESULT EQUAL 0)
message(WARNING "windeployqt6 failed: ${WINDEPLOYQT_ERROR}")
else()
message("windeployqt6 completed successfully")
endif()
# Step 2: Find and copy runtime dependencies using GET_RUNTIME_DEPENDENCIES
message("Analyzing runtime dependencies for: ${EXECUTABLE_PATH}")
file(GET_RUNTIME_DEPENDENCIES
EXECUTABLES ${EXECUTABLE_PATH}
RESOLVED_DEPENDENCIES_VAR DLLS
PRE_EXCLUDE_REGEXES "^api-ms-" "^ext-ms-" "^AVRT" "^avrt" "^MSVCP" "^VCRUNTIME" "^ucrtbase"
POST_EXCLUDE_REGEXES ".*system32/.*\\.dll" ".*SysWOW64/.*\\.dll" ".*Windows/.*\\.dll" ".*Microsoft.VC.*"
DIRECTORIES ${MSYS2_BIN_PATH} $ENV{PATH}
)
foreach(DLL ${DLLS})
get_filename_component(DLL_NAME ${DLL} NAME)
message("Copying dependency: ${DLL_NAME}")
file(COPY ${DLL} DESTINATION ${OUTPUT_DIR})
endforeach()
list(LENGTH DLLS DLL_COUNT)
message("Successfully copied ${DLL_COUNT} runtime DLL dependencies")
# Step 3: Copy GStreamer plugins
message("Copying GStreamer plugins...")
file(GLOB GSTREAMER_PLUGINS "${MSYS2_BIN_PATH}/../lib/gstreamer-1.0/*.dll")
if(GSTREAMER_PLUGINS)
# Create gstreamer-1.0 directory in output
file(MAKE_DIRECTORY ${OUTPUT_DIR}/gstreamer-1.0)
foreach(PLUGIN ${GSTREAMER_PLUGINS})
get_filename_component(PLUGIN_NAME ${PLUGIN} NAME)
message("Copying GStreamer plugin: ${PLUGIN_NAME}")
file(COPY ${PLUGIN} DESTINATION ${OUTPUT_DIR}/gstreamer-1.0)
endforeach()
list(LENGTH GSTREAMER_PLUGINS PLUGIN_COUNT)
message("Successfully copied ${PLUGIN_COUNT} GStreamer plugins")
else()
message(WARNING "No GStreamer plugins found in ${MSYS2_BIN_PATH}/../lib/gstreamer-1.0/")
endif()
# Step 4: Copy additional MinGW runtime DLLs that might be missed
set(ADDITIONAL_DLLS
"libgcc_s_seh-1.dll"
"libstdc++-6.dll"
"libwinpthread-1.dll"
"libgstreamer-1.0-0.dll"
"libgstbase-1.0-0.dll"
"libgobject-2.0-0.dll"
"libglib-2.0-0.dll"
"libintl-8.dll"
"libiconv-2.dll"
)
message("Copying additional MinGW runtime DLLs...")
foreach(DLL_NAME ${ADDITIONAL_DLLS})
set(DLL_PATH "${MSYS2_BIN_PATH}/${DLL_NAME}")
if(EXISTS ${DLL_PATH})
message("Copying additional DLL: ${DLL_NAME}")
file(COPY ${DLL_PATH} DESTINATION ${OUTPUT_DIR})
endif()
endforeach()
message("=== Windows deployment completed ===")
+2 -2
View File
@@ -76,8 +76,8 @@ plist_t get_device_info(const char *udid, int use_network, int simple,
}
plist_t disk_info = nullptr;
u_int64_t total_space = 0;
u_int64_t free_space = 0;
uint64_t total_space = 0;
uint64_t free_space = 0;
/* {
"AmountDataAvailable": 6663077888,
"AmountDataReserved": 209715200,
+2
View File
@@ -25,7 +25,9 @@
#include <libimobiledevice/notification_proxy.h>
#include <libtatsu/tss.h>
#include <plist/plist.h>
#ifndef _WIN32
#include <printf.h>
#endif
QPair<bool, plist_t> _get_mounted_image(const char *udid)
{
+3 -1
View File
@@ -19,9 +19,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define _GNU_SOURCE 1
#include "../../iDescriptor.h"
#include <stdlib.h>
#define _GNU_SOURCE 1
#define __USE_GNU 1
#include <errno.h>
#include <getopt.h>
@@ -45,7 +45,9 @@
#include <libimobiledevice/notification_proxy.h>
#include <libtatsu/tss.h>
#include <plist/plist.h>
#ifndef _WIN32
#include <printf.h>
#endif
static int list_mode = 0;
static int use_network = 0;
+3
View File
@@ -35,6 +35,9 @@
#include <libkern/OSByteOrder.h>
#include <machine/endian.h>
#define htobe32(x) OSSwapHostToBigInt32(x)
#elif defined(_WIN32)
#include <winsock2.h>
#define htobe32(x) htonl(x)
#else
#include <endian.h>
#endif