diff options
| author | ruki <[email protected]> | 2015-06-02 10:12:47 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-02 10:12:47 +0800 |
| commit | bf6315e4e63270175eb27d9ab73dc98f3408cea8 (patch) | |
| tree | a30eb35c334883b1a7e01479c0ffdf614807cab5 /xmake/scripts/linker/linker.lua | |
| parent | f6177ffb405aa474e5d8e8af787778bd8ed8439c (diff) | |
append config and target flags
Diffstat (limited to 'xmake/scripts/linker/linker.lua')
| -rw-r--r-- | xmake/scripts/linker/linker.lua | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/xmake/scripts/linker/linker.lua b/xmake/scripts/linker/linker.lua index d2e4ec9ec..22b4c5ea1 100644 --- a/xmake/scripts/linker/linker.lua +++ b/xmake/scripts/linker/linker.lua @@ -58,33 +58,47 @@ function linker._mapflags(self, flags) end -- make the command -function linker._make(self, kind, objfiles, targetfile, flags) +function linker._make(self, target, objfiles, targetfile) -- check - assert(self and self._make) + assert(self and self._make and target) -- the configure local configs = self._CONFIGS assert(configs) - -- get the common flags string for the current linker - local flags_common = nil - if kind == "binary" then flags_common = configs.ldflags - elseif kind == "static" then flags_common = configs.arflags - elseif kind == "shared" then flags_common = configs.shflags + -- the target kind + local kind = target.kind or "" + + -- the flag name + local flag_name = nil + if kind == "binary" then flag_name = "ldflags" + elseif kind == "static" then flag_name = "arflags" + elseif kind == "shared" then flag_name = "shflags" + else + -- error + utils.error("unknown type for linker: %s", kind) + return end - flags_common = flags_common or "" - -- map flags - flags = linker._mapflags(self, utils.wrap(flags)) - assert(flags) - - -- make flags string - flags = table.concat(flags) - assert(flags) + -- get the common flags from the current linker + local flags_common = configs[flag_name] or "" + + -- get the target flags from the current project + local flags_target = target[flag_name] or "" + flags_target = table.concat(linker._mapflags(self, utils.wrap(flags_target)), " ") + assert(flags_target) + + -- get the config flags + local flags_config = config.get(flag_name) or "" + flags_config = table.concat(linker._mapflags(self, utils.wrap(flags_config)), " ") + assert(flags_config) + + -- make the flags string + local flags = string.format("%s %s %s", flags_common, flags_target, flags_config) -- make it - return self._make(configs, table.concat(objfiles), targetfile, flags_common .. " " .. flags) + return self._make(configs, table.concat(objfiles, " "), targetfile, flags) end -- load the given linker |
