Back to Wazuh

Intro Engine Message Protocol Buffers (eMessage)

src/engine/source/proto/readme.md

4.14.41.9 KB
Original Source

Intro Engine Message Protocol Buffers (eMessage)

The generateCode.sh script formats and generates the code for all *.proto files in the src folder and saves them to the include folder. This Script will be executed during compilation as long as the protoc compiler is installed on the system. The script also has the functionality of deleting all the files generated by protobuf when regenerating, avoiding the existence of obsolete files. CMake takes care of finding all the *.cpp/hpp files in the include folder and generating the corresponding static library.

Style guide: https://protobuf.dev/programming-guides/style/ </br> syntax: Proto3 </br> proto version: 12.21 </br> clang-format.style: "Engine proyect style" </br>

Protocol Compiler Installation

Ubuntu 22.04

bash
apt-get update
# Instal protobuff compiler dependencies
apt-get install -y g++ git curl gnupg clang-format
# Install bazel (https://bazel.build/install/ubuntu?hl=en)
# Add Bazel distribution URI as a package source
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
mv bazel.gpg /etc/apt/trusted.gpg.d/
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list
# Install and update Bazel 5.4.0 (Bazel 6 is not supported by protobuff yet)
apt update && apt install -y bazel-5.4.0 && apt full-upgrade
# Remove the symbolic link to the old version
rm /usr/bin/bazel
# Create a symbolic link to the new version
ln -s /usr/bin/bazel-5.4.0 /usr/bin/bazel
# Check the version
bazel --version

# Install protoc (https://github.com/protocolbuffers/protobuf/blob/main/src/README.md)
cd ~
# Get the source code
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
# Checkout the version
git checkout v21.12
# Update submodules
git submodule update --init --recursive
# Build
bazel build :protoc :protobuf
# Install
cp bazel-bin/protoc /usr/local/bin