diff options
| author | ruki <[email protected]> | 2023-11-29 00:37:34 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-11-29 00:37:34 +0800 |
| commit | 37f0edd18cb9f2fc95a8dbea1fb165983cf03f39 (patch) | |
| tree | d6b9a5e9b1d6299b789a85fad34464e648888907 /xmake/modules/core/tools/armlink.lua | |
| parent | b1a69af220a489014cde717e192c2079414ded8e (diff) | |
improve armlink output
Diffstat (limited to 'xmake/modules/core/tools/armlink.lua')
| -rw-r--r-- | xmake/modules/core/tools/armlink.lua | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/xmake/modules/core/tools/armlink.lua b/xmake/modules/core/tools/armlink.lua index fa8a1510f..939e8e24b 100644 --- a/xmake/modules/core/tools/armlink.lua +++ b/xmake/modules/core/tools/armlink.lua @@ -21,6 +21,7 @@ -- imports import("core.base.option") import("core.base.global") +import("core.project.policy") import("utils.progress") function init(self) @@ -64,7 +65,65 @@ end -- link the target file function link(self, objectfiles, targetkind, targetfile, flags) - os.mkdir(path.directory(targetfile)) - os.runv(linkargv(self, objectfiles, targetkind, targetfile, flags)) + opt = opt or {} + try + { + function () + os.mkdir(path.directory(targetfile)) + local program, argv = linkargv(self, objectfiles, targetkind, targetfile, flags) + os.runv(program, argv) + end, + catch + { + function (errors) + + -- parse and strip errors + local lines = errors and tostring(errors):split('\n', {plain = true}) or {} + if not option.get("verbose") then + + -- find the start line of error + local start = 0 + for index, line in ipairs(lines) do + if line:find("error:", 1, true) or line:find("错误:", 1, true) then + start = index + break + end + end + + -- get 16 lines of errors + if start > 0 then + lines = table.slice(lines, start, start + ((#lines - start > 16) and 16 or (#lines - start))) + end + end + + -- raise errors + local results = #lines > 0 and table.concat(lines, "\n") or "" + if not option.get("verbose") then + results = results .. "\n ${yellow}> in ${bright}" .. sourcefile + end + raise(results) + end + }, + finally + { + function (ok, outdata, errdata) + + -- show warnings? + if ok and errdata and #errdata > 0 and policy.build_warnings() then + local lines = errdata:split('\n', {plain = true}) + if #lines > 0 then + if not option.get("diagnosis") then + lines = table.slice(lines, 1, (#lines > 16 and 16 or #lines)) + end + local warnings = table.concat(lines, "\n") + if progress.showing_without_scroll() then + print("") + end + cprint("${color.warning}%s", warnings) + end + end + end + } + } end |
