-- Copyright Epic Games, Inc. All Rights Reserved. target("zenserver") set_kind("binary") add_deps("zencore", "zenhttp", "zennet", "zenstore", "zenutil", "zenvfs") add_headerfiles("**.h") add_rules("utils.bin2c", {extensions = {".zip"}}) add_files("**.cpp") add_files("frontend/*.zip") add_files("zenserver.cpp", {unity_ignored = true }) add_includedirs(".") set_symbols("debug") if is_mode("release") then set_optimize("fastest") end if is_plat("windows") then add_ldflags("/subsystem:console,5.02") add_ldflags("/MANIFEST:EMBED") add_ldflags("/LTCG") add_files("zenserver.rc") add_cxxflags("/bigobj") add_links("delayimp", "projectedfslib") add_ldflags("/delayload:ProjectedFSLib.dll") else remove_files("windows/**") end if is_plat("macosx") then add_ldflags("-framework CoreFoundation") add_ldflags("-framework CoreGraphics") add_ldflags("-framework CoreText") add_ldflags("-framework Foundation") add_ldflags("-framework Security") add_ldflags("-framework SystemConfiguration") end add_options("compute") add_options("exec") add_packages( "vcpkg::asio", "vcpkg::cxxopts", "vcpkg::http-parser", "vcpkg::json11", "vcpkg::lua", "vcpkg::mimalloc", "vcpkg::sol2" ) -- to work around some unfortunate Ctrl-C behaviour on Linux/Mac due to -- our use of setsid() at startup we pass in `--no-detach` to zenserver -- ensure that it recieves signals when the user requests termination on_run(function(target) -- the following is roughly cribbed from xmake/actions/run/xmake.lua -- it would be nicer if we had the option of amending the arguments -- via before_run for instance, but I can't figure out a way to do that import("core.base.option") -- get the run directory of target local rundir = target:rundir() -- get the absolute target file path local targetfile = path.absolute(target:targetfile()) -- get run arguments local args = table.wrap(option.get("arguments") or target:get("runargs")) table.insert(args, "--detach=false") -- debugging? if option.get("debug") then debugger.run(targetfile, args, {curdir = rundir}) else os.execv(targetfile, args, {curdir = rundir, detach = option.get("detach")}) end end)