Skip to content

azzyr/gdbuf

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gdbuf

Seamlessly use Google Protobuf messages as native Resources in Godot.

gdbuf compiles your .proto files into a high-performance GDExtension (C++), automatically bridging the gap between your network/data layer and the Godot Engine.


Note: This project was developed with the assistance of AI coding tool OpenCode using the Google Gemini 3 model.

Much care and guidance was exercised.

Note: lol. trying to de-slop this so its actually functional


Why gdbuf?

  • Native Resources: Your Protobuf messages become first-class Godot Resource objects. Create, edit, and save them (.tres) directly in the Godot Editor.
  • Inspector Integration: View and modify message fields in the Inspector with full type support.
  • Documentation: Comments in your .proto files are automatically converted into Godot Editor tooltips and documentation.
  • Performance: Built on GDExtension and C++ for maximum speed.
  • Zero Boilerplate: No manual C++ coding required. Just run the tool.

Installation

Prerequisites

  • Go (1.21+)
  • protoc (The Protocol Buffers compiler) installed and in your system PATH.
  • C++ Compiler (gcc/clang/msvc) & CMake (for building the extension).

Build gdbuf

git clone --recursive https://github.com/onion-4-dinner/gdbuf.git
cd gdbuf
make build
# The binary will be in bin/gdbuf

Usage

Run gdbuf pointing to your Protobuf definitions directory. It will handle parsing, code generation, and compiling the GDExtension library for you.

./bin/gdbuf \
  --proto ./path/to/your/protos \
  --include ./path/to/your/protos/public \
  --include ./path/to/your/protos/private \
  --out ./path/to/godot_project/addons/my_proto_extension \
  --name MyProtoLib

Arguments

  • --proto: Path to the directory containing your .proto files (Required).

  • --include: Additional directories to include for resolving imports. Can be specified multiple times.

  • --out: Directory where the compiled GDExtension (library + .gdextension file) will be placed (Default: ./out).

  • --genout: Directory where the intermediate C++ source code will be generated (Default: .).

  • --generate-only: Only generate the C++ source code, skipping the GDExtension compilation step (Default: false).

  • --name: Name of the GDExtension library (Default: gdbufgen).

  • --platform: Target platform(s) to build for. Can be a single platform (linux, windows, web, android), a comma-separated list (linux,web), or all. Default: Host OS.

  • --cache: Custom directory for build artifacts and toolchain downloads (Android NDK, Emscripten SDK). Default: System cache directory (~/.cache/gdbuf on Linux, ~/Library/Caches/gdbuf on macOS).

  • --debug: Build debug binaries instead (Default: false)

  • --threaded: Build multi-threaded binaries for web (Default: false)

  • --double: Build with double-precision floating point variables (Default: false)

In Godot

Once the extension is generated and placed in your project:

  1. Restart Godot to load the new extension.
  2. Use in GDScript:
    # Create a message
    var msg = MyMessage.new()
    msg.health = 100
    msg.name = "Player 1"
    
    # Serialize
    var bytes = msg.to_byte_array()
    
    # Save to disk
    ResourceSaver.save(msg, "res://player_data.tres")
  3. Use in Editor: Right-click in FileSystem -> New Resource -> Search for your message name.

Documentation

About

Protobuf to GDExtension - C++ code generator and GDExtension builder in Go

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Go 52.3%
  • Go Template 37.0%
  • Makefile 7.7%
  • CMake 3.0%