浏览代码

p11-kit: add package (#6490)

* libtasn1: add support for additional platforms

* p11-kit: add package

* p11-kit: add license

---------

Co-authored-by: star9029 <[email protected]>
Doekin 6 月之前
父节点
当前提交
1938273e10
共有 2 个文件被更改,包括 51 次插入2 次删除
  1. 7 2
      packages/l/libtasn1/xmake.lua
  2. 44 0
      packages/p/p11-kit/xmake.lua

+ 7 - 2
packages/l/libtasn1/xmake.lua

@@ -9,8 +9,10 @@ package("libtasn1")
     add_versions("4.15.0", "dd77509fe8f5304deafbca654dc7f0ea57f5841f41ba530cff9a5bf71382739e")
     add_versions("4.19.0", "1613f0ac1cf484d6ec0ce3b8c06d56263cc7242f1c23b30d82d23de345a63f7a")
 
-    on_install("macosx", "linux", function (package)
-        package:addenv("PATH", "bin")
+    on_install("!windows and !wasm", function (package)
+        if not package:is_cross() then
+            package:addenv("PATH", "bin")
+        end
         local configs = {"--disable-doc", "--disable-dependency-tracking"}
         if package:config("shared") then
             table.insert(configs, "--enable-shared")
@@ -19,6 +21,9 @@ package("libtasn1")
             table.insert(configs, "--disable-shared")
             table.insert(configs, "--enable-static")
         end
+        if is_host("windows") then
+            io.replace("configure", "LIBTOOL='$(SHELL) $(top_builddir)/libtool'", "LIBTOOL='\"$(SHELL)\" $(top_builddir)/libtool'", {plain = true})
+        end
         import("package.tools.autoconf").install(package, configs)
     end)
 

+ 44 - 0
packages/p/p11-kit/xmake.lua

@@ -0,0 +1,44 @@
+package("p11-kit")
+    set_homepage("https://p11-glue.github.io/p11-glue/p11-kit.html")
+    set_description("Provides a way to load and enumerate PKCS#11 modules.")
+    set_license("BSD-3-Clause")
+
+    add_urls("https://github.com/p11-glue/p11-kit/releases/download/$(version)/p11-kit-$(version).tar.xz",
+             "https://github.com/p11-glue/p11-kit.git")
+
+    add_versions("0.25.5", "04d0a86450cdb1be018f26af6699857171a188ac6d5b8c90786a60854e1198e5")
+
+    if is_plat("mingw") and is_subhost("msys") then
+        add_extsources("pacman::p11-kit")
+    elseif is_plat("linux") then
+        add_extsources("pacman::libp11-kit", "apt::libp11-kit-dev")
+    elseif is_plat("macosx") then
+        add_extsources("brew::p11-kit")
+    end
+
+    add_deps("meson", "ninja")
+    add_deps("libffi", "libtasn1")
+
+    on_load(function (package)
+        if package:is_cross() then
+            package:add("deps", "libtasn1~host", {host = true, private = true})
+        else
+            package:addenv("PATH", "bin")
+        end
+    end)
+
+    on_install("linux", "mingw", "macosx", "iphoneos", "bsd", "cross", function (package)
+        local configs = {"-Dsystemd=disabled", "-Dbash_completion=disabled", "-Dtest=false"}
+        table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
+        import("package.tools.meson").install(package, configs)
+        os.trymv(package:installdir("include", "p11-kit-1", "*"), package:installdir("include"))
+    end)
+
+    on_test(function (package)
+        assert(package:check_csnippets({test = [[
+            void test(CK_FUNCTION_LIST_PTR_PTR modules) {
+                p11_kit_modules_finalize(modules);
+                p11_kit_modules_release(modules);
+            }
+        ]]}, {includes = "p11-kit/p11-kit.h"}))
+    end)