ide: fix creation of project .lrs files before the build if they does not exist (issue #0014620)

git-svn-id: trunk@21760 -
This commit is contained in:
paul 2009-09-18 15:00:06 +00:00
parent 464c907ed3
commit c7998ac533
2 changed files with 13 additions and 9 deletions

View File

@ -546,7 +546,7 @@ type
// uses sections // uses sections
function FindUnitInAllUsesSections(Code: TCodeBuffer; function FindUnitInAllUsesSections(Code: TCodeBuffer;
const AnUnitName: string; const AnUnitName: string;
out NamePos, InPos: integer): boolean; out NamePos, InPos: integer; const IgnoreMissingIncludeFiles: Boolean = False): boolean;
function RenameUsedUnit(Code: TCodeBuffer; function RenameUsedUnit(Code: TCodeBuffer;
const OldUnitName, NewUnitName, NewUnitInFile: string): boolean; const OldUnitName, NewUnitName, NewUnitInFile: string): boolean;
function ReplaceUsedUnits(Code: TCodeBuffer; function ReplaceUsedUnits(Code: TCodeBuffer;
@ -3879,8 +3879,10 @@ end;
function TCodeToolManager.FindUnitInAllUsesSections(Code: TCodeBuffer; function TCodeToolManager.FindUnitInAllUsesSections(Code: TCodeBuffer;
const AnUnitName: string; const AnUnitName: string;
out NamePos, InPos: integer): boolean; out NamePos, InPos: integer; const IgnoreMissingIncludeFiles: Boolean = False): boolean;
var NameAtomPos, InAtomPos: TAtomPosition; var
NameAtomPos, InAtomPos: TAtomPosition;
OldIgnoreMissingIncludeFiles: Boolean;
begin begin
Result:=false; Result:=false;
{$IFDEF CTDEBUG} {$IFDEF CTDEBUG}
@ -3890,7 +3892,9 @@ begin
{$IFDEF CTDEBUG} {$IFDEF CTDEBUG}
DebugLn('TCodeToolManager.FindUnitInAllUsesSections B ',Code.Filename,' UnitName=',AnUnitName); DebugLn('TCodeToolManager.FindUnitInAllUsesSections B ',Code.Filename,' UnitName=',AnUnitName);
{$ENDIF} {$ENDIF}
OldIgnoreMissingIncludeFiles := FCurCodeTool.Scanner.IgnoreMissingIncludeFiles;
try try
FCurCodeTool.Scanner.IgnoreMissingIncludeFiles := IgnoreMissingIncludeFiles;
Result:=FCurCodeTool.FindUnitInAllUsesSections(UpperCaseStr(AnUnitName), Result:=FCurCodeTool.FindUnitInAllUsesSections(UpperCaseStr(AnUnitName),
NameAtomPos, InAtomPos); NameAtomPos, InAtomPos);
if Result then begin if Result then begin
@ -3900,6 +3904,7 @@ begin
except except
on e: Exception do Result:=HandleException(e); on e: Exception do Result:=HandleException(e);
end; end;
FCurCodeTool.Scanner.IgnoreMissingIncludeFiles := OldIgnoreMissingIncludeFiles;
end; end;
function TCodeToolManager.RenameUsedUnit(Code: TCodeBuffer; function TCodeToolManager.RenameUsedUnit(Code: TCodeBuffer;

View File

@ -241,8 +241,7 @@ begin
LastLrsFileName := lrsFileName; LastLrsFileName := lrsFileName;
SetFileNames(MainFileName); SetFileNames(MainFileName);
if UpdateSource then UpdateCanHaveLrsInclude(MainFileName);
UpdateCanHaveLrsInclude(MainFileName);
try try
// update resources (FLazarusResources, FSystemResources, ...) // update resources (FLazarusResources, FSystemResources, ...)
@ -448,11 +447,11 @@ begin
if CodeBuf = nil then if CodeBuf = nil then
Exit; Exit;
// Check that .lrs contains Forms and Interfaces in the uses section. If it does not // Check that .lpr contains Forms and Interfaces in the uses section. If it does not
// we cannot add LResources (it is not lazarus application) // we cannot add LResources (it is not a lazarus application)
FCanHaveLrsInclude := FCanHaveLrsInclude :=
CodeToolBoss.FindUnitInAllUsesSections(CodeBuf, 'Forms', NamePos, InPos) and CodeToolBoss.FindUnitInAllUsesSections(CodeBuf, 'Forms', NamePos, InPos, True) and
CodeToolBoss.FindUnitInAllUsesSections(CodeBuf, 'Interfaces', NamePos, InPos); CodeToolBoss.FindUnitInAllUsesSections(CodeBuf, 'Interfaces', NamePos, InPos, True);
end; end;
function TProjectResources.RenameDirectives(const CurFileName, function TProjectResources.RenameDirectives(const CurFileName,