mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 07:29:21 +02:00
Converter: fix renaming units with wrong casing. Needed in case-sensitive file systems.
git-svn-id: trunk@24496 -
This commit is contained in:
parent
812cb0bdad
commit
70bba5faca
@ -142,9 +142,8 @@ type
|
|||||||
function ReadDelphiConfigFiles: TModalResult;
|
function ReadDelphiConfigFiles: TModalResult;
|
||||||
function ExtractOptionsFromDOF(const DOFFilename: string): TModalResult;
|
function ExtractOptionsFromDOF(const DOFFilename: string): TModalResult;
|
||||||
function ExtractOptionsFromCFG(const CFGFilename: string): TModalResult;
|
function ExtractOptionsFromCFG(const CFGFilename: string): TModalResult;
|
||||||
function DoMissingUnits(MissingUnits: TStrings): integer;
|
function DoMissingUnits(MissingUnits: TStrings;
|
||||||
function DoCaseErrorUnits(MissingUnits: TStrings;
|
UnitsToRename: TStringToStringTree): integer;
|
||||||
UnitsToRename: TStringToStringTree): integer;
|
|
||||||
procedure CacheUnitsInPath(const APath, ABasePath: string);
|
procedure CacheUnitsInPath(const APath, ABasePath: string);
|
||||||
procedure CacheUnitsInPath(const APath: string);
|
procedure CacheUnitsInPath(const APath: string);
|
||||||
function GetCachedUnitPath(const AUnitName: string): string;
|
function GetCachedUnitPath(const AUnitName: string): string;
|
||||||
@ -663,9 +662,7 @@ begin
|
|||||||
fOwnerConverter.fPrevSelectedPath:=ExtractFilePath(UnitDirDialog.Filename);
|
fOwnerConverter.fPrevSelectedPath:=ExtractFilePath(UnitDirDialog.Filename);
|
||||||
// Add the new path to project if missing units are found.
|
// Add the new path to project if missing units are found.
|
||||||
fOwnerConverter.CacheUnitsInPath(UnitDirDialog.Filename);
|
fOwnerConverter.CacheUnitsInPath(UnitDirDialog.Filename);
|
||||||
TryAgain:=fOwnerConverter.DoMissingUnits(fMissingUnits)>0;
|
TryAgain:=fOwnerConverter.DoMissingUnits(fMissingUnits, fUnitsToRename)>0;
|
||||||
if TryAgain then
|
|
||||||
TryAgain:=fOwnerConverter.DoCaseErrorUnits(fMissingUnits, fUnitsToRename)>0;
|
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -745,7 +742,7 @@ begin
|
|||||||
|
|
||||||
if Assigned(fOwnerConverter) then begin
|
if Assigned(fOwnerConverter) then begin
|
||||||
// Try to find from subdirectories scanned earlier.
|
// Try to find from subdirectories scanned earlier.
|
||||||
if fOwnerConverter.DoMissingUnits(fMissingUnits)=0 then exit;
|
if fOwnerConverter.DoMissingUnits(fMissingUnits, fUnitsToRename)=0 then exit;
|
||||||
// Comment out automatically units that were commented in other files.
|
// Comment out automatically units that were commented in other files.
|
||||||
if CommentAutomatically=0 then exit;
|
if CommentAutomatically=0 then exit;
|
||||||
end;
|
end;
|
||||||
@ -1071,41 +1068,25 @@ begin
|
|||||||
Options.SrcPath:=CleanProjectSearchPath(Options.SrcPath);
|
Options.SrcPath:=CleanProjectSearchPath(Options.SrcPath);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TConvertDelphiPBase.DoMissingUnits(MissingUnits: TStrings): integer;
|
function TConvertDelphiPBase.DoMissingUnits(MissingUnits: TStrings;
|
||||||
|
UnitsToRename: TStringToStringTree): integer;
|
||||||
// Locate unit names in earlier cached list and remove them from MissingUnits.
|
// Locate unit names in earlier cached list and remove them from MissingUnits.
|
||||||
// Return the number of units still missing.
|
// Return the number of units still missing.
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
sUnitPath: string;
|
mUnit, sUnitPath, RealUnitName: string;
|
||||||
begin
|
|
||||||
for i:=MissingUnits.Count-1 downto 0 do begin
|
|
||||||
sUnitPath:=GetCachedUnitPath(MissingUnits[i]);
|
|
||||||
if sUnitPath<>'' then begin
|
|
||||||
// Found: add unit path to project's settings.
|
|
||||||
with CompOpts do
|
|
||||||
OtherUnitFiles:=MergeSearchPaths(OtherUnitFiles,sUnitPath);
|
|
||||||
// No more missing, delete from list.
|
|
||||||
MissingUnits.Delete(i);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
Result:=MissingUnits.Count;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TConvertDelphiPBase.DoCaseErrorUnits(MissingUnits: TStrings;
|
|
||||||
UnitsToRename: TStringToStringTree): integer;
|
|
||||||
// Locate existing unit names with different case add them to UnitsToRename.
|
|
||||||
// Return the number of units still missing.
|
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
sUnitPath, mUnit, RealUnitName: string;
|
|
||||||
begin
|
begin
|
||||||
for i:=MissingUnits.Count-1 downto 0 do begin
|
for i:=MissingUnits.Count-1 downto 0 do begin
|
||||||
mUnit:=MissingUnits[i];
|
mUnit:=MissingUnits[i];
|
||||||
sUnitPath:=GetCachedUnitPath(mUnit);
|
sUnitPath:=GetCachedUnitPath(mUnit);
|
||||||
Assert(sUnitPath='', 'sUnitPath should be empty');
|
if sUnitPath<>'' then begin
|
||||||
if NeedsRenameUnit(mUnit, RealUnitName) then begin
|
// Found: add unit path to project's settings.
|
||||||
// Add to rename unit list, delete from missing unit list.
|
with CompOpts do
|
||||||
UnitsToRename[mUnit]:=RealUnitName;
|
OtherUnitFiles:=MergeSearchPaths(OtherUnitFiles,sUnitPath);
|
||||||
|
// Rename a unit with different casing.
|
||||||
|
if NeedsRenameUnit(mUnit, RealUnitName) then
|
||||||
|
UnitsToRename[mUnit]:=RealUnitName;
|
||||||
|
// No more missing, delete from list.
|
||||||
MissingUnits.Delete(i);
|
MissingUnits.Delete(i);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1319,9 +1300,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
finally
|
finally
|
||||||
// set unit paths to find all project units
|
|
||||||
AllPath:=LazProject.SourceDirectories.CreateSearchPathFromAllFiles;
|
AllPath:=LazProject.SourceDirectories.CreateSearchPathFromAllFiles;
|
||||||
UselessPath:='.;'+VirtualDirectory+';'+VirtualTempDir+';'+LazProject.ProjectDirectory;
|
UselessPath:='.;'+VirtualDirectory+';'+VirtualTempDir+';'+LazProject.ProjectDirectory;
|
||||||
|
// set unit paths to find all project units
|
||||||
NewSearchPath:=MergeSearchPaths(LazProject.CompilerOptions.OtherUnitFiles,AllPath);
|
NewSearchPath:=MergeSearchPaths(LazProject.CompilerOptions.OtherUnitFiles,AllPath);
|
||||||
NewSearchPath:=RemoveSearchPaths(NewSearchPath,UselessPath);
|
NewSearchPath:=RemoveSearchPaths(NewSearchPath,UselessPath);
|
||||||
LazProject.CompilerOptions.OtherUnitFiles:=MinimizeSearchPath(
|
LazProject.CompilerOptions.OtherUnitFiles:=MinimizeSearchPath(
|
||||||
@ -1605,9 +1586,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
finally
|
finally
|
||||||
// set unit paths to find all project units
|
|
||||||
AllPath:=LazPackage.SourceDirectories.CreateSearchPathFromAllFiles;
|
AllPath:=LazPackage.SourceDirectories.CreateSearchPathFromAllFiles;
|
||||||
UselessPath:='.;'+VirtualDirectory+';'+VirtualTempDir+';'+LazPackage.Directory;
|
UselessPath:='.;'+VirtualDirectory+';'+VirtualTempDir+';'+LazPackage.Directory;
|
||||||
|
// set unit paths to find all project units
|
||||||
NewSearchPath:=MergeSearchPaths(LazPackage.CompilerOptions.OtherUnitFiles,AllPath);
|
NewSearchPath:=MergeSearchPaths(LazPackage.CompilerOptions.OtherUnitFiles,AllPath);
|
||||||
NewSearchPath:=RemoveSearchPaths(NewSearchPath,UselessPath);
|
NewSearchPath:=RemoveSearchPaths(NewSearchPath,UselessPath);
|
||||||
LazPackage.CompilerOptions.OtherUnitFiles:=MinimizeSearchPath(
|
LazPackage.CompilerOptions.OtherUnitFiles:=MinimizeSearchPath(
|
||||||
|
@ -146,6 +146,7 @@ begin
|
|||||||
fReplaceUnits:=TStringToStringTree.Create(false);
|
fReplaceUnits:=TStringToStringTree.Create(false);
|
||||||
fReplaceUnits['Windows']:='LCLIntf, LCLType, LMessages';
|
fReplaceUnits['Windows']:='LCLIntf, LCLType, LMessages';
|
||||||
fReplaceUnits['Variants']:='';
|
fReplaceUnits['Variants']:='';
|
||||||
|
fReplaceUnits['ShellApi']:='';
|
||||||
fReplaceUnits['TntActnList']:='ActnList';
|
fReplaceUnits['TntActnList']:='ActnList';
|
||||||
fReplaceUnits['TntMenus']:='Menus';
|
fReplaceUnits['TntMenus']:='Menus';
|
||||||
fReplaceUnits['TntClasses']:='Classes';
|
fReplaceUnits['TntClasses']:='Classes';
|
||||||
|
Loading…
Reference in New Issue
Block a user