├── .gitmodules ├── CHANGELOG ├── LICENSE ├── README.md ├── lib ├── vs2015 │ ├── libprotobuf-lite.lib │ ├── libprotobuf.lib │ ├── libprotoc.lib │ └── protoc.exe └── vs2015win64 │ ├── libprotobuf-lite.lib │ ├── libprotobuf.lib │ ├── libprotoc.lib │ └── protoc.exe ├── libprotobuf.Build.cs └── regenerateforue4.py /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "protobuf"] 2 | path = protobuf 3 | url = https://github.com/google/protobuf.git 4 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | 2016-04-13 version 0.1-beta-1 2 | * Create the project 3 | * Import the Google's Protocal-Buffers 4 | * Compile the static library for Win32 and Win64 by VS2015 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 code 4 game 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | libprotobuf for [Unreal Engine 4][] 2 | ===== 3 | 4 | [![Join the chat at https://gitter.im/code4game/libprotobuf](https://badges.gitter.im/code4game/libprotobuf.svg)](https://gitter.im/code4game/libprotobuf?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 5 | 6 | Link the google's `protocol bufffers` library as the third party in [Unreal Engine 4][]. 7 | 8 | 9 | Usage 10 | ----- 11 | 12 | 1. Import or copy this project into `/Source/ThirdParty/libprotobuf`. 13 | 1. Add the libprotobuf as a module into `.Build.cs` 14 | * `PrivateDependencyModuleNames.AddRange(new string[] { "CoreUObject", "Engine", "libprotobuf" });` 15 | 1. Generate two code files (header & source, ex: Message.pb.h & Message.pb.cc) of the protocal by `protoc` for `cpp`. (Ref: [Google's Protocol Buffers][]) 16 | 1. Put them into the source directory (`Private` or `Public`) of your project. 17 | 1. Regenerate the code file for [Unreal Engine 4][] by `regenerateforue4.py`. 18 | * `python regenerateforue4.py 'the source file'` 19 | * ex: `python regenerateforue4.py Message.pb.cc` 20 | * You should get this information: `Success to regenerate the code for UE4` 21 | 1. You need include two header files when include the header file(ex: Message.pb.h). 22 | * `#include "AllowWindowsPlatformTypes.h"` //< before include the header file 23 | * `#include "your code header file"` //< ex: `#include "Message.pb.h"` 24 | * `#include "HideWindowsPlatformTypes.h"` //< after include the header file 25 | 1. Include and use the header file(ex: Message.pb.h) in your `.cpp` file. 26 | 1. That's all. 27 | 28 | 29 | Roadmap 30 | ----- 31 | 32 | * Write a tutorial for the usage and create an example 33 | * Support mobile platforms - Android/iOS/Windows Phone 34 | 35 | 36 | License 37 | ----- 38 | 39 | Use The MIT License. 40 | 41 | 42 | **Copyright (c) 2016, [Code 4 Game][].** 43 | 44 | [Unreal Engine 4]: https://www.unrealengine.com/ 45 | [Google's Protocol Buffers]: https://developers.google.com/protocol-buffers/ 46 | [Code 4 Game]: https://c4g.io/ 47 | -------------------------------------------------------------------------------- /lib/vs2015/libprotobuf-lite.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/code4game/libprotobuf_ue4/72aa192eca3d09ebb1c69e2cb1292d62cfa4960f/lib/vs2015/libprotobuf-lite.lib -------------------------------------------------------------------------------- /lib/vs2015/libprotobuf.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/code4game/libprotobuf_ue4/72aa192eca3d09ebb1c69e2cb1292d62cfa4960f/lib/vs2015/libprotobuf.lib -------------------------------------------------------------------------------- /lib/vs2015/libprotoc.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/code4game/libprotobuf_ue4/72aa192eca3d09ebb1c69e2cb1292d62cfa4960f/lib/vs2015/libprotoc.lib -------------------------------------------------------------------------------- /lib/vs2015/protoc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/code4game/libprotobuf_ue4/72aa192eca3d09ebb1c69e2cb1292d62cfa4960f/lib/vs2015/protoc.exe -------------------------------------------------------------------------------- /lib/vs2015win64/libprotobuf-lite.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/code4game/libprotobuf_ue4/72aa192eca3d09ebb1c69e2cb1292d62cfa4960f/lib/vs2015win64/libprotobuf-lite.lib -------------------------------------------------------------------------------- /lib/vs2015win64/libprotobuf.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/code4game/libprotobuf_ue4/72aa192eca3d09ebb1c69e2cb1292d62cfa4960f/lib/vs2015win64/libprotobuf.lib -------------------------------------------------------------------------------- /lib/vs2015win64/libprotoc.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/code4game/libprotobuf_ue4/72aa192eca3d09ebb1c69e2cb1292d62cfa4960f/lib/vs2015win64/libprotoc.lib -------------------------------------------------------------------------------- /lib/vs2015win64/protoc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/code4game/libprotobuf_ue4/72aa192eca3d09ebb1c69e2cb1292d62cfa4960f/lib/vs2015win64/protoc.exe -------------------------------------------------------------------------------- /libprotobuf.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Code 4 Game. All Rights Reserved. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class libprotobuf : ModuleRules 6 | { 7 | public libprotobuf(TargetInfo Target) 8 | { 9 | Type = ModuleType.External; 10 | 11 | bool is_supported = false; 12 | if ((Target.Platform == UnrealTargetPlatform.Win32) || (Target.Platform == UnrealTargetPlatform.Win64)) 13 | { 14 | is_supported = true; 15 | 16 | string vs_path = "vs" 17 | + WindowsPlatform.GetVisualStudioCompilerVersionName() 18 | + ((Target.Platform == UnrealTargetPlatform.Win64) ? "win64" : ""); 19 | string protobuf_lib_directory_full_path = System.IO.Path.Combine(ModuleDirectoryFullPath, "lib", vs_path); 20 | 21 | PublicLibraryPaths.Add(protobuf_lib_directory_full_path); 22 | 23 | PublicAdditionalLibraries.Add("libprotobuf.lib"); 24 | 25 | Definitions.AddRange( 26 | new string[] 27 | { 28 | ((Target.Platform == UnrealTargetPlatform.Win64) ? "WIN64" : "WIN32"), 29 | "_WINDOWS", 30 | "NDEBUG", 31 | "GOOGLE_PROTOBUF_CMAKE_BUILD", 32 | }); 33 | } 34 | 35 | if (is_supported) 36 | { 37 | string protobuf_code_directory_full_path = System.IO.Path.Combine(ModuleDirectoryFullPath, "protobuf", "src"); 38 | 39 | PublicSystemIncludePaths.Add(protobuf_code_directory_full_path); 40 | } 41 | } 42 | 43 | string ModuleDirectoryFullPath 44 | { 45 | get { return System.IO.Path.GetFullPath(ModuleDirectory); } 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /regenerateforue4.py: -------------------------------------------------------------------------------- 1 | # Copyright @ 2016, Code 4 Game, Under The MIT License. 2 | 3 | from datetime import * 4 | import os 5 | import sys 6 | 7 | comment = '// Added for UE4 in {0}(UTC)'.format(datetime.utcnow()) 8 | include_allow_header = '#include "AllowWindowsPlatformTypes.h"' 9 | include_hide_header = '#include "HideWindowsPlatformTypes.h"' 10 | 11 | def Check(_CodeFile): 12 | if (os.path.isfile(_CodeFile) is False): 13 | print "Can't find the code file!!!" 14 | return False 15 | 16 | code_file = open(_CodeFile, 'r') 17 | if (code_file is None): 18 | print "Failed to read the code file!!!" 19 | return False 20 | code_lines = code_file.readlines() 21 | code_file.close() 22 | 23 | for line in code_lines[:10]: 24 | if (line.find(include_allow_header) < 0 and line.find(include_hide_header) < 0): 25 | continue 26 | print "Already was regenerated?" 27 | return False 28 | return True 29 | 30 | def Generate(_CodeFile): 31 | if (Check(_CodeFile) is False): 32 | print "Failed to check the code file!!!" 33 | return 34 | 35 | if (os.path.isfile(_CodeFile) is False): 36 | print "Can't find the code file!!!" 37 | return 38 | 39 | code_file = open(_CodeFile, 'r') 40 | if (code_file is None): 41 | print "Failed to read the code file!!!" 42 | return 43 | code_lines = code_file.readlines() 44 | code_file.close() 45 | 46 | code_file = open(_CodeFile, 'w') 47 | if (code_file is None): 48 | print "Failed to write the code file!!!" 49 | return 50 | meet_first_include = False 51 | meet_last_include = False 52 | for line in code_lines: 53 | if (meet_first_include is False and line[0:10] == "#include \""): 54 | code_file.write('\n{0} {1}\n\n'.format(include_allow_header, comment)) 55 | meet_first_include = True 56 | code_file.write(line) 57 | if (meet_last_include is False and line[:len(line) - 1] == "// @@protoc_insertion_point(includes)"): 58 | code_file.write('\n{0} {1}\n\n'.format(include_hide_header, comment)) 59 | meet_last_include = True 60 | code_file.close() 61 | if (meet_first_include is False): 62 | print "Can't add the allow header!!!" 63 | if (meet_last_include is False): 64 | print "Can't add the hide header!!!" 65 | if (meet_first_include and meet_last_include): 66 | print "Success to regenerate the code for UE4" 67 | 68 | if len(sys.argv) <= 1: 69 | print "Usage: python regenerateforue4.py `code file`" 70 | else: 71 | Generate(sys.argv[1]) 72 | --------------------------------------------------------------------------------