From 6717e1b9d053518e836ec11f49bd1d501b1a650e Mon Sep 17 00:00:00 2001 From: myd7349 Date: Fri, 24 Apr 2020 12:25:04 +0800 Subject: [PATCH] [iniparser] Add new port (#10710) * [iniparser] Add new port * [iniparser] Fix build errors on UWP * [iniparser] Move linkage check before code downloading --- ports/iniparser/CMakeLists.txt | 54 +++++++++++++++++++++++++++++ ports/iniparser/CONTROL | 4 +++ ports/iniparser/portfile.cmake | 26 ++++++++++++++ ports/iniparser/win32_ssize_t.patch | 29 ++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 ports/iniparser/CMakeLists.txt create mode 100644 ports/iniparser/CONTROL create mode 100644 ports/iniparser/portfile.cmake create mode 100644 ports/iniparser/win32_ssize_t.patch diff --git a/ports/iniparser/CMakeLists.txt b/ports/iniparser/CMakeLists.txt new file mode 100644 index 0000000000..9c4f6edf7f --- /dev/null +++ b/ports/iniparser/CMakeLists.txt @@ -0,0 +1,54 @@ +cmake_minimum_required(VERSION 3.14) + +project(iniparser LANGUAGES C) + +include(GNUInstallDirs) + +set(CMAKE_DISABLE_SOURCE_CHANGES ON) +set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) + +# iniparser.pc +set(prefix ${CMAKE_INSTALL_PREFIX}) +set(libdir ${prefix}/${CMAKE_INSTALL_LIBDIR}) +set(includedir ${prefix}/${CMAKE_INSTALL_INCLUDEDIR}) +set(datarootdir ${prefix}/${CMAKE_INSTALL_DATAROOTDIR}) +set(datadir ${prefix}/${CMAKE_INSTALL_DATADIR}) + +configure_file(iniparser.pc ${CMAKE_CURRENT_BINARY_DIR}/iniparser.pc) + +set(iniparser_sources + src/dictionary.c + src/iniparser.c +) + +add_library(iniparser ${iniparser_sources}) + +target_include_directories(iniparser + PUBLIC + $ + $ +) + +target_compile_definitions(iniparser + PRIVATE + $<$:_CRT_SECURE_NO_WARNINGS> +) + +install(TARGETS iniparser EXPORT unofficial-iniparser-config) + +install( + EXPORT unofficial-iniparser-config + NAMESPACE unofficial::iniparser:: + DESTINATION share/unofficial-iniparser + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ +) + +install( + FILES src/dictionary.h src/iniparser.h + DESTINATION include +) + +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/iniparser.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig +) diff --git a/ports/iniparser/CONTROL b/ports/iniparser/CONTROL new file mode 100644 index 0000000000..ee5f47c00d --- /dev/null +++ b/ports/iniparser/CONTROL @@ -0,0 +1,4 @@ +Source: iniparser +Version: 2020-04-06 +Homepage: ndevilla.free.fr/iniparser +Description: C library for parsing INI-style files diff --git a/ports/iniparser/portfile.cmake b/ports/iniparser/portfile.cmake new file mode 100644 index 0000000000..94eb59601e --- /dev/null +++ b/ports/iniparser/portfile.cmake @@ -0,0 +1,26 @@ +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO ndevilla/iniparser + REF f858275f7f307eecba84c2f5429483f9f28007f8 + SHA512 48c80b2163f86d8ca0f3253128d8528214e2f0680b4bceb686180c01b29cd2a0c3b9d6e7156a8e28649b14bc1d8a51b34c2d3d258013b35f69aaf6c3ded9ecdc + HEAD_REF master + PATCHES + win32_ssize_t.patch +) + +file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA +) + +vcpkg_install_cmake() + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) + +vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-${PORT} TARGET_PATH share/unofficial-${PORT}) + +file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) diff --git a/ports/iniparser/win32_ssize_t.patch b/ports/iniparser/win32_ssize_t.patch new file mode 100644 index 0000000000..3fefee6c8c --- /dev/null +++ b/ports/iniparser/win32_ssize_t.patch @@ -0,0 +1,29 @@ +diff --git a/src/dictionary.c b/src/dictionary.c +index cb7ccd4..7985ab3 100644 +--- a/src/dictionary.c ++++ b/src/dictionary.c +@@ -18,7 +18,6 @@ + #include + #include + #include +-#include + + /** Maximum value size for integers and doubles. */ + #define MAXVALSZ 1024 +diff --git a/src/dictionary.h b/src/dictionary.h +index d04b6ce..929ae17 100644 +--- a/src/dictionary.h ++++ b/src/dictionary.h +@@ -21,7 +21,12 @@ + #include + #include + #include ++#ifdef _MSC_VER ++#include ++typedef SSIZE_T ssize_t; ++#else + #include ++#endif + + #ifdef __cplusplus + extern "C" {