diff options
| author | ruki <[email protected]> | 2020-05-19 22:39:51 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-05-19 09:59:07 +0800 |
| commit | 6ee9db874fcfeb94fcc06982f132ea469ec98e0e (patch) | |
| tree | 85d36f6fed4718827bfec3267ef62cef27dedda1 /xmake/modules/core/tools/dmd.lua | |
| parent | 5dfb51f3e1c06c07097158153f39c45830029685 (diff) | |
add dlang toolchain
Diffstat (limited to 'xmake/modules/core/tools/dmd.lua')
| -rw-r--r-- | xmake/modules/core/tools/dmd.lua | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/xmake/modules/core/tools/dmd.lua b/xmake/modules/core/tools/dmd.lua index 4d74c21ae..378c68642 100644 --- a/xmake/modules/core/tools/dmd.lua +++ b/xmake/modules/core/tools/dmd.lua @@ -134,15 +134,30 @@ end -- make the rpathdir flag function nf_rpathdir(self, dir) - local flag = "-L-rpath=" .. os.args(dir) - if self:has_flags(flag) then - return flag + dir = path.translate(dir) + if self:has_flags("-L-rpath=" .. dir, "ldflags") then + return "-L-rpath=" .. os.args(dir:gsub("@[%w_]+", function (name) + local maps = {["@loader_path"] = "$ORIGIN", ["@executable_path"] = "$ORIGIN"} + return maps[name] + end)) + + elseif self:has_flags("-L-rpath -L" .. dir, "ldflags") then + return "-L-rpath -L" .. os.args(dir:gsub("%$ORIGIN", "@loader_path")) end end -- make the link arguments list function linkargv(self, objectfiles, targetkind, targetfile, flags) - return self:program(), table.join(flags, "-of" .. targetfile, objectfiles) + + -- add rpath for dylib (macho), e.g. -install_name @rpath/file.dylib + local flags_extra = {} + if targetkind == "shared" and is_plat("macosx") then + table.insert(flags_extra, "-L-install_name") + table.insert(flags_extra, "-L@rpath/" .. path.filename(targetfile)) + end + + -- init arguments + return self:program(), table.join(flags, flags_extra, "-of" .. targetfile, objectfiles) end -- link the target file |
