2
0
Эх сурвалжийг харах

netcdf-c: add new package (#7865)

* netcdf-c: add new package

* fix deps

* revert hdf5

* verbose log for linux arm64

* Update ubuntu_arm64.yml

---------

Co-authored-by: star9029 <[email protected]>
choyy 3 долоо хоног өмнө
parent
commit
b56ddd25b2

+ 6 - 6
packages/l/libcurl/xmake.lua

@@ -38,7 +38,7 @@ package("libcurl")
 
     -- we init all configurations in on_load, because package("curl") need it.
     on_load(function (package)
-        if package:is_plat("linux", "android", "cross") then
+        if package:is_plat("linux", "bsd", "android", "cross") then
             -- if no TLS backend has been enabled nor disabled, enable openssl by default
             if package:config("openssl") == nil and package:config("openssl3") == nil and package:config("mbedtls") == nil then
                 package:config_set("openssl", true)
@@ -49,7 +49,7 @@ package("libcurl")
 
         if package:is_plat("macosx", "iphoneos") then
             package:add("frameworks", "Security", "CoreFoundation", "SystemConfiguration")
-        elseif package:is_plat("linux") then
+        elseif package:is_plat("linux", "bsd") then
             package:add("syslinks", "pthread")
         elseif package:is_plat("windows", "mingw") then
             package:add("syslinks", "advapi32", "crypt32", "wldap32", "winmm", "ws2_32", "user32")
@@ -57,7 +57,7 @@ package("libcurl")
 
         if package:is_plat("mingw") and is_subhost("msys") then
             package:add("extsources", "pacman::curl")
-        elseif package:is_plat("linux") then
+        elseif package:is_plat("linux", "bsd") then
             package:add("extsources", "pacman::curl", "apt::libcurl4-gnutls-dev", "apt::libcurl4-nss-dev", "apt::libcurl4-openssl-dev")
         elseif package:is_plat("macosx") then
             package:add("extsources", "brew::curl")
@@ -89,12 +89,12 @@ package("libcurl")
                 has_deps = true
             end
         end
-        if has_deps and package:is_plat("linux", "macosx") then
+        if has_deps and package:is_plat("linux", "bsd", "macosx") then
             package:add("deps", "pkg-config")
         end
     end)
 
-    on_install("windows", "mingw", "linux", "macosx", "iphoneos", "cross", "android", function (package)
+    on_install("windows", "mingw", "linux", "bsd", "macosx", "iphoneos", "cross", "android", function (package)
         local version = package:version()
 
         local configs = {"-DBUILD_TESTING=OFF", "-DENABLE_MANUAL=OFF", "-DENABLE_CURL_MANUAL=OFF"}
@@ -134,7 +134,7 @@ package("libcurl")
         if package:is_plat("mingw") and version:le("7.85.0") then
             io.replace("src/CMakeLists.txt", 'COMMAND ${CMAKE_COMMAND} -E echo "/* built-in manual is disabled, blank function */" > tool_hugehelp.c', "", {plain = true})
         end
-        if package:is_plat("linux", "cross") then
+        if package:is_plat("linux", "bsd", "cross") then
             io.replace("CMakeLists.txt", "list(APPEND CURL_LIBS OpenSSL::SSL OpenSSL::Crypto)", "list(APPEND CURL_LIBS OpenSSL::SSL OpenSSL::Crypto dl)", {plain = true})
             io.replace("CMakeLists.txt", "list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES})", "list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES} dl)", {plain = true})
         end

+ 109 - 0
packages/n/netcdf-c/patches/v4.9.3/deps.patch

@@ -0,0 +1,109 @@
+diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake
+index d06a276..b7ada29 100644
+--- a/cmake/dependencies.cmake
++++ b/cmake/dependencies.cmake
+@@ -134,7 +134,14 @@ if(USE_HDF5)
+   #####
+   # First, find the C and HL libraries.
+   #####
+-  find_package(HDF5 COMPONENTS C HL REQUIRED)
++  find_package(HDF5 NO_MODULE COMPONENTS C HL REQUIRED)
++  if(TARGET hdf5::hdf5-static)
++    add_library(HDF5::HDF5 ALIAS hdf5::hdf5-static)
++    add_library(hdf5::hdf5_hl ALIAS hdf5::hdf5_hl-static)
++  else()
++    add_library(HDF5::HDF5 ALIAS hdf5::hdf5-shared)
++    add_library(hdf5::hdf5_hl ALIAS hdf5::hdf5_hl-shared)
++  endif()
+ 
+   message(STATUS "Found HDF5 version: ${HDF5_VERSION}")
+   if(${HDF5_VERSION} VERSION_LESS ${HDF5_VERSION_REQUIRED})
+@@ -173,6 +180,13 @@ if(USE_HDF5)
+     message(STATUS "HDF5 has zlib.")
+   endif()
+ 
++  if(NOT TARGET ZLIB::ZLIB)
++    add_library(ZLIB::ZLIB UNKNOWN IMPORTED)
++    set_target_properties(ZLIB::ZLIB PROPERTIES
++      IMPORTED_LOCATION "${ZLIB_LIBRARY}"
++      INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}"
++    )
++  endif()
+ 
+   # Check to see if H5Z_SZIP exists in HDF5_Libraries. If so, we must use szip library.
+   check_hdf5_feature(HAVE_H5Z_SZIP H5_HAVE_FILTER_SZIP)
+@@ -466,8 +480,8 @@ endif()
+ ################################
+ # see if we have libxml2
+ if(NETCDF_ENABLE_LIBXML2)
+-  find_package(LibXml2)
+-  if(LibXml2_FOUND)
++  find_package(libxml2 CONFIG REQUIRED)
++  if(TARGET LibXml2::LibXml2)
+     set(HAVE_LIBXML2 TRUE)
+     target_include_directories(netcdf
+       PRIVATE
+diff --git a/libdispatch/CMakeLists.txt b/libdispatch/CMakeLists.txt
+index 0f5d66d..2f65518 100644
+--- a/libdispatch/CMakeLists.txt
++++ b/libdispatch/CMakeLists.txt
+@@ -14,6 +14,8 @@ target_sources(dispatch
+     ncproplist.c 
+ )
+ 
++target_link_libraries(dispatch PUBLIC CURL::libcurl ${CURL_LIBRARIES})
++
+ if (NETCDF_ENABLE_DLL)
+   target_compile_definitions(dispatch PRIVATE DLL_NETCDF DLL_EXPORT)
+ endif()
+diff --git a/libhdf5/CMakeLists.txt b/libhdf5/CMakeLists.txt
+index 9281a25..61198b2 100644
+--- a/libhdf5/CMakeLists.txt
++++ b/libhdf5/CMakeLists.txt
+@@ -17,6 +17,8 @@ target_sources(netcdfhdf5 PRIVATE
+     hdf5set_format_compatibility.c hdf5debug.c
+ )
+ 
++target_link_libraries(netcdfhdf5 PUBLIC CURL::libcurl)
++
+ if (NETCDF_ENABLE_DLL)
+     target_compile_definitions(netcdfhdf5 PRIVATE DLL_NETCDF DLL_EXPORT)
+ endif()
+diff --git a/libncxml/CMakeLists.txt b/libncxml/CMakeLists.txt
+index b8fa4b2..f881a92 100644
+--- a/libncxml/CMakeLists.txt
++++ b/libncxml/CMakeLists.txt
+@@ -12,6 +12,7 @@ if(HAVE_LIBXML2)
+     PRIVATE
+       ${LIBXML2_INCLUDE_DIRS}
+ )
++target_link_libraries(ncxml PUBLIC LibXml2::LibXml2)
+ else()
+   target_include_directories(ncxml
+   PUBLIC
+diff --git a/libncxml/ncxml_xml2.c b/libncxml/ncxml_xml2.c
+index 12132a7..7da27d5 100644
+--- a/libncxml/ncxml_xml2.c
++++ b/libncxml/ncxml_xml2.c
+@@ -3,7 +3,7 @@
+ #include <stddef.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include <libxml2/libxml/parser.h>
++#include <libxml/parser.h>
+ #include <libxml/tree.h>
+ #include "ncxml.h"
+ 
+diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
+index fbaeb21..740bdb1 100644
+--- a/plugins/CMakeLists.txt
++++ b/plugins/CMakeLists.txt
+@@ -58,7 +58,7 @@ macro(buildplugin TARGET TARGETLIB)
+     set_target_properties(${TARGET} PROPERTIES RUNTIME_OUTPUT_NAME ${MANGLELIB})
+     set_target_properties(${TARGET} PROPERTIES PREFIX "") # Critical that this be set to ""
+     set_target_properties(${TARGET} PROPERTIES SUFFIX ".${PLUGINEXT}")
+-    target_link_libraries(${TARGET} PUBLIC ${ALL_TLL_LIBS};${ARGN})
++    target_link_libraries(${TARGET} PUBLIC ${ALL_TLL_LIBS};${ARGN};ZLIB::ZLIB)
+   if(MSVC)
+     target_compile_options(${TARGET} PRIVATE /Zi)
+     # Tell linker to include symbol data

+ 33 - 0
packages/n/netcdf-c/xmake.lua

@@ -0,0 +1,33 @@
+package("netcdf-c")
+    set_homepage("https://github.com/Unidata/netcdf-c")
+    set_description("Network Common Data Form (NetCDF) libraries and utilities.")
+    set_license("BSD-3-Clause")
+
+    add_urls("https://github.com/Unidata/netcdf-c/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/Unidata/netcdf-c.git")
+    add_versions("v4.9.3", "990f46d49525d6ab5dc4249f8684c6deeaf54de6fec63a187e9fb382cc0ffdff")
+    add_patches("v4.9.3", "patches/v4.9.3/deps.patch", "a133eba3f888902cc12e2cf65dc7d463ce1f466bea4d09ad09a3d448ef952ed8")
+
+    add_deps("cmake", "libcurl", "libxml2", "libzip", "zlib")
+    add_deps("hdf5", {configs = {zlib = true}})
+
+    on_install("windows", "linux", "macosx", "bsd", function (package)
+        local configs = {
+            "-DNCNN_SHARED_LIB=" .. (package:config("shared") and "ON" or "OFF"),
+            "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"),
+            "-DBUILD_TESTING=OFF",
+            "-DENABLE_EXAMPLES=OFF",
+            "-DENABLE_TESTS=OFF",
+            "-DENABLE_FILTER_TESTING=OFF",
+            "-DENABLE_DAP_REMOTE_TESTS=OFF",
+            "-DDISABLE_INSTALL_DEPENDENCIES=ON",
+        }
+        if is_plat("windows") and package:config("shared") then
+            table.insert(configs, "-DNETCDF_ENABLE_DLL=ON")
+        end
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("nc_create", {includes = "netcdf.h"}))
+    end)