Skip to content

Commit

Permalink
add lua fmt lib
Browse files Browse the repository at this point in the history
  • Loading branch information
sniper00 committed Sep 1, 2024
1 parent b3e3e2d commit e3f81b6
Show file tree
Hide file tree
Showing 9 changed files with 774 additions and 7 deletions.
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ifeq ($(config),debug)
sharetable_config = debug
crypt_config = debug
pb_config = debug
lfmt_config = debug
mongo_config = debug
lualib_config = debug

Expand All @@ -25,14 +26,15 @@ else ifeq ($(config),release)
sharetable_config = release
crypt_config = release
pb_config = release
lfmt_config = release
mongo_config = release
lualib_config = release

else
$(error "invalid configuration $(config)")
endif

PROJECTS := lua mimalloc moon sharetable crypt pb mongo lualib
PROJECTS := lua mimalloc moon sharetable crypt pb lfmt mongo lualib

.PHONY: all clean help $(PROJECTS)

Expand All @@ -50,7 +52,7 @@ ifneq (,$(mimalloc_config))
@${MAKE} --no-print-directory -C build/projects/mimalloc -f Makefile config=$(mimalloc_config)
endif

moon: lua lualib crypt pb sharetable mongo mimalloc
moon: lua lualib crypt pb sharetable mongo mimalloc lfmt
ifneq (,$(moon_config))
@echo "==== Building moon ($(moon_config)) ===="
@${MAKE} --no-print-directory -C build/projects/moon -f Makefile config=$(moon_config)
Expand All @@ -74,6 +76,12 @@ ifneq (,$(pb_config))
@${MAKE} --no-print-directory -C build/projects/pb -f Makefile config=$(pb_config)
endif

lfmt:
ifneq (,$(lfmt_config))
@echo "==== Building lfmt ($(lfmt_config)) ===="
@${MAKE} --no-print-directory -C build/projects/lfmt -f Makefile config=$(lfmt_config)
endif

mongo:
ifneq (,$(mongo_config))
@echo "==== Building mongo ($(mongo_config)) ===="
Expand All @@ -93,6 +101,7 @@ clean:
@${MAKE} --no-print-directory -C build/projects/sharetable -f Makefile clean
@${MAKE} --no-print-directory -C build/projects/crypt -f Makefile clean
@${MAKE} --no-print-directory -C build/projects/pb -f Makefile clean
@${MAKE} --no-print-directory -C build/projects/lfmt -f Makefile clean
@${MAKE} --no-print-directory -C build/projects/mongo -f Makefile clean
@${MAKE} --no-print-directory -C build/projects/lualib -f Makefile clean

Expand All @@ -112,6 +121,7 @@ help:
@echo " sharetable"
@echo " crypt"
@echo " pb"
@echo " lfmt"
@echo " mongo"
@echo " lualib"
@echo ""
Expand Down
6 changes: 6 additions & 0 deletions Server.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "crypt", "build\projects\crypt\crypt.vcxproj", "{D70E3F0F-4323-67C0-0CA5-0A20787863F1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lfmt", "build\projects\lfmt\lfmt.vcxproj", "{D8089A7C-C43F-9B0D-6D2C-81105942170F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua", "build\projects\lua\lua.vcxproj", "{C78D880B-3397-887C-BC12-9F7C281B947C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lualib", "build\projects\lualib\lualib.vcxproj", "{BE65480C-AA07-73E2-93C2-86367F03FA32}"
Expand All @@ -27,6 +29,10 @@ Global
{D70E3F0F-4323-67C0-0CA5-0A20787863F1}.Debug|x64.Build.0 = Debug|x64
{D70E3F0F-4323-67C0-0CA5-0A20787863F1}.Release|x64.ActiveCfg = Release|x64
{D70E3F0F-4323-67C0-0CA5-0A20787863F1}.Release|x64.Build.0 = Release|x64
{D8089A7C-C43F-9B0D-6D2C-81105942170F}.Debug|x64.ActiveCfg = Debug|x64
{D8089A7C-C43F-9B0D-6D2C-81105942170F}.Debug|x64.Build.0 = Debug|x64
{D8089A7C-C43F-9B0D-6D2C-81105942170F}.Release|x64.ActiveCfg = Release|x64
{D8089A7C-C43F-9B0D-6D2C-81105942170F}.Release|x64.Build.0 = Release|x64
{C78D880B-3397-887C-BC12-9F7C281B947C}.Debug|x64.ActiveCfg = Debug|x64
{C78D880B-3397-887C-BC12-9F7C281B947C}.Debug|x64.Build.0 = Debug|x64
{C78D880B-3397-887C-BC12-9F7C281B947C}.Release|x64.ActiveCfg = Release|x64
Expand Down
137 changes: 137 additions & 0 deletions build/projects/lfmt/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Alternative GNU Make project makefile autogenerated by Premake

ifndef config
config=debug
endif

ifndef verbose
SILENT = @
endif

.PHONY: clean prebuild

SHELLTYPE := posix
ifeq (.exe,$(findstring .exe,$(ComSpec)))
SHELLTYPE := msdos
endif

# Configurations
# #############################################

RESCOMP = windres
INCLUDES += -I../../.. -I../../../third -I../../../third/lua
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS +=
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64
LINKCMD = $(AR) -rcs "$@" $(OBJECTS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef

ifeq ($(config),debug)
TARGETDIR = ../../bin/Debug
TARGET = $(TARGETDIR)/liblfmt.a
OBJDIR = ../../obj/lfmt/Debug
DEFINES += -DDEBUG -DSOL_ALL_SAFETIES_ON
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall -std=c++17

else ifeq ($(config),release)
TARGETDIR = ../../bin/Release
TARGET = $(TARGETDIR)/liblfmt.a
OBJDIR = ../../obj/lfmt/Release
DEFINES += -DNDEBUG -DSOL_ALL_SAFETIES_ON
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -g -Wall
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -g -Wall -std=c++17

endif

# Per File Configurations
# #############################################


# File sets
# #############################################

GENERATED :=
OBJECTS :=

GENERATED += $(OBJDIR)/lfmt.o
OBJECTS += $(OBJDIR)/lfmt.o

# Rules
# #############################################

all: $(TARGET)
@:

$(TARGET): $(GENERATED) $(OBJECTS) $(LDDEPS) | $(TARGETDIR)
$(PRELINKCMDS)
@echo Linking lfmt
$(SILENT) $(LINKCMD)
$(POSTBUILDCMDS)

$(TARGETDIR):
@echo Creating $(TARGETDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(TARGETDIR)
else
$(SILENT) mkdir $(subst /,\\,$(TARGETDIR))
endif

$(OBJDIR):
@echo Creating $(OBJDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) mkdir -p $(OBJDIR)
else
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
endif

clean:
@echo Cleaning lfmt
ifeq (posix,$(SHELLTYPE))
$(SILENT) rm -f $(TARGET)
$(SILENT) rm -rf $(GENERATED)
$(SILENT) rm -rf $(OBJDIR)
else
$(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET))
$(SILENT) if exist $(subst /,\\,$(GENERATED)) del /s /q $(subst /,\\,$(GENERATED))
$(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR))
endif

prebuild: | $(OBJDIR)
$(PREBUILDCMDS)

ifneq (,$(PCH))
$(OBJECTS): $(GCH) | $(PCH_PLACEHOLDER)
$(GCH): $(PCH) | prebuild
@echo $(notdir $<)
$(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
$(PCH_PLACEHOLDER): $(GCH) | $(OBJDIR)
ifeq (posix,$(SHELLTYPE))
$(SILENT) touch "$@"
else
$(SILENT) echo $null >> "$@"
endif
else
$(OBJECTS): | prebuild
endif


# File Rules
# #############################################

$(OBJDIR)/lfmt.o: ../../../third/lfmt/lfmt.c
@echo "$(notdir $<)"
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"

-include $(OBJECTS:%.o=%.d)
ifneq (,$(PCH))
-include $(PCH_PLACEHOLDER).d
endif
105 changes: 105 additions & 0 deletions build/projects/lfmt/lfmt.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D8089A7C-C43F-9B0D-6D2C-81105942170F}</ProjectGuid>
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
<Keyword>Win32Proj</Keyword>
<RootNamespace>lfmt</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>..\..\bin\Debug\</OutDir>
<IntDir>..\..\obj\lfmt\Debug\</IntDir>
<TargetName>lfmt</TargetName>
<TargetExt>.lib</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>..\..\bin\Release\</OutDir>
<IntDir>..\..\obj\lfmt\Release\</IntDir>
<TargetName>lfmt</TargetName>
<TargetExt>.lib</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>DEBUG;SOL_ALL_SAFETIES_ON;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\..;..\..\..\third;..\..\..\third\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<AdditionalOptions>/experimental:c11atomics %(AdditionalOptions)</AdditionalOptions>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<ExternalWarningLevel>Level3</ExternalWarningLevel>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>NDEBUG;SOL_ALL_SAFETIES_ON;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\..;..\..\..\third;..\..\..\third\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<MinimalRebuild>false</MinimalRebuild>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<AdditionalOptions>/experimental:c11atomics %(AdditionalOptions)</AdditionalOptions>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<ExternalWarningLevel>Level3</ExternalWarningLevel>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\third\lfmt\lfmt.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
6 changes: 3 additions & 3 deletions build/projects/moon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ INCLUDES += -I../../.. -I../../../moon-src -I../../../moon-src/core -I../../../t
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -llua -llualib -lcrypt -lpb -lsharetable -lmongo -lmimalloc -ldl -lpthread -lstdc++fs
LIBS += -llua -llualib -lcrypt -lpb -lsharetable -lmongo -lmimalloc -llfmt -ldl -lpthread -lstdc++fs
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
Expand All @@ -37,7 +37,7 @@ OBJDIR = ../../obj/moon/Debug
DEFINES += -DDEBUG -DASIO_STANDALONE -DASIO_NO_DEPRECATED -DMOON_ENABLE_MIMALLOC
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall -std=c++17
LDDEPS += ../../bin/Debug/liblua.a ../../bin/Debug/liblualib.a ../../bin/Debug/libcrypt.a ../../bin/Debug/libpb.a ../../bin/Debug/libsharetable.a ../../bin/Debug/libmongo.a ../../bin/Debug/libmimalloc.a
LDDEPS += ../../bin/Debug/liblua.a ../../bin/Debug/liblualib.a ../../bin/Debug/libcrypt.a ../../bin/Debug/libpb.a ../../bin/Debug/libsharetable.a ../../bin/Debug/libmongo.a ../../bin/Debug/libmimalloc.a ../../bin/Debug/liblfmt.a
ALL_LDFLAGS += $(LDFLAGS) -L../../bin/Debug -L/usr/lib64 -m64 -static-libstdc++ -static-libgcc -Wl,-E,--as-needed,-rpath=./
define POSTBUILDCMDS
@echo Running postbuild commands
Expand All @@ -51,7 +51,7 @@ OBJDIR = ../../obj/moon/Release
DEFINES += -DNDEBUG -DASIO_STANDALONE -DASIO_NO_DEPRECATED -DMOON_ENABLE_MIMALLOC
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -g -Wall
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -g -Wall -std=c++17
LDDEPS += ../../bin/Release/liblua.a ../../bin/Release/liblualib.a ../../bin/Release/libcrypt.a ../../bin/Release/libpb.a ../../bin/Release/libsharetable.a ../../bin/Release/libmongo.a ../../bin/Release/libmimalloc.a
LDDEPS += ../../bin/Release/liblua.a ../../bin/Release/liblualib.a ../../bin/Release/libcrypt.a ../../bin/Release/libpb.a ../../bin/Release/libsharetable.a ../../bin/Release/libmongo.a ../../bin/Release/libmimalloc.a ../../bin/Release/liblfmt.a
ALL_LDFLAGS += $(LDFLAGS) -L../../bin/Release -L/usr/lib64 -m64 -static-libstdc++ -static-libgcc -Wl,-E,--as-needed,-rpath=./
define POSTBUILDCMDS
@echo Running postbuild commands
Expand Down
3 changes: 3 additions & 0 deletions build/projects/moon/moon.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@
<ProjectReference Include="..\mimalloc\mimalloc.vcxproj">
<Project>{7381B8AB-5F4E-13B7-8867-015F74934845}</Project>
</ProjectReference>
<ProjectReference Include="..\lfmt\lfmt.vcxproj">
<Project>{D8089A7C-C43F-9B0D-6D2C-81105942170F}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
1 change: 1 addition & 0 deletions moon-src/moon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,6 @@ void open_custom_libs(lua_State* L) {
REGISTER_CUSTOM_LIBRARY("navmesh", luaopen_navmesh);
REGISTER_CUSTOM_LIBRARY("uuid", luaopen_uuid);
REGISTER_CUSTOM_LIBRARY("schema", luaopen_schema);
REGISTER_CUSTOM_LIBRARY("fmt", luaopen_fmt);
}
}
Loading

0 comments on commit e3f81b6

Please sign in to comment.