diff --git a/CMakeLists.txt b/CMakeLists.txt index 59cbf2b..c2fc60e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/cmake/win-deploy.cmake b/cmake/win-deploy.cmake new file mode 100644 index 0000000..bd8684b --- /dev/null +++ b/cmake/win-deploy.cmake @@ -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 ===") diff --git a/src/core/services/get-device-info.cpp b/src/core/services/get-device-info.cpp index 62b498e..b418935 100644 --- a/src/core/services/get-device-info.cpp +++ b/src/core/services/get-device-info.cpp @@ -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, diff --git a/src/core/services/get_mounted_image.cpp b/src/core/services/get_mounted_image.cpp index a714861..f1acafb 100644 --- a/src/core/services/get_mounted_image.cpp +++ b/src/core/services/get_mounted_image.cpp @@ -25,7 +25,9 @@ #include #include #include +#ifndef _WIN32 #include +#endif QPair _get_mounted_image(const char *udid) { diff --git a/src/core/services/mount_dev_image.cpp b/src/core/services/mount_dev_image.cpp index b3c44fb..13a5c93 100644 --- a/src/core/services/mount_dev_image.cpp +++ b/src/core/services/mount_dev_image.cpp @@ -19,9 +19,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#define _GNU_SOURCE 1 #include "../../iDescriptor.h" #include -#define _GNU_SOURCE 1 #define __USE_GNU 1 #include #include @@ -45,7 +45,9 @@ #include #include #include +#ifndef _WIN32 #include +#endif static int list_mode = 0; static int use_network = 0; diff --git a/src/core/services/set_location.cpp b/src/core/services/set_location.cpp index 3f43368..ae70f80 100644 --- a/src/core/services/set_location.cpp +++ b/src/core/services/set_location.cpp @@ -35,6 +35,9 @@ #include #include #define htobe32(x) OSSwapHostToBigInt32(x) +#elif defined(_WIN32) +#include +#define htobe32(x) htonl(x) #else #include #endif