aboutsummaryrefslogtreecommitdiff
path: root/bundle.lua
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2022-01-20 09:27:55 +0100
committerMartin Ridgers <[email protected]>2022-01-20 10:22:07 +0100
commit36f62433f8176548b7a6e66c147394a6c4616c0c (patch)
tree90334db131f14f45a80d9a7d610d0d7aff843ba3 /bundle.lua
parentTidied bundle task's description as it will support all platforms (diff)
downloadzen-36f62433f8176548b7a6e66c147394a6c4616c0c.tar.xz
zen-36f62433f8176548b7a6e66c147394a6c4616c0c.zip
Refactored 'xmake bundle' so steps can be reused on other platforms
Diffstat (limited to 'bundle.lua')
-rw-r--r--bundle.lua139
1 files changed, 82 insertions, 57 deletions
diff --git a/bundle.lua b/bundle.lua
index 81e292034..3ab6016a8 100644
--- a/bundle.lua
+++ b/bundle.lua
@@ -1,86 +1,111 @@
-- Copyright Epic Games, Inc. All Rights Reserved.
-local function bundle_windows()
- import("core.base.option")
- import("detect.tools.find_zip")
- import("detect.tools.find_7z")
- import("detect.sdks.find_vcpkgdir")
+--------------------------------------------------------------------------------
+local function _exec(cmd, ...)
+ print("--", cmd, ...)
+ local ret = os.execv(cmd, {...})
+ print()
+ return ret
+end
- local zip_cmd = find_7z()
- if not zip_cmd then
- raise("unable to find zip tool")
+--------------------------------------------------------------------------------
+local function _build(arch, debug, config_args)
+ variant = debug and "debug" or "release"
+ local ret = _exec(
+ "xmake",
+ "config",
+ "--clean",
+ "--mode="..variant,
+ "--arch="..arch,
+ config_args)
+ if ret > 0 then
+ raise("Failed to configure xmake")
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" );
+ ret = _exec("xmake", "clean", "zenserver")
+ if ret > 0 then
+ raise("Clean failed")
end
- dirs.vcpkg.tools = dirs.vcpkg.root.."/installed/x64-windows-static/tools"
- dirs.sentry.root = dirs.vcpkg.tools.."/sentry-native"
+ ret = _exec("xmake", "build", "zenserver")
+ if ret > 0 then
+ raise("Build failed")
+ end
+end
- dirs.package_root = "./build/packages/z"
+--------------------------------------------------------------------------------
+local function _zip(zip_path, ...)
+ os.rm(zip_path)
- local external_files = {
- dirs.sentry.root.."/crashpad_handler.exe"
- }
+ import("detect.tools.find_7z")
+ local cmd = find_7z()
+ if cmd then
+ -- A ./ prefix makes 7z ignore the directory structure
+ input_paths = {}
+ for _, input_path in ipairs({...}) do
+ input_path = path.relative(input_path, ".")
+ if input_path:sub(2,2) ~= ":" then
+ input_path = "./"..input_path
+ end
+ table.insert(input_paths, input_path)
+ end
+
+ local ret = _exec("7z", "a", zip_path, table.unpack(input_paths))
+ if ret > 0 then
+ raise("Received error from 7z")
+ end
+ return
+ end
+ print("7z not found")
- dirs.package.root = "./build/packages/z"
- dirs.package.zenserver = {
- root = dirs.package.root.."/zenserver",
- windows = dirs.package.root.."/zenserver/windows/x64/release/bin"
- }
+ raise("Unable to find a suitable zip tool")
+end
- local config = "-c -m release -a x64"
- if option.get("withtrace") then
- config = config.." --zentrace=yes"
+--------------------------------------------------------------------------------
+local function _find_vcpkg_binary(triple, port, binary)
+ import("detect.sdks.find_vcpkgdir")
+ local root_dir = find_vcpkgdir()
+ if root_dir == nil or root_dir == "" then
+ raise("Unable to find vcpkg root directory")
end
- print(os.exec("xmake config "..config))
- print(os.exec("xmake build zenserver"))
- print(os.exec("xmake package -f local zenserver"))
+ bin_path = root_dir.."/installed/"..triple.."/tools/"..port.."/"..binary
+ return bin_path
+end
- -- 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
+--------------------------------------------------------------------------------
+local function main_windows()
+ import("core.base.option")
- -- create zip file
- local bundle_name = "zenserver-win64.zip"
+ zip_path = "build/zenserver-win64.zip"
+ config_args = nil
if option.get("withtrace") then
- bundle_name = "zenserver-trace-win64.zip"
+ zip_path = "build/zenserver-trace-win64.zip"
+ config_args = "--zentrace=yes"
end
- local bundle_path = dirs.package.zenserver.root.."/"..bundle_name
+ local crashpad_handler_path = _find_vcpkg_binary(
+ "x64-windows-static",
+ "sentry-native",
+ "crashpad_handler.exe")
- local zip_args = {}
- table.insert(zip_args, "a")
- table.insert(zip_args, bundle_path)
- table.insert(zip_args, dirs.package.zenserver.windows.."/*.*")
+ _build("x64", false, config_args)
+
+ _zip(
+ zip_path,
+ "build/windows/x64/release/zenserver.exe",
+ "build/windows/x64/release/zenserver.pdb",
+ crashpad_handler_path)
+end
- 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
+--------------------------------------------------------------------------------
function main()
if is_host("windows") then
- return bundle_windows()
+ return main_windows()
end
raise("'xmake bundle' not currently supported on this platform")