Skip to content

Commit 10fc1b0

Browse files
committed
gnutls: add package
1 parent 7b89664 commit 10fc1b0

File tree

5 files changed

+154
-88
lines changed

5 files changed

+154
-88
lines changed

packages/b/brotli/xmake.lua

Lines changed: 85 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,85 @@
1-
package("brotli")
2-
set_homepage("https://github.com/google/brotli")
3-
set_description("Brotli compression format.")
4-
set_license("MIT")
5-
6-
set_urls("https://github.com/google/brotli/archive/$(version).tar.gz",
7-
"https://github.com/google/brotli.git")
8-
9-
add_versions("v1.1.0", "e720a6ca29428b803f4ad165371771f5398faba397edf6778837a18599ea13ff")
10-
add_versions("v1.0.9", "f9e8d81d0405ba66d181529af42a3354f838c939095ff99930da6aa9cdf6fe46")
11-
12-
-- Fix VC C++ 12.0 BROTLI_MSVC_VERSION_CHECK calls
13-
-- VC <= 2012 build failed
14-
if is_plat("windows") then
15-
add_patches("v1.0.9", path.join(os.scriptdir(), "patches", "1.0.9", "common_platform.patch"),
16-
"5d7363a6ed1f9a504dc7af08920cd184f0d04d1ad12d25d657364cf0a2dae6bb")
17-
add_patches("v1.0.9", path.join(os.scriptdir(), "patches", "1.0.9", "tool_brotli.patch"),
18-
"333e2a0306cf33f2fac381aa6b81afd3d1237e7511e5cc8fe7fb760d16d01ca1")
19-
end
20-
21-
add_links("brotlienc", "brotlidec", "brotlicommon")
22-
23-
if is_plat("mingw") and is_subhost("msys") then
24-
add_extsources("pacman::brotli")
25-
elseif is_plat("linux") then
26-
add_extsources("pacman::brotli", "apt::libbrotli-dev")
27-
elseif is_plat("macosx") then
28-
add_extsources("brew::brotli")
29-
end
30-
31-
on_load(function (package)
32-
package:addenv("PATH", "bin")
33-
end)
34-
35-
if on_fetch then
36-
on_fetch("linux", "macosx", function (package, opt)
37-
if opt.system then
38-
local result
39-
for _, name in ipairs({"libbrotlidec", "libbrotlienc", "libbrotlicommon"}) do
40-
local pkginfo = package.find_package and package:find_package("pkgconfig::" .. name, opt)
41-
if pkginfo then
42-
if not result then
43-
result = table.copy(pkginfo)
44-
else
45-
local includedirs = pkginfo.sysincludedirs or pkginfo.includedirs
46-
result.links = table.wrap(result.links)
47-
result.linkdirs = table.wrap(result.linkdirs)
48-
result.includedirs = table.wrap(result.includedirs)
49-
table.join2(result.includedirs, includedirs)
50-
table.join2(result.linkdirs, pkginfo.linkdirs)
51-
table.join2(result.links, pkginfo.links)
52-
end
53-
end
54-
end
55-
return result
56-
end
57-
end)
58-
end
59-
60-
on_install(function (package)
61-
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
62-
local configs = {buildir = "xbuild", vers = package:version_str()}
63-
if package:config("shared") then
64-
configs.kind = "shared"
65-
end
66-
if package:is_plat("linux") and package:config("pic") ~= false then
67-
configs.cxflags = "-fPIC"
68-
end
69-
import("package.tools.xmake").install(package, configs)
70-
end)
71-
72-
on_test(function(package)
73-
if not package:is_cross() then
74-
os.vrun("brotli --version")
75-
end
76-
assert(package:check_csnippets([[
77-
void test() {
78-
BrotliEncoderState* s = BrotliEncoderCreateInstance(NULL, NULL, NULL);
79-
BrotliEncoderDestroyInstance(s);
80-
}
81-
]], {includes = "brotli/encode.h"}))
82-
end)
1+
package("brotli")
2+
set_homepage("https://github.com/google/brotli")
3+
set_description("Brotli compression format.")
4+
set_license("MIT")
5+
6+
set_urls("https://github.com/google/brotli/archive/$(version).tar.gz",
7+
"https://github.com/google/brotli.git")
8+
9+
add_versions("v1.1.0", "e720a6ca29428b803f4ad165371771f5398faba397edf6778837a18599ea13ff")
10+
add_versions("v1.0.9", "f9e8d81d0405ba66d181529af42a3354f838c939095ff99930da6aa9cdf6fe46")
11+
12+
-- Fix VC C++ 12.0 BROTLI_MSVC_VERSION_CHECK calls
13+
-- VC <= 2012 build failed
14+
if is_plat("windows") then
15+
add_patches("v1.0.9", path.join(os.scriptdir(), "patches", "1.0.9", "common_platform.patch"),
16+
"5d7363a6ed1f9a504dc7af08920cd184f0d04d1ad12d25d657364cf0a2dae6bb")
17+
add_patches("v1.0.9", path.join(os.scriptdir(), "patches", "1.0.9", "tool_brotli.patch"),
18+
"333e2a0306cf33f2fac381aa6b81afd3d1237e7511e5cc8fe7fb760d16d01ca1")
19+
end
20+
21+
if is_plat("cross") then
22+
add_syslinks("m")
23+
end
24+
25+
add_links("brotlienc", "brotlidec", "brotlicommon")
26+
27+
if is_plat("mingw") and is_subhost("msys") then
28+
add_extsources("pacman::brotli")
29+
elseif is_plat("linux") then
30+
add_extsources("pacman::brotli", "apt::libbrotli-dev")
31+
elseif is_plat("macosx") then
32+
add_extsources("brew::brotli")
33+
end
34+
35+
if on_fetch then
36+
on_fetch("linux", "macosx", function (package, opt)
37+
if opt.system then
38+
local result
39+
for _, name in ipairs({"libbrotlidec", "libbrotlienc", "libbrotlicommon"}) do
40+
local pkginfo = package.find_package and package:find_package("pkgconfig::" .. name, opt)
41+
if pkginfo then
42+
if not result then
43+
result = table.copy(pkginfo)
44+
else
45+
local includedirs = pkginfo.sysincludedirs or pkginfo.includedirs
46+
result.links = table.wrap(result.links)
47+
result.linkdirs = table.wrap(result.linkdirs)
48+
result.includedirs = table.wrap(result.includedirs)
49+
table.join2(result.includedirs, includedirs)
50+
table.join2(result.linkdirs, pkginfo.linkdirs)
51+
table.join2(result.links, pkginfo.links)
52+
end
53+
end
54+
end
55+
return result
56+
end
57+
end)
58+
end
59+
60+
on_install(function (package)
61+
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
62+
local configs = {buildir = "xbuild", vers = package:version_str():gsub("^v", "")}
63+
if package:config("shared") then
64+
configs.kind = "shared"
65+
end
66+
if package:is_plat("linux") and package:config("pic") ~= false then
67+
configs.cxflags = "-fPIC"
68+
end
69+
import("package.tools.xmake").install(package, configs)
70+
if not package:is_cross() then
71+
package:addenv("PATH", "bin")
72+
end
73+
end)
74+
75+
on_test(function(package)
76+
if not package:is_cross() then
77+
os.vrun("brotli --version")
78+
end
79+
assert(package:check_csnippets([[
80+
void test() {
81+
BrotliEncoderState* s = BrotliEncoderCreateInstance(NULL, NULL, NULL);
82+
BrotliEncoderDestroyInstance(s);
83+
}
84+
]], {includes = "brotli/encode.h"}))
85+
end)

packages/g/gmp/xmake.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,15 @@ package("gmp")
5252
end)
5353

5454
on_test(function (package)
55-
assert(package:has_cfuncs("gmp_randinit", {includes = "gmp.h"}))
55+
assert(package:check_csnippets([[
56+
void factorial(int n) {
57+
int i;
58+
mpz_t p;
59+
mpz_init_set_ui(p,1);
60+
for (i=1; i <= n ; ++i){
61+
mpz_mul_ui(p,p,i);
62+
}
63+
mpz_clear(p);
64+
}
65+
]], {includes = "gmp.h"}))
5666
end)

packages/g/gnutls/xmake.lua

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package("gnutls")
2+
set_homepage("https://www.gnutls.org/")
3+
set_description("GnuTLS is a secure communications library implementing the SSL, TLS and DTLS protocols and technologies around them.")
4+
set_license("LGPL-2.1")
5+
6+
add_urls("https://www.gnupg.org/ftp/gcrypt/gnutls/v3.8/gnutls-$(version).tar.xz")
7+
add_versions("3.8.9", "69e113d802d1670c4d5ac1b99040b1f2d5c7c05daec5003813c049b5184820ed")
8+
9+
if is_plat("mingw") then
10+
add_syslinks("ws2_32", "crypt32", "bcrypt", "ncrypt")
11+
end
12+
13+
add_links("gnutls-openssl", "gnutlsxx", "gnutls")
14+
15+
add_deps("pkgconf")
16+
add_deps("p11-kit")
17+
18+
on_load(function (package)
19+
package:add("deps", "nettle", "libtasn1", "libidn2", "gmp", "libunistring", "brotli", "zlib", "zstd", { configs = {shared = package:config("shared")} })
20+
end)
21+
22+
on_install("linux", "mingw", "macosx", "bsd", "cross", "iphoneos", function (package)
23+
local configs = {"--disable-tests", "--disable-doc", "--disable-nls",
24+
"--with-tpm2=no",
25+
"--with-idn",
26+
"--with-brotli",
27+
"--with-zstd",
28+
"--enable-openssl-compatibility",
29+
"--with-default-trust-store-pkcs11=pkcs11:",
30+
}
31+
table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
32+
if package:is_debug() then
33+
table.insert(configs, "--enable-debug")
34+
end
35+
local envs = import("package.tools.autoconf").buildenvs(package, {packagedeps = {"nettle", "p11-kit", "libtasn1", "libidn2", "gmp", "libunistring", "brotli", "zlib", "zstd"}})
36+
utils.dump(envs)
37+
local p11kit_files = os.files(path.join(package:dep("p11-kit"):installdir(), "**"))
38+
utils.dump(p11kit_files)
39+
import("package.tools.autoconf").install(package, configs, {packagedeps = {"nettle", "p11-kit", "libtasn1", "libidn2", "gmp", "libunistring", "brotli", "zlib", "zstd"}})
40+
end)
41+
42+
on_test(function (package)
43+
assert(package:check_csnippets([[
44+
#include <gnutls/gnutls.h>
45+
void test(void) {
46+
gnutls_session_t session;
47+
gnutls_global_deinit();
48+
}
49+
]]))
50+
end)

packages/n/nettle/xmake.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ package("nettle")
1010
add_versions("3.9.1", "ccfeff981b0ca71bbd6fbcb054f407c60ffb644389a5be80d6716d5b550c6ce3")
1111
add_versions("3.10.1", "b0fcdd7fc0cdea6e80dcf1dd85ba794af0d5b4a57e26397eee3bc193272d9132")
1212

13+
add_links("hogweed", "nettle")
14+
1315
add_deps("m4")
1416
add_deps("gmp")
1517
if is_plat("linux") then
@@ -29,11 +31,10 @@ package("nettle")
2931
table.insert(configs, "--disable-shared")
3032
table.insert(configs, "--enable-static")
3133
end
32-
import("package.tools.autoconf")
33-
local envs = autoconf.buildenvs(package, {packagedeps = {"gmp"}})
34-
autoconf.install(package, configs, {envs = envs})
35-
if os.isfile(package:installdir("lib64", "pkgconfig", "nettle.pc")) then
34+
import("package.tools.autoconf").install(package, configs, {packagedeps = {"gmp"}})
35+
if os.isfile(path.join(package:installdir(), "lib64", "pkgconfig", "nettle.pc")) then
3636
package:add("linkdirs", "lib64")
37+
os.trycp((package:installdir("lib64", "pkgconfig")), package:installdir("lib"))
3738
end
3839
end)
3940

packages/p/p11-kit/xmake.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ package("p11-kit")
88

99
add_versions("0.25.5", "04d0a86450cdb1be018f26af6699857171a188ac6d5b8c90786a60854e1198e5")
1010

11+
-- error: p11-kit cannot be used as a static library
12+
add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})
13+
1114
if is_plat("mingw") and is_subhost("msys") then
1215
add_extsources("pacman::p11-kit")
1316
elseif is_plat("linux") then
@@ -29,7 +32,6 @@ package("p11-kit")
2932

3033
on_install("linux", "mingw", "macosx", "iphoneos", "bsd", "cross", function (package)
3134
local configs = {"-Dsystemd=disabled", "-Dbash_completion=disabled", "-Dtest=false"}
32-
table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
3335
import("package.tools.meson").install(package, configs)
3436
os.trymv(package:installdir("include", "p11-kit-1", "*"), package:installdir("include"))
3537
end)

0 commit comments

Comments
 (0)