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

View File

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