Procházet zdrojové kódy

nettle: Add 'gmp' dependency to enable support for public-key algorithms (#6519)

* nettle: update to 3.10.1

* nettle: enhance tests with SHA1 and RSA snippets

* nettle: add gmp dependency

* nettle: fix links not found issue when libraries are installed to 'lib64'

* m4: Bypass test for MSYS

* gmp: add support for additional platforms

* nettle: add support for additional platforms
Doekin před 5 měsíci
rodič
revize
63c6f67d37
3 změnil soubory, kde provedl 32 přidání a 4 odebrání
  1. 1 1
      packages/g/gmp/xmake.lua
  2. 1 0
      packages/m/m4/xmake.lua
  3. 30 3
      packages/n/nettle/xmake.lua

+ 1 - 1
packages/g/gmp/xmake.lua

@@ -26,7 +26,7 @@ package("gmp")
 
     add_deps("m4")
 
-    on_install("macosx", "linux", function (package)
+    on_install("@!windows and !wasm", function (package)
         local configs = {}
         table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
         table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))

+ 1 - 0
packages/m/m4/xmake.lua

@@ -19,6 +19,7 @@ package("m4")
     end
 
     on_install("@macosx", "@linux", "@msys", "@cygwin", "@bsd", function (package)
+        io.writefile("tests/select.c", "int main(int argc, char **argv) { return 0; }\n") -- Bypass "select" function check
         if package:is_plat("linux") then
             -- fix freadahead.c:92:3: error: #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
             -- https://git.savannah.gnu.org/cgit/gnulib.git

+ 30 - 3
packages/n/nettle/xmake.lua

@@ -8,13 +8,19 @@ package("nettle")
              "https://ftp.gnu.org/gnu/nettle/nettle-$(version).tar.gz")
     add_versions("3.6", "d24c0d0f2abffbc8f4f34dcf114b0f131ec3774895f3555922fe2f40f3d5e3f1")
     add_versions("3.9.1", "ccfeff981b0ca71bbd6fbcb054f407c60ffb644389a5be80d6716d5b550c6ce3")
+    add_versions("3.10.1", "b0fcdd7fc0cdea6e80dcf1dd85ba794af0d5b4a57e26397eee3bc193272d9132")
 
     add_deps("m4")
+    add_deps("gmp")
     if is_plat("linux") then
         add_extsources("apt::nettle-dev")
     end
 
-    on_install("macosx", "linux", function (package)
+    on_install("@!windows and !wasm", function (package)
+        if package:is_plat("iphoneos") then
+            io.replace("configure", "#define gid_t int", "")
+            io.replace("configure", "#define uid_t int", "")
+        end
         local configs = {"--disable-openssl", "--disable-documentation", "--enable-pic"}
         if package:config("shared") then
             table.insert(configs, "--enable-shared")
@@ -23,9 +29,30 @@ package("nettle")
             table.insert(configs, "--disable-shared")
             table.insert(configs, "--enable-static")
         end
-        import("package.tools.autoconf").install(package, configs)
+        import("package.tools.autoconf")
+        local envs = autoconf.buildenvs(package, {packagedeps = {"gmp"}})
+        autoconf.install(package, configs, {envs = envs})
+        if os.isfile(package:installdir("lib64", "pkgconfig", "nettle.pc")) then
+            package:add("linkdirs", "lib64")
+        end
     end)
 
     on_test(function (package)
-        assert(package:has_cfuncs("sha1_init", {includes = "nettle/sha1.h"}))
+        assert(package:check_csnippets([[
+            void sha1_test(void) {
+                struct sha1_ctx ctx;
+                sha1_init(&ctx);
+                uint8_t const buffer[] = "test";
+                sha1_update(&ctx, sizeof(buffer), buffer);
+                uint8_t digest[SHA1_DIGEST_SIZE];
+                sha1_digest(&ctx, SHA1_DIGEST_SIZE, digest);
+            }
+        ]], {includes = "nettle/sha1.h"}))
+        assert(package:check_csnippets([[
+            void rsa_test(void) {
+                struct rsa_public_key pub;
+                rsa_public_key_init(&pub);
+                rsa_public_key_clear(&pub);
+            }
+        ]], {includes = "nettle/rsa.h"}))
     end)