Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions include/SKSE/Interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ namespace SKSE
struct PluginVersionData
{
public:
enum
enum Version : std::uint32_t
{
kVersion = 1,
};
Expand Down Expand Up @@ -567,24 +567,25 @@ namespace SKSE

[[nodiscard]] constexpr std::string_view GetAuthorEmail() const noexcept { return std::string_view{ supportEmail }; }

constexpr void UsesAddressLibrary() noexcept { versionIndependence |= kVersionIndependent_AddressLibraryPostAE; }
constexpr void UsesSigScanning() noexcept { versionIndependence |= kVersionIndependent_Signatures; }
constexpr void UsesUpdatedStructs() noexcept { versionIndependence |= kVersionIndependent_StructsPost629; }
constexpr void UsesSigScanning(const bool a_value) noexcept { SetOrClearBit(versionIndependence, kVersionIndependent_Signatures, a_value); }

constexpr void UsesNoStructs() noexcept { versionIndependenceEx |= kVersionIndependentEx_NoStructUse; }
constexpr void UsesAddressLibrary(const bool a_value) noexcept { SetOrClearBit(versionIndependence, kVersionIndependent_AddressLibraryPostAE, a_value); }

constexpr void MinimumRequiredXSEVersion(REL::Version a_version) noexcept { xseMinimum = a_version.pack(); }
constexpr void HasNoStructUse(const bool a_value) noexcept { SetOrClearBit(versionIndependenceEx, kVersionIndependentEx_NoStructUse, a_value); }

constexpr void IsLayoutDependent(const bool a_value) noexcept { SetOrClearBit(versionIndependence, kVersionIndependent_StructsPost629, a_value); }

constexpr void CompatibleVersions(std::initializer_list<REL::Version> a_versions) noexcept
{
// must be zero-terminated
assert(a_versions.size() < std::size(compatibleVersions) - 1);
std::transform(
a_versions.begin(),
a_versions.end(),
std::begin(compatibleVersions),
[](const REL::Version& a_version) noexcept { return a_version.pack(); });
std::ranges::transform(a_versions, std::begin(compatibleVersions), [](const REL::Version& a_version) noexcept {
return a_version.pack();
});
}

constexpr void MinimumRequiredXSEVersion(REL::Version a_version) noexcept { xseMinimum = a_version.pack(); }

[[nodiscard]] static const PluginVersionData* GetSingleton() noexcept;

const std::uint32_t dataVersion{ kVersion };
Expand All @@ -598,13 +599,19 @@ namespace SKSE
std::uint32_t xseMinimum = 0;

private:
static constexpr void SetCharBuffer(
std::string_view a_src,
std::span<char> a_dst) noexcept
static constexpr void SetCharBuffer(std::string_view a_src, std::span<char> a_dst) noexcept
{
assert(a_src.size() < a_dst.size());
std::fill(a_dst.begin(), a_dst.end(), '\0');
std::copy(a_src.begin(), a_src.end(), a_dst.begin());
std::ranges::fill(a_dst, '\0');
std::ranges::copy(a_src, a_dst.begin());
}

static constexpr void SetOrClearBit(std::uint32_t& a_data, const std::uint32_t a_bit, const bool a_set) noexcept
{
if (a_set)
a_data |= a_bit;
else
a_data &= ~a_bit;
}
};
static_assert(offsetof(PluginVersionData, dataVersion) == 0x000);
Expand Down
2 changes: 1 addition & 1 deletion lib/commonlib-shared
Submodule commonlib-shared updated 1 files
+224 −0 xmake.lua
6 changes: 4 additions & 2 deletions res/commonlibsse-plugin.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ SKSE_EXPORT constinit auto SKSEPlugin_Version = []() {
v.PluginName("${COMMONLIB_PLUGIN_NAME}");
v.AuthorName("${COMMONLIB_PLUGIN_AUTHOR}");
v.AuthorEmail("${COMMONLIB_PLUGIN_CONTACT}");
v.UsesAddressLibrary();
v.UsesUpdatedStructs();
v.UsesSigScanning(${COMMONLIBSSE_OPTION_SIG_SCANNING});
v.UsesAddressLibrary(${COMMONLIBSSE_OPTION_ADDRESS_LIBRARY});
v.HasNoStructUse(${COMMONLIBSSE_OPTION_NO_STRUCT_USE});
v.IsLayoutDependent(${COMMONLIBSSE_OPTION_LAYOUT_DEPENDENT});
v.CompatibleVersions({ SKSE::RUNTIME_LATEST });
v.MinimumRequiredXSEVersion({ ${COMMONLIB_PLUGIN_XSE_VERSION_MAJOR}, ${COMMONLIB_PLUGIN_XSE_VERSION_MINOR}, ${COMMONLIB_PLUGIN_XSE_VERSION_PATCH}, 0 });
return v;
Expand Down
54 changes: 54 additions & 0 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,38 @@ rule("commonlibsse.plugin", function()
target:add("configfiles", path.join(os.scriptdir(), "res/commonlibsse-plugin.cpp.in"))
target:add("files", path.join(target:configdir(), "commonlibsse-plugin.cpp"))

local conf = target:extraconf("rules", "commonlibsse.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
end
else
conf.options = {
sig_scanning = false,
address_library = true,
no_struct_use = false,
layout_dependent = true
}
end

target:set("configvar", "COMMONLIBSSE_OPTION_SIG_SCANNING", tostring(conf.options.sig_scanning))
target:set("configvar", "COMMONLIBSSE_OPTION_ADDRESS_LIBRARY", tostring(conf.options.address_library))
target:set("configvar", "COMMONLIBSSE_OPTION_NO_STRUCT_USE", tostring(conf.options.no_struct_use))
target:set("configvar", "COMMONLIBSSE_OPTION_LAYOUT_DEPENDENT", tostring(conf.options.layout_dependent))

if os.getenv("XSE_TES5_MODS_PATH") then
target:set("installdir", path.join(os.getenv("XSE_TES5_MODS_PATH"), target:name()))
elseif os.getenv("XSE_TES5_GAME_PATH") then
Expand All @@ -67,3 +99,25 @@ rule("commonlibsse.plugin", function()
target:add("installfiles", target:symbolfile(), { prefixdir = "SKSE/Plugins" })
end)
end)

rule("commonlibsse.archive", function()
add_deps("commonlib.archive")

on_load(function(target)
target:data_set("commonlib.archive.config", target:extraconf("rules", "commonlibsse.archive"))
target:data_set("commonlib.archive.format", "-sse" )
target:data_set("commonlib.archive.extension", ".bsa")
end)
end)

rule("commonlibsse.papyrus", function()
add_deps("commonlib.papyrus")

on_load(function(target)
target:data_set("commonlib.papyrus.config", target:extraconf("rules", "commonlibsse.papyrus"))
target:data_set("commonlib.papyrus.game", "skyrim" )
target:data_set("commonlib.papyrus.gamevar", "XSE_TES5_GAME_PATH")
target:data_set("commonlib.papyrus.defaults", { "Data/Source/Scripts" } )
target:data_set("commonlib.papyrus.flags", "TESV_Papyrus_Flags.flg")
end)
end)
Loading