Kaynağa Gözat

add gettext

ruki 6 yıl önce
ebeveyn
işleme
2cfc51619b

+ 42 - 0
README.md

@@ -55,6 +55,48 @@ If you want to know more, please refer to:
 * [Github](https://github.com/xmake-io/xmake)
 * [HomePage](https://xmake.io)
 
+## Submit package to repository
+
+Write a xmake.lua of new package in `packages/x/xxx/xmake.lua` and push a pull-request to the dev branch.
+
+For example, [packages/z/zlib/xmake.lua](https://github.com/xmake-io/xmake-repo/blob/dev/packages/z/zlib/xmake.lua):
+
+```lua
+package("zlib")
+
+    set_homepage("http://www.zlib.net")
+    set_description("A Massively Spiffy Yet Delicately Unobtrusive Compression Library")
+
+    set_urls("http://zlib.net/zlib-$(version).tar.gz",
+             "https://downloads.sourceforge.net/project/libpng/zlib/$(version)/zlib-$(version).tar.gz")
+
+    add_versions("1.2.10", "8d7e9f698ce48787b6e1c67e6bff79e487303e66077e25cb9784ac8835978017")
+    add_versions("1.2.11", "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1")
+
+    on_install("windows", function (package)
+        io.gsub("win32/Makefile.msc", "%-MD", "-" .. package:config("vs_runtime"))
+        os.vrun("nmake -f win32\\Makefile.msc zlib.lib")
+        os.cp("zlib.lib", package:installdir("lib"))
+        os.cp("*.h", package:installdir("include"))
+    end)
+
+    on_install("linux", "macosx", function (package)
+        import("package.tools.autoconf").install(package, {"--static"})
+    end)
+ 
+    on_install("iphoneos", "android@linux,macosx", "mingw@linux,macosx", function (package)
+        import("package.tools.autoconf").configure(package, {host = "", "--static"})
+        io.gsub("Makefile", "\nAR=.-\n",      "\nAR=" .. (package:build_getenv("ar") or "") .. "\n")
+        io.gsub("Makefile", "\nARFLAGS=.-\n", "\nARFLAGS=cr\n")
+        io.gsub("Makefile", "\nRANLIB=.-\n",  "\nRANLIB=\n")
+        os.vrun("make install -j4")
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("inflate", {includes = "zlib.h"}))
+    end)
+```
+
 ## Supported Packages
 
 |linux|windows|mingw|iphoneos|macosx|android|

+ 41 - 0
README_zh.md

@@ -55,6 +55,47 @@ xmake-repo是一个官方的xmake包管理仓库,收录了常用的c/c++开发
 * [在线源码](https://github.com/xmake-io/xmake)
 * [项目主页](https://xmake.io/cn)
 
+## 提交一个新包到仓库
+
+在`packages/x/xxx/xmake.lua`中写个关于新包的xmake.lua描述,然后提交一个pull-request到dev分支。
+
+例如:[packages/z/zlib/xmake.lua](https://github.com/xmake-io/xmake-repo/blob/dev/packages/z/zlib/xmake.lua):
+
+```lua
+package("zlib")
+
+    set_homepage("http://www.zlib.net")
+    set_description("A Massively Spiffy Yet Delicately Unobtrusive Compression Library")
+
+    set_urls("http://zlib.net/zlib-$(version).tar.gz",
+             "https://downloads.sourceforge.net/project/libpng/zlib/$(version)/zlib-$(version).tar.gz")
+
+    add_versions("1.2.10", "8d7e9f698ce48787b6e1c67e6bff79e487303e66077e25cb9784ac8835978017")
+    add_versions("1.2.11", "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1")
+
+    on_install("windows", function (package)
+        io.gsub("win32/Makefile.msc", "%-MD", "-" .. package:config("vs_runtime"))
+        os.vrun("nmake -f win32\\Makefile.msc zlib.lib")
+        os.cp("zlib.lib", package:installdir("lib"))
+        os.cp("*.h", package:installdir("include"))
+    end)
+
+    on_install("linux", "macosx", function (package)
+        import("package.tools.autoconf").install(package, {"--static"})
+    end)
+ 
+    on_install("iphoneos", "android@linux,macosx", "mingw@linux,macosx", function (package)
+        import("package.tools.autoconf").configure(package, {host = "", "--static"})
+        io.gsub("Makefile", "\nAR=.-\n",      "\nAR=" .. (package:build_getenv("ar") or "") .. "\n")
+        io.gsub("Makefile", "\nARFLAGS=.-\n", "\nARFLAGS=cr\n")
+        io.gsub("Makefile", "\nRANLIB=.-\n",  "\nRANLIB=\n")
+        os.vrun("make install -j4")
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("inflate", {includes = "zlib.h"}))
+    end)
+```
 
 ## 被支持的包列表
 

+ 40 - 0
packages/g/gettext/xmake.lua

@@ -0,0 +1,40 @@
+package("gettext")
+
+    set_homepage("https://www.gnu.org/software/gettext/")
+    set_description("GNU internationalization (i18n) and localization (l10n) library.")
+
+    set_urls("https://ftp.gnu.org/gnu/gettext/gettext-$(version).tar.xz",
+             "https://ftpmirror.gnu.org/gettext/gettext-$(version).tar.xz",
+             {version = function (version) return version:gsub('%-', '.') end})
+    add_versions("0.19.8-1", "105556dbc5c3fbbc2aa0edb46d22d055748b6f5c7cd7a8d99f8e7eb84e938be4")
+
+    add_deps("libiconv")
+
+    if is_plat("macosx") then
+        add_frameworks("CoreFoundation")
+    end
+
+    on_install("macosx", "linux", function (package)
+        local configs = {"--disable-dependency-tracking", 
+                         "--disable-silent-rules",
+                         "--enable-shared=no",
+                         "--enable-static=yes",
+                         "--with-included-glib",
+                         "--with-included-libcroco",
+                         "--with-included-libunistring",
+                         "--with-emacs",
+                         "--with-lispdir=#{elisp}",
+                         "--disable-java",
+                         "--disable-csharp",
+                         "--without-git",
+                         "--without-cvs",
+                         "--without-xz"}
+        if is_plat("macosx") then
+            table.insert(configs, "--with-included-gettext")
+        end
+        import("package.tools.autoconf").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("ngettext", {includes = "libintl.h"}))
+    end)

+ 9 - 6
packages/g/glib/xmake.lua

@@ -7,17 +7,20 @@ package("glib")
              {version = function (version) return table.concat(table.slice((version):split('%.'), 1, 2), '.') .. "/glib-" .. version end})
     add_versions("2.60.2", "2ef15475060addfda0443a7e8a52b28a10d5e981e82c083034061daf9a8f80d9")
 
-    add_deps("meson", "ninja", "libffi")
+    add_deps("meson", "ninja", "gettext", "libiconv", "libffi", "pcre")
+
+    add_includedirs("include/glib-2.0", "lib/glib-2.0/include")
+    add_links("glib-2.0", "gio-2.0", "gobject-2.0", "gthread-2.0", "gmodule-2.0")
+    if is_plat("macosx") then
+        add_frameworks("Foundation", "CoreFoundation")
+    end
 
     on_install("macosx", "linux", function (package)
-        local configs = {"-Dbsymbolic_functions=false", "-Ddtrace=false"}
+        local configs = {"-Dbsymbolic_functions=false", "-Ddtrace=false", "-Ddefault_library=static"}
         table.insert(configs, "-Dgio_module_dir=" .. path.join(package:installdir(), "lib/gio/modules"))
-        if is_plat("macosx") then
-            table.insert(configs, "-Diconv=native")
-        end
         import("package.tools.meson").install(package, configs)
     end)
 
     on_test(function (package)
-        assert(package:has_cfuncs("g_convert", {includes = "glib.h"}))
+        assert(package:has_cfuncs("g_list_append", {includes = "glib.h"}))
     end)

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

@@ -17,7 +17,7 @@ package("libiconv")
     end)
 
     on_install("macosx", "linux", function (package)
-        local configs = {"--enable-static", "--disable-dependency-tracking", "--enable-extra-encodings"}
+        local configs = {"--enable-static", "--enable-shared=no", "--disable-dependency-tracking", "--enable-extra-encodings"}
         if package:debug() then
             table.insert(configs, "--enable-debug")
         else
@@ -29,6 +29,6 @@ package("libiconv")
 
     on_test(function (package)
         os.vrun("iconv --version")
-        assert(package:has_cfuncs("iconv_open", {includes = "iconv.h"}))
+        assert(package:has_cfuncs("iconv_open(0, 0);", {includes = "iconv.h"}))
     end)