summaryrefslogtreecommitdiff
path: root/xmake/modules/core
diff options
context:
space:
mode:
authorruki <[email protected]>2017-08-18 22:19:25 +0800
committerruki <[email protected]>2017-08-18 22:19:25 +0800
commitc049bcb7fc2e2e032ebc69897e5170c214bf8df2 (patch)
treeaa45fac7634774f4be0916ea265e51c9cff37708 /xmake/modules/core
parentb068f28c48cb6cd7246dcfeaff648327decb3101 (diff)
improve rpath
Diffstat (limited to 'xmake/modules/core')
-rw-r--r--xmake/modules/core/tools/gcc.lua14
1 files changed, 9 insertions, 5 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index ddfc264cc..1139bed0b 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -234,12 +234,16 @@ end
-- make the rpathdir flag
function nf_rpathdir(self, dir)
- local flag_elf = "-Wl,-rpath=" .. dir
- local flag_macho = "-Xlinker -rpath -Xlinker " .. dir
if self:has_flags(flag_elf) then
- return flag_elf
- elseif self:has_flags(flag_macho) then
- return flag_macho
+ return "-Wl,-rpath=" .. (dir:gsub("@[%w_]+", function (name)
+ local maps = {["@loader_path"] = "$ORIGIN", ["@executable_path"] = "$ORIGIN"}
+ return maps[name]
+ end))
+ elseif self:has_flags("-Xlinker -rpath -Xlinker " .. dir) then
+ return "-Xlinker -rpath -Xlinker " .. (dir:gsub("%$[%w_]+", function (name)
+ local maps = {["$ORIGIN"] = "@loader_path"}
+ return maps[name]
+ end))
end
end