From ae92bc06b84afb536a53051aba3c39a4a5552d9a Mon Sep 17 00:00:00 2001 From: Hoildkv <42310255+xq114@users.noreply.github.com> Date: Fri, 22 Apr 2022 21:59:03 +0800 Subject: [PATCH] add cnpy (#1175) --- packages/c/cnpy/xmake.lua | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 packages/c/cnpy/xmake.lua diff --git a/packages/c/cnpy/xmake.lua b/packages/c/cnpy/xmake.lua new file mode 100644 index 000000000..2be412dec --- /dev/null +++ b/packages/c/cnpy/xmake.lua @@ -0,0 +1,36 @@ +package("cnpy") + + set_homepage("https://github.com/rogersce/cnpy") + set_description("library to read/write .npy and .npz files in C/C++") + set_license("MIT") + + add_urls("https://github.com/rogersce/cnpy.git") + add_versions("2018.06.01", "4e8810b1a8637695171ed346ce68f6984e585ef4") + + add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) + + add_deps("zlib") + on_install(function (package) + io.writefile("xmake.lua", [[ + add_rules("mode.debug", "mode.release") + set_languages("c++11") + add_requires("zlib") + target("cnpy") + set_kind("static") + add_files("cnpy.cpp") + add_headerfiles("cnpy.h") + add_packages("zlib") + ]]) + import("package.tools.xmake").install(package) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + void test() { + double myVar1 = 1.2; + char myVar2 = 'a'; + cnpy::npz_save("out.npz","myVar1",&myVar1,{1},"w"); + cnpy::npz_save("out.npz","myVar2",&myVar2,{1},"a"); + } + ]]}, {configs = {languages = "c++11"}, includes = "cnpy.h"})) + end)