From 3486564e4d9f97dfbce0ab11a2eaa5ec586cb630 Mon Sep 17 00:00:00 2001 From: star9029 Date: Sun, 24 Nov 2024 20:16:41 +0800 Subject: [PATCH] microsoft-apsi: add package (#5804) * microsoft-apsi: add package * disable shared * add check * disable x86 --- packages/f/flatbuffers/xmake.lua | 5 +-- packages/l/log4cplus/xmake.lua | 9 +++- packages/m/microsoft-apsi/xmake.lua | 69 +++++++++++++++++++++++++++++ packages/m/microsoft-seal/xmake.lua | 5 --- 4 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 packages/m/microsoft-apsi/xmake.lua diff --git a/packages/f/flatbuffers/xmake.lua b/packages/f/flatbuffers/xmake.lua index 4290630fc..700478c00 100644 --- a/packages/f/flatbuffers/xmake.lua +++ b/packages/f/flatbuffers/xmake.lua @@ -15,6 +15,7 @@ package("flatbuffers") add_deps("cmake") on_install(function(package) + io.replace("CMakeLists.txt", "/MT", "", {plain = true}) io.replace("CMakeLists.txt", "RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}", "RUNTIME DESTINATION bin", {plain = true}) @@ -36,9 +37,7 @@ package("flatbuffers") import("package.tools.cmake").install(package, configs) if package:is_plat("windows") and package:is_debug() then - local dir = package:installdir(package:config("shared") and "bin" or "lib") - os.trycp(path.join(package:buildir(), "flatc.pdb"), package:installdir("bin")) - os.trycp(path.join(package:buildir(), "flatbuffers.pdb"), dir) + os.trymv(package:installdir("lib/flatc.pdb"), package:installdir("bin")) end end) diff --git a/packages/l/log4cplus/xmake.lua b/packages/l/log4cplus/xmake.lua index fc651c81b..65d1d3246 100644 --- a/packages/l/log4cplus/xmake.lua +++ b/packages/l/log4cplus/xmake.lua @@ -23,10 +23,17 @@ package("log4cplus") if package:config("unicode") then package:add("defines", "UNICODE") end + if package:is_plat("windows") and package:config("shared") then + package:add("defines", "LOG4CPLUS_BUILD_DLL") + end end) on_install(function (package) - local configs = {"-DLOG4CPLUS_BUILD_TESTING=OFF", "-DWITH_UNIT_TESTS=OFF"} + local configs = { + "-DLOG4CPLUS_BUILD_TESTING=OFF", + "-DWITH_UNIT_TESTS=OFF", + "-DLOG4CPLUS_ENABLE_DECORATED_LIBRARY_NAME=OFF", + } table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) table.insert(configs, "-DUNICODE=" .. (package:config("unicode") and "ON" or "OFF")) diff --git a/packages/m/microsoft-apsi/xmake.lua b/packages/m/microsoft-apsi/xmake.lua new file mode 100644 index 000000000..f39911b6a --- /dev/null +++ b/packages/m/microsoft-apsi/xmake.lua @@ -0,0 +1,69 @@ +package("microsoft-apsi") + set_homepage("https://github.com/microsoft/APSI") + set_description("APSI is a C++ library for Asymmetric (unlabeled or labeled) Private Set Intersection.") + set_license("MIT") + + add_urls("https://github.com/microsoft/APSI.git") + + add_versions("v0.12.0", "b967a126b4e1c682b039afc2d76a98ea2c993230") + + add_configs("log4cplus", {description = "Use Log4cplus for logging", default = false, type = "boolean"}) + add_configs("cppzmq", {description = "Use ZeroMQ for networking", default = false, type = "boolean"}) + add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) + + add_deps("cmake") + add_deps("microsoft-seal", {configs = {ms_gsl = true, zstd = true, throw_tran = false}}) + add_deps("microsoft-kuku", "flatbuffers", "jsoncpp") + + if on_check then + on_check(function (package) + -- TODO: To support cross-compilation, need host flatc tool and target flatbuffers library + -- Remove cmake try_run, replace check_cxx_source_runs to check_cxx_source_compiles + if not package:is_arch64() or package:is_cross() then + raise("package(microsoft-apsi) unsupported cross-compilation") + end + end) + end + + on_load(function (package) + if package:config("log4cplus") then + package:add("deps", "log4cplus", {configs = {unicode = false}}) + end + if package:config("cppzmq") then + package:add("deps", "cppzmq") + end + + local version = package:version() + if version then + package:add("includedirs", format("include/APSI-%s.%s", version:major(), version:minor())) + else + package:add("includedirs", "include/APSI-0.12") + end + end) + + on_install("windows", "linux", "macosx", "bsd", function (package) + local configs = {} + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) + table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) + if package:is_plat("windows") then + table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''") + end + + table.insert(configs, "-DAPSI_USE_LOG4CPLUS=" .. (package:config("log4cplus") and "ON" or "OFF")) + table.insert(configs, "-DAPSI_USE_ZMQ=" .. (package:config("cppzmq") and "ON" or "OFF")) + + local opt = {} + if package:has_tool("cxx", "cl") then + opt.cxflags = {"/utf-8", "/EHsc"} + end + import("package.tools.cmake").install(package, configs, opt) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + using namespace apsi; + void test() { + ThreadPoolMgr::SetThreadCount(4); + } + ]]}, {configs = {languages = "c++17"}, includes = {"apsi/sender.h"}})) + end) diff --git a/packages/m/microsoft-seal/xmake.lua b/packages/m/microsoft-seal/xmake.lua index a75ffb9d9..83f93b67a 100644 --- a/packages/m/microsoft-seal/xmake.lua +++ b/packages/m/microsoft-seal/xmake.lua @@ -86,11 +86,6 @@ package("microsoft-seal") table.insert(configs, "-DSEAL_USE_ALIGNED_ALLOC=OFF") end import("package.tools.cmake").install(package, configs) - - if package:is_plat("windows") and package:is_debug() then - local dir = package:installdir(package:config("shared") and "bin" or "lib") - os.vcp(path.join(package:buildir(), "**.pdb"), dir) - end end) on_test(function (package)