From dc5ca1d6899eae23268dfac0b7ead5051a788aae Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 13 Jan 2021 22:38:21 +0800 Subject: fix parse_deps for gnrm/gcc --- xmake/modules/private/tools/gcc/parse_deps.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/xmake/modules/private/tools/gcc/parse_deps.lua b/xmake/modules/private/tools/gcc/parse_deps.lua index 0cb2ad4af..cb06d091c 100644 --- a/xmake/modules/private/tools/gcc/parse_deps.lua +++ b/xmake/modules/private/tools/gcc/parse_deps.lua @@ -60,10 +60,16 @@ function main(depsdata) local results = hashset.new() local projectdir = os.projectdir() local line = depsdata:rtrim() -- maybe there will be an empty newline at the end. so we trim it first - line = line:gsub("\\ ", space_placeholder) - for _, includefile in ipairs(line:split(' ', {plain = true})) do -- it will trim all internal spaces without `{strict = true}` + local plain = {plain = true} + line = line:replace("\\ ", space_placeholder, plain) + for _, includefile in ipairs(line:split(' ', plain)) do -- it will trim all internal spaces without `{strict = true}` + -- some gcc toolchains will some invalid paths (e.g. `d\:\xxx`), we need fix it + -- https://github.com/xmake-io/xmake/issues/1196 + if is_host("windows") and includefile:match("^%w\\:") then + includefile = includefile:replace("\\:", ":", plain) + end if not includefile:endswith(":") then -- ignore "xxx.o:" prefix - includefile = includefile:gsub(space_placeholder, ' ') + includefile = includefile:replace(space_placeholder, ' ', plain) if #includefile > 0 then includefile = _normailize_dep(includefile, projectdir) if includefile then -- cgit v1.3.1