diff --git a/src/u_dubproject.pas b/src/u_dubproject.pas index cd4c0ebd..094d2175 100644 --- a/src/u_dubproject.pas +++ b/src/u_dubproject.pas @@ -30,6 +30,7 @@ type strict private fName : string; fVersions: TSemVerList; + fNewNamingScheme: boolean; public constructor create; destructor destroy; override; @@ -38,6 +39,7 @@ type function highestInInterval(constref lo, hi: TSemVer): PSemVer; function highest: PSemVer; property name: string read fName write fName; + property newNamingScheme: boolean read fNewNamingScheme write fNewNamingScheme; end; TDubLocalPackages = class @@ -359,10 +361,12 @@ begin begin v := fVersions[i]^; if v < lo then - continue; - if v < hi then - result := fVersions[i]; - if v > hi then + continue + else if (v > lo) or (v = lo) then + result := fVersions[i] + else if (v < hi) and ((assigned(result) and (v > result^)) or (not assigned(result))) then + result := fVersions[i] + else if v > hi then break; end; end; @@ -395,6 +399,23 @@ begin end; class procedure TDubLocalPackages.update; + + procedure addPackageOrVersion(name, semVer: string; newNamingScheme: Boolean); + var + d: PDubLocalPackage = nil; + begin + if not find(name, d) then + begin + setLength(fLocalPackages, length(fLocalPackages) + 1); + fLocalPackages[high(fLocalPackages)] := TDubLocalPackage.create; + d := @fLocalPackages[high(fLocalPackages)]; + d^.name := name; + d^.newNamingScheme := newNamingScheme; + end; + d^.addVersion(semVer); + end; + + var p: TStringList; r: TStringList; @@ -404,9 +425,10 @@ var i: integer; j: integer = 0; k: integer; - d: PDubLocalPackage = nil; h: TStringRange = (ptr: nil; pos: 0; len: 0); x: string; + u: TStringList; + g: string; begin @@ -441,33 +463,42 @@ begin j := 0; s := p[i]; h.init(s); - while true do + // after 2.104 /// + // new naming scheme can be distinguished because '.' is not a legal char in a package name + v := s.extractFileName; + if (Pos('.', v) < 1) and (Pos('master', v) < 1) then begin - h.popUntil('-'); - if h.empty then - break; - if (h.popFront^.front in ['0'..'9']) or - h.endsWith('master') then + u := TStringList.Create; + try + listFolders(u, s + DirectorySeparator); + for g in u do + addPackageOrVersion(v, 'v' + g.extractFileName, true); + finally + u.free; + end; + end + // before 2.104 /-/ + else + begin + while true do begin - j := h.position; - break; + h.popUntil('-'); + if h.empty then + break; + if (h.popFront^.front in ['0'..'9']) or + h.endsWith('master') then + begin + j := h.position; + break; + end; + end; + if not j.equals(0) then + begin + n := s[1..j-1]; + n := n.extractFileName; + addPackageOrVersion(n, 'v' + s[j+1 .. length(s)], false); end; end; - if j.equals(0) then - continue; - - n := s[1..j-1]; - n := n.extractFileName; - if not find(n, d) then - begin - setLength(fLocalPackages, length(fLocalPackages) + 1); - fLocalPackages[high(fLocalPackages)] := TDubLocalPackage.create; - d := @fLocalPackages[high(fLocalPackages)]; - d^.name := n; - end; - v := 'v' + s[j+1 .. length(s)]; - d^.addVersion(v); - end; finally p.Free; @@ -509,7 +540,6 @@ begin hi.patch := 0; hi.additional :=''; result := package^.highestInInterval(opVer, hi); - result := result; end; end else if op = '=' then @@ -1742,15 +1772,19 @@ procedure TDubProject.updateImportPathsFromJson; for k := 0 to b.Count-1 do begin s := b[k] + n; - p := s + '-' + u^.asString + DirectorySeparator + n + DirectorySeparator; - // e.g vibe-d:http -> /vibed-/http + p := s + '-' + u^.asString + DirectorySeparator + n + DirectorySeparator; + // new naming scheme + if not p.dirExists then + p := s + DirectorySeparator + u^.asString + DirectorySeparator + n + DirectorySeparator; + // e.g vibe-d:http -> /vibed//vibed/http + // e.g ae:sys-wininet -> /ae//ae/sys/wininet if length(w) <> 0 then - p += w; + p += strutils.ReplaceText(w, '-', DirectorySeparator); if not p.dirExists then continue; if (p + 'source').dirExists then begin - fImportPaths.Add(p + 'source') ; + fImportPaths.Add(p + 'source'); break; end else if (p + 'src').dirExists then