From 204b4ee98ba93b9dd3487304542cab993d5abc73 Mon Sep 17 00:00:00 2001 From: WaterFace Date: Fri, 13 Jun 2025 19:47:05 -0400 Subject: [PATCH 1/3] changed packaging to use the Oblivion Remastered convention --- xmake-rules.lua | 250 ++++++++++++++++++++++++------------------------ 1 file changed, 125 insertions(+), 125 deletions(-) diff --git a/xmake-rules.lua b/xmake-rules.lua index c9c6e5f..1035a0a 100644 --- a/xmake-rules.lua +++ b/xmake-rules.lua @@ -58,146 +58,146 @@ END]] -- define rules rule("commonlibob64.plugin") - add_deps("win.sdk.resource") +add_deps("win.sdk.resource") - on_config(function(target) - import("core.base.semver") - import("core.project.depend") - import("core.project.project") +on_config(function(target) + import("core.base.semver") + import("core.project.depend") + import("core.project.project") - target:set("arch", "x64") - target:set("kind", "shared") + target:set("arch", "x64") + target:set("kind", "shared") - target:add("installfiles", target:targetfile(), { prefixdir = "OBSE/Plugins" }) - target:add("installfiles", target:symbolfile(), { prefixdir = "OBSE/Plugins" }) + target:add("installfiles", target:targetfile(), { prefixdir = "OBSE/Plugins" }) + target:add("installfiles", target:symbolfile(), { prefixdir = "OBSE/Plugins" }) - if os.getenv("XSE_TES4_MODS_PATH") then - target:set("installdir", path.join(os.getenv("XSE_TES4_MODS_PATH"), target:name())) - elseif os.getenv("XSE_TES4_GAME_PATH") then - target:set("installdir", os.getenv("XSE_TES4_GAME_PATH")) - end + if os.getenv("XSE_TES4_MODS_PATH") then + target:set("installdir", path.join(os.getenv("XSE_TES4_MODS_PATH"), target:name())) + elseif os.getenv("XSE_TES4_GAME_PATH") then + target:set("installdir", os.getenv("XSE_TES4_GAME_PATH")) + end - local conf = target:extraconf("rules", "commonlibob64.plugin") - local conf_dir = path.join(target:autogendir(), "rules", "commonlibob64", "plugin") - - if conf.options then - if conf.options.sig_scanning then - conf.options.address_library = false - else - conf.options.sig_scanning = false - if conf.options.address_library == nil then - conf.options.address_library = true - end - end - if conf.options.no_struct_use then - conf.options.layout_dependent = false - else - conf.options.no_struct_use = false - if conf.options.layout_dependent == nil then - conf.options.layout_dependent = true - end + local conf = target:extraconf("rules", "commonlibob64.plugin") + local conf_dir = path.join(target:autogendir(), "rules", "commonlibob64", "plugin") + + if conf.options then + if conf.options.sig_scanning then + conf.options.address_library = false + else + conf.options.sig_scanning = false + if conf.options.address_library == nil then + conf.options.address_library = true end + end + if conf.options.no_struct_use then + conf.options.layout_dependent = false else - conf.options = { - sig_scanning = false, - address_library = true, - no_struct_use = false, - layout_dependent = true - } + conf.options.no_struct_use = false + if conf.options.layout_dependent == nil then + conf.options.layout_dependent = true + end end - - local conf_map = { - PLUGIN_AUTHOR = conf.author or "", - PLUGIN_DESCRIPTION = conf.description or "", - PLUGIN_LICENSE = (target:license() or "Unknown") .. " License", - PLUGIN_NAME = conf.name or target:name(), - PLUGIN_VERSION = target:version() or "0.0.0", - PLUGIN_VERSION_MAJOR = semver.new(target:version() or "0.0.0"):major(), - PLUGIN_VERSION_MINOR = semver.new(target:version() or "0.0.0"):minor(), - PLUGIN_VERSION_PATCH = semver.new(target:version() or "0.0.0"):patch(), - PROJECT_NAME = project.name() or "", - PROJECT_VERSION = project.version() or "0.0.0", - PROJECT_VERSION_MAJOR = semver.new(project.version() or "0.0.0"):major(), - PROJECT_VERSION_MINOR = semver.new(project.version() or "0.0.0"):minor(), - PROJECT_VERSION_PATCH = semver.new(project.version() or "0.0.0"):patch(), - OPTION_ADDRESS_LIBRARY = conf.options.address_library, - OPTION_LAYOUT_DEPENDENT = conf.options.layout_dependent, - OPTION_NO_STRUCT_USE = conf.options.no_struct_use, - OPTION_SIG_SCANNING = conf.options.sig_scanning, + else + conf.options = { + sig_scanning = false, + address_library = true, + no_struct_use = false, + layout_dependent = true } + end + + local conf_map = { + PLUGIN_AUTHOR = conf.author or "", + PLUGIN_DESCRIPTION = conf.description or "", + PLUGIN_LICENSE = (target:license() or "Unknown") .. " License", + PLUGIN_NAME = conf.name or target:name(), + PLUGIN_VERSION = target:version() or "0.0.0", + PLUGIN_VERSION_MAJOR = semver.new(target:version() or "0.0.0"):major(), + PLUGIN_VERSION_MINOR = semver.new(target:version() or "0.0.0"):minor(), + PLUGIN_VERSION_PATCH = semver.new(target:version() or "0.0.0"):patch(), + PROJECT_NAME = project.name() or "", + PROJECT_VERSION = project.version() or "0.0.0", + PROJECT_VERSION_MAJOR = semver.new(project.version() or "0.0.0"):major(), + PROJECT_VERSION_MINOR = semver.new(project.version() or "0.0.0"):minor(), + PROJECT_VERSION_PATCH = semver.new(project.version() or "0.0.0"):patch(), + OPTION_ADDRESS_LIBRARY = conf.options.address_library, + OPTION_LAYOUT_DEPENDENT = conf.options.layout_dependent, + OPTION_NO_STRUCT_USE = conf.options.no_struct_use, + OPTION_SIG_SCANNING = conf.options.sig_scanning, + } + + local conf_parse = function(a_str) + return a_str:gsub("(%${([^\n]-)})", function(_, a_var) + local result = conf_map[a_var:trim()] + if type(result) ~= "string" then + result = tostring(result) + end + assert(result ~= nil, "cannot get variable(%s)", a_var) + return result + end) + end - local conf_parse = function(a_str) - return a_str:gsub("(%${([^\n]-)})", function(_, a_var) - local result = conf_map[a_var:trim()] - if type(result) ~= "string" then - result = tostring(result) - end - assert(result ~= nil, "cannot get variable(%s)", a_var) - return result - end) - end - - local add_file = function(a_path, a_data) - local file_path = path.join(conf_dir, a_path) - depend.on_changed(function() - local file = io.open(file_path, "w") - if file then - file:write(conf_parse(a_data), "\n") - file:close() - end - end, { dependfile = target:dependfile(file_path), files = project.allfiles()}) - target:add("files", file_path) - end - - 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]) + local add_file = function(a_path, a_data) + local file_path = path.join(conf_dir, a_path) + depend.on_changed(function() + local file = io.open(file_path, "w") + if file then + file:write(conf_parse(a_data), "\n") + file:close() end + end, { dependfile = target:dependfile(file_path), files = project.allfiles() }) + target:add("files", file_path) + end + + 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 +end) - on_package(function(target) - import("core.project.config") - import("core.project.project") - import("utils.archive") +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 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 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")) + local srcfiles, dstfiles = target:installfiles(path.join(root_dir, "OblivionRemastered/Binaries/Win64/")) + 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 - for idx, srcfile in ipairs(srcfiles) do - os.trycp(srcfile, dstfiles[idx]) - end - else - return + task.run("install") 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) + end, { changed = target:is_rebuilt(), files = { target:targetfile() } }) +end) From a39d5ea0cdeb671948193c13ab612417f1c72a63 Mon Sep 17 00:00:00 2001 From: WaterFace Date: Fri, 13 Jun 2025 19:49:08 -0400 Subject: [PATCH 2/3] don't make indentation changes --- xmake-rules.lua | 250 ++++++++++++++++++++++++------------------------ 1 file changed, 125 insertions(+), 125 deletions(-) diff --git a/xmake-rules.lua b/xmake-rules.lua index 1035a0a..754724c 100644 --- a/xmake-rules.lua +++ b/xmake-rules.lua @@ -58,146 +58,146 @@ END]] -- define rules rule("commonlibob64.plugin") -add_deps("win.sdk.resource") + add_deps("win.sdk.resource") -on_config(function(target) - import("core.base.semver") - import("core.project.depend") - import("core.project.project") + on_config(function(target) + import("core.base.semver") + import("core.project.depend") + import("core.project.project") - target:set("arch", "x64") - target:set("kind", "shared") + target:set("arch", "x64") + target:set("kind", "shared") - target:add("installfiles", target:targetfile(), { prefixdir = "OBSE/Plugins" }) - target:add("installfiles", target:symbolfile(), { prefixdir = "OBSE/Plugins" }) + target:add("installfiles", target:targetfile(), { prefixdir = "OBSE/Plugins" }) + target:add("installfiles", target:symbolfile(), { prefixdir = "OBSE/Plugins" }) - if os.getenv("XSE_TES4_MODS_PATH") then - target:set("installdir", path.join(os.getenv("XSE_TES4_MODS_PATH"), target:name())) - elseif os.getenv("XSE_TES4_GAME_PATH") then - target:set("installdir", os.getenv("XSE_TES4_GAME_PATH")) - end - - local conf = target:extraconf("rules", "commonlibob64.plugin") - local conf_dir = path.join(target:autogendir(), "rules", "commonlibob64", "plugin") + if os.getenv("XSE_TES4_MODS_PATH") then + target:set("installdir", path.join(os.getenv("XSE_TES4_MODS_PATH"), target:name())) + elseif os.getenv("XSE_TES4_GAME_PATH") then + target:set("installdir", os.getenv("XSE_TES4_GAME_PATH")) + end - if conf.options then - if conf.options.sig_scanning then - conf.options.address_library = false - else - conf.options.sig_scanning = false - if conf.options.address_library == nil then - conf.options.address_library = true + local conf = target:extraconf("rules", "commonlibob64.plugin") + local conf_dir = path.join(target:autogendir(), "rules", "commonlibob64", "plugin") + + if conf.options then + if conf.options.sig_scanning then + conf.options.address_library = false + else + conf.options.sig_scanning = false + if conf.options.address_library == nil then + conf.options.address_library = true + end end - end - if conf.options.no_struct_use then - conf.options.layout_dependent = false - else - conf.options.no_struct_use = false - if conf.options.layout_dependent == nil then - conf.options.layout_dependent = true + if conf.options.no_struct_use then + conf.options.layout_dependent = false + else + conf.options.no_struct_use = false + if conf.options.layout_dependent == nil then + conf.options.layout_dependent = true + end end + else + conf.options = { + sig_scanning = false, + address_library = true, + no_struct_use = false, + layout_dependent = true + } end - else - conf.options = { - sig_scanning = false, - address_library = true, - no_struct_use = false, - layout_dependent = true + + local conf_map = { + PLUGIN_AUTHOR = conf.author or "", + PLUGIN_DESCRIPTION = conf.description or "", + PLUGIN_LICENSE = (target:license() or "Unknown") .. " License", + PLUGIN_NAME = conf.name or target:name(), + PLUGIN_VERSION = target:version() or "0.0.0", + PLUGIN_VERSION_MAJOR = semver.new(target:version() or "0.0.0"):major(), + PLUGIN_VERSION_MINOR = semver.new(target:version() or "0.0.0"):minor(), + PLUGIN_VERSION_PATCH = semver.new(target:version() or "0.0.0"):patch(), + PROJECT_NAME = project.name() or "", + PROJECT_VERSION = project.version() or "0.0.0", + PROJECT_VERSION_MAJOR = semver.new(project.version() or "0.0.0"):major(), + PROJECT_VERSION_MINOR = semver.new(project.version() or "0.0.0"):minor(), + PROJECT_VERSION_PATCH = semver.new(project.version() or "0.0.0"):patch(), + OPTION_ADDRESS_LIBRARY = conf.options.address_library, + OPTION_LAYOUT_DEPENDENT = conf.options.layout_dependent, + OPTION_NO_STRUCT_USE = conf.options.no_struct_use, + OPTION_SIG_SCANNING = conf.options.sig_scanning, } - end - - local conf_map = { - PLUGIN_AUTHOR = conf.author or "", - PLUGIN_DESCRIPTION = conf.description or "", - PLUGIN_LICENSE = (target:license() or "Unknown") .. " License", - PLUGIN_NAME = conf.name or target:name(), - PLUGIN_VERSION = target:version() or "0.0.0", - PLUGIN_VERSION_MAJOR = semver.new(target:version() or "0.0.0"):major(), - PLUGIN_VERSION_MINOR = semver.new(target:version() or "0.0.0"):minor(), - PLUGIN_VERSION_PATCH = semver.new(target:version() or "0.0.0"):patch(), - PROJECT_NAME = project.name() or "", - PROJECT_VERSION = project.version() or "0.0.0", - PROJECT_VERSION_MAJOR = semver.new(project.version() or "0.0.0"):major(), - PROJECT_VERSION_MINOR = semver.new(project.version() or "0.0.0"):minor(), - PROJECT_VERSION_PATCH = semver.new(project.version() or "0.0.0"):patch(), - OPTION_ADDRESS_LIBRARY = conf.options.address_library, - OPTION_LAYOUT_DEPENDENT = conf.options.layout_dependent, - OPTION_NO_STRUCT_USE = conf.options.no_struct_use, - OPTION_SIG_SCANNING = conf.options.sig_scanning, - } - - local conf_parse = function(a_str) - return a_str:gsub("(%${([^\n]-)})", function(_, a_var) - local result = conf_map[a_var:trim()] - if type(result) ~= "string" then - result = tostring(result) - end - assert(result ~= nil, "cannot get variable(%s)", a_var) - return result - end) - end - local add_file = function(a_path, a_data) - local file_path = path.join(conf_dir, a_path) - depend.on_changed(function() - local file = io.open(file_path, "w") - if file then - file:write(conf_parse(a_data), "\n") - file:close() + local conf_parse = function(a_str) + return a_str:gsub("(%${([^\n]-)})", function(_, a_var) + local result = conf_map[a_var:trim()] + if type(result) ~= "string" then + result = tostring(result) + end + assert(result ~= nil, "cannot get variable(%s)", a_var) + return result + end) + end + + local add_file = function(a_path, a_data) + local file_path = path.join(conf_dir, a_path) + depend.on_changed(function() + local file = io.open(file_path, "w") + if file then + file:write(conf_parse(a_data), "\n") + file:close() + end + end, { dependfile = target:dependfile(file_path), files = project.allfiles()}) + target:add("files", file_path) + end + + 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, { dependfile = target:dependfile(file_path), files = project.allfiles() }) - target:add("files", file_path) - end - - 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) + end) -on_package(function(target) - import("core.project.config") - import("core.project.project") - import("utils.archive") + 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 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 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, "OblivionRemastered/Binaries/Win64/")) - 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() + local srcfiles, dstfiles = target:installfiles(path.join(root_dir, "OblivionRemastered/Binaries/Win64/")) if srcfiles and #srcfiles > 0 and dstfiles and #dstfiles > 0 then - task.run("install") + for idx, srcfile in ipairs(srcfiles) do + os.trycp(srcfile, dstfiles[idx]) + end + else + return end - end, { changed = target:is_rebuilt(), files = { target:targetfile() } }) -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 208632e467019ef8cd313a4e24ec2625092b24fa Mon Sep 17 00:00:00 2001 From: WaterFace Date: Sat, 14 Jun 2025 02:48:13 -0400 Subject: [PATCH 3/3] suggested changes --- xmake-rules.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xmake-rules.lua b/xmake-rules.lua index 754724c..ca4f8e1 100644 --- a/xmake-rules.lua +++ b/xmake-rules.lua @@ -68,8 +68,8 @@ rule("commonlibob64.plugin") target:set("arch", "x64") target:set("kind", "shared") - target:add("installfiles", target:targetfile(), { prefixdir = "OBSE/Plugins" }) - target:add("installfiles", target:symbolfile(), { prefixdir = "OBSE/Plugins" }) + target:add("installfiles", target:targetfile(), { prefixdir = "OblivionRemastered/Binaries/Win64/OBSE/Plugins" }) + target:add("installfiles", target:symbolfile(), { prefixdir = "OblivionRemastered/Binaries/Win64/OBSE/Plugins" }) if os.getenv("XSE_TES4_MODS_PATH") then target:set("installdir", path.join(os.getenv("XSE_TES4_MODS_PATH"), target:name())) @@ -173,7 +173,7 @@ rule("commonlibob64.plugin") 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, "OblivionRemastered/Binaries/Win64/")) + local srcfiles, dstfiles = target:installfiles(root_dir) if srcfiles and #srcfiles > 0 and dstfiles and #dstfiles > 0 then for idx, srcfile in ipairs(srcfiles) do os.trycp(srcfile, dstfiles[idx])