diff options
| author | ruki <[email protected]> | 2015-12-03 14:42:40 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-12-03 14:42:40 +0800 |
| commit | 35755c5252d631c539ba5893843904148173dea9 (patch) | |
| tree | 7e12d8ea27e66d5a7e8c245961efb300cda8d811 /xmake/scripts/base/makefile.lua | |
| parent | f90797a83f2c4faa4d61a1165860878242e84d98 (diff) | |
support add_files(*.o/obj)
Diffstat (limited to 'xmake/scripts/base/makefile.lua')
| -rw-r--r-- | xmake/scripts/base/makefile.lua | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/xmake/scripts/base/makefile.lua b/xmake/scripts/base/makefile.lua index a42a71788..bc9a3f297 100644 --- a/xmake/scripts/base/makefile.lua +++ b/xmake/scripts/base/makefile.lua @@ -36,12 +36,58 @@ local compiler = require("base/compiler") local tools = require("tools/tools") local platform = require("platform/platform") +-- make object for the *.o/obj source file +function makefile._make_object_for_object(file, target, srcfile, objfile) + + -- get the source file type + local filetype = path.extension(srcfile) + if not filetype then return false end + + -- get the lower file type + filetype = filetype:lower() + + -- not object file? + if filetype ~= ".o" and filetype ~= ".obj" then return false end + + -- get mode + local mode = config.get("mode") or "" + if mode == "release" then mode = ".r" + elseif mode == "debug" then mode = ".d" + elseif mode == "profile" then mode = ".p" + else mode = "" end + + -- make command + local cmd = string.format("xmake l cp %s %s", srcfile, objfile) + + -- make head + file:write(string.format("%s:", objfile)) + + -- make dependence + file:write(string.format(" %s\n", srcfile)) + + -- make body + file:write(string.format("\t@echo adding%s %s\n", mode, srcfile)) + file:write(string.format("\t@xmake l $(VERBOSE) verbose \"%s\"\n", cmd:gsub("[%s=\"]", function (w) return string.format("%%%x", w:byte()) end))) + file:write(string.format("\t@%s\n", cmd)) + + -- make tail + file:write("\n") + + -- ok + return true +end + -- make the object to the makefile function makefile._make_object(file, target, srcfile, objfile) -- check assert(file and target and srcfile and objfile) + -- make object for the *.o/obj source file + if makefile._make_object_for_object(file, target, srcfile, objfile) then + return true + end + -- get the compiler local c, errors = compiler.get(srcfile) if not c then |
