summaryrefslogtreecommitdiff
path: root/xmake/modules/core/tools/gcc.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-07-12 18:34:01 +0800
committerruki <[email protected]>2017-07-12 18:34:01 +0800
commitb72d2cd32d1919170eb621dd6c0074c975eb67e1 (patch)
treed34c3d1fbae58091301403fd9dc450bdad78647e /xmake/modules/core/tools/gcc.lua
parent693619f971581f9b7bc66fcdb1ef65d01aa002e5 (diff)
modify compflags and add compargv
Diffstat (limited to 'xmake/modules/core/tools/gcc.lua')
-rw-r--r--xmake/modules/core/tools/gcc.lua42
1 files changed, 26 insertions, 16 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 62d41abc3..3d510fb39 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -243,9 +243,9 @@ function nf_framework(self, framework)
return {"-framework", framework}
end
--- make the link command
-function linkcmd(self, objectfiles, targetkind, targetfile, flags)
- return format("%s -o %s %s %s", self:program(), targetfile, objectfiles, flags)
+-- make the link arguments list
+function linkargv(self, objectfiles, targetkind, targetfile, flags)
+ return self:program(), table.join("-o", targetfile, objectfiles, flags)
end
-- link the target file
@@ -255,11 +255,11 @@ function link(self, objectfiles, targetkind, targetfile, flags)
os.mkdir(path.directory(targetfile))
-- link it
- os.run(linkcmd(self, objectfiles, targetkind, targetfile, flags))
+ os.runv(linkargv(self, objectfiles, targetkind, targetfile, flags))
end
--- make the complie command
-function _compcmd1(self, sourcefile, objectfile, flags)
+-- make the complie arguments list
+function _compargv1(self, sourcefile, objectfile, flags)
-- get ccache
local ccache = nil
@@ -267,14 +267,24 @@ function _compcmd1(self, sourcefile, objectfile, flags)
ccache = find_ccache()
end
- -- make it
- local command = format("%s -c %s -o %s %s", self:program(), flags, objectfile, sourcefile)
+ -- make argv
+ local argv = table.join("-c", flags or {}, "-o", objectfile, sourcefile)
+
+ -- uses cache?
+ local program = self:program()
if ccache then
- command = ccache:append(command, " ")
+
+ -- parse the filename and arguments, .e.g "xcrun -sdk macosx clang"
+ if not os.isexec(program) then
+ argv = table.join(program:split("%s"), argv)
+ else
+ table.insert(argv, 1, program)
+ end
+ return ccache, argv
end
- -- ok
- return command
+ -- no cache
+ return program, argv
end
-- complie the source file
@@ -287,7 +297,7 @@ function _compile1(self, sourcefile, objectfile, incdepfile, flags)
try
{
function ()
- local outdata, errdata = os.iorun(_compcmd1(self, sourcefile, objectfile, flags))
+ local outdata, errdata = os.iorunv(_compargv1(self, sourcefile, objectfile, flags))
return (outdata or "") .. (errdata or "")
end,
catch
@@ -317,7 +327,7 @@ function _compile1(self, sourcefile, objectfile, incdepfile, flags)
local tmpfile = os.tmpfile()
-- generate it
- os.run("%s -c -MM %s -o %s %s", self:program(), flags or "", tmpfile, sourcefile)
+ os.runv(self:program(), table.join("-c", "-MM", flags or {}, "-o", tmpfile, sourcefile))
-- translate it
local results = {}
@@ -338,14 +348,14 @@ function _compile1(self, sourcefile, objectfile, incdepfile, flags)
end
end
--- make the complie command
-function compcmd(self, sourcefiles, objectfile, flags)
+-- make the complie arguments list
+function compargv(self, sourcefiles, objectfile, flags)
-- only support single source file now
assert(type(sourcefiles) ~= "table", "'object:sources' not support!")
-- for only single source file
- return _compcmd1(self, sourcefiles, objectfile, flags)
+ return _compargv1(self, sourcefiles, objectfile, flags)
end
-- complie the source file