Skip to content

Commit 0e36010

Browse files
committed
Resolve transitive package deps in fpc CI backend
TPackageGraph.BuildPackageAt built a package's -Fu search path from its direct RequiredPkgs only. That is correct for the packages here, but breaks once a package depends on another package whose units pull in a third: the intermediate's transitive deps never reach -Fu. Build the -Fu set from the transitive closure of dependency output dirs instead, reusing the CollectUnitPaths walker the project build path already relies on. Keeps the shared make.pas orchestrator identical across repos. Only the fpc backend is affected; the lazbuild backend resolves the graph itself via --add-package-link + --recursive.
1 parent e4f65a0 commit 0e36010

1 file changed

Lines changed: 23 additions & 9 deletions

File tree

.github/workflows/make.pas

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,9 +1205,10 @@ procedure TPackageGraph.CollectUnitPaths(const AIndex: Integer;
12051205
function TPackageGraph.BuildPackageAt(const AIndex: Integer): Boolean;
12061206
var
12071207
Pkg: TLpkPackage;
1208-
Args: TStringList;
1209-
BuildOutput, OutDir, DepPath: string;
1210-
J: Integer;
1208+
Args, DepPaths: TStringList;
1209+
Visited: specialize TList<Integer>;
1210+
BuildOutput, OutDir: string;
1211+
J, DepIdx: Integer;
12111212
begin
12121213
Result := True;
12131214
Pkg := GetPackage(AIndex);
@@ -1225,12 +1226,25 @@ function TPackageGraph.BuildPackageAt(const AIndex: Integer): Boolean;
12251226
for J := 0 to Pkg.SourceDirs.Count - 1 do
12261227
TLazXml.AppendFuIfMissing(Pkg.SourceDirs[J], Args);
12271228
TLazXml.AppendFuIfMissing(Pkg.PkgDir, Args);
1228-
for J := 0 to Pkg.RequiredNames.Count - 1 do
1229-
begin
1230-
if IsBuiltinPackage(Pkg.RequiredNames[J]) then
1231-
Continue;
1232-
DepPath := UnitPathFor(Pkg.RequiredNames[J]);
1233-
TLazXml.AppendFuIfMissing(DepPath, Args);
1229+
// A required package's units reference their own dependencies' units, so
1230+
// the compile needs the transitive closure of dependency output dirs on
1231+
// -Fu, not just the direct requires (mirrors how projects resolve paths).
1232+
DepPaths := TStringList.Create;
1233+
Visited := specialize TList<Integer>.Create;
1234+
try
1235+
for J := 0 to Pkg.RequiredNames.Count - 1 do
1236+
begin
1237+
if IsBuiltinPackage(Pkg.RequiredNames[J]) then
1238+
Continue;
1239+
DepIdx := FindIndexByName(Pkg.RequiredNames[J]);
1240+
if DepIdx >= 0 then
1241+
CollectUnitPaths(DepIdx, Visited, DepPaths);
1242+
end;
1243+
for J := 0 to DepPaths.Count - 1 do
1244+
TLazXml.AppendFuIfMissing(DepPaths[J], Args);
1245+
finally
1246+
Visited.Free;
1247+
DepPaths.Free;
12341248
end;
12351249
TLazXml.AppendPackageBuildArgs(Args, ExtractFileName(Pkg.StubPas), OutDir);
12361250

0 commit comments

Comments
 (0)