All Projects → jashking → Ue4protobuf

jashking / Ue4protobuf

A protobuf source integration for UE4.

Projects that are alternatives of or similar to Ue4protobuf

luban
你的最佳游戏配置解决方案 {excel, csv, xls, xlsx, json, bson, xml, yaml, lua, unity scriptableobject} => {json, bson, xml, lua, yaml, protobuf(pb), msgpack, flatbuffers, erlang, custom template} data + {c++, java, c#, go(golang), lua, javascript(js), typescript(ts), erlang, rust, gdscript, protobuf schema, flatbuffers schema, custom template} code。
Stars: ✭ 1,660 (+1975%)
Mutual labels:  protobuf, ue4
protobuf-ue4
Build Protobuf for Unreal Engine 4 with Jenkins Pipeline.
Stars: ✭ 26 (-67.5%)
Mutual labels:  protobuf, ue4
libprotobuf ue4
libprotobuf for Unreal Engine 4
Stars: ✭ 81 (+1.25%)
Mutual labels:  protobuf, ue4
Sol2proto
Ethereum contract ABI to gRPC protobuf IDL transpiler
Stars: ✭ 41 (-48.75%)
Mutual labels:  protobuf
Mortgageblockchainfabric
Mortgage Processing App using Hyperledger Fabric Blockchain. Uses channels for privacy and access, and restricts read/write previleges through endorsement policies
Stars: ✭ 45 (-43.75%)
Mutual labels:  protobuf
Node Google Play Cli
command line tools using the node-google-play library
Stars: ✭ 58 (-27.5%)
Mutual labels:  protobuf
Easyrpc
EasyRpc is a simple, high-performance, easy-to-use RPC framework based on Netty, ZooKeeper and ProtoStuff.
Stars: ✭ 79 (-1.25%)
Mutual labels:  protobuf
Grpc Contract
A tool to generate the grpc server code for a contract
Stars: ✭ 40 (-50%)
Mutual labels:  protobuf
Grpcdump
Tool for capture and parse grpc traffic
Stars: ✭ 75 (-6.25%)
Mutual labels:  protobuf
Ueviewer
Viewer and exporter for Unreal Engine 1-4 assets (UE Viewer).
Stars: ✭ 1,083 (+1253.75%)
Mutual labels:  ue4
Grpcc
A gRPC cli interface for easy testing against gRPC servers
Stars: ✭ 1,078 (+1247.5%)
Mutual labels:  protobuf
Steambridge
A UE4 implementation of the Steamworks API.
Stars: ✭ 48 (-40%)
Mutual labels:  ue4
Actionroguelike
Third-person Action Roguelike made in Unreal Engine C++ (for Stanford CS193U 2020)
Stars: ✭ 1,121 (+1301.25%)
Mutual labels:  ue4
Protocol Buffers Language Server
[WIP] Protocol Buffers Language Server
Stars: ✭ 44 (-45%)
Mutual labels:  protobuf
Actix Protobuf
Protobuf integration for actix web
Stars: ✭ 75 (-6.25%)
Mutual labels:  protobuf
Lua Protobuf
A Lua module to work with Google protobuf
Stars: ✭ 1,002 (+1152.5%)
Mutual labels:  protobuf
Bluelua
A lightweight ue4 lua framework
Stars: ✭ 69 (-13.75%)
Mutual labels:  ue4
Protoc Gen Twirp swagger
Swagger generator for twirp
Stars: ✭ 54 (-32.5%)
Mutual labels:  protobuf
Proto Extractor
Program to extract protobufs compiled for C#
Stars: ✭ 49 (-38.75%)
Mutual labels:  protobuf
Gcs Tools
GCS support for avro-tools, parquet-tools and protobuf
Stars: ✭ 57 (-28.75%)
Mutual labels:  protobuf

UE4Protobuf

A protobuf source integration for UE4.

直接在项目中集成 libprotobuf 的源码,方便使用

测试平台

  • 已测试通过

    • Win32, Win64
    • Android
    • MAC
    • iOS
  • 未测试

    • Linux

如何使用

  • Source\Protobuf 文件夹复制到自己的项目的Source目录下
  • 修改自己项目的 .build.cs 文件,在 PublicDependencyModuleNames 中增加 Protobuf 模块,并增加 bEnableShadowVariableWarnings = false; bEnableUndefinedIdentifierWarnings = false;,禁掉警告

以下记录完整步骤

提取 libprotobuf 源码

  • protobuf releases下载 protobuf-cpp 源码包
  • CMake 生成 Visual Studio 工程
cd /D protobuf-3.2.0\cmake

cmake.exe -G "Visual Studio 14 2015 Win64" .
  • 将工程 libprotobuf 中用到的源码文件和对应的头文件提取出来

修改 libprotobuf 源码

主要是去掉两个宏开关 GOOGLE_PROTOBUF_NO_RTTIHAVE_PTHREAD

去掉 HAVE_PTHREAD 宏

在非 Windows 平台下都要打开 HAVE_PTHREAD

打开 google/protobuf/stubs/common.cc,把两个地方的 elif defined(HAVE_PTHREAD) 改成 #else

并且把第一处以下两行代码删除

#else
#error "No suitable threading library available."

去掉 GOOGLE_PROTOBUF_NO_RTTI 宏

在所有平台下都要禁用 RTTI,因为 UE4 禁用了 C++ 的运行时类型识别(typeiddynamic_cast)

打开 google/protobuf/arena.h,将

#ifndef GOOGLE_PROTOBUF_NO_RTTI
#define RTTI_TYPE(type) (&typeid(type))
#else
#define RTTI_TYPE_ID(type) (NULL)
#endif

改为

#define RTTI_TYPE_ID(type) (NULL)

打开 google/protobuf/generated_message_reflection.h,将

#if defined(GOOGLE_PROTOBUF_NO_RTTI) || (defined(_MSC_VER)&&!defined(_CPPRTTI))
	return NULL;
#else
	return dynamic_cast<To>(from);
#endif

改为

return NULL;

#if defined(GOOGLE_PROTOBUF_NO_RTTI) || (defined(_MSC_VER)&&!defined(_CPPRTTI))
	bool ok = &T::default_instance() == from->GetReflection()->GetMessageFactory()->GetPrototype(from->GetDescriptor());
		return ok ? down_cast<T*>(from) : NULL;
#else
	return dynamic_cast<To>(from);
#endif

改为

bool ok = &T::default_instance() == from->GetReflection()->GetMessageFactory()->GetPrototype(from->GetDescriptor());
return ok ? down_cast<T*>(from) : NULL;

打开 google/protobuf/stubs/casts.h,删除以下两处代码

#if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI)
	assert(f == NULL || dynamic_cast<To>(f) != NULL); // RTTI: debug mode only!
#endif

#if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI)
	// RTTI: debug mode only!
	assert(dynamic_cast<ToAsPointer>(&f) != NULL); 
#endif

替换 LIBPROTOBUF_EXPORT 宏

将代码里除 google/protobuf/stubs/port.h 中的 LIBPROTOBUF_EXPORT 宏替换为 PROTOBUF_API 将代码里的两处 #elif defined(PROTOBUF_USE_DLLS) 替换为 #elif defined(PROTOBUF_API)

禁用编译警告

因为 UE4 会将一些编译警告当成错误,所以要将编译过程中 libprotobuf 中的警告禁用掉

Protobuf 模块的编译描述文件 Protobuf.build.cs 中增加

bEnableShadowVariableWarnings = false;
bEnableUndefinedIdentifierWarnings = false;

google/protobuf/map_field.h 文件开头增加

#ifdef _MSC_VER
#pragma warning(disable: 4661)
#endif //_MSC_VER

check 宏冲突问题

打开 google/protobuf/stubs/type_traits.h,将 check 宏改名为 g_check,如下

// BEGIN GOOGLE LOCAL MODIFICATION -- check is a #define on Mac.
// #undef check
// END GOOGLE LOCAL MODIFICATION

static yes g_check(const B*);
static no g_check(const void*);

enum {
	value = sizeof(g_check(static_cast<const D*>(NULL))) == sizeof(yes),
};

noexcept 关键字问题

Protobuf3.5 版本开始,逐渐使用 C++11 语法,其中就使用了 noexcept 关键字,但是在虚幻中默认是不使用异常处理的,这样就会导致编译失败,错误为

error C4577: 在未指定异常处理模式的情况下使用了 "noexcept";不一定会在异常时终止。指定 /EHsc

有以下几种改法

  • 第一种是在 build.cs 中打开 bEnableExceptions 开关,本文中就是使用了这个方法
  • 第二种是将 noexcept 关键字删掉,不过这样也需要修改 protoc 的源码,保证生成出来的 .pb.h/.pb.cc 中也没有 noexcept
  • 第三种是修改 UBT 源码,加入 /EHsc 标记,这种不推荐
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].