Skip to content

Commit c221e7b

Browse files
authored
chore: update xmake-extras options (#266)
1 parent a6bae87 commit c221e7b

File tree

1 file changed

+66
-24
lines changed

1 file changed

+66
-24
lines changed

xmake-extra.lua

Lines changed: 66 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
1+
-- Local Usage:
2+
--
3+
-- add_deps("commonlibsf")
4+
-- add_rules("commonlibsf.plugin", {
5+
-- name = "Plugin Name",
6+
-- author = "Author Name",
7+
-- description = "Plugin Description",
8+
-- email = "[email protected]"
9+
-- options = {
10+
-- -- disable all compatibility checks completely
11+
-- sig_scanning = true,
12+
-- no_struct_use = true
13+
-- }
14+
-- })
15+
116
local PLUGIN_FILE = [[
217
#include <SFSE/SFSE.h>
18+
#include <REL/Relocation.h>
19+
20+
using namespace std::literals;
321
422
extern "C" __declspec(dllexport)
523
constinit auto SFSEPlugin_Version = []() noexcept {
624
SFSE::PluginVersionData v{};
725
v.PluginVersion({ ${PLUGIN_VERSION_MAJOR}, ${PLUGIN_VERSION_MINOR}, ${PLUGIN_VERSION_PATCH} });
826
v.PluginName("${PLUGIN_NAME}");
927
v.AuthorName("${PLUGIN_AUTHOR}");
10-
v.UsesAddressLibrary(true);
11-
v.IsLayoutDependent(true);
28+
v.UsesSigScanning(${OPTION_SIG_SCANNING});
29+
v.UsesAddressLibrary(${OPTION_ADDRESS_LIBRARY});
30+
v.HasNoStructUse(${OPTION_NO_STRUCT_USE});
31+
v.IsLayoutDependent(${OPTION_LAYOUT_DEPENDENT});
1232
return v;
1333
}();]]
1434

@@ -46,15 +66,6 @@ BEGIN
4666
END
4767
END]]
4868

49-
-- Local Usage:
50-
--
51-
-- add_deps("commonlibsf")
52-
-- add_rules("commonlibsf.plugin", {
53-
-- name = "Plugin Name",
54-
-- author = "Author Name",
55-
-- description = "Plugin Description"
56-
-- })
57-
5869
rule("commonlibsf.plugin")
5970
add_deps("win.sdk.resource")
6071

@@ -68,21 +79,52 @@ rule("commonlibsf.plugin")
6879

6980
local conf = target:extraconf("rules", "commonlibsf.plugin")
7081
local conf_dir = path.join(target:autogendir(), "rules", "commonlibsf", "plugin")
82+
83+
if conf.options then
84+
if conf.options.sig_scanning then
85+
conf.options.address_library = false
86+
else
87+
conf.options.sig_scanning = false
88+
if conf.options.address_library == nil then
89+
conf.options.address_library = true
90+
end
91+
end
92+
if conf.options.no_struct_use then
93+
conf.options.layout_dependent = false
94+
else
95+
conf.options.no_struct_use = false
96+
if conf.options.layout_dependent == nil then
97+
conf.options.layout_dependent = true
98+
end
99+
end
100+
else
101+
conf.options = {
102+
sig_scanning = false,
103+
address_library = true,
104+
no_struct_use = false,
105+
layout_dependent = true
106+
}
107+
end
71108

72109
local conf_map = {
73-
PLUGIN_AUTHOR = conf.author or "",
74-
PLUGIN_DESCRIPTION = conf.description or "",
75-
PLUGIN_LICENSE = (target:license() or "Unknown") .. " License",
76-
PLUGIN_NAME = conf.name or target:name(),
77-
PLUGIN_VERSION = target:version() or "0.0.0",
78-
PLUGIN_VERSION_MAJOR = semver.new(target:version() or "0.0.0"):major(),
79-
PLUGIN_VERSION_MINOR = semver.new(target:version() or "0.0.0"):minor(),
80-
PLUGIN_VERSION_PATCH = semver.new(target:version() or "0.0.0"):patch(),
81-
PROJECT_NAME = project.name() or "",
82-
PROJECT_VERSION = project.version() or "0.0.0",
83-
PROJECT_VERSION_MAJOR = semver.new(project.version() or "0.0.0"):major(),
84-
PROJECT_VERSION_MINOR = semver.new(project.version() or "0.0.0"):minor(),
85-
PROJECT_VERSION_PATCH = semver.new(project.version() or "0.0.0"):patch(),
110+
PLUGIN_AUTHOR = conf.author or "",
111+
PLUGIN_DESCRIPTION = conf.description or "",
112+
PLUGIN_EMAIL = conf.email or "",
113+
PLUGIN_LICENSE = (target:license() or "Unknown") .. " License",
114+
PLUGIN_NAME = conf.name or target:name(),
115+
PLUGIN_VERSION = target:version() or "0.0.0",
116+
PLUGIN_VERSION_MAJOR = semver.new(target:version() or "0.0.0"):major(),
117+
PLUGIN_VERSION_MINOR = semver.new(target:version() or "0.0.0"):minor(),
118+
PLUGIN_VERSION_PATCH = semver.new(target:version() or "0.0.0"):patch(),
119+
PROJECT_NAME = project.name() or "",
120+
PROJECT_VERSION = project.version() or "0.0.0",
121+
PROJECT_VERSION_MAJOR = semver.new(project.version() or "0.0.0"):major(),
122+
PROJECT_VERSION_MINOR = semver.new(project.version() or "0.0.0"):minor(),
123+
PROJECT_VERSION_PATCH = semver.new(project.version() or "0.0.0"):patch(),
124+
OPTION_SIG_SCANNING = conf.options.sig_scanning,
125+
OPTION_ADDRESS_LIBRARY = conf.options.address_library,
126+
OPTION_NO_STRUCT_USE = conf.options.no_struct_use,
127+
OPTION_LAYOUT_DEPENDENT = conf.options.layout_dependent
86128
}
87129

88130
local conf_parse = function(a_str)

0 commit comments

Comments
 (0)