From 6c5c2707e805d0966a773ea6fb86146a0e0822da Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Sat, 12 Oct 2024 16:57:00 -0500 Subject: [PATCH 1/4] fix: only download `xbyak` if enabled --- CommonLibF4/xmake.lua | 5 +++++ xmake.lua | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CommonLibF4/xmake.lua b/CommonLibF4/xmake.lua index 1d7dc92d..25e766b4 100644 --- a/CommonLibF4/xmake.lua +++ b/CommonLibF4/xmake.lua @@ -5,6 +5,11 @@ option("f4se_xbyak", function() add_defines("F4SE_SUPPORT_XBYAK=1") end) +-- require packages +if has_config("f4se_xbyak") then + add_requires("xbyak") +end + -- define targets target("commonlibf4", function() set_kind("static") diff --git a/xmake.lua b/xmake.lua index 6627ef28..5c4f5c03 100644 --- a/xmake.lua +++ b/xmake.lua @@ -11,7 +11,7 @@ set_encodings("utf-8") add_rules("mode.debug", "mode.releasedbg") -- require packages -add_requires("rsm-binary-io", "rsm-mmio", "xbyak") +add_requires("rsm-binary-io", "rsm-mmio") add_requires("spdlog", { configs = { header_only = false, wchar = true, std_format = true } }) -- include subprojects From 5452d0eff649939372f783ea59d01e938d917d90 Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Sat, 12 Oct 2024 16:57:36 -0500 Subject: [PATCH 2/4] feat: don't build by default when subproject --- CommonLibF4/xmake.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CommonLibF4/xmake.lua b/CommonLibF4/xmake.lua index 25e766b4..97bbaf33 100644 --- a/CommonLibF4/xmake.lua +++ b/CommonLibF4/xmake.lua @@ -14,6 +14,9 @@ end target("commonlibf4", function() set_kind("static") + -- set build by default + set_default(path.directory(os.scriptdir()) == os.projectdir()) + -- set build group set_group("commonlibf4") From c3e4ddc7d05e57f6623068964e42a714ada7787b Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Sat, 12 Oct 2024 16:58:07 -0500 Subject: [PATCH 3/4] feat: add support for plugin install and package --- CommonLibF4/xmake.lua | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/CommonLibF4/xmake.lua b/CommonLibF4/xmake.lua index 97bbaf33..c262d388 100644 --- a/CommonLibF4/xmake.lua +++ b/CommonLibF4/xmake.lua @@ -149,6 +149,15 @@ rule("commonlibf4.plugin") target:set("arch", "x64") target:set("kind", "shared") + target:add("installfiles", target:targetfile(), { prefixdir = "F4SE/Plugins" }) + target:add("installfiles", target:symbolfile(), { prefixdir = "F4SE/Plugins" }) + + if os.getenv("XSE_FO4_MODS_PATH") then + target:set("installdir", path.join(os.getenv("XSE_FO4_MODS_PATH"), target:name())) + elseif os.getenv("XSE_FO4_GAME_PATH") then + target:set("installdir", path.join(os.getenv("XSE_FO4_GAME_PATH"), "Data")) + end + local conf = target:extraconf("rules", "commonlibf4.plugin") local conf_dir = path.join(target:autogendir(), "rules", "commonlibf4", "plugin") @@ -194,3 +203,52 @@ rule("commonlibf4.plugin") add_file("plugin.cpp", PLUGIN_FILE) add_file("version.rc", PLUGIN_RC_FILE) end) + + on_install(function(target) + local srcfiles, dstfiles = target:installfiles() + if srcfiles and #srcfiles > 0 and dstfiles and #dstfiles > 0 then + for idx, srcfile in ipairs(srcfiles) do + os.trycp(srcfile, dstfiles[idx]) + end + end + end) + + on_package(function(target) + import("core.project.config") + import("core.project.project") + import("utils.archive") + + local archive_name = target:name() .. "-" .. (target:version() or "0.0.0") .. ".zip" + print("packing %s .. ", archive_name) + + local root_dir = path.join(os.tmpdir(), "packages", project.name() or "", target:name()) + os.tryrm(root_dir) + + local srcfiles, dstfiles = target:installfiles(path.join(root_dir, "Data")) + if srcfiles and #srcfiles > 0 and dstfiles and #dstfiles > 0 then + for idx, srcfile in ipairs(srcfiles) do + os.trycp(srcfile, dstfiles[idx]) + end + else + return + end + + local archive_path = path.join(config.buildir(), "packages", archive_name) + local old_dir = os.cd(root_dir) + local archive_files = os.files("**") + os.cd(old_dir) + archive.archive(path.absolute(archive_path), archive_files, { curdir = root_dir }) + end) + + after_build(function(target) + import("core.project.depend") + import("core.project.project") + import("core.project.task") + + depend.on_changed(function() + local srcfiles, dstfiles = target:installfiles() + if srcfiles and #srcfiles > 0 and dstfiles and #dstfiles > 0 then + task.run("install") + end + end, { changed = target:is_rebuilt(), files = { target:targetfile() } }) + end) From aab2069b592827d553ba284ec445acc1e37677e9 Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Sat, 12 Oct 2024 17:08:28 -0500 Subject: [PATCH 4/4] fix: build --- CommonLibF4/include/REL/Version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CommonLibF4/include/REL/Version.h b/CommonLibF4/include/REL/Version.h index f2d84167..b96100f4 100644 --- a/CommonLibF4/include/REL/Version.h +++ b/CommonLibF4/include/REL/Version.h @@ -116,7 +116,7 @@ template struct fmt::formatter : formatter { template - auto format(const REL::Version& a_version, FormatContext& a_ctx) + auto format(const REL::Version& a_version, FormatContext& a_ctx) const { return formatter::format(a_version.string(), a_ctx); }