diff options
| author | ruki <[email protected]> | 2019-06-04 00:52:06 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-06-03 23:12:41 +0800 |
| commit | 138edbbd1ccca0e002775cced48a14733c98e484 (patch) | |
| tree | 4c807f10db0bb209f2ea1e4e98f2692b09a0b7c4 | |
| parent | b464eb657ec7b4c24d3c7593294c6bf15f1f6338 (diff) | |
improve to load dep file
| -rw-r--r-- | xmake/modules/core/project/depend.lua | 5 | ||||
| -rw-r--r-- | xmake/modules/private/tools/gcc/parse_deps.lua | 19 |
2 files changed, 15 insertions, 9 deletions
diff --git a/xmake/modules/core/project/depend.lua b/xmake/modules/core/project/depend.lua index 4a4f7636b..15189a204 100644 --- a/xmake/modules/core/project/depend.lua +++ b/xmake/modules/core/project/depend.lua @@ -20,7 +20,10 @@ -- load dependent info from the given file (.d) function load(dependfile) - return os.isfile(dependfile) and io.load(dependfile) or nil + if os.isfile(dependfile) then + -- may be the depend file has been incomplete when if the compilation process is abnormally interrupted + return try { function() return io.load(dependfile) end } + end end -- save dependent info to file diff --git a/xmake/modules/private/tools/gcc/parse_deps.lua b/xmake/modules/private/tools/gcc/parse_deps.lua index 4e9b42140..382a3dcdf 100644 --- a/xmake/modules/private/tools/gcc/parse_deps.lua +++ b/xmake/modules/private/tools/gcc/parse_deps.lua @@ -26,17 +26,20 @@ local space_placeholder = "\001" -- normailize path of a dependecy function _normailize_dep(dep) + + -- check dep = dep:trim() if #dep == 0 then return nil end + + -- tranlate dep path dep = path.relative(dep, project.directory()) dep = path.absolute(dep, project.directory()) + -- save it if belong to the project if dep:startswith(os.projectdir()) then - -- get the relative - dep = path.relative(dep, project.directory()) - return dep + return path.relative(dep, project.directory()) end end @@ -52,18 +55,18 @@ end -- build/iphoneos/x86_64/release/tbox.config.h \ -- function main(depsdata) + + -- check if not depsdata or #depsdata == 0 then return {} end + -- parse results local results = {} - - -- translate it local data = depsdata:gsub("\\\n", "") - for _, line in ipairs(data:split("\n")) do local p = line:find(':', 1, true) - if p ~= nil then + if p then line = line:sub(p + 1) line = line:gsub("\\ ", space_placeholder) for _, includefile in ipairs(line:split("%s")) do @@ -76,4 +79,4 @@ function main(depsdata) end end return table.unique(results) -end
\ No newline at end of file +end |
