diff options
| author | ruki <[email protected]> | 2022-11-01 00:44:04 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-11-01 00:44:04 +0800 |
| commit | ad6067482d7220a384dc0f5430bb8df1159fec50 (patch) | |
| tree | f04ad3ad50484804b8e34adca81dfe6f3f1c95f5 | |
| parent | 9f242e47e9ad175a073414a3606a193dfe06d8a6 (diff) | |
improve to parse cl deps
| -rw-r--r-- | xmake/modules/private/tools/cl/parse_deps_json.lua | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/xmake/modules/private/tools/cl/parse_deps_json.lua b/xmake/modules/private/tools/cl/parse_deps_json.lua index f274dc382..459a8b112 100644 --- a/xmake/modules/private/tools/cl/parse_deps_json.lua +++ b/xmake/modules/private/tools/cl/parse_deps_json.lua @@ -80,15 +80,54 @@ function _normailize_dep(dep, projectdir) end -- parse depsfiles from string +-- +--[[ +{ + "Version": "1.2", + "Data": { + "Source": "c:\users\ruki\desktop\user_headerunit\src\main.cpp", + "ProvidedModule": "", + "Includes": [], + "ImportedModules": [ + { + "Name": "hello", + "BMI": "c:\users\ruki\desktop\user_headerunit\src\hello.ifc" + } + ], + "ImportedHeaderUnits": [ + { + "Header": "c:\users\ruki\desktop\user_headerunit\src\header.hpp", + "BMI": "c:\users\ruki\desktop\user_headerunit\src\header.hpp.ifc" + } + ] + } +}]] function main(depsdata) -- decode json data first depsdata = json.decode(depsdata) -- get includes - local includes - if depsdata and depsdata.Data then - includes = depsdata.Data.Includes + local data + if depsdata then + data = depsdata.Data + end + if data then + includes = data.Includes + for _, item in ipairs(data.ImportedModules) do + local bmifile = item.BMI + if bmifile then + includes = includes or {} + table.insert(includes, bmifile) + end + end + for _, item in ipairs(data.ImportedHeaderUnits) do + local bmifile = item.BMI + if bmifile then + includes = includes or {} + table.insert(includes, bmifile) + end + end end -- translate it |
