diff options
| author | ruki <[email protected]> | 2015-06-01 10:39:42 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-01 10:39:42 +0800 |
| commit | 52b7de2f4d73e08aba2fea79aa04bb06a9af449d (patch) | |
| tree | af2be552b083244d6fc7abcb1c8006580befeeec /xmake | |
| parent | 7381a36a64f50a6db22155ebce996351201b90cb (diff) | |
private mapflags
Diffstat (limited to 'xmake')
| -rw-r--r-- | xmake/scripts/compiler/compiler.lua | 46 | ||||
| -rw-r--r-- | xmake/scripts/linker/linker.lua | 64 |
2 files changed, 39 insertions, 71 deletions
diff --git a/xmake/scripts/compiler/compiler.lua b/xmake/scripts/compiler/compiler.lua index 2be9eaf45..9a6192b26 100644 --- a/xmake/scripts/compiler/compiler.lua +++ b/xmake/scripts/compiler/compiler.lua @@ -28,34 +28,6 @@ local utils = require("base/utils") local string = require("base/string") local config = require("base/config") --- get the configure from the given name -function compiler._get(self, name) - - -- check - assert(self and name); - - -- the compiler configure - local configs = self._CONFIGS - assert(configs) - - -- get it - return configs[name] -end - --- make the compile command -function compiler._make(self, srcfile, objfile, flags) - - -- check - assert(self); - - -- the configure - local configs = self._CONFIGS - assert(configs) - - -- get it - return self._make(configs, srcfile, objfile, flags) -end - -- map gcc flags to the given compiler flags function compiler._mapflags(self, flags) @@ -85,6 +57,20 @@ function compiler._mapflags(self, flags) return flag_mapped end +-- make the compile command +function compiler._make(self, srcfile, objfile, flags) + + -- check + assert(self); + + -- the configure + local configs = self._CONFIGS + assert(configs) + + -- get it + return self._make(configs, srcfile, objfile, compiler._mapflags(self, flags)) +end + -- load the given compiler function compiler.load(name) @@ -129,9 +115,7 @@ function compiler.load(name) c._init(configs) -- init interfaces - c["get"] = compiler._get - c["make"] = compiler._make - c["mapflags"] = compiler._mapflags + c["make"] = compiler._make -- ok? return c 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 |
