summaryrefslogtreecommitdiff
path: root/xmake/modules/core/tools/dotnet.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/modules/core/tools/dotnet.lua')
-rw-r--r--xmake/modules/core/tools/dotnet.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/xmake/modules/core/tools/dotnet.lua b/xmake/modules/core/tools/dotnet.lua
index 9a502b616..90d585b87 100644
--- a/xmake/modules/core/tools/dotnet.lua
+++ b/xmake/modules/core/tools/dotnet.lua
@@ -97,7 +97,10 @@ end
-- make the build arguments list
function buildargv(self, sourcefiles, targetkind, targetfile, flags, opt)
- local argv = {"build"}
+ -- use `dotnet publish` for NativeAOT, otherwise `dotnet build`
+ local target = opt and opt.target
+ local publish_aot = target and target:values("csharp.publish_aot")
+ local argv = {publish_aot and "publish" or "build"}
-- add .csproj file
local csprojfile = _get_csprojfile(opt)
@@ -123,4 +126,11 @@ function build(self, sourcefiles, targetkind, targetfile, flags, opt)
os.mkdir(path.directory(targetfile))
local program, argv = buildargv(self, sourcefiles, targetkind, targetfile, flags, opt)
os.runv(program, argv, {envs = self:runenvs()})
+
+ -- fix install_name for NativeAOT shared library on macOS
+ local target = opt and opt.target
+ local publish_aot = target and target:values("csharp.publish_aot")
+ if publish_aot and targetkind == "shared" and self:is_plat("macosx", "iphoneos", "watchos") then
+ os.runv("install_name_tool", {"-id", "@rpath/" .. path.filename(targetfile), targetfile})
+ end
end