[libirecovery] Add tools feature (#33868)

* [libirecovery] Add tools feature

* Update version database

* Remove tools from default-features

* Update version database
This commit is contained in:
Weihang Ding 2023-09-23 07:05:44 +08:00 коммит произвёл GitHub
Родитель 7c13895ff7
Коммит 2337b851fe
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 91 добавлений и 21 удалений

Просмотреть файл

@ -23,17 +23,3 @@ index 45ff6f2..d9ff1e6 100644
struct irecv_client_private {
int debug;
int usb_config;
diff --git a/tools/irecovery.c b/tools/irecovery.c
index 34e80bf..deffe89 100644
--- a/tools/irecovery.c
+++ b/tools/irecovery.c
@@ -27,7 +27,9 @@
#include <stdio.h>
#include <stdlib.h>
+#ifndef _MSC_VER
#include <unistd.h>
+#endif
#include <string.h>
#include <getopt.h>
#include <inttypes.h>

Просмотреть файл

@ -0,0 +1,14 @@
diff --git a/tools/irecovery.c b/tools/irecovery.c
index 34e80bf..deffe89 100644
--- a/tools/irecovery.c
+++ b/tools/irecovery.c
@@ -27,7 +27,9 @@
#include <stdio.h>
#include <stdlib.h>
+#ifndef _MSC_VER
#include <unistd.h>
+#endif
#include <string.h>
#include <getopt.h>
#include <inttypes.h>

Просмотреть файл

@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(libirecovery C)
option(BUILD_TOOLS "Build tools." OFF)
include(GNUInstallDirs)
file(GLOB_RECURSE LIBIRECOVERY_HEADER include/*.h)
@ -22,17 +24,16 @@ endif()
if(WIN32)
list(APPEND DEFINITIONS -D_CRT_SECURE_NO_WARNINGS)
list(APPEND DEFINITIONS -DWIN32_LEAN_AND_MEAN)
list(APPEND DEFINITIONS -DWIN32)
endif()
find_package(unofficial-libimobiledevice-glue CONFIG REQUIRED)
add_library(libirecovery ${LIBIRECOVERY_SOURCE})
target_include_directories(libirecovery
PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
PUBLIC
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
target_include_directories(libirecovery PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
target_compile_definitions(libirecovery PRIVATE ${DEFINITIONS})
target_link_libraries(libirecovery
@ -85,3 +86,40 @@ install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/libirecovery-1.0.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
)
if(BUILD_TOOLS)
add_executable(irecovery "tools/irecovery.c")
target_compile_definitions(irecovery PRIVATE
-DPACKAGE_VERSION="1.1.0"
-DPACKAGE_URL="https://github.com/libimobiledevice/libirecovery"
-DPACKAGE_BUGREPORT="https://github.com/libimobiledevice/libirecovery/issues"
)
if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(irecovery PRIVATE -DIRECV_STATIC)
endif()
if(WIN32)
target_compile_definitions(irecovery PRIVATE
-D_CRT_SECURE_NO_WARNINGS
-DWIN32_LEAN_AND_MEAN
-DWIN32
)
find_package(unofficial-getopt-win32 REQUIRED)
target_link_libraries(irecovery PRIVATE unofficial::getopt-win32::getopt Ws2_32)
endif()
if(APPLE)
target_compile_definitions(irecovery PRIVATE -DHAVE_IOKIT)
target_link_libraries(irecovery PRIVATE "-framework IOKit" "-framework CoreFoundation")
endif()
if(NOT WIN32 AND NOT APPLE)
find_package(libusb CONFIG REQUIRED)
target_include_directories(irecovery PRIVATE ${LIBUSB_INCLUDE_DIRS})
target_link_libraries(irecovery PRIVATE ${LIBUSB_LIBRARIES})
endif()
find_package(PkgConfig REQUIRED)
pkg_check_modules(readline REQUIRED IMPORTED_TARGET readline)
target_link_libraries(irecovery PRIVATE libirecovery PkgConfig::readline)
install(
TARGETS irecovery
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
endif()

Просмотреть файл

@ -8,17 +8,33 @@ vcpkg_from_github(
001_fix_static_build.patch
002_fix_api.patch
003_fix_msvc.patch
004_fix_tools_msvc.patch
)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
tools BUILD_TOOLS
)
if("tools" IN_LIST FEATURES)
vcpkg_find_acquire_program(PKGCONFIG)
list(APPEND FEATURE_OPTIONS "-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}")
endif()
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 irecovery AUTO_CLEAN)
endif()
if (VCPKG_LIBRARY_LINKAGE STREQUAL "static")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/libirecovery.h"

Просмотреть файл

@ -1,6 +1,7 @@
{
"name": "libirecovery",
"version-date": "2023-05-13",
"port-version": 1,
"description": "Library and utility to talk to iBoot/iBSS via USB on Mac OS X, Windows, and Linux",
"homepage": "https://libimobiledevice.org/",
"license": "LGPL-2.1-or-later",
@ -19,5 +20,15 @@
"name": "vcpkg-cmake-config",
"host": true
}
]
],
"features": {
"tools": {
"description": "build command line tool",
"supports": "!android & !ios & !xbox",
"dependencies": [
"getopt",
"readline"
]
}
}
}

Просмотреть файл

@ -4294,7 +4294,7 @@
},
"libirecovery": {
"baseline": "2023-05-13",
"port-version": 0
"port-version": 1
},
"libjpeg-turbo": {
"baseline": "3.0.0",

Просмотреть файл

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "72b9637bc62e62eb478d09618545c419bf21ed48",
"version-date": "2023-05-13",
"port-version": 1
},
{
"git-tree": "0e9b8ce22a277344a7f29c62f38bf44458a129ba",
"version-date": "2023-05-13",