mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 15:29:11 +02:00
* resolving of examples fixed
git-svn-id: trunk@9905 -
This commit is contained in:
parent
052c1bf5ae
commit
4ed0d4a5bf
@ -3211,11 +3211,99 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
Procedure TBuildEngine.ResolveFileNames(APackage : TPackage; ACPU:TCPU;AOS:TOS);
|
Procedure TBuildEngine.ResolveFileNames(APackage : TPackage; ACPU:TCPU;AOS:TOS);
|
||||||
|
|
||||||
|
procedure FindMainSource(T:TTarget);
|
||||||
|
var
|
||||||
|
SD,SF : String;
|
||||||
|
begin
|
||||||
|
LogSearchPath('package source',APackage.SourcePath,ACPU,AOS,APackage.Directory);
|
||||||
|
SD:=Dictionary.ReplaceStrings(T.Directory);
|
||||||
|
SF:=Dictionary.ReplaceStrings(T.SourceFileName);
|
||||||
|
if SD='' then
|
||||||
|
FindFileInPath(APackage.SourcePath,SF,SD,ACPU,AOS,APackage.Directory)
|
||||||
|
else
|
||||||
|
if APackage.Directory<>'' then
|
||||||
|
SD:=IncludeTrailingPathDelimiter(APackage.Directory)+SD;
|
||||||
|
if SD<>'' then
|
||||||
|
SD:=IncludeTrailingPathDelimiter(SD);
|
||||||
|
T.FTargetSourceFileName:=SD+SF;
|
||||||
|
if FileExists(T.TargetSourceFileName) then
|
||||||
|
Log(vlDebug,SDbgResolvedSourceFile,[T.SourceFileName,T.TargetSourceFileName])
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Log(vlWarning,SWarnSourceFileNotFound,[T.SourceFileName,MakeTargetString(ACPU,AOS)]);
|
||||||
|
T.FTargetSourceFileName:='';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure FindIncludeSources(T:TTarget);
|
||||||
|
var
|
||||||
|
SD,SF : String;
|
||||||
|
D : TDependency;
|
||||||
|
j : integer;
|
||||||
|
begin
|
||||||
|
LogSearchPath('target include',T.IncludePath,ACPU,AOS,APackage.Directory);
|
||||||
|
LogSearchPath('package include',APackage.IncludePath,ACPU,AOS,APackage.Directory);
|
||||||
|
for j:=0 to T.Dependencies.Count-1 do
|
||||||
|
begin
|
||||||
|
D:=T.Dependencies[j];
|
||||||
|
if (D.DependencyType=depInclude) then
|
||||||
|
begin
|
||||||
|
D.TargetFileName:='';
|
||||||
|
if (ACPU in D.CPUs) and (AOS in D.OSes) then
|
||||||
|
begin
|
||||||
|
if ExtractFilePath(D.Value)='' then
|
||||||
|
begin
|
||||||
|
SF:=Dictionary.ReplaceStrings(D.Value);
|
||||||
|
SD:='';
|
||||||
|
// first check the target specific path
|
||||||
|
if not FindFileInPath(T.IncludePath,SF,SD,ACPU,AOS,APackage.Directory) then
|
||||||
|
FindFileInPath(APackage.IncludePath,SF,SD,ACPU,AOS,APackage.Directory);
|
||||||
|
if SD<>'' then
|
||||||
|
SD:=IncludeTrailingPathDelimiter(SD);
|
||||||
|
D.TargetFileName:=SD+SF;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
D.TargetFileName:=D.Value;
|
||||||
|
if FileExists(D.TargetFileName) then
|
||||||
|
Log(vlDebug,SDbgResolvedIncludeFile,[D.Value,D.TargetFileName])
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Log(vlWarning,SWarnIncludeFileNotFound,[D.Value,MakeTargetString(ACPU,AOS)]);
|
||||||
|
D.TargetFileName:='';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure FindExampleSource(T:TTarget);
|
||||||
|
var
|
||||||
|
SD,SF : String;
|
||||||
|
begin
|
||||||
|
LogSearchPath('package example',APackage.ExamplePath,ACPU,AOS,APackage.Directory);
|
||||||
|
SD:=Dictionary.ReplaceStrings(T.Directory);
|
||||||
|
SF:=Dictionary.ReplaceStrings(T.SourceFileName);
|
||||||
|
if SD='' then
|
||||||
|
FindFileInPath(APackage.ExamplePath,SF,SD,ACPU,AOS,APackage.Directory)
|
||||||
|
else
|
||||||
|
if APackage.Directory<>'' then
|
||||||
|
SD:=IncludeTrailingPathDelimiter(APackage.Directory)+SD;
|
||||||
|
if SD<>'' then
|
||||||
|
SD:=IncludeTrailingPathDelimiter(SD);
|
||||||
|
T.FTargetSourceFileName:=SD+SF;
|
||||||
|
if FileExists(T.TargetSourceFileName) then
|
||||||
|
Log(vlDebug,SDbgResolvedSourceFile,[T.SourceFileName,T.TargetSourceFileName])
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Log(vlWarning,SWarnSourceFileNotFound,[T.SourceFileName,MakeTargetString(ACPU,AOS)]);
|
||||||
|
T.FTargetSourceFileName:='';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
SD,SF : String;
|
|
||||||
D : TDependency;
|
|
||||||
T : TTarget;
|
T : TTarget;
|
||||||
i,j : Integer;
|
i : Integer;
|
||||||
begin
|
begin
|
||||||
Dictionary.AddVariable('CPU',CPUToString(ACPU));
|
Dictionary.AddVariable('CPU',CPUToString(ACPU));
|
||||||
Dictionary.AddVariable('OS',OSToString(AOS));
|
Dictionary.AddVariable('OS',OSToString(AOS));
|
||||||
@ -3228,62 +3316,21 @@ begin
|
|||||||
Log(vlDebug,SDbgResolvingSourcesOfTarget,[T.Name,MakeTargetString(ACPU,AOS)]);
|
Log(vlDebug,SDbgResolvingSourcesOfTarget,[T.Name,MakeTargetString(ACPU,AOS)]);
|
||||||
LogIndent;
|
LogIndent;
|
||||||
|
|
||||||
// Log Search paths
|
case T.TargetType of
|
||||||
LogSearchPath('package source',APackage.SourcePath,ACPU,AOS,APackage.Directory);
|
ttProgram,
|
||||||
LogSearchPath('target include',T.IncludePath,ACPU,AOS,APackage.Directory);
|
ttUnit,
|
||||||
LogSearchPath('package include',APackage.IncludePath,ACPU,AOS,APackage.Directory);
|
ttImplicitUnit :
|
||||||
|
begin
|
||||||
// Main source file
|
FindMainSource(T);
|
||||||
SD:=Dictionary.ReplaceStrings(T.Directory);
|
if T.Dependencies.Count>0 then
|
||||||
SF:=Dictionary.ReplaceStrings(T.SourceFileName);
|
FindIncludeSources(T);
|
||||||
if SD='' then
|
end;
|
||||||
FindFileInPath(APackage.SourcePath,SF,SD,ACPU,AOS,APackage.Directory)
|
ttExampleUnit,
|
||||||
else
|
ttExampleProgram :
|
||||||
if APackage.Directory<>'' then
|
begin
|
||||||
SD:=IncludeTrailingPathDelimiter(APackage.Directory)+SD;
|
FindExampleSource(T);
|
||||||
if SD<>'' then
|
end;
|
||||||
SD:=IncludeTrailingPathDelimiter(SD);
|
end;
|
||||||
T.FTargetSourceFileName:=SD+SF;
|
|
||||||
if FileExists(T.TargetSourceFileName) then
|
|
||||||
Log(vlDebug,SDbgResolvedSourceFile,[T.SourceFileName,T.TargetSourceFileName])
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
Log(vlWarning,SWarnSourceFileNotFound,[T.SourceFileName,MakeTargetString(ACPU,AOS)]);
|
|
||||||
T.FTargetSourceFileName:='';
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Include files
|
|
||||||
for j:=0 to T.Dependencies.Count-1 do
|
|
||||||
begin
|
|
||||||
D:=T.Dependencies[j];
|
|
||||||
if (D.DependencyType=depInclude) then
|
|
||||||
begin
|
|
||||||
D.TargetFileName:='';
|
|
||||||
if (ACPU in D.CPUs) and (AOS in D.OSes) then
|
|
||||||
begin
|
|
||||||
if ExtractFilePath(D.Value)='' then
|
|
||||||
begin
|
|
||||||
SF:=Dictionary.ReplaceStrings(D.Value);
|
|
||||||
SD:='';
|
|
||||||
// first check the target specific path
|
|
||||||
if not FindFileInPath(T.IncludePath,SF,SD,ACPU,AOS,APackage.Directory) then
|
|
||||||
FindFileInPath(APackage.IncludePath,SF,SD,ACPU,AOS,APackage.Directory);
|
|
||||||
if SD<>'' then
|
|
||||||
SD:=IncludeTrailingPathDelimiter(SD);
|
|
||||||
D.TargetFileName:=SD+SF;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
D.TargetFileName:=D.Value;
|
|
||||||
if FileExists(D.TargetFileName) then
|
|
||||||
Log(vlDebug,SDbgResolvedIncludeFile,[D.Value,D.TargetFileName])
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
Log(vlWarning,SWarnIncludeFileNotFound,[D.Value,MakeTargetString(ACPU,AOS)]);
|
|
||||||
D.TargetFileName:='';
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
LogUnIndent;
|
LogUnIndent;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user