diff options
| author | ruki <[email protected]> | 2020-05-24 21:10:49 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-05-24 21:10:49 +0800 |
| commit | fb2ba113ca1534249b0872002af0f133becd7e51 (patch) | |
| tree | d5bc9fb1553f622842712b18a7959a0c08a92d63 /xmake/modules/core/tools/dmd.lua | |
| parent | dd09a2264181f82a0b6aefb38dce5c92fb3af8fe (diff) | |
| parent | 5ad2eaee8cd65987359dbdfc5149bdd61b9260fc (diff) | |
Merge pull request #792 from xmake-io/toolchain
Improve to detect cross-compilation toolchains
Diffstat (limited to 'xmake/modules/core/tools/dmd.lua')
| -rw-r--r-- | xmake/modules/core/tools/dmd.lua | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/xmake/modules/core/tools/dmd.lua b/xmake/modules/core/tools/dmd.lua index eaadb249c..378c68642 100644 --- a/xmake/modules/core/tools/dmd.lua +++ b/xmake/modules/core/tools/dmd.lua @@ -27,10 +27,10 @@ import("core.project.project") function init(self) -- init arflags - self:set("dc-arflags", "-lib") + self:set("dcarflags", "-lib") -- init shflags - self:set("dc-shflags", "-shared", "-fPIC") + self:set("dcshflags", "-shared", "-fPIC") -- init dcflags for the kind: shared self:set("shared.dcflags", "-fPIC") @@ -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 |
