Skip to content

Commit

Permalink
support to parse include deps for sdcc
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Oct 14, 2024
1 parent e0017ba commit 7fa81fa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
5 changes: 1 addition & 4 deletions xmake/modules/core/tools/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -866,12 +866,9 @@ 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
opt = opt or {}
local depfile = dependinfo and os.tmpfile() or nil
try
{
Expand Down
29 changes: 23 additions & 6 deletions xmake/modules/core/tools/sdcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -217,21 +225,30 @@ 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
},
finally
{
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
}
}
Expand Down

0 comments on commit 7fa81fa

Please sign in to comment.