Skip to content

Commit e3f81b6

Browse files
committed
add lua fmt lib
1 parent b3e3e2d commit e3f81b6

File tree

9 files changed

+774
-7
lines changed

9 files changed

+774
-7
lines changed

Makefile

+12-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ ifeq ($(config),debug)
1515
sharetable_config = debug
1616
crypt_config = debug
1717
pb_config = debug
18+
lfmt_config = debug
1819
mongo_config = debug
1920
lualib_config = debug
2021

@@ -25,14 +26,15 @@ else ifeq ($(config),release)
2526
sharetable_config = release
2627
crypt_config = release
2728
pb_config = release
29+
lfmt_config = release
2830
mongo_config = release
2931
lualib_config = release
3032

3133
else
3234
$(error "invalid configuration $(config)")
3335
endif
3436

35-
PROJECTS := lua mimalloc moon sharetable crypt pb mongo lualib
37+
PROJECTS := lua mimalloc moon sharetable crypt pb lfmt mongo lualib
3638

3739
.PHONY: all clean help $(PROJECTS)
3840

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

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

79+
lfmt:
80+
ifneq (,$(lfmt_config))
81+
@echo "==== Building lfmt ($(lfmt_config)) ===="
82+
@${MAKE} --no-print-directory -C build/projects/lfmt -f Makefile config=$(lfmt_config)
83+
endif
84+
7785
mongo:
7886
ifneq (,$(mongo_config))
7987
@echo "==== Building mongo ($(mongo_config)) ===="
@@ -93,6 +101,7 @@ clean:
93101
@${MAKE} --no-print-directory -C build/projects/sharetable -f Makefile clean
94102
@${MAKE} --no-print-directory -C build/projects/crypt -f Makefile clean
95103
@${MAKE} --no-print-directory -C build/projects/pb -f Makefile clean
104+
@${MAKE} --no-print-directory -C build/projects/lfmt -f Makefile clean
96105
@${MAKE} --no-print-directory -C build/projects/mongo -f Makefile clean
97106
@${MAKE} --no-print-directory -C build/projects/lualib -f Makefile clean
98107

@@ -112,6 +121,7 @@ help:
112121
@echo " sharetable"
113122
@echo " crypt"
114123
@echo " pb"
124+
@echo " lfmt"
115125
@echo " mongo"
116126
@echo " lualib"
117127
@echo ""

Server.sln

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "crypt", "build\projects\crypt\crypt.vcxproj", "{D70E3F0F-4323-67C0-0CA5-0A20787863F1}"
55
EndProject
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lfmt", "build\projects\lfmt\lfmt.vcxproj", "{D8089A7C-C43F-9B0D-6D2C-81105942170F}"
7+
EndProject
68
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua", "build\projects\lua\lua.vcxproj", "{C78D880B-3397-887C-BC12-9F7C281B947C}"
79
EndProject
810
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lualib", "build\projects\lualib\lualib.vcxproj", "{BE65480C-AA07-73E2-93C2-86367F03FA32}"
@@ -27,6 +29,10 @@ Global
2729
{D70E3F0F-4323-67C0-0CA5-0A20787863F1}.Debug|x64.Build.0 = Debug|x64
2830
{D70E3F0F-4323-67C0-0CA5-0A20787863F1}.Release|x64.ActiveCfg = Release|x64
2931
{D70E3F0F-4323-67C0-0CA5-0A20787863F1}.Release|x64.Build.0 = Release|x64
32+
{D8089A7C-C43F-9B0D-6D2C-81105942170F}.Debug|x64.ActiveCfg = Debug|x64
33+
{D8089A7C-C43F-9B0D-6D2C-81105942170F}.Debug|x64.Build.0 = Debug|x64
34+
{D8089A7C-C43F-9B0D-6D2C-81105942170F}.Release|x64.ActiveCfg = Release|x64
35+
{D8089A7C-C43F-9B0D-6D2C-81105942170F}.Release|x64.Build.0 = Release|x64
3036
{C78D880B-3397-887C-BC12-9F7C281B947C}.Debug|x64.ActiveCfg = Debug|x64
3137
{C78D880B-3397-887C-BC12-9F7C281B947C}.Debug|x64.Build.0 = Debug|x64
3238
{C78D880B-3397-887C-BC12-9F7C281B947C}.Release|x64.ActiveCfg = Release|x64

build/projects/lfmt/Makefile

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Alternative GNU Make project makefile autogenerated by Premake
2+
3+
ifndef config
4+
config=debug
5+
endif
6+
7+
ifndef verbose
8+
SILENT = @
9+
endif
10+
11+
.PHONY: clean prebuild
12+
13+
SHELLTYPE := posix
14+
ifeq (.exe,$(findstring .exe,$(ComSpec)))
15+
SHELLTYPE := msdos
16+
endif
17+
18+
# Configurations
19+
# #############################################
20+
21+
RESCOMP = windres
22+
INCLUDES += -I../../.. -I../../../third -I../../../third/lua
23+
FORCE_INCLUDE +=
24+
ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES)
25+
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
26+
LIBS +=
27+
LDDEPS +=
28+
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64
29+
LINKCMD = $(AR) -rcs "$@" $(OBJECTS)
30+
define PREBUILDCMDS
31+
endef
32+
define PRELINKCMDS
33+
endef
34+
define POSTBUILDCMDS
35+
endef
36+
37+
ifeq ($(config),debug)
38+
TARGETDIR = ../../bin/Debug
39+
TARGET = $(TARGETDIR)/liblfmt.a
40+
OBJDIR = ../../obj/lfmt/Debug
41+
DEFINES += -DDEBUG -DSOL_ALL_SAFETIES_ON
42+
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall
43+
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall -std=c++17
44+
45+
else ifeq ($(config),release)
46+
TARGETDIR = ../../bin/Release
47+
TARGET = $(TARGETDIR)/liblfmt.a
48+
OBJDIR = ../../obj/lfmt/Release
49+
DEFINES += -DNDEBUG -DSOL_ALL_SAFETIES_ON
50+
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -g -Wall
51+
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -g -Wall -std=c++17
52+
53+
endif
54+
55+
# Per File Configurations
56+
# #############################################
57+
58+
59+
# File sets
60+
# #############################################
61+
62+
GENERATED :=
63+
OBJECTS :=
64+
65+
GENERATED += $(OBJDIR)/lfmt.o
66+
OBJECTS += $(OBJDIR)/lfmt.o
67+
68+
# Rules
69+
# #############################################
70+
71+
all: $(TARGET)
72+
@:
73+
74+
$(TARGET): $(GENERATED) $(OBJECTS) $(LDDEPS) | $(TARGETDIR)
75+
$(PRELINKCMDS)
76+
@echo Linking lfmt
77+
$(SILENT) $(LINKCMD)
78+
$(POSTBUILDCMDS)
79+
80+
$(TARGETDIR):
81+
@echo Creating $(TARGETDIR)
82+
ifeq (posix,$(SHELLTYPE))
83+
$(SILENT) mkdir -p $(TARGETDIR)
84+
else
85+
$(SILENT) mkdir $(subst /,\\,$(TARGETDIR))
86+
endif
87+
88+
$(OBJDIR):
89+
@echo Creating $(OBJDIR)
90+
ifeq (posix,$(SHELLTYPE))
91+
$(SILENT) mkdir -p $(OBJDIR)
92+
else
93+
$(SILENT) mkdir $(subst /,\\,$(OBJDIR))
94+
endif
95+
96+
clean:
97+
@echo Cleaning lfmt
98+
ifeq (posix,$(SHELLTYPE))
99+
$(SILENT) rm -f $(TARGET)
100+
$(SILENT) rm -rf $(GENERATED)
101+
$(SILENT) rm -rf $(OBJDIR)
102+
else
103+
$(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET))
104+
$(SILENT) if exist $(subst /,\\,$(GENERATED)) del /s /q $(subst /,\\,$(GENERATED))
105+
$(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR))
106+
endif
107+
108+
prebuild: | $(OBJDIR)
109+
$(PREBUILDCMDS)
110+
111+
ifneq (,$(PCH))
112+
$(OBJECTS): $(GCH) | $(PCH_PLACEHOLDER)
113+
$(GCH): $(PCH) | prebuild
114+
@echo $(notdir $<)
115+
$(SILENT) $(CC) -x c-header $(ALL_CFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<"
116+
$(PCH_PLACEHOLDER): $(GCH) | $(OBJDIR)
117+
ifeq (posix,$(SHELLTYPE))
118+
$(SILENT) touch "$@"
119+
else
120+
$(SILENT) echo $null >> "$@"
121+
endif
122+
else
123+
$(OBJECTS): | prebuild
124+
endif
125+
126+
127+
# File Rules
128+
# #############################################
129+
130+
$(OBJDIR)/lfmt.o: ../../../third/lfmt/lfmt.c
131+
@echo "$(notdir $<)"
132+
$(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"
133+
134+
-include $(OBJECTS:%.o=%.d)
135+
ifneq (,$(PCH))
136+
-include $(PCH_PLACEHOLDER).d
137+
endif

build/projects/lfmt/lfmt.vcxproj

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|x64">
5+
<Configuration>Debug</Configuration>
6+
<Platform>x64</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|x64">
9+
<Configuration>Release</Configuration>
10+
<Platform>x64</Platform>
11+
</ProjectConfiguration>
12+
</ItemGroup>
13+
<PropertyGroup Label="Globals">
14+
<ProjectGuid>{D8089A7C-C43F-9B0D-6D2C-81105942170F}</ProjectGuid>
15+
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
16+
<Keyword>Win32Proj</Keyword>
17+
<RootNamespace>lfmt</RootNamespace>
18+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
19+
</PropertyGroup>
20+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
21+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
22+
<ConfigurationType>StaticLibrary</ConfigurationType>
23+
<UseDebugLibraries>true</UseDebugLibraries>
24+
<CharacterSet>MultiByte</CharacterSet>
25+
<PlatformToolset>v143</PlatformToolset>
26+
</PropertyGroup>
27+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
28+
<ConfigurationType>StaticLibrary</ConfigurationType>
29+
<UseDebugLibraries>false</UseDebugLibraries>
30+
<CharacterSet>MultiByte</CharacterSet>
31+
<PlatformToolset>v143</PlatformToolset>
32+
</PropertyGroup>
33+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
34+
<ImportGroup Label="ExtensionSettings">
35+
</ImportGroup>
36+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
37+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
38+
</ImportGroup>
39+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
40+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
41+
</ImportGroup>
42+
<PropertyGroup Label="UserMacros" />
43+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
44+
<OutDir>..\..\bin\Debug\</OutDir>
45+
<IntDir>..\..\obj\lfmt\Debug\</IntDir>
46+
<TargetName>lfmt</TargetName>
47+
<TargetExt>.lib</TargetExt>
48+
</PropertyGroup>
49+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
50+
<OutDir>..\..\bin\Release\</OutDir>
51+
<IntDir>..\..\obj\lfmt\Release\</IntDir>
52+
<TargetName>lfmt</TargetName>
53+
<TargetExt>.lib</TargetExt>
54+
</PropertyGroup>
55+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
56+
<ClCompile>
57+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
58+
<WarningLevel>Level4</WarningLevel>
59+
<PreprocessorDefinitions>DEBUG;SOL_ALL_SAFETIES_ON;%(PreprocessorDefinitions)</PreprocessorDefinitions>
60+
<AdditionalIncludeDirectories>..\..\..;..\..\..\third;..\..\..\third\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
61+
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
62+
<Optimization>Disabled</Optimization>
63+
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
64+
<AdditionalOptions>/experimental:c11atomics %(AdditionalOptions)</AdditionalOptions>
65+
<LanguageStandard>stdcpp17</LanguageStandard>
66+
<LanguageStandard_C>stdc11</LanguageStandard_C>
67+
<ExternalWarningLevel>Level3</ExternalWarningLevel>
68+
</ClCompile>
69+
<Link>
70+
<SubSystem>Windows</SubSystem>
71+
<GenerateDebugInformation>true</GenerateDebugInformation>
72+
</Link>
73+
</ItemDefinitionGroup>
74+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
75+
<ClCompile>
76+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
77+
<WarningLevel>Level4</WarningLevel>
78+
<PreprocessorDefinitions>NDEBUG;SOL_ALL_SAFETIES_ON;%(PreprocessorDefinitions)</PreprocessorDefinitions>
79+
<AdditionalIncludeDirectories>..\..\..;..\..\..\third;..\..\..\third\lua;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
80+
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
81+
<Optimization>Full</Optimization>
82+
<FunctionLevelLinking>true</FunctionLevelLinking>
83+
<IntrinsicFunctions>true</IntrinsicFunctions>
84+
<MinimalRebuild>false</MinimalRebuild>
85+
<StringPooling>true</StringPooling>
86+
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
87+
<AdditionalOptions>/experimental:c11atomics %(AdditionalOptions)</AdditionalOptions>
88+
<LanguageStandard>stdcpp17</LanguageStandard>
89+
<LanguageStandard_C>stdc11</LanguageStandard_C>
90+
<ExternalWarningLevel>Level3</ExternalWarningLevel>
91+
</ClCompile>
92+
<Link>
93+
<SubSystem>Windows</SubSystem>
94+
<GenerateDebugInformation>true</GenerateDebugInformation>
95+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
96+
<OptimizeReferences>true</OptimizeReferences>
97+
</Link>
98+
</ItemDefinitionGroup>
99+
<ItemGroup>
100+
<ClCompile Include="..\..\..\third\lfmt\lfmt.c" />
101+
</ItemGroup>
102+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
103+
<ImportGroup Label="ExtensionTargets">
104+
</ImportGroup>
105+
</Project>

build/projects/moon/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ INCLUDES += -I../../.. -I../../../moon-src -I../../../moon-src/core -I../../../t
2323
FORCE_INCLUDE +=
2424
ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES)
2525
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
26-
LIBS += -llua -llualib -lcrypt -lpb -lsharetable -lmongo -lmimalloc -ldl -lpthread -lstdc++fs
26+
LIBS += -llua -llualib -lcrypt -lpb -lsharetable -lmongo -lmimalloc -llfmt -ldl -lpthread -lstdc++fs
2727
LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
2828
define PREBUILDCMDS
2929
endef
@@ -37,7 +37,7 @@ OBJDIR = ../../obj/moon/Debug
3737
DEFINES += -DDEBUG -DASIO_STANDALONE -DASIO_NO_DEPRECATED -DMOON_ENABLE_MIMALLOC
3838
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall
3939
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall -std=c++17
40-
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
40+
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
4141
ALL_LDFLAGS += $(LDFLAGS) -L../../bin/Debug -L/usr/lib64 -m64 -static-libstdc++ -static-libgcc -Wl,-E,--as-needed,-rpath=./
4242
define POSTBUILDCMDS
4343
@echo Running postbuild commands
@@ -51,7 +51,7 @@ OBJDIR = ../../obj/moon/Release
5151
DEFINES += -DNDEBUG -DASIO_STANDALONE -DASIO_NO_DEPRECATED -DMOON_ENABLE_MIMALLOC
5252
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -g -Wall
5353
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -g -Wall -std=c++17
54-
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
54+
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
5555
ALL_LDFLAGS += $(LDFLAGS) -L../../bin/Release -L/usr/lib64 -m64 -static-libstdc++ -static-libgcc -Wl,-E,--as-needed,-rpath=./
5656
define POSTBUILDCMDS
5757
@echo Running postbuild commands

build/projects/moon/moon.vcxproj

+3
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@
152152
<ProjectReference Include="..\mimalloc\mimalloc.vcxproj">
153153
<Project>{7381B8AB-5F4E-13B7-8867-015F74934845}</Project>
154154
</ProjectReference>
155+
<ProjectReference Include="..\lfmt\lfmt.vcxproj">
156+
<Project>{D8089A7C-C43F-9B0D-6D2C-81105942170F}</Project>
157+
</ProjectReference>
155158
</ItemGroup>
156159
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
157160
<ImportGroup Label="ExtensionTargets">

moon-src/moon.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -309,5 +309,6 @@ void open_custom_libs(lua_State* L) {
309309
REGISTER_CUSTOM_LIBRARY("navmesh", luaopen_navmesh);
310310
REGISTER_CUSTOM_LIBRARY("uuid", luaopen_uuid);
311311
REGISTER_CUSTOM_LIBRARY("schema", luaopen_schema);
312+
REGISTER_CUSTOM_LIBRARY("fmt", luaopen_fmt);
312313
}
313314
}

0 commit comments

Comments
 (0)