set_version("0.1.0", { build = "%Y%m%d%H%M" }) set_configvar("ZEN_SCHEMA_VERSION", 3) -- changed cas oplog format (p3rl) add_requires( "vcpkg::asio", "vcpkg::cpr", "vcpkg::curl", "vcpkg::cxxopts", "vcpkg::doctest", "vcpkg::fmt", "vcpkg::gsl-lite", "vcpkg::http-parser", "vcpkg::json11", "vcpkg::lua", "vcpkg::lz4", "vcpkg::mimalloc", "vcpkg::openssl", "vcpkg::robin-map", "vcpkg::sentry-native", "vcpkg::sol2", "vcpkg::spdlog", "vcpkg::xxhash", "vcpkg::zlib", "vcpkg::zstd" ) add_rules("mode.debug", "mode.release") if is_mode("release") then set_optimize("smallest") if is_plat("windows") then add_ldflags("/LTCG") end end if is_mode("debug") then add_defines("DEBUG") end if is_mode("debug") then add_defines("ZEN_WITH_TESTS=1") else add_defines("ZEN_WITH_TESTS=0") end if is_os("windows") then add_defines( "_CRT_SECURE_NO_WARNINGS", "_UNICODE", "UNICODE", "_CONSOLE", "NOMINMAX", -- stop Windows SDK defining 'min' and 'max' "NOGDI", -- otherwise Windows.h defines 'GetObject' "WIN32_LEAN_AND_MEAN", -- cut down Windows.h "_WIN32_WINNT=0x0A00" ) -- add_ldflags("/MAP") end if is_os("linux") or is_os("macosx") then add_cxxflags("-Wno-implicit-fallthrough") add_cxxflags("-Wno-missing-field-initializers") add_cxxflags("-Wno-strict-aliasing") add_cxxflags("-Wno-unused-private-field") add_cxxflags("-Wno-unused-value") end -- Turn use of undefined cpp macros into errors if is_os("windows") then add_cxxflags("/we4668") else add_cxxflags("-Wundef") end function add_define_by_config(define, config_name) local value = has_config(config_name) and 1 or 0 add_defines(define.."="..value) end option("zensentry") set_default(true) set_showmenu(true) set_description("Enables Sentry support in Zen") option_end() add_define_by_config("USE_SENTRY", "zensentry") option("zenmimalloc") set_default(true) set_showmenu(true) set_description("Use MiMalloc as Zen's allocator") option_end() add_define_by_config("ZEN_USE_MIMALLOC", "zenmimalloc") if is_os("windows") then option("vfs") set_showmenu(true) set_description("Enable VFS functionality") option_end() add_define_by_config("ZEN_WITH_VFS", "vfs") option("httpsys") set_default(true) set_showmenu(true) set_description("Enable http.sys server") option_end() add_define_by_config("ZEN_WITH_HTTPSYS", "httpsys") end option("compute") set_default(is_os("windows")) set_showmenu(true) set_description("Enable compute services endpoint") option_end() add_define_by_config("ZEN_WITH_COMPUTE_SERVICES", "compute") option("zenmesh") set_default(false) set_showmenu(true) set_description("Enables Zen's mesh feature") option_end() add_define_by_config("ZEN_ENABLE_MESH", "zenmesh") option("zentrace") set_default(false) set_showmenu(true) set_description("Enable UE's Trace support") option_end() add_define_by_config("ZEN_WITH_TRACE", "zentrace") set_warnings("allextra", "error") set_languages("cxx20") -- always generate debug information set_symbols("debug") includes("zencore", "zencore-test") includes("zenhttp") includes("zenstore", "zenstore-test") includes("zenutil") includes("zenserver", "zenserver-test") includes("zen") task("bundle") set_menu { usage = "xmake bundle", description = "Create Zip bundle from binaries (Windows Only)", options = { {nil, "withtrace", "k", nil, "Compiles with trace support"}, } } on_run(function() import("core.base.option") import("detect.tools.find_zip") import("detect.tools.find_7z") import("detect.sdks.find_vcpkgdir") local zip_cmd = find_7z() if not zip_cmd then raise("unable to find zip tool") end local dirs = { vcpkg = { root = find_vcpkgdir(), tools = "" }, sentry = { root = "" }, package = { root = "" } } if dirs.vcpkg.root == nil or dirs.vcpkg.root == "" then raise("unable to find vcpkg root directory" ); end dirs.vcpkg.tools = dirs.vcpkg.root.."/installed/x64-windows-static/tools" dirs.sentry.root = dirs.vcpkg.tools.."/sentry-native" dirs.package_root = "./build/packages/z" local external_files = { dirs.sentry.root.."/crashpad_handler.exe" } dirs.package.root = "./build/packages/z" dirs.package.zenserver = { root = dirs.package.root.."/zenserver", windows = dirs.package.root.."/zenserver/windows/x64/release/bin" } local config = "-c -m release -a x64" if option.get("withtrace") then config = config.." --zentrace=yes" end print(os.exec("xmake config "..config)) print(os.exec("xmake build zenserver")) print(os.exec("xmake package -f local zenserver")) -- copy extenral file(s) for _,file in ipairs(external_files) do printf("copy '%s' -> '%s'\n", file, dirs.package.zenserver.windows) os.cp(file, dirs.package.zenserver.windows.."/") end -- create zip file local bundle_name = "zenserver-win64.zip" if option.get("withtrace") then bundle_name = "zenserver-trace-win64.zip" end local bundle_path = dirs.package.zenserver.root.."/"..bundle_name local zip_args = {} table.insert(zip_args, "a") table.insert(zip_args, bundle_path) table.insert(zip_args, dirs.package.zenserver.windows.."/*.*") print(string.format("creating bundle '%s' from '%s'\n",bundle_path, dirs.package.zenserver.windows.."/")) os.runv(zip_cmd, zip_args) print(string.format("bundle '%s' ok!", bundle_name)) end) task("test") set_menu { usage = "xmake runtest [core|store|server|integration|all]", description = "Run Zen tests", options = { {'r', "run", "kv", "all", "Run test(s)", " - all", " - core ", " - store", " - server", " - integration"} } } on_run(function() import("core.base.option") local testname = option.get("run") local available_tests = { core = "zencore-test", store = "zenstore-test", server = "zenserver", integration = "zenserver-test" } print(os.exec("xmake config -c -m debug -a x64")) print(os.exec("xmake")) local tests = {} for name, test in pairs(available_tests) do if name == testname or testname == "all" then tests[name] = test end end for name, test in pairs(tests) do printf("=== %s ===\n", test) local cmd = string.format("xmake run %s", test) if name == "server" then cmd = string.format("xmake run %s test", test) end print(os.exec(cmd)) end end)