From f4e95cc4c5cfd0887faa7e3f23ad9ddbc2f8cb01 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Mon, 18 Oct 2021 12:11:26 +0200 Subject: [PATCH] fix #98 - sources not detected in subPackages described in JSON objects --- CHANGELOG.md | 1 + src/u_dubproject.pas | 36 ++++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51d3cadf..af9a3a25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Bugs fixed - DUB projects, access violation for subpackages entries described using JSON objects. +- DUB projects, source files of subpackage described in an object not visible in the project inspector (#98) # v3.9.14 diff --git a/src/u_dubproject.pas b/src/u_dubproject.pas index 6c3af1b5..eeb9dcaa 100644 --- a/src/u_dubproject.pas +++ b/src/u_dubproject.pas @@ -1371,6 +1371,26 @@ begin fSrcs.Add(patchPlateformPath(ExtractRelativepath(fBasePath, abs))); end; end; +procedure trySubpPackages(a: TJSONArray); +var + n: TJSONData; + o: TJSONObject; + i: integer; + j: TJSONtype; +begin + for i := 0 to a.Count-1 do + begin + j := a.Types[i] ; + if j = jtString then + tryAddFromFolder(fBasePath + a.Strings[i]) + else if j = jtObject then + begin + o := a.Objects[i]; + if o.findAny('name', n) then + tryAddFromFolder(fBasePath + n.AsString); + end; + end; +end; var pth: string; //glb: TRegExpr; @@ -1407,13 +1427,7 @@ begin tryAddRelOrAbsFile(arr.Strings[i]); // subpackages if fJSON.findArray('subPackages', arr) then - for i := 0 to arr.Count-1 do - begin - if arr.JSONType = jtString then - tryAddFromFolder(fBasePath + arr.Strings[i]) - else if arr.JSONType = jtObject then - tryAddFromFolder(arr.Objects[i].Strings['name']); - end; + trySubpPackages(arr); // by config conf := getCurrentCustomConfig; if conf.isAssigned then @@ -1438,13 +1452,7 @@ begin end; // subpackages if conf.findArray('subPackages', arr) then - for i := 0 to arr.Count-1 do - begin - if arr.JSONType = jtString then - tryAddFromFolder(fBasePath + arr.Strings[i]) - else if arr.JSONType = jtObject then - tryAddFromFolder(arr.Objects[i].Strings['name']); - end; + trySubpPackages(arr); // custom files in current config if conf.findArray('sourceFiles', arr) then for i := 0 to arr.Count-1 do