Skip to content

Commit c1dfa16

Browse files
author
Peng Hu
committed
protobuf plugin
1 parent e9262ad commit c1dfa16

File tree

238 files changed

+132954
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

238 files changed

+132954
-7
lines changed

Plugins/ue4-protobuf/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Binaries/
2+
Intermediate/
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"FileVersion": 3,
3+
"Version": 1,
4+
"VersionName": "1.0",
5+
"FriendlyName": "Protobuf",
6+
"Description": "",
7+
"Category": "Other",
8+
"CreatedBy": "",
9+
"CreatedByURL": "",
10+
"DocsURL": "",
11+
"MarketplaceURL": "",
12+
"SupportURL": "",
13+
"CanContainContent": true,
14+
"IsBetaVersion": false,
15+
"Installed": false,
16+
"Modules": [
17+
{
18+
"Name": "Protobuf",
19+
"Type": "Runtime",
20+
"LoadingPhase": "PreDefault"
21+
},
22+
{
23+
"Name": "ProtobufEditor",
24+
"Type": "Editor",
25+
"LoadingPhase": "Default"
26+
}
27+
]
28+
}

Plugins/ue4-protobuf/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
### What is this?
2+
3+
This is an Unreal Engine 4 plugin that integrates [Protobuf](https://github.com/protocolbuffers/protobuf) into the project without requiring you to add system PATH or anything else.
4+
5+
### How do use?
6+
7+
1. add the plugin to the project and enable it.
8+
2. add the following property to `build.cs` of the project :
9+
10+
```csharp
11+
PublicDependencyModuleNames.Add("Protobuf");
12+
bEnableUndefinedIdentifierWarnings = false;
13+
bEnableExceptions = true;
14+
```
15+
16+
4. Create `.proto` file into project source code folder
17+
5. Launch the Project in Editor, Click the `Protoc` button.
18+
19+
### Protobuf Version
20+
21+
- Protobuf v3.5.1
22+
1.83 KB
Loading
5.54 KB
Loading
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
2+
3+
#include "Protobuf.h"
4+
5+
#define LOCTEXT_NAMESPACE "FProtobufModule"
6+
7+
void FProtobufModule::StartupModule()
8+
{
9+
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
10+
}
11+
12+
void FProtobufModule::ShutdownModule()
13+
{
14+
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
15+
// we call this function before unloading the module.
16+
}
17+
18+
#undef LOCTEXT_NAMESPACE
19+
20+
IMPLEMENT_MODULE(FProtobufModule, Protobuf)
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
2+
3+
using UnrealBuildTool;
4+
using System.IO;
5+
public class Protobuf : ModuleRules
6+
{
7+
private string ModulePath
8+
{
9+
get { return ModuleDirectory; }
10+
}
11+
12+
private string ThridPartyPath
13+
{
14+
get { return Path.Combine(ModulePath, "ThirdParty/"); }
15+
}
16+
17+
public Protobuf(ReadOnlyTargetRules Target) : base(Target)
18+
{
19+
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
20+
21+
PublicIncludePaths.AddRange(
22+
new string[] {
23+
// ... add public include paths required here ...
24+
}
25+
);
26+
27+
28+
PrivateIncludePaths.AddRange(
29+
new string[] {
30+
// ... add other private include paths required here ...
31+
}
32+
);
33+
34+
35+
PublicDependencyModuleNames.AddRange(
36+
new string[]
37+
{
38+
"Core",
39+
// ... add other public dependencies that you statically link with here ...
40+
}
41+
);
42+
43+
44+
PrivateDependencyModuleNames.AddRange(
45+
new string[]
46+
{
47+
// ... add private dependencies that you statically link with here ...
48+
}
49+
);
50+
51+
52+
DynamicallyLoadedModuleNames.AddRange(
53+
new string[]
54+
{
55+
// ... add any modules that your module loads dynamically here ...
56+
}
57+
);
58+
59+
PublicSystemIncludePaths.AddRange(
60+
new string[]
61+
{
62+
Path.Combine(ThridPartyPath,"protobuf/include")
63+
}
64+
);
65+
66+
PublicAdditionalLibraries.AddRange(
67+
new string[]
68+
{
69+
}
70+
);
71+
72+
if(Target.bForceEnableRTTI)
73+
{
74+
bUseRTTI = true;
75+
PublicDefinitions.Add("GOOGLE_PROTOBUF_NO_RTTI=0");
76+
}
77+
else
78+
{
79+
bUseRTTI = false;
80+
PublicDefinitions.Add("GOOGLE_PROTOBUF_NO_RTTI=1");
81+
}
82+
if(Target.Platform != UnrealTargetPlatform.Win32 && Target.Platform != UnrealTargetPlatform.Win64)
83+
{
84+
PublicDefinitions.Add("HAVE_PTHREAD");
85+
}
86+
87+
PublicDefinitions.Add("_CRT_SECURE_NO_WARNINGS");
88+
89+
bEnableShadowVariableWarnings = false;
90+
bEnableUndefinedIdentifierWarnings = false;
91+
bEnableExceptions = true;
92+
}
93+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
2+
3+
#pragma once
4+
5+
#include "CoreMinimal.h"
6+
#include "Modules/ModuleManager.h"
7+
8+
class FProtobufModule : public IModuleInterface
9+
{
10+
public:
11+
12+
/** IModuleInterface implementation */
13+
virtual void StartupModule() override;
14+
virtual void ShutdownModule() override;
15+
};
Binary file not shown.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
set(PACKAGE_VERSION "3.5.1")
2+
set(${PACKAGE_FIND_NAME}_VERSION_PRERELEASE "" PARENT_SCOPE)
3+
4+
# Prerelease versions cannot be passed in directly via the find_package command,
5+
# so we allow users to specify it in a variable
6+
if(NOT DEFINED "${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE")
7+
set("${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}" "")
8+
else()
9+
set(PACKAGE_FIND_VERSION ${PACKAGE_FIND_VERSION}-${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE})
10+
endif()
11+
set(PACKAGE_FIND_VERSION_PRERELEASE "${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}")
12+
13+
# VERSION_EQUAL ignores the prerelease strings, so we use STREQUAL.
14+
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
15+
set(PACKAGE_VERSION_EXACT TRUE)
16+
endif()
17+
18+
set(PACKAGE_VERSION_COMPATIBLE TRUE) #Assume true until shown otherwise
19+
20+
if(PACKAGE_FIND_VERSION) #Only perform version checks if one is given
21+
if(NOT PACKAGE_FIND_VERSION_MAJOR EQUAL "3")
22+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
23+
elseif(PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
24+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
25+
elseif(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
26+
# Do not match prerelease versions to non-prerelease version requests.
27+
if(NOT "" STREQUAL "" AND PACKAGE_FIND_VERSION_PRERELEASE STREQUAL "")
28+
message(AUTHOR_WARNING "To use this prerelease version of ${PACKAGE_FIND_NAME}, set ${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE to '' or greater.")
29+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
30+
endif()
31+
32+
# Not robustly SemVer compliant, but protobuf never uses '.' separated prerelease identifiers.
33+
if(PACKAGE_FIND_VERSION_PRERELEASE STRGREATER "")
34+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
35+
endif()
36+
endif()
37+
endif()
38+
39+
# Check and save build options used to create this package
40+
macro(_check_and_save_build_option OPTION VALUE)
41+
if(DEFINED ${PACKAGE_FIND_NAME}_${OPTION} AND
42+
NOT ${PACKAGE_FIND_NAME}_${OPTION} STREQUAL ${VALUE})
43+
set(PACKAGE_VERSION_UNSUITABLE TRUE)
44+
endif()
45+
set(${PACKAGE_FIND_NAME}_${OPTION} ${VALUE} PARENT_SCOPE)
46+
endmacro()
47+
_check_and_save_build_option(WITH_ZLIB OFF)
48+
_check_and_save_build_option(MSVC_STATIC_RUNTIME ON)
49+
_check_and_save_build_option(BUILD_SHARED_LIBS OFF)
50+
51+
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
52+
if(CMAKE_SIZEOF_VOID_P AND "4")
53+
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
54+
if(NOT CMAKE_SIZEOF_VOID_P EQUAL "4")
55+
math(EXPR installedBits "4 * 8")
56+
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
57+
set(PACKAGE_VERSION_UNSUITABLE TRUE)
58+
endif()
59+
endif()
60+

0 commit comments

Comments
 (0)