summaryrefslogtreecommitdiff
path: root/xmake/rules/csharp/generator
diff options
context:
space:
mode:
authorruki <[email protected]>2026-03-19 23:15:48 +0800
committerruki <[email protected]>2026-03-19 23:15:48 +0800
commit930be83656eb0e6dc968f672e889d43aaa166550 (patch)
tree3628c9923964f6360c531daec57a45812452ecea /xmake/rules/csharp/generator
parent879355cb0236593d8b73b4141f547585f37134e0 (diff)
add native aot
Diffstat (limited to 'xmake/rules/csharp/generator')
-rw-r--r--xmake/rules/csharp/generator/properties.lua23
1 files changed, 22 insertions, 1 deletions
diff --git a/xmake/rules/csharp/generator/properties.lua b/xmake/rules/csharp/generator/properties.lua
index 15702eae4..0fbab66e3 100644
--- a/xmake/rules/csharp/generator/properties.lua
+++ b/xmake/rules/csharp/generator/properties.lua
@@ -67,6 +67,27 @@ function _resolve_assembly_name(context)
end
+-- resolve runtime identifier from user config or auto-detect from target plat/arch
+-- e.g. "osx-x64", "osx-arm64", "linux-x64", "win-x64"
+function _resolve_runtime_identifier(context)
+ local rid = _get_target_value(context.target, "csharp.runtime_identifier")
+ if rid then
+ return rid
+ end
+ -- auto-detect RID when publish_aot is enabled
+ local publish_aot = _get_target_value(context.target, "csharp.publish_aot")
+ if not publish_aot then
+ return nil
+ end
+ local target = context.target
+ local plat = target:plat()
+ local arch = target:arch()
+ local rid_arch = ({x86_64 = "x64", i386 = "x86", x64 = "x64", x86 = "x86",
+ arm64 = "arm64", ["arm64-v8a"] = "arm64", armv7 = "arm"})[arch] or arch
+ local rid_os = ({macosx = "osx", linux = "linux", windows = "win", mingw = "win"})[plat] or plat
+ return rid_os .. "-" .. rid_arch
+end
+
-- register a single-value csharp.* property entry
function _register_property(register, suffix, xml, default, extra)
local entry = table.join({
@@ -128,7 +149,7 @@ function main()
_register_property(register, "generate_documentation_file", "GenerateDocumentationFile")
_register_property(register, "documentation_file", "DocumentationFile")
- _register_property(register, "runtime_identifier", "RuntimeIdentifier")
+ register({kind = "property", xml = "RuntimeIdentifier", resolve = _resolve_runtime_identifier})
_register_list_property(register, "runtime_identifiers", "RuntimeIdentifiers")
_register_property(register, "self_contained", "SelfContained")
_register_property(register, "use_app_host", "UseAppHost")