Skip to content

Commit

Permalink
Add flatbuffers to all build systems.
Browse files Browse the repository at this point in the history
  • Loading branch information
akrieger committed Sep 16, 2022
1 parent cda6b38 commit b157d7e
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 9 deletions.
15 changes: 10 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ ifeq ($(PCH), 1)
endif
endif

CPPFLAGS += -isystem ${SRC_DIR}/third-party
CPPFLAGS += -Isrc -isystem ${SRC_DIR}/third-party
CXXFLAGS += $(WARNINGS) $(DEBUG) $(DEBUGSYMS) $(PROFILE) $(OTHERS)
TOOL_CXXFLAGS = -DCATA_IN_TOOL

Expand Down Expand Up @@ -820,6 +820,7 @@ endif

# Enumerations of all the source files and headers.
SOURCES := $(wildcard $(SRC_DIR)/*.cpp)
THIRD_PARTY_SOURCES := $(wildcard $(SRC_DIR)/third-party/flatbuffers/*.cpp)
HEADERS := $(wildcard $(SRC_DIR)/*.h)
TESTSRC := $(wildcard tests/*.cpp)
TESTHDR := $(wildcard tests/*.h)
Expand All @@ -842,6 +843,9 @@ ASTYLE_SOURCES := $(sort \
$(CLANG_TIDY_PLUGIN_SOURCES) \
$(CLANG_TIDY_PLUGIN_HEADERS))

# Third party sources should not be astyle'd
SOURCES += $(THIRD_PARTY_SOURCES)

_OBJS = $(SOURCES:$(SRC_DIR)/%.cpp=%.o)
ifeq ($(TARGETSYSTEM),WINDOWS)
RSRC = $(wildcard $(SRC_DIR)/*.rc)
Expand Down Expand Up @@ -939,8 +943,9 @@ prefix:
if [ "x$$PREFIX_STRING" != "x$$OLDPREFIX" ]; then printf '// NOLINT(cata-header-guard)\n#define PREFIX "%s"\n' "$$PREFIX_STRING" | tee $(SRC_DIR)/prefix.h ; fi \
)

# Unconditionally create the object dir on every invocation.
$(shell mkdir -p $(ODIR))
# Unconditionally create the object dirs on every invocation.
DIRS = $(sort $(dir $(OBJS)))
$(shell mkdir -p $(DIRS))

$(ODIR)/%.inc: $(SRC_DIR)/%.cpp
$(CXX) $(CPPFLAGS) $(DEFINES) $(CXXFLAGS) -H -E $< -o /dev/null 2> $@
Expand Down Expand Up @@ -978,7 +983,7 @@ lang/mo_built.stamp: $(MO_DEPS)
localization: lang/mo_built.stamp

$(CHKJSON_BIN): $(CHKJSON_SOURCES)
$(CXX) $(CXXFLAGS) $(TOOL_CXXFLAGS) -Isrc/chkjson -Isrc $(CHKJSON_SOURCES) -o $(CHKJSON_BIN)
$(CXX) $(CXXFLAGS) $(TOOL_CXXFLAGS) -Isrc/chkjson -Isrc -isystem src/third-party $(CHKJSON_SOURCES) -o $(CHKJSON_BIN)

json-check: $(CHKJSON_BIN)
./$(CHKJSON_BIN)
Expand Down Expand Up @@ -1240,7 +1245,7 @@ style-all-json-parallel: $(JSON_FORMATTER_BIN)
find data -name "*.json" -print0 | xargs -0 -L 1 -P $$(nproc) $(JSON_FORMATTER_BIN)

$(JSON_FORMATTER_BIN): $(JSON_FORMATTER_SOURCES)
$(CXX) $(CXXFLAGS) -MMD -MP $(TOOL_CXXFLAGS) -Itools/format -Isrc \
$(CXX) $(CXXFLAGS) -MMD -MP $(TOOL_CXXFLAGS) -Itools/format -Isrc -isystem src/third-party \
$(JSON_FORMATTER_SOURCES) -o $(JSON_FORMATTER_BIN)

python-check:
Expand Down
10 changes: 6 additions & 4 deletions android/app/jni/src/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ LOCAL_PATH := $(call my-dir)/../../../../src

include $(CLEAR_VARS)

LOCAL_C_INCLUDES := $(LOCAL_PATH)/third-party

LOCAL_MODULE := main

LOCAL_CPP_FEATURES := exceptions rtti

# Add your application source files here...
FILE_LIST := $(sort $(wildcard $(LOCAL_PATH)/*.cpp))
LOCAL_SRC_FILES := $(sort $(FILE_LIST:$(LOCAL_PATH)/%=%))
CATA_SRCS := $(sort $(wildcard $(LOCAL_PATH)/*.cpp))
LOCAL_SRC_FILES := $(sort $(CATA_SRCS:$(LOCAL_PATH)/%=%))

LOCAL_STATIC_LIBRARIES := third-party

LOCAL_SHARED_LIBRARIES := libhidapi SDL2 SDL2_mixer SDL2_image SDL2_ttf mpg123

Expand All @@ -26,3 +26,5 @@ ifeq ($(OS),Windows_NT)
endif

include $(BUILD_SHARED_LIBRARY)

include $(LOCAL_PATH)/../android/app/jni/src/third-party/Android.mk
24 changes: 24 additions & 0 deletions android/app/jni/src/third-party/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
LOCAL_PATH := $(call my-dir)/../../../../../src/third-party

include $(CLEAR_VARS)

LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/..

LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)

LOCAL_MODULE := third-party

LOCAL_CPP_FEATURES := exceptions rtti

# Add your application source files here...
FLATBUFFERS_SRCS := $(sort $(wildcard $(LOCAL_PATH)/flatbuffers/*.cpp))
LOCAL_SRC_FILES := $(sort $(FLATBUFFERS_SRCS:$(LOCAL_PATH)/%=%))

LOCAL_CFLAGS += -DBACKTRACE=1 -DLOCALIZE=1 -Wextra -Wall -fsigned-char

ifeq ($(OS),Windows_NT)
# needed to bypass 8191 character limit on Windows command line
LOCAL_SHORT_COMMANDS := true
endif

include $(BUILD_STATIC_LIBRARY)
5 changes: 5 additions & 0 deletions msvc-full-features/Cataclysm-lib-vcpkg-static.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@
<ItemGroup>
<ClCompile Include="..\src\*.cpp" Exclude="..\src\main.cpp;..\src\messages.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="flatbuffers.vcxproj">
<Project>{8a533a64-435d-4d4f-9ff0-1e97aace9374}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
18 changes: 18 additions & 0 deletions msvc-full-features/Cataclysm-vcpkg-static.sln
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JsonFormatter-lib-vcpkg-sta
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ObjectCreator-vcpkg-static", "..\msvc-object_creator\ObjectCreator-vcpkg-static.vcxproj", "{EC6E05EB-8EE1-4D16-914E-F8DA029E5F50}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "flatbuffers", "flatbuffers.vcxproj", "{8A533A64-435D-4D4F-9FF0-1E97AACE9374}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand Down Expand Up @@ -134,6 +136,22 @@ Global
{EC6E05EB-8EE1-4D16-914E-F8DA029E5F50}.Release-NoTiles|x64.Build.0 = Release|x64
{EC6E05EB-8EE1-4D16-914E-F8DA029E5F50}.Release-NoTiles|x86.ActiveCfg = Release|Win32
{EC6E05EB-8EE1-4D16-914E-F8DA029E5F50}.Release-NoTiles|x86.Build.0 = Release|Win32
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Debug|x64.ActiveCfg = Debug|x64
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Debug|x64.Build.0 = Debug|x64
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Debug|x86.ActiveCfg = Debug|Win32
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Debug|x86.Build.0 = Debug|Win32
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Debug-NoTiles|x64.ActiveCfg = Debug|x64
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Debug-NoTiles|x64.Build.0 = Debug|x64
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Debug-NoTiles|x86.ActiveCfg = Debug|Win32
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Debug-NoTiles|x86.Build.0 = Debug|Win32
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Release|x64.ActiveCfg = Release|x64
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Release|x64.Build.0 = Release|x64
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Release|x86.ActiveCfg = Release|Win32
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Release|x86.Build.0 = Release|Win32
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Release-NoTiles|x64.ActiveCfg = Release|x64
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Release-NoTiles|x64.Build.0 = Release|x64
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Release-NoTiles|x86.ActiveCfg = Release|Win32
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Release-NoTiles|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
120 changes: 120 additions & 0 deletions msvc-full-features/flatbuffers.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\third-party\flatbuffers\base.h" />
<ClInclude Include="..\src\third-party\flatbuffers\code_generators.h" />
<ClInclude Include="..\src\third-party\flatbuffers\flatbuffers.h" />
<ClInclude Include="..\src\third-party\flatbuffers\flatc.h" />
<ClInclude Include="..\src\third-party\flatbuffers\flexbuffers.h" />
<ClInclude Include="..\src\third-party\flatbuffers\grpc.h" />
<ClInclude Include="..\src\third-party\flatbuffers\hash.h" />
<ClInclude Include="..\src\third-party\flatbuffers\idl.h" />
<ClInclude Include="..\src\third-party\flatbuffers\minireflect.h" />
<ClInclude Include="..\src\third-party\flatbuffers\reflection.h" />
<ClInclude Include="..\src\third-party\flatbuffers\reflection_generated.h" />
<ClInclude Include="..\src\third-party\flatbuffers\registry.h" />
<ClInclude Include="..\src\third-party\flatbuffers\stl_emulation.h" />
<ClInclude Include="..\src\third-party\flatbuffers\util.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\third-party\flatbuffers\idl_parser.cpp" />
<ClCompile Include="..\src\third-party\flatbuffers\util.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{8a533a64-435d-4d4f-9ff0-1e97aace9374}</ProjectGuid>
<RootNamespace>flatbuffers</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>false</WholeProgramOptimization>
</PropertyGroup>
<Import Project="Cataclysm.Cpp.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="Cataclysm-common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Label="Vcpkg">
<VcpkgEnabled>false</VcpkgEnabled>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
10 changes: 10 additions & 0 deletions msvc-object_creator/ObjectCreator-vcpkg-static.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cataclysm-lib-vcpkg-static"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JsonFormatter-lib-vcpkg-static", "..\msvc-full-features\JsonFormatter-lib-vcpkg-static.vcxproj", "{534A4E38-96A1-40E4-BDA7-8D17607F0270}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "flatbuffers", "..\msvc-full-features\flatbuffers.vcxproj", "{8A533A64-435D-4D4F-9FF0-1E97AACE9374}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand Down Expand Up @@ -48,6 +50,14 @@ Global
{534A4E38-96A1-40E4-BDA7-8D17607F0270}.Release|x64.Build.0 = Release|x64
{534A4E38-96A1-40E4-BDA7-8D17607F0270}.Release|x86.ActiveCfg = Release|Win32
{534A4E38-96A1-40E4-BDA7-8D17607F0270}.Release|x86.Build.0 = Release|Win32
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Debug|x64.ActiveCfg = Debug|x64
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Debug|x64.Build.0 = Debug|x64
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Debug|x86.ActiveCfg = Debug|Win32
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Debug|x86.Build.0 = Debug|Win32
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Release|x64.ActiveCfg = Release|x64
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Release|x64.Build.0 = Release|x64
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Release|x86.ActiveCfg = Release|Win32
{8A533A64-435D-4D4F-9FF0-1E97AACE9374}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
24 changes: 24 additions & 0 deletions src/third-party/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.1.4)

# Don't clang-tidy third party code
set(CMAKE_CXX_CLANG_TIDY "")

# Root third-party library which will export all individual ones.
add_library(
Expand All @@ -8,6 +10,27 @@ add_library(

set(THIRD_PARTY_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/third-party)

file(GLOB FLATBUFFERS_HEADERS ${THIRD_PARTY_SOURCE_DIR}/flatbuffers/**/*.h)
file(GLOB FLATBUFFERS_SOURCES ${THIRD_PARTY_SOURCE_DIR}/flatbuffers/*.cpp)

add_library(
flatbuffers
STATIC
${FLATBUFFER_HEADERS}
${FLATBUFFERS_SOURCES})

target_include_directories(
flatbuffers
SYSTEM
PUBLIC
${THIRD_PARTY_SOURCE_DIR})

# For cata_flatbuffers_assert.h
target_include_directories(
flatbuffers
PUBLIC
${CMAKE_SOURCE_DIR}/src)

file(GLOB GHC_HEADERS ${THIRD_PARTY_SOURCE_DIR}/ghc/*.hpp)

add_library(
Expand All @@ -28,4 +51,5 @@ target_include_directories(
target_link_libraries(
third-party
INTERFACE
flatbuffers
ghc-filesystem)

0 comments on commit b157d7e

Please sign in to comment.