diff options
Diffstat (limited to 'xmake/scripts/linker/linker.lua')
| -rw-r--r-- | xmake/scripts/linker/linker.lua | 64 |
1 files changed, 24 insertions, 40 deletions
diff --git a/xmake/scripts/linker/linker.lua b/xmake/scripts/linker/linker.lua index 9f3cfe184..5f909857c 100644 --- a/xmake/scripts/linker/linker.lua +++ b/xmake/scripts/linker/linker.lua @@ -28,18 +28,33 @@ local utils = require("base/utils") local string = require("base/string") local config = require("base/config") --- get the configure from the given name -function linker._get(self, name) +-- map gcc flags to the given linker flags +function linker._mapflags(self, flags) -- check - assert(self and name); + assert(self and flags); + + -- need not map flags? return it directly + if not self.mapflag then + return flags + end - -- the linker configure + -- the configure local configs = self._CONFIGS assert(configs) - -- get it - return configs[name] + -- map flags + local flags_mapped = {} + for _, flag in pairs(flags) do + -- map it + local flag_mapped = self._mapflag(configs, flag) + if flag_mapped then + flags_mapped[table.getn(flags_mapped) + 1] = flag_mapped + end + end + + -- ok? + return flags_mapped end -- make the binary command @@ -53,7 +68,7 @@ function linker._make_binary(self, objfiles, targetfile, flags) assert(configs) -- make it - return self._make_binary(configs, objfiles, targetfile, flags) + return self._make_binary(configs, objfiles, targetfile, linker._mapflags(self, flags)) end -- make the static library command @@ -67,7 +82,7 @@ function linker._make_static(self, objfiles, targetfile, flags) assert(configs) -- make it - return self._make_static(configs, objfiles, targetfile, flags) + return self._make_static(configs, objfiles, targetfile, linker._mapflags(self, flags)) end -- make the shared library command @@ -81,36 +96,7 @@ function linker._make_shared(self, objfiles, targetfile, flags) assert(configs) -- make it - return self._make_shared(configs, objfiles, targetfile, flags) -end - --- map gcc flags to the given linker flags -function linker._mapflags(self, flags) - - -- check - assert(self and flags); - - -- need not map flags? return it directly - if not self.mapflag then - return flags - end - - -- the configure - local configs = self._CONFIGS - assert(configs) - - -- map flags - local flags_mapped = {} - for _, flag in pairs(flags) do - -- map it - local flag_mapped = self._mapflag(configs, flag) - if flag_mapped then - flags_mapped[table.getn(flags_mapped) + 1] = flag_mapped - end - end - - -- ok? - return flag_mapped + return self._make_shared(configs, objfiles, targetfile, linker._mapflags(self, flags)) end -- load the given linker @@ -157,8 +143,6 @@ function linker.load(name) l._init(configs) -- init interfaces - l["get"] = linker._get - l["mapflags"] = linker._mapflags l["make_binary"] = linker._make_binary l["make_static"] = linker._make_static l["make_shared"] = linker._make_shared |
