package An official xmake package repository https://xrepo.xmake.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.7 KiB

6 years ago
package("protobuf-cpp")
set_homepage("https://developers.google.com/protocol-buffers/")
6 years ago
set_description("Google's data interchange format for cpp")
6 years ago
add_urls("https://github.com/protocolbuffers/protobuf/releases/download/v$(version)/protobuf-cpp-$(version).zip")
add_versions("3.8.0", "91ea92a8c37825bd502d96af9054064694899c5c7ecea21b8d11b1b5e7e993b5")
add_versions("3.12.3", "74da289e0d0c24b2cb097f30fdc09fa30754175fd5ebb34fae4032c6d95d4ce3")
add_versions("3.13.0", "f7b99f47822b0363175a6751ab59ccaa4ee980bf1198f11a4c3cef162698dde3")
add_versions("3.14.0", "87d6e96166cf5cafc16f2bcfa91c0b54f48bab38538285bee1b9331d992569fa")
add_versions("3.15.5", "cdd7d3925240af541a95a4361ab100b703bee3a9df0d7e9e05c069cf2c76a039")
6 years ago
if is_plat("windows") then
add_deps("cmake")
end
if is_plat("windows") then
add_links("libprotobuf")
else
add_links("protobuf")
end
6 years ago
6 years ago
on_load(function (package)
package:addenv("PATH", "bin")
end)
6 years ago
on_install("windows", function (package)
os.cd("cmake")
local configs = {"-Dprotobuf_BUILD_TESTS=OFF", "-Dprotobuf_BUILD_PROTOC_BINARIES=ON"}
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-Dprotobuf_MSVC_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
if package:config("shared") then
package:add("defines", "PROTOBUF_USE_DLLS")
end
import("package.tools.cmake").install(package, configs)
os.cp("build_*/Release/protoc.exe", package:installdir("bin"))
6 years ago
end)
on_install("linux", "macosx", function (package)
local configs = {}
if package:config("pic") ~= false then
table.insert(configs, "--with-pic")
end
if package:config("shared") then
table.insert(configs, "--enable-shared=yes")
table.insert(configs, "--enable-static=no")
else
table.insert(configs, "--enable-static=yes")
table.insert(configs, "--enable-shared=no")
end
import("package.tools.autoconf").install(package, configs)
6 years ago
end)
on_test(function (package)
io.writefile("test.proto", [[
syntax = "proto3";
package test;
message TestCase {
string name = 4;
}
message Test {
repeated TestCase case = 1;
}
]])
6 years ago
os.vrun("protoc test.proto --cpp_out=.")
6 years ago
assert(package:check_cxxsnippets({test = io.readfile("test.pb.cc")}, {configs = {includedirs = {".", package:installdir("include")}, languages = "c++11"}}))
end)