summaryrefslogtreecommitdiff
path: root/xmake/tools/gcc.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-02-14 09:00:26 +0800
committerruki <[email protected]>2017-02-14 09:00:26 +0800
commit5e23aa6f9344b21dee98ad3fad9182808d690485 (patch)
tree2592b6b087dce76b6447d4de2a5a1446b6c98169 /xmake/tools/gcc.lua
parentf7eaf51c4cad7d94989e130de2172df2cbc74193 (diff)
modify interface for compiling multiple source files
Diffstat (limited to 'xmake/tools/gcc.lua')
-rwxr-xr-xxmake/tools/gcc.lua46
1 files changed, 33 insertions, 13 deletions
diff --git a/xmake/tools/gcc.lua b/xmake/tools/gcc.lua
index 6ad26c04e..0f555245d 100755
--- a/xmake/tools/gcc.lua
+++ b/xmake/tools/gcc.lua
@@ -245,8 +245,18 @@ function linkcmd(objectfiles, targetfile, flags)
return format("%s -o %s %s %s", _g.shellname, targetfile, objectfiles, flags)
end
+-- link the target file
+function link(objectfiles, targetfile, flags)
+
+ -- ensure the target directory
+ os.mkdir(path.directory(targetfile))
+
+ -- link it
+ os.run(linkcmd(objectfiles, targetfile, flags))
+end
+
-- make the complie command
-function compcmd(sourcefile, objectfile, flags)
+function _compcmd1(sourcefile, objectfile, flags)
-- get ccache
local ccache = nil
@@ -264,18 +274,8 @@ function compcmd(sourcefile, objectfile, flags)
return command
end
--- link the target file
-function link(objectfiles, targetfile, flags)
-
- -- ensure the target directory
- os.mkdir(path.directory(targetfile))
-
- -- link it
- os.run(linkcmd(objectfiles, targetfile, flags))
-end
-
-- complie the source file
-function compile(sourcefile, objectfile, incdepfile, flags)
+function _compile1(sourcefile, objectfile, incdepfile, flags)
-- ensure the object directory
os.mkdir(path.directory(objectfile))
@@ -284,7 +284,7 @@ function compile(sourcefile, objectfile, incdepfile, flags)
try
{
function ()
- local outdata, errdata = os.iorun(compcmd(sourcefile, objectfile, flags))
+ local outdata, errdata = os.iorun(_compcmd1(sourcefile, objectfile, flags))
return (outdata or "") .. (errdata or "")
end,
finally
@@ -347,6 +347,26 @@ function compile(sourcefile, objectfile, incdepfile, flags)
end
end
+-- make the complie command
+function compcmd(sourcefiles, objectfile, flags)
+
+ -- only support single source file now
+ assert(type(sourcefiles) == "string", "not support")
+
+ -- for only single source file
+ return _compcmd1(sourcefiles, objectfile, flags)
+end
+
+-- complie the source file
+function compile(sourcefiles, objectfile, incdepfiles, flags)
+
+ -- only support single source file now
+ assert(type(sourcefiles) == "string", "not support")
+
+ -- for only single source file
+ _compile1(sourcefiles, objectfile, incdepfiles, flags)
+end
+
-- check the given flags
function check(flags)