Преглед изворни кода

add support of `libiconv` on `android@windows` (#4299)

* add `MingW` support for `unistd_h`

* Update xmake.lua

* switch mingw and android for `libiconv` to xmake port

* fix android for `libiconv`: define `O_BINARY` for android

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

* Update xmake.lua

---------

Co-authored-by: ruki <[email protected]>
zjyhjqs пре 1 година
родитељ
комит
94acda8148
3 измењених фајлова са 22 додато и 21 уклоњено
  1. 13 8
      packages/l/libiconv/port/xmake.lua
  2. 8 12
      packages/l/libiconv/xmake.lua
  3. 1 1
      packages/u/unistd_h/xmake.lua

+ 13 - 8
packages/l/libiconv/port/xmake.lua

@@ -31,11 +31,7 @@ if has_config("vers") then
     set_configvar("PACKAGE_STRING", "libiconv " .. get_config("vers"))
 end
 
-includes("check_cfuncs.lua")
-includes("check_ctypes.lua")
-includes("check_macros.lua")
-includes("check_cincludes.lua")
-includes("check_csnippets.lua")
+includes("@builtin/check")
 
 -- config.h variables
 option("__NO_BROKEN_WCHAR_H")
@@ -101,11 +97,14 @@ set_configvar("GNULIB_TEST_REALPATH", 1)
 set_configvar("GNULIB_TEST_SIGPROCMASK", 1)
 set_configvar("GNULIB_TEST_STAT", 1)
 set_configvar("GNULIB_TEST_STRERROR", 1)
-set_configvar("ssize_t", "int", {quote = false})
-set_configvar("uid_t", "int", {quote = false})
+if not is_plat("android") then
+    set_configvar("ssize_t", "int", {quote = false})
+    set_configvar("uid_t", "int", {quote = false})
+end
 configvar_check_ctypes("USE_MBSTATE_T", "mbstate_t", {includes = "wchar.h", default = 0})
 configvar_check_cincludes("ENABLE_NLS", "libintl.h", {default = 0})
 configvar_check_cincludes("HAVE_DLFCN_H", "dlfcn.h")
+configvar_check_cincludes("HAVE_FCNTL", "fcntl.h")
 configvar_check_cincludes("HAVE_INTTYPES_H", "inttypes.h")
 configvar_check_cincludes("HAVE_MACH_O_DYLD_H", "mach-o/dyld.h")
 configvar_check_cincludes("HAVE_MEMORY_H", "memory.h")
@@ -194,7 +193,7 @@ configvar_check_csnippets("GNULIB_SIGPIPE", [[#include <signal.h>
 #error SIGPIPE not defined
 #endif]])
 configvar_check_csnippets("HAVE_LANGINFO_CODESET", [[#include <langinfo.h>
-int test() { char* cs = nl_langinfo(CODESET); return !cs; }]])
+int test() { char* cs = nl_langinfo(CODESET); return !cs; }]], {links = "c"})
 configvar_check_csnippets("HAVE_ENVIRON_DECL=0", [[extern struct {int foo;} environ;
 void test() {environ.foo = 1;}]], {includes = has_config("__HAVE_UNISTD_H") and "unistd.h" or "stdlib.h", default = 1})
 
@@ -260,3 +259,9 @@ target("iconv_no_i18n")
         add_defines("LOCALEDIR=\"" .. path.join(get_config("installprefix"), "share", "locale"):gsub("\\", "\\\\") .. "\"")
     end
     add_files("src/iconv_no_i18n.c")
+
+    if is_plat("android") then
+        -- Gnulib defines these macros to 0 on GNU and other platforms that do not distinguish between text and binary I/O.
+        -- https://www.gnu.org/software/gnulib/manual/html_node/fcntl_002eh.html
+        add_defines("O_BINARY=0")
+    end

+ 8 - 12
packages/l/libiconv/xmake.lua

@@ -13,9 +13,6 @@ package("libiconv")
     if is_plat("macosx") then
         add_patches("1.15", path.join(os.scriptdir(), "patches", "1.15", "patch-utf8mac.diff"),
             "e8128732f22f63b5c656659786d2cf76f1450008f36bcf541285268c66cabeab")
-    elseif is_plat("android") then
-        add_patches("1.x", path.join(os.scriptdir(), "patches", "1.16", "makefile.in.patch"),
-            "d09e4212040f5adf1faa5cf5a9a18f6f79d4cdce9affb05f2e75df2ea3b3d686")
     elseif is_plat("wasm") then
         add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
     end
@@ -34,13 +31,17 @@ package("libiconv")
         package:addenv("PATH", "bin")
     end)
 
-    on_install("windows", "mingw", function (package)
+    on_install("windows", "mingw", "android", function (package)
         io.gsub("config.h.in", "%$", "")
         io.gsub("config.h.in", "# ?undef (.-)\n", "${define %1}\n")
         io.gsub("libcharset/config.h.in", "%$", "")
         io.gsub("libcharset/config.h.in", "# ?undef (.-)\n", "${define %1}\n")
-        io.gsub("srclib/safe-read.c", "#include <unistd.h>", "")
-        io.gsub("srclib/progreloc.c", "#include <unistd.h>", "")
+
+        if package:is_plat("windows") then
+            io.gsub("srclib/safe-read.c", "#include <unistd.h>", "")
+            io.gsub("srclib/progreloc.c", "#include <unistd.h>", "")
+        end
+
         os.cp(path.join(os.scriptdir(), "port", "xmake.lua"), ".")
         import("package.tools.xmake").install(package, {
             relocatable = true,
@@ -49,17 +50,13 @@ package("libiconv")
         })
     end)
 
-    on_install("macosx", "linux", "bsd", "cross", "android", "wasm", function (package)
+    on_install("macosx", "linux", "bsd", "cross", "wasm", function (package)
         local configs = {"--disable-dependency-tracking", "--enable-extra-encodings", "--enable-relocatable"}
         table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
         table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
         if package:debug() then
             table.insert(configs, "--enable-debug")
         end
-        if package:is_plat("android") then
-            io.replace("./configure", "#define gid_t int", "")
-            io.replace("./configure", "#define uid_t int", "")
-        end
         os.vrunv("make", {"-f", "Makefile.devel", "CFLAGS=" .. (package:config("cflags") or "")})
         import("package.tools.autoconf").install(package, configs)
     end)
@@ -76,4 +73,3 @@ package("libiconv")
             }
         ]]}))
     end)
-

+ 1 - 1
packages/u/unistd_h/xmake.lua

@@ -7,7 +7,7 @@ package("unistd_h")
     add_urls("https://github.com/win32ports/unistd_h.git")
     add_versions("2019.07.30", "0dfc48c1bc67fa27b02478eefe0443b8d2750cc2")
 
-    on_install("windows", function (package)
+    on_install("windows", "mingw", function (package)
         os.cp("unistd.h", package:installdir("include"))
     end)