summaryrefslogtreecommitdiff
path: root/xmake/modules/core/tools/sdcc.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2024-10-15 00:55:31 +0800
committerruki <[email protected]>2024-10-15 00:55:31 +0800
commit7fa81fa0ac749aae01627daf073e195c1e917d1a (patch)
treed9247612c6ff40386681ded218061803820de26c /xmake/modules/core/tools/sdcc.lua
parente0017bacc10923be9f179fce68aeb6cee971ef4a (diff)
support to parse include deps for sdcc
Diffstat (limited to 'xmake/modules/core/tools/sdcc.lua')
-rw-r--r--xmake/modules/core/tools/sdcc.lua29
1 files changed, 23 insertions, 6 deletions
diff --git a/xmake/modules/core/tools/sdcc.lua b/xmake/modules/core/tools/sdcc.lua
index ee5ffbb79..6cbec5d43 100644
--- a/xmake/modules/core/tools/sdcc.lua
+++ b/xmake/modules/core/tools/sdcc.lua
@@ -183,15 +183,23 @@ end
-- compile the source file
function compile(self, sourcefile, objectfile, dependinfo, flags, opt)
-
- -- ensure the object directory
+ opt = opt or {}
os.mkdir(path.directory(objectfile))
- -- compile it
+ local depfile = dependinfo and os.tmpfile() .. ".rel" or nil
try
{
function ()
- local outdata, errdata = os.iorunv(compargv(self, sourcefile, objectfile, flags))
+
+ -- generate includes file
+ local compflags = flags
+ if depfile then
+ compflags = table.join(compflags, "-M")
+ end
+ os.iorunv(compargv(self, sourcefile, depfile, compflags))
+
+ -- do compile
+ outdata, errdata = os.iorunv(compargv(self, sourcefile, objectfile, flags))
return (outdata or "") .. (errdata or "")
end,
catch
@@ -217,7 +225,6 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt)
errors = table.concat(table.slice(lines, start, start + ((#lines - start > 16) and 16 or (#lines - start))), "\n")
end
- -- raise compiling errors
raise(errors)
end
},
@@ -225,13 +232,23 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt)
{
function (ok, warnings)
- -- print some warnings
+ -- show warnings
if warnings and #warnings > 0 and policy.build_warnings(opt) then
if progress.showing_without_scroll() then
print("")
end
cprint("${color.warning}%s", table.concat(table.slice(warnings:split('\n'), 1, 8), '\n'))
end
+
+ -- generate the dependent includes
+ if depfile and os.isfile(depfile) then
+ if dependinfo then
+ dependinfo.depfiles_gcc = io.readfile(depfile, {continuation = "\\"})
+ end
+
+ -- remove the temporary dependent file
+ os.tryrm(depfile)
+ end
end
}
}