Browse Source

libiconv: add 1.18 version (#6999)

* libiconv: add 1.18 version

* Update xmake.lua

* Try fix shared build on Windows

* Update xmake.lua

* Update xmake.lua

* Enforce windows fix for android with windows OS subhost

* Update xmake.lua

---------

Co-authored-by: Saikari <[email protected]>
star9029 3 months ago
parent
commit
099c1148c1
2 changed files with 25 additions and 3 deletions
  1. 14 2
      packages/l/libiconv/port/xmake.lua
  2. 11 1
      packages/l/libiconv/xmake.lua

+ 14 - 2
packages/l/libiconv/port/xmake.lua

@@ -1,6 +1,6 @@
 set_project("libiconv")
 
-add_rules("mode.debug", "mode.release")
+add_rules("mode.debug", "mode.release", "set_language")
 
 set_configvar("PACKAGE", "libiconv")
 set_configvar("PACKAGE_NAME", "libiconv")
@@ -220,7 +220,7 @@ target("iconv")
     add_deps("charset", {inherit = false})
     add_defines("HAVE_CONFIG_H", "NO_XMALLOC", "IN_LIBRARY")
     if is_kind("shared") then
-        add_defines("BUILDING_LIBICONV", "BUILDING_DLL")
+        add_defines("BUILDING_LIBICONV", "BUILDING_DLL", "DLL_EXPORT")
     end
     set_configdir(".")
     set_configvar("DLL_VARIABLE", (is_plat("windows") and is_kind("shared")) and "__declspec(dllimport)" or "")
@@ -265,3 +265,15 @@ target("iconv_no_i18n")
         -- https://www.gnu.org/software/gnulib/manual/html_node/fcntl_002eh.html
         add_defines("O_BINARY=0")
     end
+
+rule("set_language")
+    on_load(function (target)
+        import("core.base.semver")
+
+        local ver = semver.new(get_config("vers"))
+        if ver:ge("1.18") then
+            target:set("languages", "c23")
+        else
+            target:set("languages", "c99")
+        end
+    end)

+ 11 - 1
packages/l/libiconv/xmake.lua

@@ -6,6 +6,7 @@ package("libiconv")
     set_urls("https://ftpmirror.gnu.org/gnu/libiconv/libiconv-$(version).tar.gz",
              "https://ftp.gnu.org/gnu/libiconv/libiconv-$(version).tar.gz")
 
+    add_versions("1.18", "3b08f5f4f9b4eb82f151a7040bfd6fe6c6fb922efe4b1659c66ea933276965e8")
     add_versions("1.17", "8f74213b56238c85a50a5329f77e06198771e70dd9a739779f4c02f65d971313")
     add_versions("1.16", "e6a1b1b589654277ee790cce3734f07876ac4ccfaecbee8afa0b649cf529cc04")
     add_versions("1.15", "ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc8913178")
@@ -38,8 +39,17 @@ package("libiconv")
         io.gsub("libcharset/config.h.in", "# ?undef (.-)\n", "${define %1}\n")
 
         if package:is_plat("windows") then
-            io.gsub("srclib/safe-read.c", "#include <unistd.h>", "")
+            io.gsub("srclib/safe-read.c", "#include <unistd.h>", "#include <io.h>")
             io.gsub("srclib/progreloc.c", "#include <unistd.h>", "")
+            for _, file in ipairs(os.files("**")) do
+                io.gsub(file, "#include <stdbool.h>", "#include <cstdbool>")
+            end
+            io.gsub("config.h.in", "#  if HAVE_STDBOOL_H", "#  if 1")
+            io.replace("srclib/binary-io.h", "#  define __gl_setmode _setmode", "#  include <io.h>\n#  define __gl_setmode _setmode", {plain = true})
+        end
+        -- Enforce #include <stdbool.h>
+        if package:is_plat("android") then
+            io.gsub("config.h.in", "#  if HAVE_STDBOOL_H", "#  if 1")
         end
 
         os.cp(path.join(os.scriptdir(), "port", "xmake.lua"), ".")