libb2: add package (#4833)
* libb2: add package * add configs * rename to b2 * fix openmp * blake2: add packagepull/4835/head
parent
b758151d07
commit
cf467b2eb7
4 changed files with 171 additions and 0 deletions
@ -0,0 +1,54 @@ |
||||
option("openmp", {default = false}) |
||||
option("sse", {default = false}) |
||||
option("neno", {default = false}) |
||||
|
||||
if has_config("openmp") then |
||||
add_requires("openmp") |
||||
add_packages("openmp") |
||||
end |
||||
|
||||
add_rules("mode.debug", "mode.release") |
||||
|
||||
target("blake2") |
||||
set_kind("$(kind)") |
||||
add_headerfiles("ref/blake2.h") |
||||
add_files("src/blake2bp.c", "src/blake2sp.c") |
||||
|
||||
if has_config("sse") then |
||||
add_files( |
||||
"sse/blake2b.c", |
||||
"sse/blake2bp.c", |
||||
"sse/blake2s.c", |
||||
"sse/blake2sp.c", |
||||
"sse/blake2xb.c", |
||||
"sse/blake2xs.c" |
||||
) |
||||
add_vectorexts("all") |
||||
elseif has_config("neno") then |
||||
add_files( |
||||
"neon/blake2b-neon.c", |
||||
"neon/blake2bp.c", |
||||
"neon/blake2s-neon", |
||||
"neon/blake2xb.c", |
||||
"neon/blake2sp.c", |
||||
"neon/blake2xs.c" |
||||
) |
||||
add_vectorexts("all") |
||||
else |
||||
add_files( |
||||
"ref/blake2bp-ref.c", |
||||
"ref/blake2b-ref.c", |
||||
"ref/blake2sp-refon", |
||||
"ref/blake2s-ref.c", |
||||
"ref/blake2xb-ref.c", |
||||
"ref/blake2xs-ref.c" |
||||
) |
||||
end |
||||
|
||||
if is_plat("windows") and is_kind("shared") then |
||||
add_rules("utils.symbols.export_all") |
||||
end |
||||
|
||||
if is_plat("linux", "bsd") then |
||||
add_syslinks("m") |
||||
end |
@ -0,0 +1,37 @@ |
||||
package("blake2") |
||||
set_homepage("https://blake2.net") |
||||
set_description("BLAKE2 official implementations") |
||||
set_license("CC0-1.0") |
||||
|
||||
add_urls("https://github.com/BLAKE2/BLAKE2/archive/ed1974ea83433eba7b2d95c5dcd9ac33cb847913.tar.gz", |
||||
"https://github.com/BLAKE2/BLAKE2.git") |
||||
|
||||
add_versions("2023.02.12", "e1d1194cde9fec0f150961cca8f3d9bdf7c5a5cbe020d1cdfb962b4887793124") |
||||
|
||||
add_configs("openmp", {description = "Enable Openmp", default = false, type = "boolean"}) |
||||
add_configs("sse", {description = "Enable SSE", default = false, type = "boolean"}) |
||||
add_configs("neno", {description = "Enable neno", default = false, type = "boolean"}) |
||||
|
||||
if is_plat("linux", "bsd") then |
||||
add_syslinks("m") |
||||
end |
||||
|
||||
on_load(function (package) |
||||
if package:config("openmp") then |
||||
package:add("deps", "openmp") |
||||
end |
||||
end) |
||||
|
||||
on_install(function (package) |
||||
local configs = { |
||||
openmp = package:config("openmp"), |
||||
sse = package:config("sse"), |
||||
neno = package:config("neno"), |
||||
} |
||||
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua") |
||||
import("package.tools.xmake").install(package, configs) |
||||
end) |
||||
|
||||
on_test(function (package) |
||||
assert(package:has_cfuncs("blake2", {includes = "blake2.h"})) |
||||
end) |
@ -0,0 +1,36 @@ |
||||
option("openmp", {default = false}) |
||||
option("sse", {default = false}) |
||||
|
||||
if has_config("openmp") then |
||||
add_requires("openmp") |
||||
add_packages("openmp") |
||||
end |
||||
|
||||
add_rules("mode.debug", "mode.release") |
||||
|
||||
target("b2") |
||||
set_kind("$(kind)") |
||||
add_headerfiles("src/blake2.h") |
||||
add_files("src/blake2bp.c", "src/blake2sp.c") |
||||
|
||||
if has_config("sse") then |
||||
add_files( |
||||
"src/blake2s.c", |
||||
"src/blake2b.c" |
||||
) |
||||
add_vectorexts("all") |
||||
else |
||||
add_files( |
||||
"src/blake2s-ref.c", |
||||
"src/blake2b-ref.c" |
||||
) |
||||
end |
||||
|
||||
if is_kind("shared") then |
||||
add_defines("BLAKE2_DLL_EXPORTS") |
||||
add_defines("BLAKE2_DLL", {public = true}) |
||||
end |
||||
|
||||
if is_plat("linux", "bsd") then |
||||
add_syslinks("m") |
||||
end |
@ -0,0 +1,44 @@ |
||||
package("libb2") |
||||
set_homepage("https://blake2.net") |
||||
set_description("C library providing BLAKE2b, BLAKE2s, BLAKE2bp, BLAKE2sp") |
||||
set_license("CC0-1.0") |
||||
|
||||
add_urls("https://github.com/BLAKE2/libb2/archive/643decfbf8ae600c3387686754d74c84144950d1.tar.gz", |
||||
"https://github.com/BLAKE2/libb2.git") |
||||
|
||||
add_versions("v0.98.1", "9eb776149c41a34619e801adeae8056ca68faadc7cea3a68a54b2a4d93ef1937") |
||||
|
||||
add_configs("openmp", {description = "Enable Openmp", default = false, type = "boolean"}) |
||||
add_configs("sse", {description = "Enable SSE", default = false, type = "boolean"}) |
||||
|
||||
if is_plat("linux", "bsd") then |
||||
add_syslinks("m") |
||||
end |
||||
|
||||
on_load(function (package) |
||||
if package:config("openmp") then |
||||
package:add("deps", "openmp") |
||||
end |
||||
end) |
||||
|
||||
on_install(function (package) |
||||
if package:config("shared") then |
||||
package:add("defines", "BLAKE2_DLL") |
||||
end |
||||
|
||||
local configs = { |
||||
openmp = package:config("openmp"), |
||||
sse = package:config("sse"), |
||||
} |
||||
|
||||
io.writefile("src/config.h") |
||||
io.replace("src/blake2-impl.h", |
||||
"#define BLAKE2_IMPL_NAME(fun) BLAKE2_IMPL_EVAL(fun, SUFFIX)", |
||||
"#define BLAKE2_IMPL_NAME", {plain = true}) |
||||
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua") |
||||
import("package.tools.xmake").install(package, configs) |
||||
end) |
||||
|
||||
on_test(function (package) |
||||
assert(package:has_cfuncs("blake2", {includes = "blake2.h"})) |
||||
end) |
Loading…
Reference in new issue