From ef32bc5e2afd606eab6db1b2b02292a2ee2e89c4 Mon Sep 17 00:00:00 2001 From: Jack Date: Thu, 29 Dec 2022 22:40:29 +0800 Subject: Fix includedir invalid issue #3215 --- xmake/modules/core/tools/c51.lua | 23 ++++++++++++++++------- 1 file 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 -- cgit v1.3.1 From dd07f27ebe1425ced29154abc89a985cf9152816 Mon Sep 17 00:00:00 2001 From: Jack Date: Thu, 29 Dec 2022 22:41:00 +0800 Subject: Fix cannot link multi-objects issue --- xmake/modules/core/tools/bl51.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/modules/core/tools/bl51.lua b/xmake/modules/core/tools/bl51.lua index 70c04385b..aed92c01c 100644 --- a/xmake/modules/core/tools/bl51.lua +++ b/xmake/modules/core/tools/bl51.lua @@ -28,7 +28,7 @@ end -- make the link arguments list function linkargv(self, objectfiles, targetkind, targetfile, flags) - return self:program(), table.join(objectfiles, "TO", targetfile) + return self:program(), table.join(table.concat(objectfiles,","), "TO", targetfile) end -- link the target file -- cgit v1.3.1 From 2c4d597e6c25f5212d9f410a4edd0c62d03629d3 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 30 Dec 2022 08:30:16 +0800 Subject: Implement suggestions from code review --- xmake/modules/core/tools/c51.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xmake/modules/core/tools/c51.lua b/xmake/modules/core/tools/c51.lua index af87661b4..4c4696a78 100644 --- a/xmake/modules/core/tools/c51.lua +++ b/xmake/modules/core/tools/c51.lua @@ -37,11 +37,11 @@ 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 @@ -55,10 +55,10 @@ 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") .. ")") + table.insert(flags, "OBJECT(" .. objectfile .. ")") + table.insert(flags, "PRINT(" .. objectfile:gsub(".c.obj", ".lst") .. ")") if #paths > 0 then - table.insert(flags, 3, "INCDIR(" .. table.concat(paths, ";") .. ")") + table.insert(flags, "INCDIR(" .. table.concat(paths, ";") .. ")") end return self:program(), table.join(sourcefile, flags) end -- cgit v1.3.1 From e71cb70e55d3b6a9cf3521744ed48cf0f0c02fca Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 30 Dec 2022 21:39:48 +0800 Subject: Implement suggestions from second round of code review --- xmake/modules/core/tools/bl51.lua | 2 +- xmake/modules/core/tools/c51.lua | 18 +++--------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/xmake/modules/core/tools/bl51.lua b/xmake/modules/core/tools/bl51.lua index aed92c01c..075a0289c 100644 --- a/xmake/modules/core/tools/bl51.lua +++ b/xmake/modules/core/tools/bl51.lua @@ -28,7 +28,7 @@ end -- make the link arguments list function linkargv(self, objectfiles, targetkind, targetfile, flags) - return self:program(), table.join(table.concat(objectfiles,","), "TO", targetfile) + return self:program(), table.join(table.concat(objectfiles, ","), "TO", targetfile) end -- link the target file diff --git a/xmake/modules/core/tools/c51.lua b/xmake/modules/core/tools/c51.lua index 4c4696a78..469fa96fa 100644 --- a/xmake/modules/core/tools/c51.lua +++ b/xmake/modules/core/tools/c51.lua @@ -28,16 +28,9 @@ 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 @@ -55,12 +48,7 @@ end -- make the compile arguments list function compargv(self, sourcefile, objectfile, flags) - table.insert(flags, "OBJECT(" .. objectfile .. ")") - table.insert(flags, "PRINT(" .. objectfile:gsub(".c.obj", ".lst") .. ")") - if #paths > 0 then - table.insert(flags, "INCDIR(" .. table.concat(paths, ";") .. ")") - end - return self:program(), table.join(sourcefile, flags) + return self:program(), table.join(sourcefile, "OBJECT(" .. objectfile .. ")", "PRINT(" .. (objectfile:gsub("%.c%.obj", ".lst")) .. ")", flags) end -- compile the source file @@ -72,7 +60,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags) try { function () - local outdata, errdata = os.iorunv(compargv(self, sourcefile, objectfile, dependinfo, flags)) + local outdata, errdata = os.iorunv(compargv(self, sourcefile, objectfile, flags)) return (outdata or "") .. (errdata or "") end, catch -- cgit v1.3.1