summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmake/modules/core/tools/c51.lua23
1 files changed, 16 insertions, 7 deletions
diff --git a/xmake/modules/core/tools/c51.lua b/xmake/modules/core/tools/c51.lua
index c172d0bb6..af87661b4 100644
--- a/xmake/modules/core/tools/c51.lua
+++ b/xmake/modules/core/tools/c51.lua
@@ -28,13 +28,20 @@ import("utils.progress")
function init(self)
end
+--[[
+The flags variable in the compile function is empty when you run the command `xmake -r`.
+But The `xmake -rv` command is no problem.
+Use these ways to walk around first.
+--]]
+local paths = {}
+
-- make the includedir flag
function nf_includedirs(self, dirs)
- local paths = {}
+-- local paths = {}
for _, dir in ipairs(dirs) do
table.insert(paths, path.translate(dir))
end
- if #paths > 0 then
+ if #paths > 0 then
return {"INCDIR(" .. table.concat(paths, ";") .. ")"}
end
end
@@ -48,7 +55,12 @@ end
-- make the compile arguments list
function compargv(self, sourcefile, objectfile, flags)
- return self:program(), table.join(sourcefile, flags)
+ table.insert(flags, 1, "OBJECT(" .. objectfile .. ")")
+ table.insert(flags, 2, "PRINT(" .. objectfile:gsub(".c.obj", ".lst") .. ")")
+ if #paths > 0 then
+ table.insert(flags, 3, "INCDIR(" .. table.concat(paths, ";") .. ")")
+ end
+ return self:program(), table.join(sourcefile, flags)
end
-- compile the source file
@@ -56,14 +68,11 @@ function compile(self, sourcefile, objectfile, dependinfo, flags)
-- ensure the object directory
os.mkdir(path.directory(objectfile))
-
-- compile it
try
{
function ()
- local realsourcefile = objectfile:gsub("\\.obj$", "")
- os.cp(sourcefile, realsourcefile)
- local outdata, errdata = os.iorunv(compargv(self, realsourcefile, objectfile, dependinfo, flags))
+ local outdata, errdata = os.iorunv(compargv(self, sourcefile, objectfile, dependinfo, flags))
return (outdata or "") .. (errdata or "")
end,
catch