Skip to content

Commit

Permalink
update build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sniper00 committed Oct 19, 2024
1 parent c3443ac commit 41efe3f
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 49 deletions.
2 changes: 0 additions & 2 deletions build/projects/crypt/crypt.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
<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>
Expand All @@ -85,7 +84,6 @@
<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>
Expand Down
2 changes: 0 additions & 2 deletions build/projects/lfmt/lfmt.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<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>
Expand All @@ -83,7 +82,6 @@
<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>
Expand Down
26 changes: 16 additions & 10 deletions build/projects/lua/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,36 @@ 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)
ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 -shared -Wl,-soname=liblua.so
LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef

ifeq ($(config),debug)
TARGETDIR = ../../bin/Debug
TARGET = $(TARGETDIR)/liblua.a
TARGET = $(TARGETDIR)/liblua.so
OBJDIR = ../../obj/lua/Debug
DEFINES += -DDEBUG -DMAKE_LIB -DLUA_USE_LINUX
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -g -Wall -std=c++17
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -fPIC -g -Wall
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -fPIC -g -Wall -std=c++17
define POSTBUILDCMDS
@echo Running postbuild commands
cp -rf ../../bin/Debug/liblua.so ../../..
endef

else ifeq ($(config),release)
TARGETDIR = ../../bin/Release
TARGET = $(TARGETDIR)/liblua.a
TARGET = $(TARGETDIR)/liblua.so
OBJDIR = ../../obj/lua/Release
DEFINES += -DNDEBUG -DMAKE_LIB -DLUA_USE_LINUX
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -g -Wall
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -g -Wall -std=c++17
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -fPIC -g -Wall
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O2 -fPIC -g -Wall -std=c++17
define POSTBUILDCMDS
@echo Running postbuild commands
cp -rf ../../bin/Release/liblua.so ../../..
endef

endif

Expand Down
2 changes: 0 additions & 2 deletions build/projects/lua/lua.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
<AdditionalIncludeDirectories>..\..\..\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>
Expand Down Expand Up @@ -91,7 +90,6 @@
<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>
Expand Down
2 changes: 0 additions & 2 deletions build/projects/lualib/lualib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<AdditionalIncludeDirectories>..\..\..;..\..\..\third;..\..\..\third\lua;..\..\..\moon-src;..\..\..\moon-src\core;..\..\..\third\mimalloc\include;..\..\..\third\recastnavigation\Detour\Include;..\..\..\third\recastnavigation\DetourCrowd\Include;..\..\..\third\recastnavigation\DetourTileCache\Include;..\..\..\third\recastnavigation\Recast\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<AdditionalOptions>/experimental:c11atomics %(AdditionalOptions)</AdditionalOptions>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
Expand All @@ -83,7 +82,6 @@
<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>
Expand Down
2 changes: 0 additions & 2 deletions build/projects/mimalloc/mimalloc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<AdditionalIncludeDirectories>..\..\..\third\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<AdditionalOptions>/experimental:c11atomics %(AdditionalOptions)</AdditionalOptions>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
Expand All @@ -83,7 +82,6 @@
<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>
Expand Down
2 changes: 0 additions & 2 deletions build/projects/mongo/mongo.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
<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>
Expand All @@ -85,7 +84,6 @@
<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>
Expand Down
8 changes: 4 additions & 4 deletions build/projects/moon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ 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 ../../bin/Debug/liblfmt.a
ALL_LDFLAGS += $(LDFLAGS) -L../../bin/Debug -L/usr/lib64 -m64 -static-libstdc++ -static-libgcc -Wl,-E,--as-needed,-rpath=./
LDDEPS += ../../bin/Debug/liblua.so ../../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 -Wl,-rpath,'$$ORIGIN' -m64 -static-libstdc++ -static-libgcc -Wl,--as-needed,-rpath=./
define POSTBUILDCMDS
@echo Running postbuild commands
cp -rf ../../bin/Debug/moon-d ../../..
Expand All @@ -51,8 +51,8 @@ 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 ../../bin/Release/liblfmt.a
ALL_LDFLAGS += $(LDFLAGS) -L../../bin/Release -L/usr/lib64 -m64 -static-libstdc++ -static-libgcc -Wl,-E,--as-needed,-rpath=./
LDDEPS += ../../bin/Release/liblua.so ../../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 -Wl,-rpath,'$$ORIGIN' -m64 -static-libstdc++ -static-libgcc -Wl,--as-needed,-rpath=./
define POSTBUILDCMDS
@echo Running postbuild commands
cp -rf ../../bin/Release/moon ../../..
Expand Down
2 changes: 0 additions & 2 deletions build/projects/moon/moon.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
<AdditionalIncludeDirectories>..\..\..;..\..\..\moon-src;..\..\..\moon-src\core;..\..\..\third;..\..\..\third\lua;..\..\..\third\mimalloc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<AdditionalOptions>/experimental:c11atomics %(AdditionalOptions)</AdditionalOptions>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
Expand All @@ -89,7 +88,6 @@
<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>
Expand Down
2 changes: 0 additions & 2 deletions build/projects/pb/pb.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<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>
Expand All @@ -83,7 +82,6 @@
<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>
Expand Down
2 changes: 0 additions & 2 deletions build/projects/sharetable/sharetable.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<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>
Expand All @@ -83,7 +82,6 @@
<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>
Expand Down
87 changes: 70 additions & 17 deletions premake5.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---@diagnostic disable: undefined-global
---@diagnostic disable: undefined-global, undefined-field

os.execute("git pull")
os.execute("git submodule init")
os.execute("git submodule update")
if _ACTION ~= "build" and _ACTION ~= "clean" and _ACTION ~= "publish" then
os.execute("git pull")
os.execute("git submodule init")
os.execute("git submodule update")
end

local LUA_BUILD_AS_SHARED = true

Expand All @@ -12,7 +14,9 @@ workspace "Server"
cppdialect "C++17"
location "./"
architecture "x64"
staticruntime "on"
if not LUA_BUILD_AS_SHARED then
staticruntime "on"
end

filter "configurations:Debug"
defines { "DEBUG" }
Expand All @@ -29,9 +33,6 @@ workspace "Server"
warnings "Extra"
cdialect "C11"
buildoptions{"/experimental:c11atomics"}
if LUA_BUILD_AS_DLL then
staticruntime "off"
end

filter { "system:linux" }
warnings "High"
Expand Down Expand Up @@ -119,7 +120,7 @@ project "moon"
links{"dl","pthread","stdc++fs"}
linkoptions {
"-static-libstdc++ -static-libgcc",
"-Wl,-E,--as-needed,-rpath=./"
"-Wl,--as-needed,-rpath=./"
}
filter {"system:macosx"}
links{"dl","pthread"}
Expand Down Expand Up @@ -275,14 +276,25 @@ local function string_trim(input, chars)
return string.gsub(input, pattern, "")
end

local function cleanup()
os.remove("moon")
os.remove("moon.debug")
os.rmdir("build/obj")
os.rmdir("build/bin")
os.rmdir(".vs")
end

if _ACTION == "clean" then
cleanup()
end

newaction {
trigger = "build",
description = "Build",
execute = function ()
local host = os.host()
local switch = {
windows = function ()
os.execute("premake5.exe clean")
os.execute("premake5.exe vs2022")
local command = os.getenv("ProgramFiles(x86)")..[[\Microsoft Visual Studio\Installer\vswhere.exe]]
command = string.format('"%s" %s', string_trim(command), " -latest -products * -requires Microsoft.Component.MSBuild -property installationPath")
Expand All @@ -292,23 +304,64 @@ newaction {
os.execute(string.format('"%s%s" -maxcpucount:4 Server.sln /t:rebuild /p:Configuration=Release ', string_trim(command), [[\MSBuild\Current\Bin\MSBuild.exe]]))
end,
linux = function ()
os.execute("premake5 clean")
os.execute("premake5 gmake2")
os.execute("make -j4 config=release")
os.execute([[
#!/bin/bash
if objdump --section-headers "moon" | grep -q ".debug_info"; then
objcopy --only-keep-debug moon moon.debug
objcopy --only-keep-debug liblua.so liblua.so.debug
strip moon
strip liblua.so
objcopy --add-gnu-debuglink=moon.debug moon
objcopy --add-gnu-debuglink=liblua.so.debug liblua.so
fi
]])
end,
macosx = function ()
os.execute("premake5 clean")
os.execute("premake5 gmake2 --cc=clang")
os.execute("make -j4 config=release")
end,
}

-- cleanup()
switch[host]()
end
}

if _ACTION == "clean" then
os.rmdir("build/obj")
os.rmdir("build/bin")
os.rmdir(".vs")
end
newaction {
trigger = "publish",
description = "Publish",
execute = function ()
local host = os.host()
local switch = {
windows = function ()
os.execute("if exist moon-windows.zip del /f moon-windows.zip")
os.execute("if not exist clib mkdir clib")
os.execute("echo Compressing files into moon-windows.zip...")
os.execute("powershell Compress-Archive -Path moon.exe, lua.dll, lualib, service, clib -DestinationPath moon-windows.zip")
os.execute("echo Checking if moon-windows.zip was created...")
os.execute("if exist moon-windows.zip (echo moon-windows.zip created successfully.) else (echo Failed to create moon-windows.zip.)")
end,
linux = function ()
os.execute([[
#!/bin/bash
rm -f moon-linux.zip
mkdir -p clib
zip -r moon-linux.zip moon liblua.so lualib service clib/*.so moon.debug liblua.so.debug
# zip -r moon-linux-debuginfo.zip moon.debug liblua.so.debug
]])
end,
macosx = function ()
os.execute([[
#!/bin/bash
rm -f moon-linux.zip
mkdir -p clib
zip -r moon-linux.zip moon liblua.dylib lualib service clib/*.dylib
]])
end,
}

switch[host]()
end
}

0 comments on commit 41efe3f

Please sign in to comment.