[libplist] Add tools feature (#33837)

* [libplist] Add tools feature

* Update version database

* Remove tools from default-features

* Update version database

* Optimize STDIN_FILENO macro in patch

* Update version database
This commit is contained in:
Weihang Ding 2023-09-20 00:52:57 +08:00 committed by GitHub
parent 25c41db771
commit d55379ba17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 73 additions and 16 deletions

View File

@ -0,0 +1,18 @@
diff --git a/tools/plistutil.c b/tools/plistutil.c
index 8121a7d..98b440e 100644
--- a/tools/plistutil.c
+++ b/tools/plistutil.c
@@ -32,10 +32,13 @@
#include <string.h>
#include <sys/stat.h>
#include <errno.h>
+#ifndef _MSC_VER
#include <unistd.h>
+#endif
#ifdef _MSC_VER
#pragma warning(disable:4996)
+#define STDIN_FILENO _fileno(stdin)
#endif
typedef struct _options

View File

@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(libplist C CXX)
option(BUILD_TOOLS "Build tools." OFF)
include(GNUInstallDirs)
file(GLOB_RECURSE LIBCNARY_SOURCE libcnary/node.c libcnary/node_list.c)
@ -26,13 +28,11 @@ if(WIN32)
endif()
add_library(libplist ${LIBPLIST_SOURCE} ${LIBCNARY_SOURCE})
target_include_directories(libplist
PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/libcnary/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src>"
PUBLIC
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
target_include_directories(libplist PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/libcnary/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
target_compile_definitions(libplist PRIVATE ${DEFINITIONS})
set_target_properties(libplist PROPERTIES OUTPUT_NAME plist-2.0)
@ -41,13 +41,11 @@ if(UNIX AND NOT APPLE)
endif()
add_library(libplist++ STATIC ${LIBPLISTPP_SOURCE} ${LIBCNARY_SOURCE})
target_include_directories(libplist++
PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/libcnary/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src>"
PUBLIC
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
target_include_directories(libplist++ PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/libcnary/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
target_compile_definitions(libplist++ PRIVATE ${DEFINITIONS})
target_link_libraries(libplist++ PUBLIC libplist)
@ -85,3 +83,21 @@ foreach(PLIST_PKGCONFIG libplist-2.0.pc libplist++-2.0.pc)
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
)
endforeach()
if(BUILD_TOOLS)
add_executable(plistutil "tools/plistutil.c")
target_compile_definitions(plistutil PRIVATE
-DPACKAGE_VERSION="2.3.0"
-DPACKAGE_URL="https://github.com/libimobiledevice/libplist"
-DPACKAGE_BUGREPORT="https://github.com/libimobiledevice/libplist/issues"
)
if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(plistutil PRIVATE -DLIBPLIST_STATIC)
endif()
target_link_libraries(plistutil PRIVATE libplist)
install(
TARGETS plistutil
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
endif()

View File

@ -8,17 +8,28 @@ 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
)
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 plistutil AUTO_CLEAN)
endif()
if (VCPKG_LIBRARY_LINKAGE STREQUAL "static")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/plist/plist.h"

View File

@ -1,6 +1,7 @@
{
"name": "libplist",
"version-date": "2023-06-15",
"port-version": 1,
"description": "A library to handle Apple Property List format in binary or XML",
"homepage": "https://libimobiledevice.org/",
"license": "LGPL-2.1-or-later",
@ -13,5 +14,11 @@
"name": "vcpkg-cmake-config",
"host": true
}
]
],
"features": {
"tools": {
"description": "build command line tool",
"supports": "!android & !ios & !xbox"
}
}
}

View File

@ -4498,7 +4498,7 @@
},
"libplist": {
"baseline": "2023-06-15",
"port-version": 0
"port-version": 1
},
"libpmemobj-cpp": {
"baseline": "1.13.0",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "c0550bd82aaa3f3ae23f9b481285c6cb9f92b44c",
"version-date": "2023-06-15",
"port-version": 1
},
{
"git-tree": "8a79aaf94792ae73eea5094eebac773fe6705b54",
"version-date": "2023-06-15",