mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-04 19:00:27 +02:00
MG: clean ups for main.pp, many minor fixes
git-svn-id: trunk@1544 -
This commit is contained in:
parent
5d76031986
commit
3f5788bc3f
@ -285,13 +285,28 @@ var
|
|||||||
p, StartPos, l: integer;
|
p, StartPos, l: integer;
|
||||||
CurPath, Base: string;
|
CurPath, Base: string;
|
||||||
begin
|
begin
|
||||||
if (Filename='')
|
//writeln('[SearchFileInPath] Filename="',Filename,'" BasePath="',BasePath,'" SearchPath="',SearchPath,'" Delimiter="',Delimiter,'"');
|
||||||
or (FilenameIsAbsolute(Filename) and FileExists(Filename))
|
if (Filename='') then begin
|
||||||
then begin
|
|
||||||
Result:=Filename;
|
Result:=Filename;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
// check if filename absolute
|
||||||
|
if FilenameIsAbsolute(Filename) then begin
|
||||||
|
if FileExists(Filename) then begin
|
||||||
|
Result:=Filename;
|
||||||
|
exit;
|
||||||
|
end else begin
|
||||||
|
Result:='';
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
Base:=ExpandFilename(AppendPathDelim(BasePath));
|
Base:=ExpandFilename(AppendPathDelim(BasePath));
|
||||||
|
// search in current directory
|
||||||
|
if FileExists(Base+Filename) then begin
|
||||||
|
Result:=Base+Filename;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
// search in search path
|
||||||
StartPos:=1;
|
StartPos:=1;
|
||||||
l:=length(SearchPath);
|
l:=length(SearchPath);
|
||||||
while StartPos<=l do begin
|
while StartPos<=l do begin
|
||||||
|
1535
ide/main.pp
1535
ide/main.pp
File diff suppressed because it is too large
Load Diff
@ -142,7 +142,7 @@ type
|
|||||||
fModified: boolean;
|
fModified: boolean;
|
||||||
fOnFileBackup: TOnFileBackup;
|
fOnFileBackup: TOnFileBackup;
|
||||||
fOutputDirectory: String;
|
fOutputDirectory: String;
|
||||||
fProjectFile: String; // the lpi filename
|
fProjectInfoFile: String; // the lpi filename
|
||||||
fProjectType: TProjectType;
|
fProjectType: TProjectType;
|
||||||
fSrcPath: string; // source path addition for units in ProjectDir
|
fSrcPath: string; // source path addition for units in ProjectDir
|
||||||
fTargetFileExt: String;
|
fTargetFileExt: String;
|
||||||
@ -150,12 +150,13 @@ type
|
|||||||
fUnitList: TList; // list of TUnitInfo
|
fUnitList: TList; // list of TUnitInfo
|
||||||
fUnitOutputDirectory: String;
|
fUnitOutputDirectory: String;
|
||||||
fRunParameterOptions: TRunParamsOptions;
|
fRunParameterOptions: TRunParamsOptions;
|
||||||
|
|
||||||
|
function GetMainFilename: String;
|
||||||
|
function GetMainUnitInfo: TUnitInfo;
|
||||||
function GetProjectInfoFile: string;
|
function GetProjectInfoFile: string;
|
||||||
function GetTargetFilename: string;
|
function GetTargetFilename: string;
|
||||||
function GetUnits(Index:integer):TUnitInfo;
|
function GetUnits(Index:integer):TUnitInfo;
|
||||||
procedure SetUnits(Index:integer; AUnitInfo: TUnitInfo);
|
procedure SetUnits(Index:integer; AUnitInfo: TUnitInfo);
|
||||||
procedure SetProjectFile(const NewProjectFilename: string);
|
|
||||||
procedure SetProjectInfoFile(const NewFilename:string);
|
procedure SetProjectInfoFile(const NewFilename:string);
|
||||||
procedure SetTargetFilename(const NewTargetFilename: string);
|
procedure SetTargetFilename(const NewTargetFilename: string);
|
||||||
procedure OnLoadSaveFilename(var AFilename:string; Load:boolean);
|
procedure OnLoadSaveFilename(var AFilename:string; Load:boolean);
|
||||||
@ -215,10 +216,11 @@ type
|
|||||||
read fJumpHistory write fJumpHistory;
|
read fJumpHistory write fJumpHistory;
|
||||||
property MainUnit: Integer //this is the unit index of the program file
|
property MainUnit: Integer //this is the unit index of the program file
|
||||||
read fMainUnit write fMainUnit;
|
read fMainUnit write fMainUnit;
|
||||||
|
property MainUnitInfo: TUnitInfo read GetMainUnitInfo;
|
||||||
property Modified: boolean read fModified write fModified;
|
property Modified: boolean read fModified write fModified;
|
||||||
property OnFileBackup: TOnFileBackup read fOnFileBackup write fOnFileBackup;
|
property OnFileBackup: TOnFileBackup read fOnFileBackup write fOnFileBackup;
|
||||||
property OutputDirectory: String read fOutputDirectory write fOutputDirectory;
|
property OutputDirectory: String read fOutputDirectory write fOutputDirectory;
|
||||||
property ProjectFile: String read fProjectFile write SetProjectFile;
|
property MainFilename: String read GetMainFilename;
|
||||||
property ProjectInfoFile: string
|
property ProjectInfoFile: string
|
||||||
read GetProjectInfoFile write SetProjectInfoFile;
|
read GetProjectInfoFile write SetProjectInfoFile;
|
||||||
property ProjectType: TProjectType read fProjectType write fProjectType;
|
property ProjectType: TProjectType read fProjectType write fProjectType;
|
||||||
@ -244,6 +246,7 @@ const
|
|||||||
+'A graphical lcl/freepascal program. The program file is '
|
+'A graphical lcl/freepascal program. The program file is '
|
||||||
+'automatically maintained by lazarus.'#13
|
+'automatically maintained by lazarus.'#13
|
||||||
+#13
|
+#13
|
||||||
|
+#13
|
||||||
+'WARNING:'#13
|
+'WARNING:'#13
|
||||||
+'Form editing is under development and should not be used.'
|
+'Form editing is under development and should not be used.'
|
||||||
|
|
||||||
@ -629,7 +632,7 @@ begin
|
|||||||
fMainUnit := -1;
|
fMainUnit := -1;
|
||||||
fModified := false;
|
fModified := false;
|
||||||
fOutputDirectory := '.';
|
fOutputDirectory := '.';
|
||||||
fProjectFile := '';
|
fProjectInfoFile := '';
|
||||||
fRunParameterOptions:=TRunParamsOptions.Create;
|
fRunParameterOptions:=TRunParamsOptions.Create;
|
||||||
fSrcPath := '';
|
fSrcPath := '';
|
||||||
fTargetFileExt := DefaultTargetFileExt;
|
fTargetFileExt := DefaultTargetFileExt;
|
||||||
@ -707,7 +710,7 @@ var
|
|||||||
begin
|
begin
|
||||||
Result := mrCancel;
|
Result := mrCancel;
|
||||||
|
|
||||||
confPath := ChangeFileExt(ProjectFile,'.lpi');
|
confPath := ProjectInfoFile;
|
||||||
if Assigned(fOnFileBackup) then begin
|
if Assigned(fOnFileBackup) then begin
|
||||||
Result:=fOnFileBackup(confPath,true);
|
Result:=fOnFileBackup(confPath,true);
|
||||||
if Result=mrAbort then exit;
|
if Result=mrAbort then exit;
|
||||||
@ -816,7 +819,7 @@ begin
|
|||||||
|
|
||||||
// Load the compiler options
|
// Load the compiler options
|
||||||
CompilerOptions.XMLConfigFile := xmlconfig;
|
CompilerOptions.XMLConfigFile := xmlconfig;
|
||||||
CompilerOptions.ProjectFile := ProjectFile;
|
CompilerOptions.ProjectFile := MainFilename;
|
||||||
CompilerOptions.LoadCompilerOptions(true);
|
CompilerOptions.LoadCompilerOptions(true);
|
||||||
CreateProjectDefineTemplate(CompilerOptions,FSrcPath);
|
CreateProjectDefineTemplate(CompilerOptions,FSrcPath);
|
||||||
|
|
||||||
@ -824,7 +827,7 @@ begin
|
|||||||
RunParameterOptions.Load(xmlconfig,'ProjectOptions/');
|
RunParameterOptions.Load(xmlconfig,'ProjectOptions/');
|
||||||
|
|
||||||
CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'ProjectDir']:=
|
CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'ProjectDir']:=
|
||||||
ExtractFilePath(ProjectFile);
|
ProjectDirectory;
|
||||||
CodeToolBoss.DefineTree.ClearCache;
|
CodeToolBoss.DefineTree.ClearCache;
|
||||||
finally
|
finally
|
||||||
xmlconfig.Free;
|
xmlconfig.Free;
|
||||||
@ -915,7 +918,7 @@ begin
|
|||||||
fMainUnit := -1;
|
fMainUnit := -1;
|
||||||
fModified := false;
|
fModified := false;
|
||||||
fOutputDirectory := '.';
|
fOutputDirectory := '.';
|
||||||
fProjectFile := '';
|
fProjectInfoFile := '';
|
||||||
fSrcPath := '';
|
fSrcPath := '';
|
||||||
fTargetFileExt := {$IFDEF win32}'.exe'{$ELSE}''{$ENDIF};
|
fTargetFileExt := {$IFDEF win32}'.exe'{$ELSE}''{$ENDIF};
|
||||||
fTitle := '';
|
fTitle := '';
|
||||||
@ -941,11 +944,8 @@ end;
|
|||||||
function TProject.NewUniqueUnitName(NewUnitType:TNewUnitType):string;
|
function TProject.NewUniqueUnitName(NewUnitType:TNewUnitType):string;
|
||||||
|
|
||||||
function ExpandedUnitname(const AnUnitName:string):string;
|
function ExpandedUnitname(const AnUnitName:string):string;
|
||||||
var Ext:string;
|
|
||||||
begin
|
begin
|
||||||
Result:=uppercase(ExtractFileName(AnUnitName));
|
Result:=uppercase(ExtractFileNameOnly(AnUnitName));
|
||||||
Ext:=ExtractFileExt(Result);
|
|
||||||
Result:=copy(Result,1,length(Result)-length(Ext));
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function UnitNameExists(const AnUnitName:string):boolean;
|
function UnitNameExists(const AnUnitName:string):boolean;
|
||||||
@ -954,7 +954,7 @@ function TProject.NewUniqueUnitName(NewUnitType:TNewUnitType):string;
|
|||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
ExpName:=ExpandedUnitName(AnUnitName);
|
ExpName:=ExpandedUnitName(AnUnitName);
|
||||||
if ExpandedUnitname(fProjectFile)=Expname then exit;
|
if ExtractFileNameOnly(fProjectInfoFile)=Expname then exit;
|
||||||
for i:=0 to UnitCount-1 do
|
for i:=0 to UnitCount-1 do
|
||||||
if (Units[i].IsPartOfProject)
|
if (Units[i].IsPartOfProject)
|
||||||
and (ExpandedUnitName(Units[i].FileName)=ExpName) then
|
and (ExpandedUnitName(Units[i].FileName)=ExpName) then
|
||||||
@ -1189,26 +1189,31 @@ begin
|
|||||||
fCompilerOptions.TargetFilename:=NewTargetFilename;
|
fCompilerOptions.TargetFilename:=NewTargetFilename;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TProject.SetProjectFile(const NewProjectFilename: string);
|
function TProject.GetMainFilename: String;
|
||||||
begin
|
begin
|
||||||
if (AnsiCompareText(fTitle,ExtractFileNameOnly(fProjectFile))=0)
|
if MainUnit>=0 then Result:=Units[MainUnit].Filename
|
||||||
or (fProjectFile='') then
|
else Result:='';
|
||||||
fTitle:=ExtractFileNameOnly(NewProjectFilename);
|
end;
|
||||||
fProjectFile:=NewProjectFilename;
|
|
||||||
|
function TProject.GetMainUnitInfo: TUnitInfo;
|
||||||
Modified:=true;
|
begin
|
||||||
|
if MainUnit>=0 then Result:=Units[MainUnit] else Result:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TProject.GetProjectInfoFile:string;
|
function TProject.GetProjectInfoFile:string;
|
||||||
begin
|
begin
|
||||||
Result:=fProjectFile;
|
Result:=fProjectInfoFile;
|
||||||
if Result<>'' then Result:=ChangeFileExt(Result,'.lpi');
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TProject.SetProjectInfoFile(const NewFilename:string);
|
procedure TProject.SetProjectInfoFile(const NewFilename:string);
|
||||||
begin
|
begin
|
||||||
if NewFilename='' then exit;
|
if NewFilename='' then exit;
|
||||||
ProjectFile:=ChangeFileExt(NewFilename,ProjectDefaultExt[ProjectType]);
|
fProjectInfoFile:=NewFilename;
|
||||||
|
if (AnsiCompareText(fTitle,ExtractFileNameOnly(fProjectInfoFile))=0)
|
||||||
|
or (fProjectInfoFile='') then
|
||||||
|
fTitle:=ExtractFileNameOnly(NewFilename);
|
||||||
|
|
||||||
|
Modified:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TProject.OnUnitFileBackup(const Filename:string;
|
function TProject.OnUnitFileBackup(const Filename:string;
|
||||||
@ -1223,7 +1228,7 @@ end;
|
|||||||
procedure TProject.OnLoadSaveFilename(var AFilename:string; Load:boolean);
|
procedure TProject.OnLoadSaveFilename(var AFilename:string; Load:boolean);
|
||||||
var ProjectPath:string;
|
var ProjectPath:string;
|
||||||
begin
|
begin
|
||||||
ProjectPath:=ExtractFilePath(ProjectFile);
|
ProjectPath:=ProjectDirectory;
|
||||||
if ProjectPath='' then ProjectPath:=GetCurrentDir;
|
if ProjectPath='' then ProjectPath:=GetCurrentDir;
|
||||||
DoDirSeparators(AFilename);
|
DoDirSeparators(AFilename);
|
||||||
if Load then begin
|
if Load then begin
|
||||||
@ -1244,7 +1249,7 @@ function TProject.RemoveProjectPathFromFilename(
|
|||||||
const AFilename: string): string;
|
const AFilename: string): string;
|
||||||
var ProjectPath:string;
|
var ProjectPath:string;
|
||||||
begin
|
begin
|
||||||
ProjectPath:=ExtractFilePath(ProjectFile);
|
ProjectPath:=ProjectDirectory;
|
||||||
if ProjectPath='' then ProjectPath:=GetCurrentDir;
|
if ProjectPath='' then ProjectPath:=GetCurrentDir;
|
||||||
Result:=AFilename;
|
Result:=AFilename;
|
||||||
DoDirSeparators(Result);
|
DoDirSeparators(Result);
|
||||||
@ -1258,7 +1263,7 @@ end;
|
|||||||
|
|
||||||
function TProject.ProjectDirectory: string;
|
function TProject.ProjectDirectory: string;
|
||||||
begin
|
begin
|
||||||
Result:=ExtractFilePath(ProjectFile);
|
Result:=ExtractFilePath(ProjectInfoFile);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TProject.FileIsInProjectDir(const AFilename: string): boolean;
|
function TProject.FileIsInProjectDir(const AFilename: string): boolean;
|
||||||
@ -1350,6 +1355,9 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.56 2002/03/25 16:48:26 lazarus
|
||||||
|
MG: clean ups for main.pp, many minor fixes
|
||||||
|
|
||||||
Revision 1.55 2002/03/25 07:29:23 lazarus
|
Revision 1.55 2002/03/25 07:29:23 lazarus
|
||||||
MG: added TOpen/SaveFlags and splittet some methods
|
MG: added TOpen/SaveFlags and splittet some methods
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user