Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libplist] Add tools feature #33837

Merged
merged 6 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions ports/libplist/004_fix_tools_msvc.patch
Original file line number Diff line number Diff line change
@@ -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
44 changes: 30 additions & 14 deletions ports/libplist/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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()
11 changes: 11 additions & 0 deletions ports/libplist/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 8 additions & 1 deletion ports/libplist/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -13,5 +14,11 @@
"name": "vcpkg-cmake-config",
"host": true
}
]
],
"features": {
"tools": {
"description": "build command line tool",
"supports": "!android & !ios & !xbox"
}
}
}
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4498,7 +4498,7 @@
},
"libplist": {
"baseline": "2023-06-15",
"port-version": 0
"port-version": 1
},
"libpmemobj-cpp": {
"baseline": "1.13.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/libplist.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "c0550bd82aaa3f3ae23f9b481285c6cb9f92b44c",
"version-date": "2023-06-15",
"port-version": 1
},
{
"git-tree": "8a79aaf94792ae73eea5094eebac773fe6705b54",
"version-date": "2023-06-15",
Expand Down