build.lua 1634 bytes · raw
-- protobuf's CMake project, the runtime libraries, static, with the Abseil of deps; in the tool slice (a tool dependency, or a
-- tool a project delivers to its own build) protoc too, with libprotoc and libupb, which its upb generator needs. Nothing is
-- fetched. What it installs: libprotobuf.a or libprotobuf-lite.a and libutf8_validity.a (it holds utf8_range as well).
function build(slice, options, deps)
local defines = {
protobuf_BUILD_TESTS = false, protobuf_BUILD_CONFORMANCE = false, protobuf_BUILD_EXAMPLES = false,
protobuf_BUILD_PROTOC_BINARIES = slice.is_tool, protobuf_BUILD_LIBPROTOC = slice.is_tool,
protobuf_BUILD_LIBUPB = slice.is_tool,
protobuf_BUILD_SHARED_LIBS = false, protobuf_MSVC_STATIC_RUNTIME = false,
protobuf_LOCAL_DEPENDENCIES_ONLY = true, protobuf_WITH_ZLIB = options.zlib,
absl_DIR = deps.abseil.prefix .. "/lib/cmake/absl",
}
if options.zlib then
local z = deps.zlib
defines.ZLIB_USE_STATIC_LIBS = z.linkage == "static"
defines.ZLIB_INCLUDE_DIR = z.include
defines.ZLIB_LIBRARY = z.libraries.z
end
otok.cmake{ defines = defines }
local p = slice.prefix
local lite = options.runtime == "lite"
local libraries = {}
for _, name in ipairs{ lite and "protobuf-lite" or "protobuf", "utf8_validity" } do
libraries[name] = otok.glob("lib/lib" .. name .. ".a", p)[1]
end
local out = { libraries = libraries, headers = p .. "/include" }
if slice.is_tool then out.programs = { protoc = p .. "/bin/protoc" .. (slice.os == "windows" and ".exe" or "") } end
return out
end
recipe.toml 2048 bytes · raw
# The otok recipe of Protocol Buffers (https://github.com/apotocki/otok): the C++ runtime (libprotobuf or libprotobuf-lite) for Linux, from the
# release archive, with protobuf's CMake and the Abseil of deps, static; protoc for the build machine where it is a tool.
[recipe]
api = 1
library = "protobuf"
name = "protobuf"
version = "36.2"
revision = 1
license = "BSD-3-Clause"
license-files = ["LICENSE"]
homepage = "https://protobuf.dev"
documentation = "https://protobuf.dev/reference/cpp/"
description = "Protocol Buffers, Google's data interchange format: the C++ runtime, and protoc for the build machine."
keywords = ["protobuf", "serialization", "rpc"]
cxx-standard = ">= 17"
linkage = ["static"]
# protoc in the tool slice (build.lua): for the recipes that generate code with it and for projects that deliver it
[tool]
programs = ["protoc"]
[source]
url = "https://github.com/protocolbuffers/protobuf/releases/download/v36.2/protobuf-36.2.tar.gz"
sha256 = "3d9642a662d10e68ebae5e53f14dcce5105684212d5078f8e0d47d1ab3ae6b64"
[options.runtime]
type = "enum"
values = ["full", "lite"]
default = "full"
doc = "The runtime: full (libprotobuf: reflection, descriptors, text and JSON) or lite (libprotobuf-lite: messages optimized for code size, no reflection). A program uses one of them."
[options.zlib]
type = "bool"
default = false
additive = true
doc = "GzipOutputStream and ZeroCopyGzip streams, with zlib."
[platforms]
supported = ["linux"]
build-on = ["linux/gcc", "linux/clang"]
[deps.abseil]
version = ">= 20260000"
default-recipe = "apotocki/abseil"
[deps.zlib]
version = ">= 1.2"
default-recipe = "apotocki/zlib"
when = { option = "zlib" }
[toolchains]
cmake = { version = ">= 3.20", default-recipe = "apotocki/cmake" }
ninja = { version = ">= 1.10", default-recipe = "apotocki/ninja" }
[[product]]
name = "Protobuf"
when = { option = "runtime", is = "full" }
libraries = ["protobuf", "utf8_validity"]
[[product]]
name = "ProtobufLite"
when = { option = "runtime", is = "lite" }
libraries = ["protobuf-lite", "utf8_validity"]