summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-12-27 00:45:04 +0800
committerruki <[email protected]>2018-12-26 22:30:24 +0800
commit8a33fd82a9e747c1ff5ecd9b8202732bdd3e5f1d (patch)
treea034d88703d17cc3e067ebcad65f810bddd56521
parent529983f0606dd9fd7a82305d83a41da7230f944c (diff)
improve to get compile info
-rw-r--r--xmake/modules/core/tools/gcc.lua24
-rw-r--r--xmake/platforms/macosx/check.lua2
2 files changed, 10 insertions, 16 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index a1d92e6dd..91010fbdb 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -343,24 +343,18 @@ end
-- Multiple include guards may be useful for:
-- /usr/include/bits/long-double.h
-- /usr/include/bits/sigaction.h
+-- /usr/include/string
--
function _get_compile_info(outdata)
-- filter dependent header info and get compile output
local results = {}
for _, line in ipairs(outdata:split("\n")) do
- if not line:startswith("!") and
- not line:startswith(".") and
- not line:endswith(".h") and
- not line:endswith(".hpp") and
- not line:endswith(".inc") and
- not line:endswith(".inl") and
- not line:endswith(".c") and
- not line:endswith(".cpp") and
- not line:endswith(".cc") and
- not line:endswith(".m") and
- not line:endswith(".mm") and
- not line:endswith(':') then
+ if not line:startswith("!") and -- ! xxx.h
+ not line:startswith(".") and -- ... xxx.h
+ not (path.is_absolute(line) and not line:find(':', 3, true)) and -- /usr/xxx/string, C:\xx\string
+ not line:find("%.%a+$") and -- src/xxx.[h|hpp|c|..]
+ not (line:endswith(':') and not line:find("%d")) then -- Multiple include guards may be useful for:
table.insert(results, line)
end
end
@@ -493,10 +487,10 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags)
os.tryrm(objectfile)
-- parse and strip errors
+ local lines = _get_compile_info(errors)
if not option.get("verbose") then
-- find the start line of error
- local lines = _get_compile_info(errors)
local start = 0
for index, line in ipairs(lines) do
if line:find("error:", 1, true) or line:find("错误:", 1, true) then
@@ -507,12 +501,12 @@ function _compile1(self, sourcefile, objectfile, dependinfo, flags)
-- get 16 lines of errors
if start > 0 then
- errors = table.concat(table.slice(lines, start, start + ifelse(#lines - start > 16, 16, #lines - start)), "\n")
+ lines = table.slice(lines, start, start + ifelse(#lines - start > 16, 16, #lines - start))
end
end
-- raise compiling errors
- raise(errors)
+ raise(#lines > 0 and table.concat(lines, "\n") or "")
end
},
finally
diff --git a/xmake/platforms/macosx/check.lua b/xmake/platforms/macosx/check.lua
index 1a6f4d1ef..43d37dd1c 100644
--- a/xmake/platforms/macosx/check.lua
+++ b/xmake/platforms/macosx/check.lua
@@ -99,7 +99,7 @@ function _toolchains(config)
-- insert dlang tools to toolchains
checker.toolchain_insert(toolchains, "dc", "", "$(env DC)", "the dlang compiler")
- checker.toolchain_insert(toolchains, "dc-ar", "", "$(env Dc)", "the dlang static library archiver")
+ checker.toolchain_insert(toolchains, "dc-ar", "", "$(env DC)", "the dlang static library archiver")
checker.toolchain_insert(toolchains, "dc-sh", "", "$(env DC)", "the dlang shared library linker")
checker.toolchain_insert(toolchains, "dc-ld", "", "$(env DC)", "the dlang linker")
checker.toolchain_insert(toolchains, "dc", "", "dmd", "the dlang compiler")