Otok public index

apotocki/protobuf

Protocol Buffers, Google's data interchange format: the C++ runtime.

Library
protobuf
Newest
36.2 (r1, android)
Targets
android, apple, linux, windows
License
BSD-3-Clause
Homepage
https://protobuf.dev
Documentation
https://protobuf.dev/reference/cpp/
Keywords
protobuf, serialization, rpc

Use it

In otok.toml:

[deps.protobuf]
recipe = "apotocki/protobuf"
version = "~> 36.2"

Versions

VersionTargetChannelPublishedStatus
36.2 (r1, android) android stable 2026-11-14
36.2 (r1, apple) apple stable 2026-11-14
36.2 (r1, linux) linux stable 2026-11-14
36.2 (r1, windows) windows stable 2026-11-14

36.2 (r1, android)

Platforms

android

Options

OptionTypeDefaultDescription
runtime enum of ["full", "lite"] "full" 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.
zlibadditive bool false GzipOutputStream and ZeroCopyGzip streams, with zlib.

Dependencies

LibraryVersionRecipeDetails
abseil >= 20260000 apotocki/abseil

Toolchains

Recipe files

build.lua 1209 bytes · raw
-- protobuf's CMake project, the runtime libraries only, static, with the Abseil of deps and no protoc (the compiler runs on the
-- build machine: a program that generates code gets it from its own tools). 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 = false, protobuf_BUILD_LIBPROTOC = false, protobuf_BUILD_LIBUPB = false,
        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",
    }
    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
    return { libraries = libraries, headers = p .. "/include" }
end
recipe.toml 1870 bytes · raw
# The otok recipe of Protocol Buffers (https://github.com/apotocki/otok): the C++ runtime (libprotobuf or libprotobuf-lite) for Android, from the
# release archive, with protobuf's CMake and the Abseil of deps, static, without protoc.
[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."
keywords = ["protobuf", "serialization", "rpc"]
cxx-standard = ">= 17"
linkage = ["static"]

[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 = ["android"]
build-on = ["*/ndk"]

[deps.abseil]
version = ">= 20260000"
default-recipe = "apotocki/abseil"

[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"]
link = { libraries = [{ library = "z", when = { option = "zlib" } }] }

[[product]]
name = "ProtobufLite"
when = { option = "runtime", is = "lite" }
libraries = ["protobuf-lite", "utf8_validity"]
link = { libraries = [{ library = "z", when = { option = "zlib" } }] }