Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support include deps for sdcc #5715

Merged
merged 3 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
1 change: 1 addition & 0 deletions xmake/plugins/pack/batchcmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
-- imports
import("core.base.option")
import("core.base.hashset")
import("core.project.project")
import("utils.archive")
import("utils.binary.deplibs", {alias = "get_depend_libraries"})
import("private.utils.batchcmds")
Expand Down
6 changes: 3 additions & 3 deletions xmake/toolchains/sdcc/check.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

-- imports
import("core.project.config")
import("lib.detect.find_tool")
import("detect.sdks.find_cross_toolchain")

-- check the cross toolchain
Expand All @@ -31,8 +32,7 @@ function main(toolchain)
toolchain:config_set("cross", cross_toolchain.cross)
toolchain:config_set("bindir", cross_toolchain.bindir)
toolchain:configs_save()
else
raise("sdcc toolchain not found!")
return true
end
return cross_toolchain
return find_tool("sdcc")
end
14 changes: 2 additions & 12 deletions xmake/toolchains/sdcc/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,11 @@
-- @file xmake.lua
--

-- define toolchain
toolchain("sdcc")

-- set homepage
set_kind("standalone")
set_homepage("http://sdcc.sourceforge.net/")
set_description("Small Device C Compiler")

-- mark as standalone toolchain
set_kind("standalone")

-- set toolset
set_toolset("cc", "sdcc")
set_toolset("cxx", "sdcc")
set_toolset("cpp", "sdcpp")
Expand All @@ -37,22 +31,18 @@ toolchain("sdcc")
set_toolset("sh", "sdcc")
set_toolset("ar", "sdar")

-- set archs
set_archs("stm8", "mcs51", "z80", "z180", "r2k", "r3ka", "s08", "hc08")

-- set formats
set_formats("static", "$(name).lib")
set_formats("object", "$(name).rel")
set_formats("binary", "$(name).bin")
set_formats("symbol", "$(name).sym")

-- check toolchain
on_check("check")

-- on load
on_load(function (toolchain)
local arch = toolchain:arch()
if arch then
if arch and arch ~= "none" then
toolchain:add("cxflags", "-m" .. arch)
toolchain:add("ldflags", "-m" .. arch)
end
Expand Down
Loading