Sfoglia il codice sorgente

xlsxio: add package (#2669)

* xlsxio: add package

* disable plat
star9029 1 anno fa
parent
commit
82f8c703ca
2 ha cambiato i file con 105 aggiunte e 0 eliminazioni
  1. 53 0
      packages/x/xlsxio/port/xmake.lua
  2. 52 0
      packages/x/xlsxio/xmake.lua

+ 53 - 0
packages/x/xlsxio/port/xmake.lua

@@ -0,0 +1,53 @@
+set_allowedplats("windows", "linux", "macosx", "mingw", "cross")
+
+option("libzip", {showmenu = true,  default = false})
+option("minizip_ng", {showmenu = true,  default = false})
+option("wide", {showmenu = true,  default = false})
+
+add_rules("mode.debug", "mode.release")
+
+add_requires("expat")
+
+if has_config("libzip") then
+    add_requires("libzip")
+elseif has_config("minizip_ng") then
+    add_requires("minizip-ng", {configs = {zlib = true}})
+else
+    add_requires("minizip")
+end
+
+target("xlsxio")
+    set_kind("$(kind)")
+    add_files("lib/*.c")
+    add_includedirs("include")
+    add_headerfiles("include/*.h")
+
+    add_defines("BUILD_XLSXIO")
+    if is_kind("shared") then
+        add_defines("BUILD_XLSXIO_SHARED", {public = true})
+    else
+        add_defines("BUILD_XLSXIO_STATIC", {public = true})
+    end
+
+    if has_config("wide") then
+        add_defines("XML_UNICODE", {public = true})
+    end
+
+    if is_plat("linux", "bsd") then
+        add_syslinks("pthread")
+    end
+
+    if has_config("libzip") then
+        add_defines("USE_LIBZIP")
+        add_packages("libzip")
+    else
+        add_defines("USE_MINIZIP")
+        if has_config("minizip_ng") then
+            add_defines("USE_MINIZIP_NG")
+            add_packages("minizip-ng")
+        else
+            add_packages("minizip")
+        end
+    end
+
+    add_packages("expat")

+ 52 - 0
packages/x/xlsxio/xmake.lua

@@ -0,0 +1,52 @@
+package("xlsxio")
+    set_homepage("https://github.com/brechtsanders/xlsxio")
+    set_description("XLSX I/O - C library for reading and writing .xlsx files")
+    set_license("MIT")
+
+    add_urls("https://github.com/brechtsanders/xlsxio/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/brechtsanders/xlsxio.git")
+
+    add_versions("0.2.34", "726e3bc3cf571ac20e5c39b1f192f3793d24ebfdeaadcd210de74aa1ec100bb6")
+
+    add_configs("libzip", {description = "Use libzip instead of Minizip", default = false, type = "boolean"})
+    add_configs("minizip_ng", {description = "Use Minizip NG", default = false, type = "boolean"})
+    add_configs("wide", {description = "Also build UTF-16 library (libxlsxio_readw)", default = false, type = "boolean"})
+
+    if is_plat("linux", "bsd") then
+        add_syslinks("pthread")
+    end
+
+    add_deps("expat")
+
+    on_load(function (package)
+        if package:config("libzip") then
+            package:add("deps", "libzip")
+        elseif package:config("minizip_ng") then
+            package:add("deps", "minizip-ng", {configs = {zlib = true}})
+        else
+            package:add("deps", "minizip")
+        end
+    end)
+
+    on_install("windows", "linux", "macosx", "mingw", "cross", function (package)
+        local configs = {}
+        if package:config("libzip") then
+            configs.libzip = true
+        elseif package:config("minizip_ng") then
+            configs.minizip_ng = true
+        end
+        if package:config("wide") then
+            package:add("defines", "XML_UNICODE")
+            configs.wide = true
+        end
+        package:add("defines", "BUILD_XLSXIO_" .. (package:config("shared") and "SHARED" or "STATIC"))
+
+        io.replace("lib/xlsxio_read.c", "minizip/", "", {plain = true})
+        io.replace("lib/xlsxio_write.c", "minizip/", "", {plain = true})
+        os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
+        import("package.tools.xmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("xlsxioread_open", {includes = "xlsxio_read.h"}))
+    end)