Explorar el Código

libnpy-matajoh: new package (#7384)

Saikari hace 2 meses
padre
commit
88e91ed165

+ 90 - 0
packages/l/libnpy-matajoh/patches/v1.5.3/fix.diff

@@ -0,0 +1,90 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 41ce88d..62d0850 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -95,7 +95,7 @@ endif()
+ 
+ target_include_directories(npy
+   PUBLIC
+-    $<INSTALL_INTERFACE:build/native/include>
++    $<INSTALL_INTERFACE:include>
+     $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+   PRIVATE
+     ${CMAKE_CURRENT_SOURCE_DIR}/src
+@@ -124,11 +124,12 @@ set(INSTALL_CONFIGDIR "cmake")
+ 
+ install(TARGETS npy 
+   EXPORT npy-targets
+-  ARCHIVE DESTINATION "build/native/lib"
+-  LIBRARY DESTINATION "build/native/lib"
++  ARCHIVE DESTINATION "lib"
++  LIBRARY DESTINATION "lib"
++  RUNTIME DESTINATION "bin"
+ )
+ 
+-install(DIRECTORY include/ DESTINATION "build/native/include")
++install(DIRECTORY include/ DESTINATION "include")
+ 
+ install(EXPORT npy-targets
+   FILE
+@@ -166,23 +167,19 @@ export(PACKAGE npy)
+ 
+ # -------------------- Package ------------------------------------
+ 
+-set( PROJECT_FILES
+-  README.md
+-  CHANGELOG.md
+-)
+ 
+ # copy these files into the root of the distribution zip
+-install( FILES ${PROJECT_FILES} DESTINATION "." )
+ 
+-if( MSVC )
++if( 0 )
+   # NuGet files
+   set( LIBNPY_NUGET_NAME "npy-${SYSTEM_TOOLKIT}-${SYSTEM_BITS}-${CMAKE_BUILD_TYPE}" CACHE STRING "npy NuGet Name" FORCE )
+   file( READ RELEASE_NOTES LIBNPY_RELEASE_NOTES )
+ 
+   configure_file("${CMAKE_CURRENT_SOURCE_DIR}/nuget/template.nuspec.in" "${CMAKE_CURRENT_BINARY_DIR}/nuget/${LIBNPY_NUGET_NAME}.nuspec" @ONLY )
+   configure_file("${CMAKE_CURRENT_SOURCE_DIR}/nuget/template.targets.in"
+-                "${CMAKE_CURRENT_BINARY_DIR}/nuget/build/native/${LIBNPY_NUGET_NAME}.targets" @ONLY )
+-else()
++                "${CMAKE_CURRENT_BINARY_DIR}/nuget/${LIBNPY_NUGET_NAME}.targets" @ONLY )
++endif()
++if( 0 )
+   set( CPACK_SYSTEM_NAME ${SYSTEM_NAME} )
+   set( CPACK_PACKAGE_VERSION "${LIBNPY_VERSION}" )
+   set( CPACK_GENERATOR "ZIP" )
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 66f8af4..6423546 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -4,12 +4,13 @@ set( SOURCES
+    npz.cpp
+    tensor.cpp
+    zip.cpp
+-   miniz/miniz.cpp
+ )
+ 
+ add_definitions( -DLIBNPY_VERSION=${LIBNPY_VERSION} )
+ 
+-add_library( npy STATIC ${SOURCES} )
++add_library( npy ${SOURCES} )
++find_package( miniz REQUIRED )
++target_link_libraries( npy PRIVATE miniz::miniz )
+ add_library( npy::npy ALIAS npy )
+ 
+ if (LIBNPY_SANITIZE)
+diff --git a/src/zip.cpp b/src/zip.cpp
+index 1269704..0c35083 100644
+--- a/src/zip.cpp
++++ b/src/zip.cpp
+@@ -4,6 +4,8 @@
+ 
+ #include "npy/core.h"
+ #include "zip.h"
++#include <vector>
++#include <sstream>
+ 
+ namespace {
+ const size_t CHUNK = 1024 * 1024;

+ 40 - 0
packages/l/libnpy-matajoh/xmake.lua

@@ -0,0 +1,40 @@
+package("libnpy-matajoh")
+    set_homepage("https://github.com/matajoh/libnpy")
+    set_description("C++ library for reading and writing of numpy's .npy files")
+    set_license("MIT")
+
+    add_urls("https://github.com/matajoh/libnpy/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/matajoh/libnpy.git")
+
+    add_versions("v1.5.3", "27f6ce7136fe9d4bc823b98585e21f5cd8c27b72d634afa9d613cd4101e6aff1")
+    add_patches("v1.5.3", "patches/v1.5.3/fix.diff", "a1db18e4615ece28b6ef0c7e3befcca8bdd696191b983968843ba69213c1d77f")
+
+    add_includedirs("include", "include/npy")
+
+    add_deps("cmake")
+    add_deps("miniz")
+
+    on_install(function (package)
+        os.rm("doc", "src/miniz")
+        local configs = {}
+        if package:config("shared") and package:is_plat("windows") then
+            table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
+        end
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
+        table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+            #include <tensor.h>
+            #include <npy.h>
+            #include <npz.h>
+            void test() {
+                std::vector<size_t> shape({65, 12, 8});
+                npy::tensor<std::uint8_t> color(shape);
+                npy::save("color.npy", color);
+                npy::onpzstream output("test.npz");
+            }
+        ]]}, {configs = {languages = "c++17"}}))
+    end)