From 0d8b396a5a8420b9691b3e0fd8cd01de0bf4636d Mon Sep 17 00:00:00 2001 From: Weihang Ding <798047000@qq.com> Date: Fri, 28 Jul 2023 23:20:17 +0800 Subject: [PATCH] [vincentlaucsb-csv-parser] New port (#32780) --- .../001-fix-cmake.patch | 67 +++++++++++++++++++ .../002-fix-include.patch | 45 +++++++++++++ ports/vincentlaucsb-csv-parser/portfile.cmake | 37 ++++++++++ ports/vincentlaucsb-csv-parser/usage | 4 ++ ports/vincentlaucsb-csv-parser/vcpkg.json | 21 ++++++ versions/baseline.json | 4 ++ versions/v-/vincentlaucsb-csv-parser.json | 9 +++ 7 files changed, 187 insertions(+) create mode 100644 ports/vincentlaucsb-csv-parser/001-fix-cmake.patch create mode 100644 ports/vincentlaucsb-csv-parser/002-fix-include.patch create mode 100644 ports/vincentlaucsb-csv-parser/portfile.cmake create mode 100644 ports/vincentlaucsb-csv-parser/usage create mode 100644 ports/vincentlaucsb-csv-parser/vcpkg.json create mode 100644 versions/v-/vincentlaucsb-csv-parser.json diff --git a/ports/vincentlaucsb-csv-parser/001-fix-cmake.patch b/ports/vincentlaucsb-csv-parser/001-fix-cmake.patch new file mode 100644 index 00000000000000..a86da83bc2207b --- /dev/null +++ b/ports/vincentlaucsb-csv-parser/001-fix-cmake.patch @@ -0,0 +1,67 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e729a8b..c63edab 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,6 +1,12 @@ + cmake_minimum_required(VERSION 3.9) + project(csv) + ++include(GNUInstallDirs) ++ ++find_path(HEDLEY_INCLUDE_DIRS "hedley.h") ++find_package(mio CONFIG REQUIRED) ++find_package(string-view-lite CONFIG REQUIRED) ++ + if(CSV_CXX_STANDARD) + set(CMAKE_CXX_STANDARD ${CSV_CXX_STANDARD}) + else() +@@ -38,16 +44,27 @@ set(CSV_TEST_DIR ${CMAKE_CURRENT_LIST_DIR}/tests) + + include_directories(${CSV_INCLUDE_DIR}) + +-## Load developer specific CMake settings +-if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) +- SET(CSV_DEVELOPER TRUE) +-endif() ++SET(CSV_DEVELOPER OFF) + + ## Main Library + add_subdirectory(${CSV_SOURCE_DIR}) + +-## Executables +-add_subdirectory("programs") ++install(TARGETS csv EXPORT unofficial-vincentlaucsb-csv-parser) ++ ++install( ++ EXPORT unofficial-vincentlaucsb-csv-parser ++ FILE unofficial-vincentlaucsb-csv-parser-config.cmake ++ DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/unofficial-vincentlaucsb-csv-parser" ++ NAMESPACE unofficial::vincentlaucsb-csv-parser:: ++) ++ ++install( ++ DIRECTORY "${CMAKE_SOURCE_DIR}/include/" ++ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/vincentlaucsb-csv-parser" ++ PATTERN "*.cpp" EXCLUDE ++ PATTERN "CMakeLists.txt" EXCLUDE ++ PATTERN "external" EXCLUDE ++) + + ## Developer settings + if (CSV_DEVELOPER) +diff --git a/include/internal/CMakeLists.txt b/include/internal/CMakeLists.txt +index 42cac24..30ea9e7 100644 +--- a/include/internal/CMakeLists.txt ++++ b/include/internal/CMakeLists.txt +@@ -23,5 +23,9 @@ target_sources(csv + data_type.h + ) + +-set_target_properties(csv PROPERTIES LINKER_LANGUAGE CXX) +-target_link_libraries(csv PRIVATE Threads::Threads) ++set_target_properties(csv PROPERTIES LINKER_LANGUAGE CXX OUTPUT_NAME "vincentlaucsb-csv-parser-csv") ++target_include_directories(csv ++ PUBLIC ${HEDLEY_INCLUDE_DIRS} ++ INTERFACE $ ++) ++target_link_libraries(csv PRIVATE Threads::Threads PUBLIC mio::mio mio::mio-headers nonstd::string-view-lite) diff --git a/ports/vincentlaucsb-csv-parser/002-fix-include.patch b/ports/vincentlaucsb-csv-parser/002-fix-include.patch new file mode 100644 index 00000000000000..18e818a4d5bd08 --- /dev/null +++ b/ports/vincentlaucsb-csv-parser/002-fix-include.patch @@ -0,0 +1,45 @@ +diff --git a/include/internal/basic_csv_parser.hpp b/include/internal/basic_csv_parser.hpp +index d76b2d9..8dd0110 100644 +--- a/include/internal/basic_csv_parser.hpp ++++ b/include/internal/basic_csv_parser.hpp +@@ -15,7 +15,7 @@ + #include + #include + +-#include "../external/mio.hpp" ++#include "mio/mmap.hpp" + #include "col_names.hpp" + #include "common.hpp" + #include "csv_format.hpp" +diff --git a/include/internal/common.hpp b/include/internal/common.hpp +index c132bfb..dff4d03 100644 +--- a/include/internal/common.hpp ++++ b/include/internal/common.hpp +@@ -28,12 +28,12 @@ + #pragma once + #include + +-#include "../external/string_view.hpp" ++#include "nonstd/string_view.hpp" + + // If there is another version of Hedley, then the newer one + // takes precedence. + // See: https://github.com/nemequ/hedley +-#include "../external/hedley.h" ++#include "hedley.h" + + namespace csv { + #ifdef _MSC_VER +diff --git a/include/internal/csv_reader.hpp b/include/internal/csv_reader.hpp +index 798ef3b..007fa23 100644 +--- a/include/internal/csv_reader.hpp ++++ b/include/internal/csv_reader.hpp +@@ -15,7 +15,7 @@ + #include + #include + +-#include "../external/mio.hpp" ++#include "mio/mmap.hpp" + #include "basic_csv_parser.hpp" + #include "common.hpp" + #include "data_type.h" diff --git a/ports/vincentlaucsb-csv-parser/portfile.cmake b/ports/vincentlaucsb-csv-parser/portfile.cmake new file mode 100644 index 00000000000000..931943870e5a39 --- /dev/null +++ b/ports/vincentlaucsb-csv-parser/portfile.cmake @@ -0,0 +1,37 @@ +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO vincentlaucsb/csv-parser + REF "${VERSION}" + SHA512 26ed124ebe9592931ad141bdc53569537b7599de2ba6a7230d4a514cba27bf2684f2b320be9a39a7c5277fcfd75eb972aa3a39bd9613dd237f865b50f5437178 + HEAD_REF master + PATCHES + 001-fix-cmake.patch + 002-fix-include.patch +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DBUILD_PYTHON=OFF + MAYBE_UNUSED_VARIABLES + BUILD_PYTHON +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-vincentlaucsb-csv-parser) + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +file(READ "${CURRENT_PACKAGES_DIR}/share/unofficial-vincentlaucsb-csv-parser/unofficial-vincentlaucsb-csv-parser-config.cmake" cmake_config) +file(WRITE "${CURRENT_PACKAGES_DIR}/share/unofficial-vincentlaucsb-csv-parser/unofficial-vincentlaucsb-csv-parser-config.cmake" +"include(CMakeFindDependencyMacro) +find_dependency(Threads) +find_dependency(mio CONFIG) +find_dependency(string-view-lite CONFIG) +${cmake_config} +") + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") diff --git a/ports/vincentlaucsb-csv-parser/usage b/ports/vincentlaucsb-csv-parser/usage new file mode 100644 index 00000000000000..d7d068f3dca127 --- /dev/null +++ b/ports/vincentlaucsb-csv-parser/usage @@ -0,0 +1,4 @@ +csv-parser provides CMake targets: + + find_package(unofficial-vincentlaucsb-csv-parser CONFIG REQUIRED) + target_link_libraries(main PRIVATE unofficial::vincentlaucsb-csv-parser::csv) diff --git a/ports/vincentlaucsb-csv-parser/vcpkg.json b/ports/vincentlaucsb-csv-parser/vcpkg.json new file mode 100644 index 00000000000000..c931d637b4c00a --- /dev/null +++ b/ports/vincentlaucsb-csv-parser/vcpkg.json @@ -0,0 +1,21 @@ +{ + "name": "vincentlaucsb-csv-parser", + "version": "2.1.3", + "description": "A modern C++ library for reading, writing, and analyzing CSV (and similar) files.", + "homepage": "https://github.com/vincentlaucsb/csv-parser", + "license": "MIT", + "supports": "!uwp", + "dependencies": [ + "hedley", + "mio", + "string-view-lite", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/versions/baseline.json b/versions/baseline.json index 49276ef594a808..b9d6f974e204a1 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -8528,6 +8528,10 @@ "baseline": "1.0.0+20221123", "port-version": 1 }, + "vincentlaucsb-csv-parser": { + "baseline": "2.1.3", + "port-version": 0 + }, "visit-struct": { "baseline": "1.1.0", "port-version": 0 diff --git a/versions/v-/vincentlaucsb-csv-parser.json b/versions/v-/vincentlaucsb-csv-parser.json new file mode 100644 index 00000000000000..6f6e5984f8fcdc --- /dev/null +++ b/versions/v-/vincentlaucsb-csv-parser.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "85d641f84a8f718a13d9f7ac169a4f2542c4d7c8", + "version": "2.1.3", + "port-version": 0 + } + ] +}