diff options
| author | ruki <[email protected]> | 2017-06-26 22:26:33 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-06-26 22:26:33 +0800 |
| commit | 08423656d08715670959b69c64957e9e9b1b3db1 (patch) | |
| tree | 8739a1ef0ed686ab83239910681b70c0dea858ad /xmake/core/tool/compiler.lua | |
| parent | f57db3954d227c29d15b68316e9b18838a55c3d4 (diff) | |
modify compiler and linker args
Diffstat (limited to 'xmake/core/tool/compiler.lua')
| -rw-r--r-- | xmake/core/tool/compiler.lua | 63 |
1 files changed, 50 insertions, 13 deletions
diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua index d6a1c74ed..a4f8dc5f4 100644 --- a/xmake/core/tool/compiler.lua +++ b/xmake/core/tool/compiler.lua @@ -124,36 +124,73 @@ function compiler.load(sourcekind) return instance end --- build the source files -function compiler:build(sourcefiles, targetkind, targetfile, target) +-- build the source files (compile and link) +function compiler:build(sourcefiles, targetfile, opt) + + -- init options + opt = opt or {} + + -- make flags + local flags = self:compflags(opt) + if opt.target then + flags = flags .. " " .. (opt.target:linkflags()) + end + + -- get target kind + local targetkind = opt.targetkind + if not targetkind and opt.target then + targetkind = opt.target:get("kind") + end -- get it - return sandbox.load(self:_tool().build, self:_tool(), sourcefiles, targetkind, targetfile, (self:compflags(target)) .. " " .. (target:linkflags())) + return sandbox.load(self:_tool().build, self:_tool(), sourcefiles, targetkind or "binary", targetfile, flags) end --- get the build command -function compiler:buildcmd(sourcefiles, targetkind, targetfile, target) +-- get the build command (compile and link) +function compiler:buildcmd(sourcefiles, targetfile, opt) + + -- init options + opt = opt or {} + + -- make flags + local flags = self:compflags(opt) + if opt.target then + flags = flags .. " " .. (opt.target:linkflags()) + end + + -- get target kind + local targetkind = opt.targetkind + if not targetkind and opt.target then + targetkind = opt.target:get("kind") + end -- get it - return self:_tool():buildcmd(sourcefiles, targetkind, targetfile, (self:compflags(target) .. " " .. (target:linkflags()))) + return self:_tool():buildcmd(sourcefiles, targetkind or "binary", targetfile, flags) end -- compile the source files -function compiler:compile(sourcefiles, objectfile, incdepfile, target) +function compiler:compile(sourcefiles, objectfile, opt) + + -- init options + opt = opt or {} -- compile it - return sandbox.load(self:_tool().compile, self:_tool(), sourcefiles, objectfile, incdepfile, (self:compflags(target))) + return sandbox.load(self:_tool().compile, self:_tool(), sourcefiles, objectfile, opt.incdepfiles, (self:compflags(opt))) end -- get the compile command -function compiler:compcmd(sourcefiles, objectfile, target) - - -- get it - return self:_tool():compcmd(sourcefiles, objectfile, (self:compflags(target))) +function compiler:compcmd(sourcefiles, objectfile, opt) + return self:_tool():compcmd(sourcefiles, objectfile, (self:compflags(opt))) end -- get the compling flags -function compiler:compflags(target) +function compiler:compflags(opt) + + -- init options + opt = opt or {} + + -- get target + local target = opt.target -- no target? if not target then |
