Fix includedir invalid issue
@@ -28,9 +28,16 @@ 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
@@ -48,6 +55,11 @@ end
-- make the compile arguments list
function compargv(self, sourcefile, objectfile, 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
@@ -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
