diff --git a/ports/libusbmuxd/005_fix_tools_msvc.patch b/ports/libusbmuxd/005_fix_tools_msvc.patch new file mode 100644 index 00000000000000..2804e61058f5e8 --- /dev/null +++ b/ports/libusbmuxd/005_fix_tools_msvc.patch @@ -0,0 +1,42 @@ +diff --git a/tools/inetcat.c b/tools/inetcat.c +index f70215b..748db15 100644 +--- a/tools/inetcat.c ++++ b/tools/inetcat.c +@@ -33,7 +33,9 @@ + #include + #include + #include ++#ifndef _MSC_VER + #include ++#endif + #include + #include + #ifdef WIN32 +@@ -50,6 +52,13 @@ + #include "usbmuxd.h" + #include + ++#ifdef _MSC_VER ++#include ++typedef SSIZE_T ssize_t; ++#define STDIN_FILENO _fileno(stdin) ++#define STDOUT_FILENO _fileno(stdout) ++#endif ++ + static int debug_level = 0; + + static size_t read_data_socket(int fd, uint8_t* buf, size_t bufsize) +diff --git a/tools/iproxy.c b/tools/iproxy.c +index d5f66b6..6510cb8 100644 +--- a/tools/iproxy.c ++++ b/tools/iproxy.c +@@ -34,7 +34,9 @@ + #include + #include + #include ++#ifndef _MSC_VER + #include ++#endif + #include + #include + #ifdef WIN32 diff --git a/ports/libusbmuxd/CMakeLists.txt b/ports/libusbmuxd/CMakeLists.txt index a13a9862690575..cfe8eae8a076ca 100644 --- a/ports/libusbmuxd/CMakeLists.txt +++ b/ports/libusbmuxd/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.15) project(libusbmuxd C) +option(BUILD_TOOLS "Build tools." OFF) + include(GNUInstallDirs) file(GLOB_RECURSE LIBUSBMUXD_HEADER include/*.h) @@ -25,6 +27,7 @@ endif() if(WIN32) list(APPEND DEFINITIONS -D_CRT_SECURE_NO_WARNINGS) + list(APPEND DEFINITIONS -DWIN32_LEAN_AND_MEAN) list(APPEND DEFINITIONS -DWIN32) endif() @@ -32,11 +35,9 @@ find_package(unofficial-libplist CONFIG REQUIRED) find_package(unofficial-libimobiledevice-glue CONFIG REQUIRED) add_library(libusbmuxd ${LIBUSBMUXD_SOURCE}) -target_include_directories(libusbmuxd - PRIVATE - "$" - PUBLIC - "$" +target_include_directories(libusbmuxd PUBLIC + "$" + "$" ) target_compile_definitions(libusbmuxd PRIVATE ${DEFINITIONS}) target_link_libraries(libusbmuxd @@ -82,3 +83,35 @@ install( FILES "${CMAKE_CURRENT_BINARY_DIR}/libusbmuxd-2.0.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" ) + +if(BUILD_TOOLS) + if(WIN32) + find_package(unofficial-getopt-win32 REQUIRED) + endif() + + function(add_tool name source) + add_executable("${name}" "${source}") + target_compile_definitions("${name}" PRIVATE + -DPACKAGE_VERSION="2.0.2" + -DPACKAGE_URL="https://github.com/libimobiledevice/libusbmuxd" + -DPACKAGE_BUGREPORT="https://github.com/libimobiledevice/libusbmuxd/issues" + ) + target_link_libraries("${name}" PRIVATE libusbmuxd unofficial::libimobiledevice-glue::libimobiledevice-glue) + if(WIN32) + target_compile_definitions("${name}" PRIVATE + -D_CRT_SECURE_NO_WARNINGS + -DWIN32_LEAN_AND_MEAN + -DWIN32 + ) + target_link_libraries("${name}" PRIVATE unofficial::getopt-win32::getopt Ws2_32) + endif() + endfunction(add_tool) + + add_tool(inetcat "tools/inetcat.c") + add_tool(iproxy "tools/iproxy.c") + + install( + TARGETS inetcat iproxy + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ) +endif() diff --git a/ports/libusbmuxd/portfile.cmake b/ports/libusbmuxd/portfile.cmake index 52bbb31df11d5c..3bd300e452858a 100644 --- a/ports/libusbmuxd/portfile.cmake +++ b/ports/libusbmuxd/portfile.cmake @@ -9,18 +9,29 @@ vcpkg_from_github( 002_fix_struct_pack.patch 003_fix_msvc.patch 004_fix_api.patch + 005_fix_tools_msvc.patch ) file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") file(COPY "${CMAKE_CURRENT_LIST_DIR}/exports.def" DESTINATION "${SOURCE_PATH}") +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + tools BUILD_TOOLS +) + vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${FEATURE_OPTIONS} ) vcpkg_cmake_install() vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-${PORT}) vcpkg_fixup_pkgconfig() +if("tools" IN_LIST FEATURES) + vcpkg_copy_tools(TOOL_NAMES inetcat iproxy AUTO_CLEAN) +endif() file(READ "${CURRENT_PACKAGES_DIR}/share/unofficial-${PORT}/unofficial-${PORT}-config.cmake" cmake_config) file(WRITE "${CURRENT_PACKAGES_DIR}/share/unofficial-${PORT}/unofficial-${PORT}-config.cmake" diff --git a/ports/libusbmuxd/vcpkg.json b/ports/libusbmuxd/vcpkg.json index f52434bb6f2615..78a75a3743715e 100644 --- a/ports/libusbmuxd/vcpkg.json +++ b/ports/libusbmuxd/vcpkg.json @@ -1,6 +1,7 @@ { "name": "libusbmuxd", "version-date": "2023-06-21", + "port-version": 1, "description": "A client library to multiplex connections from and to iOS devices", "homepage": "https://libimobiledevice.org/", "license": "LGPL-2.1-or-later", @@ -16,5 +17,14 @@ "name": "vcpkg-cmake-config", "host": true } - ] + ], + "features": { + "tools": { + "description": "build command line tool", + "supports": "!android & !ios & !xbox", + "dependencies": [ + "getopt" + ] + } + } } diff --git a/versions/baseline.json b/versions/baseline.json index 1ad0325c66d4e2..f65d12b975c511 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -4790,7 +4790,7 @@ }, "libusbmuxd": { "baseline": "2023-06-21", - "port-version": 0 + "port-version": 1 }, "libuuid": { "baseline": "1.0.3", diff --git a/versions/l-/libusbmuxd.json b/versions/l-/libusbmuxd.json index 0c252809c28981..f040decbac8f81 100644 --- a/versions/l-/libusbmuxd.json +++ b/versions/l-/libusbmuxd.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "ba5bfe9a2e679d22d3b3b520e432c493df3919e9", + "version-date": "2023-06-21", + "port-version": 1 + }, { "git-tree": "7a9145917e1df41e8820d26c2e167f3839d7a947", "version-date": "2023-06-21",