登录 注册

lua-protobuf

去点 Star
其他
1,914
Stars
398
Forks
88
Watchers
48
Open Issues
MIT
许可证
Lua
语言
2015-05-03
创建时间
2026-11-01
最近更新

项目能做什么

用于处理 Google protobuf 的 Lua 模块。
来源:基于仓库元数据 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
# Google protobuf support for Lua

[![Build Status](https://img.shields.io/github/actions/workflow/status/starwing/lua-protobuf/test.yml?branch=master)](https://github.com/starwing/lua-protobuf/actions?query=branch%3Amaster)[![Coverage Status](https://img.shields.io/coveralls/github/starwing/lua-protobuf)](https://coveralls.io/github/starwing/lua-protobuf?branch=master)

English | [中文](https://github.com/starwing/lua-protobuf/blob/master/README.zh.md)

---

This project offers a C module for Lua (5.1, 5.2, 5.3, 5.4, 5.5 and LuaJIT) manipulating Google's protobuf protocol, both for version 2 and 3 syntax and semantics. It splits to the lower-level and the high-level parts for different goals.

For converting between binary protobuf data with Lua tables, using `pb.load()` loads the compiled protobuf schema content (`*.pb` file) generated by Google protobuf's compiler named `protoc` and call `pb.encode()`/`pb.decode()`.

Or use these modules to manipulate the raw wire format in lower-level way:

  - `pb.slice`: a wire format decoding module.
  - `pb.buffer`: a buffer implement that use to encode basic types into protobuf's wire format.  It can be used to support streaming decode protobuf data.
  - `pb.conv`: a module converting integers in the protobuf wire format.
  - `pb.io`: a module access `stdin/stdout` or other files in binary mode.

If you don't want to depend Google's protobuf compiler, `protoc.lua` is a pure Lua module translating text-based protobuf schema content into the `*.pb` binary format.

## Install

To install, you could just use `luarocks`:

```shell
luarocks install lua-protobuf
```

If you want to build it from source, just clone the repo and use luarocks:

```shell
git clone https://github.com/starwing/lua-protobuf
luarocks make rockspecs/lua-protobuf-scm-1.rockspec
```

If you don't have luarocks, use `hererocks` to install Lua and luarocks:

```shell
pip install hererocks
git clone https://github.com/starwing/lua-protobuf
hererocks -j 2.0 -rlatest .
bin/luarocks make lua-protobuf/rockspecs/lua-protobuf-scm-1.rockspec CFLAGS="-fPIC -Wall -Wextra" LIBFLAGS="-shared"
cp protoc.lua pb.so ..
```

Or you can build it by hand, it only has a pure Lua module `protoc.lua` and a pair of C source: `pb.h` and `pb.c`. *Notice* that in order to build the `pb` C module, you need Lua header file and/or libary file installed. replace `$LUA_HEADERS` and `$LUA_LIBS` below to real install locations.

To build it on macOS, use your favor compiler:

```shell
gcc -O2 -shared -undefined dynamic_lookup -I "$LUA_HEADERS" pb.c -o pb.so
```

On Linux, use the nearly same command:

```shell
gcc -O2 -shared -fPIC -I "$LUA_HEADERS" pb.c -o pb.so
```

On Windows, you could use MinGW or MSVC, create a `*.sln` project or build it on the command line (notice the `Lua_BUILD_AS_DLL` flag):

```shell
cl /O2 /LD /Fepb.dll /I "$LUA_HEADERS" /DLUA_BUILD_AS_DLL pb.c "$LUA_LIBS"
```

Or use the bundled `build.bat` to build a release `pb.dll` with MSVC (static CRT, no V
阅读完整原文

项目深度分析 规则生成(AI 未配置)

综合评分 41.1 分。该项目在“个人可实施性”维度得 35 分,“付费可能性”维度得 20.0 分,差异化空间 70.0 分(评分依据见评分卡)。

面向细分需求的二次开发产品

产品构想基于 lua-protobuf 的核心能力,聚焦一个更窄的场景(如某平台、某行业)做差异化。
目标用户该细分场景用户
难度/周期中 · 2~6 周
收费模式买断制 / 订阅制 / 广告
竞争风险细分需求规模需验证
依据 AI 推测:基于项目主题标签的判断
以上为规则引擎基于仓库公开数据生成的参考结论,包含推测成分,不构成投资或创业承诺;配置 AI 后可获得更深入的分析。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

相似项目数据正在完善中,暂不展示(避免误导)

项目优势与风险

技术成熟度创建于 2015-05-03,近 30 天仍在推送,发布过 10 个 Release
社区活跃Star 1,914 / Fork 398 / Issue 48(数据支持,可自行核实)
许可证MIT
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

此项目未提供 Docker 镜像,安装步骤以原仓库 README 为准(涉及依赖安装与环境配置,对新手门槛较高)。