nanopb: add package

nanopb
star9029 1 week ago
parent 60ad6f5456
commit a53e1b8383
  1. 44
      packages/n/nanopb/xmake.lua

@ -0,0 +1,44 @@
package("nanopb")
set_homepage("https://jpa.kapsi.fi/nanopb/")
set_description("Protocol Buffers with small code size")
set_license("zlib")
set_urls("https://github.com/nanopb/nanopb/archive/refs/tags/$(version).tar.gz",
"https://github.com/nanopb/nanopb.git")
add_versions("0.4.9", "524882ce9b6b8abeab3d458b9f15449c3f11d60c099eb388d8732d1bf2944eb3")
add_configs("generator", {description = "Build the protoc plugin for code generation", default = false, type = "boolean"})
add_deps("cmake")
add_deps("protobuf-cpp", {kind = "binary"})
on_load(function (package)
if package:config("generator") then
package:add("deps", "python 3.x")
end
end)
on_install("windows", "linux", "macosx", function (package)
local configs = {
"-Dnanopb_BUILD_RUNTIME=ON",
"-Dnanopb_MSVC_STATIC_RUNTIME=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, "-DBUILD_STATIC_LIBS=" .. (package:config("shared") and "OFF" or "ON"))
if package:config("shared") and package:is_plat("windows") then
table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
end
table.insert(configs, "-Dnanopb_BUILD_GENERATOR=" .. (package:config("generator") and "ON" or "OFF"))
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(), "*.pdb"), dir)
end
end)
on_test(function (package)
assert(package:has_cfuncs("pb_encode", {includes = "nanopb/pb_encode.h"}))
end)
Loading…
Cancel
Save