فهرست منبع

coinutils: add new package (#7502)

* coinutils: add new package

* test existing xmake.lua

* just use export_all rule

* fix

---------

Co-authored-by: star9029 <[email protected]>
Saikari 2 ماه پیش
والد
کامیت
f5444f66fb
2فایلهای تغییر یافته به همراه111 افزوده شده و 0 حذف شده
  1. 60 0
      packages/c/coin-or-coinutils/port/xmake.lua
  2. 51 0
      packages/c/coin-or-coinutils/xmake.lua

+ 60 - 0
packages/c/coin-or-coinutils/port/xmake.lua

@@ -0,0 +1,60 @@
+includes("@builtin/check")
+configvar_check_cincludes("COINUTILS_HAS_CSTDINT", "cstdint")
+configvar_check_cincludes("COINUTILS_HAS_STDINT_H", "stdint.h")
+-- configvar_check_cincludes("COIN_HAS_BLAS",  "cblas.h")
+-- configvar_check_cincludes("COIN_HAS_GLPK", "glpk.h")
+-- configvar_check_cincludes("COIN_HAS_LAPACK", "lapacke_utils.h")
+configvar_check_cincludes("HAVE_CFLOAT", "cfloat")
+configvar_check_cincludes("HAVE_CIEEEFP", "cieeefp")
+configvar_check_cincludes("HAVE_CINTTYPES", "cinttypes")
+configvar_check_cincludes("HAVE_CMATH", "cmath")
+configvar_check_cincludes("HAVE_CSTDINT", "cstdint")
+configvar_check_cincludes("HAVE_DLFCN_H", "dlfcn.h")
+configvar_check_cincludes("HAVE_ENDIAN_H", "endian.h")
+configvar_check_cincludes("HAVE_FLOAT_H", "float.h")
+configvar_check_cincludes("HAVE_IEEEFP_H", "ieeefp.h")
+configvar_check_cincludes("HAVE_INTTYPES_H", "inttypes.h")
+configvar_check_cincludes("HAVE_MATH_H", "math.h")
+configvar_check_cincludes("HAVE_MEMORY_H", "memory.h")
+configvar_check_cincludes("HAVE_STDINT_H", "stdint.h")
+configvar_check_cincludes("HAVE_STDLIB_H", "stdlib.h")
+configvar_check_cincludes("HAVE_STRINGS_H", "strings.h")
+configvar_check_cincludes("HAVE_STRING_H", "string.h")
+configvar_check_cincludes("HAVE_SYS_STAT_H", "sys/stat.h")
+configvar_check_cincludes("HAVE_SYS_TYPES_H", "sys/types.h")
+configvar_check_cincludes("HAVE_UNISTD_H", "unistd.h")
+configvar_check_cincludes("HAVE_WINDOWS_H", "windows.h")
+check_sizeof("SIZEOF_DOUBLE", "double")
+check_sizeof("SIZEOF_INT", "int")
+check_sizeof("SIZEOF_INT_P", "int *")
+check_sizeof("SIZEOF_LONG", "long")
+check_sizeof("SIZEOF_LONG_LONG", "long long")
+configvar_check_cincludes("STDC_HEADERS", {"stdlib.h", "string.h"})
+
+add_rules("mode.debug", "mode.release")
+
+add_requires("bzip2", "zlib")
+add_defines("COIN_HAS_ZLIB", "COIN_HAS_BZLIB")
+if is_plat("linux", "macosx", "bsd") then
+    add_requires("readline")
+    add_packages("readline")
+    add_defines("COIN_HAS_READLINE")
+end
+
+set_languages("c++11")
+
+target("CoinUtils")
+    set_kind("$(kind)")
+    add_files("CoinUtils/src/*.cpp")
+    add_headerfiles("CoinUtils/src/*.hpp", "CoinUtils/src/*.h", {prefixdir = "coin"})
+    add_configfiles("CoinUtils/src/(config.h.in)", {filename = "config.h"})
+    add_configfiles("CoinUtils/src/(config_coinutils.h.in)", {filename = "config_coinutils.h"})
+    if is_plat("windows") and is_kind("shared") then
+        add_rules("utils.symbols.export_all", {export_classes = true})
+    end
+    add_packages("bzip2", "zlib")
+    if is_plat("macosx", "iphoneos") then
+        add_frameworks("Accelerate")
+    elseif is_plat("linux", "bsd") then
+        add_syslinks("m")
+    end

+ 51 - 0
packages/c/coin-or-coinutils/xmake.lua

@@ -0,0 +1,51 @@
+package("coin-or-coinutils")
+    set_homepage("https://github.com/coin-or/CoinUtils")
+    set_description("COIN-OR Utilities")
+    set_license("EPL-2.0")
+
+    add_urls("https://github.com/coin-or/CoinUtils/archive/refs/tags/releases/$(version).tar.gz",
+             "https://github.com/coin-or/CoinUtils.git")
+
+    add_versions("2.11.12", "eef1785d78639b228ae2de26b334129fe6a7d399c4ac6f8fc5bb9054ba00de64")
+
+    if is_plat("mingw") and is_subhost("msys") then
+        add_extsources("pacman::coin-or-coinutils")
+    elseif is_plat("linux") then
+        add_extsources("apt::coinor-libcoinutils-dev", "pacman::coin-or-coinutils")
+    elseif is_plat("macosx") then
+        add_extsources("brew::coinutils")
+    end
+
+    add_deps("bzip2", "zlib")
+    if is_plat("linux", "macosx", "bsd") then
+        add_deps("readline")
+    end
+
+    if is_plat("macosx", "iphoneos") then
+        add_frameworks("Accelerate")
+    elseif is_plat("linux", "bsd") then
+        add_syslinks("m")
+    end
+
+    on_install(function (package)
+        io.replace("CoinUtils/src/CoinFinite.cpp", [[#include "CoinUtilsConfig.h"]], [[#include "CoinUtilsConfig.h"
+#include <cfloat>]], {plain = true})
+        io.gsub("CoinUtils/src/config.h.in", "# *undef (.-)\n", "${define %1}\n")
+        io.gsub("CoinUtils/src/config_coinutils.h.in", "# *undef (.-)\n", "${define %1}\n")
+        os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
+        import("package.tools.xmake").install(package)
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+            #include <coin/CoinPackedVector.hpp>
+            void test() {
+                const int ne = 4;
+                const int inx[ne] =   {  1,   4,  0,   2 };
+                const double el[ne] = { 10., 40., 1., 50. };
+                CoinPackedVector r(ne, inx, el);
+                r.sortIncrElement();
+                r.sortOriginalOrder();
+            }
+        ]]}, {configs = {languages = "c++11"}}))
+    end)