IDE: moved project types to projectdefs

git-svn-id: trunk@26991 -
This commit is contained in:
mattias 2010-08-03 10:38:43 +00:00
parent 0af3b0c7d5
commit 60f7ac9ff1
3 changed files with 505 additions and 501 deletions

View File

@ -56,7 +56,7 @@ uses
// IDEIntf // IDEIntf
ProjectIntf, MacroIntf, LazIDEIntf, ProjectIntf, MacroIntf, LazIDEIntf,
// IDE // IDE
CompOptsModes, ProjectResources, LazConf, frmCustomApplicationOptions, CompOptsModes, ProjectResources, LazConf,
LazarusIDEStrConsts, CompilerOptions, LazarusIDEStrConsts, CompilerOptions,
TransferMacros, EditorOptions, IDEProcs, RunParamsOpts, ProjectDefs, TransferMacros, EditorOptions, IDEProcs, RunParamsOpts, ProjectDefs,
FileReferenceList, EditDefineTree, PackageDefs, PackageSystem, IDEOptionsIntf, FileReferenceList, EditDefineTree, PackageDefs, PackageSystem, IDEOptionsIntf,
@ -594,73 +594,6 @@ type
end; end;
//----------------------------------------------------------------------------
{ TProjectApplicationDescriptor }
TProjectApplicationDescriptor = class(TProjectDescriptor)
public
constructor Create; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
function InitProject(AProject: TLazProject): TModalResult; override;
function CreateStartFiles(AProject: TLazProject): TModalResult; override;
end;
{ TProjectProgramDescriptor }
TProjectProgramDescriptor = class(TProjectDescriptor)
public
constructor Create; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
function InitProject(AProject: TLazProject): TModalResult; override;
function CreateStartFiles(AProject: TLazProject): TModalResult; override;
end;
{ TProjectConsoleApplicationDescriptor }
TProjectConsoleApplicationDescriptor = class(TProjectDescriptor)
public
constructor Create; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
function InitProject(AProject: TLazProject): TModalResult; override;
function CreateStartFiles(AProject: TLazProject): TModalResult; override;
end;
{ TProjectLibraryDescriptor }
TProjectLibraryDescriptor = class(TProjectDescriptor)
public
constructor Create; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
function InitProject(AProject: TLazProject): TModalResult; override;
function CreateStartFiles(AProject: TLazProject): TModalResult; override;
end;
{ TProjectManualProgramDescriptor }
TProjectManualProgramDescriptor = class(TProjectDescriptor)
private
FAddMainSource: boolean;
public
constructor Create; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
function InitProject(AProject: TLazProject): TModalResult; override;
function CreateStartFiles(AProject: TLazProject): TModalResult; override;
property AddMainSource: boolean read FAddMainSource write FAddMainSource;
end;
{ TProjectEmptyProgramDescriptor }
TProjectEmptyProgramDescriptor = class(TProjectManualProgramDescriptor)
public
constructor Create; override;
end;
{ TProject } { TProject }
TEndUpdateProjectEvent = TEndUpdateProjectEvent =
@ -6006,270 +5939,6 @@ begin
IncreaseCompilerParseStamp; IncreaseCompilerParseStamp;
end; end;
{ TProjectProgramDescriptor }
constructor TProjectProgramDescriptor.Create;
begin
inherited Create;
Name:=ProjDescNameProgram;
Flags:=Flags-[pfMainUnitHasCreateFormStatements,pfMainUnitHasTitleStatement]
+[pfUseDefaultCompilerOptions];
end;
function TProjectProgramDescriptor.GetLocalizedName: string;
begin
Result:=lisProgram;
end;
function TProjectProgramDescriptor.GetLocalizedDescription: string;
begin
Result:=Format(lisProgramAFreepascalProgramTheProgramFileIsAutomatic, [#13]);
end;
function TProjectProgramDescriptor.InitProject(AProject: TLazProject
): TModalResult;
var
le: String;
NewSource: String;
MainFile: TLazProjectFile;
begin
Result:=inherited InitProject(AProject);
MainFile:=AProject.CreateProjectFile('project1.lpr');
MainFile.IsPartOfProject:=true;
AProject.AddFile(MainFile,false);
AProject.MainFileID:=0;
// create program source
le:=LineEnding;
NewSource:='program Project1;'+le
+le
+'{$mode objfpc}{$H+}'+le
+le
+'uses'+le
+' {$IFDEF UNIX}{$IFDEF UseCThreads}'+le
+' cthreads,'+le
+' {$ENDIF}{$ENDIF}'+le
+' Classes'+le
+' { you can add units after this };'+le
+le
+'begin'+le
+'end.'+le
+le;
AProject.MainFile.SetSourceText(NewSource);
AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
AProject.LazCompilerOptions.TargetFilename:='project1';
end;
function TProjectProgramDescriptor.CreateStartFiles(AProject: TLazProject
): TModalResult;
begin
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
[ofProjectLoading,ofRegularFile]);
end;
{ TProjectApplicationDescriptor }
constructor TProjectApplicationDescriptor.Create;
begin
inherited Create;
Name:=ProjDescNameApplication;
Flags:=Flags+[pfUseDefaultCompilerOptions];
end;
function TProjectApplicationDescriptor.GetLocalizedName: string;
begin
Result:=dlgPOApplication;
end;
function TProjectApplicationDescriptor.GetLocalizedDescription: string;
begin
Result:=Format(lisApplicationAGraphicalLclFreepascalProgramTheProgra, [#13]);
end;
function TProjectApplicationDescriptor.InitProject(
AProject: TLazProject): TModalResult;
var
le: string;
NewSource: String;
MainFile: TLazProjectFile;
begin
Result:=inherited InitProject(AProject);
MainFile:=AProject.CreateProjectFile('project1.lpr');
MainFile.IsPartOfProject:=true;
AProject.AddFile(MainFile,false);
AProject.MainFileID:=0;
// create program source
le:=LineEnding;
NewSource:='program Project1;'+le
+le
+'{$mode objfpc}{$H+}'+le
+le
+'uses'+le
+' {$IFDEF UNIX}{$IFDEF UseCThreads}'+le
+' cthreads,'+le
+' {$ENDIF}{$ENDIF}'+le
+' Interfaces, // this includes the LCL widgetset'+le
+' Forms'+le
+' { you can add units after this };'+le
+le
+'begin'+le
+' Application.Initialize;'+le
+' Application.Run;'+le
+'end.'+le
+le;
AProject.MainFile.SetSourceText(NewSource);
// add lcl pp/pas dirs to source search path
AProject.AddPackageDependency('LCL');
AProject.LazCompilerOptions.Win32GraphicApp:=true;
AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
AProject.LazCompilerOptions.TargetFilename:='project1';
end;
function TProjectApplicationDescriptor.CreateStartFiles(AProject: TLazProject
): TModalResult;
begin
Result:=LazarusIDE.DoNewEditorFile(FileDescriptorForm,'','',
[nfIsPartOfProject,nfOpenInEditor,nfCreateDefaultSrc]);
end;
{ TProjectManualProgramDescriptor }
constructor TProjectManualProgramDescriptor.Create;
begin
inherited Create;
VisibleInNewDialog:=false;
Name:=ProjDescNameCustomProgram;
Flags:=Flags-[pfMainUnitHasUsesSectionForAllUnits,
pfMainUnitHasCreateFormStatements,
pfMainUnitHasTitleStatement]
+[pfUseDefaultCompilerOptions];
FAddMainSource:=true;
end;
function TProjectManualProgramDescriptor.GetLocalizedName: string;
begin
Result:=lisCustomProgram;
end;
function TProjectManualProgramDescriptor.GetLocalizedDescription: string;
begin
Result:=Format(lisCustomProgramAFreepascalProgram, [#13]);
end;
function TProjectManualProgramDescriptor.InitProject(AProject: TLazProject
): TModalResult;
var
le: string;
NewSource: String;
MainFile: TLazProjectFile;
begin
Result:=inherited InitProject(AProject);
if AddMainSource then begin
MainFile:=AProject.CreateProjectFile('project1.pas');
MainFile.IsPartOfProject:=true;
AProject.AddFile(MainFile,false);
AProject.MainFileID:=0;
// create program source
le:=LineEnding;
NewSource:='program Project1;'+le
+le
+'{$mode objfpc}{$H+}'+le
+le
+'uses'+le
+' Classes, SysUtils'+le
+' { you can add units after this };'+le
+le
+'begin'+le
+'end.'+le
+le;
AProject.MainFile.SetSourceText(NewSource);
end;
end;
function TProjectManualProgramDescriptor.CreateStartFiles(AProject: TLazProject
): TModalResult;
begin
if AProject.MainFile<>nil then
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
[ofProjectLoading,ofRegularFile]);
end;
{ TProjectEmptyProgramDescriptor }
constructor TProjectEmptyProgramDescriptor.Create;
begin
inherited Create;
FAddMainSource:=false;
end;
{ TProjectLibraryDescriptor }
constructor TProjectLibraryDescriptor.Create;
begin
inherited Create;
Name:=ProjDescNameLibrary;
Flags:=Flags-[pfMainUnitHasCreateFormStatements,pfMainUnitHasTitleStatement]
+[pfUseDefaultCompilerOptions];
end;
function TProjectLibraryDescriptor.GetLocalizedName: string;
begin
Result:=lisPckOptsLibrary;
end;
function TProjectLibraryDescriptor.GetLocalizedDescription: string;
begin
Result:= Format(lisLibraryAFreepascalLibraryDllUnderWindowsSoUnderLin, [#13]);
end;
function TProjectLibraryDescriptor.InitProject(AProject: TLazProject
): TModalResult;
var
le: String;
NewSource: String;
MainFile: TLazProjectFile;
begin
Result:=inherited InitProject(AProject);
MainFile:=AProject.CreateProjectFile('project1.lpr');
MainFile.IsPartOfProject:=true;
AProject.AddFile(MainFile,false);
AProject.MainFileID:=0;
AProject.LazCompilerOptions.ExecutableType:=cetLibrary;
// create program source
le:=LineEnding;
NewSource:='library Project1;'+le
+le
+'{$mode objfpc}{$H+}'+le
+le
+'uses'+le
+' Classes'+le
+' { you can add units after this };'+le
+le
+'begin'+le
+'end.'+le
+le;
AProject.MainFile.SetSourceText(NewSource);
AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
AProject.LazCompilerOptions.TargetFilename:='project1';
end;
function TProjectLibraryDescriptor.CreateStartFiles(AProject: TLazProject
): TModalResult;
begin
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
[ofProjectLoading,ofRegularFile]);
end;
{ TUnitComponentDependency } { TUnitComponentDependency }
procedure TUnitComponentDependency.SetRequiresUnit(const AValue: TUnitInfo); procedure TUnitComponentDependency.SetRequiresUnit(const AValue: TUnitInfo);
@ -6432,172 +6101,6 @@ begin
end; end;
end; end;
{ TProjectConsoleApplicationDescriptor }
constructor TProjectConsoleApplicationDescriptor.Create;
begin
inherited Create;
Name:=ProjDescNameConsoleApplication;
Flags:=Flags-[pfMainUnitHasCreateFormStatements,pfMainUnitHasTitleStatement]
+[pfUseDefaultCompilerOptions];
end;
function TProjectConsoleApplicationDescriptor.GetLocalizedName: string;
begin
Result:=lisConsoleApplication;
end;
function TProjectConsoleApplicationDescriptor.GetLocalizedDescription: string;
begin
Result:=GetLocalizedName+#13
+lisFreepascalProgramUsingTCustomApplicationToEasilyCh;
end;
function TProjectConsoleApplicationDescriptor.InitProject(AProject: TLazProject
): TModalResult;
var
NewSource: TStringList;
MainFile: TLazProjectFile;
C, T : String;
CC,CD,CU,CS, CO : Boolean;
begin
Result:=inherited InitProject(AProject);
If Result<>mrOk then
Exit;
With TCustomApplicationOptionsForm.Create(Application) do
try
Result:=ShowModal;
If Result<>mrOk then
Exit;
C:=Trim(AppClassName);
T:=StringReplace(Title,'''','''''',[rfReplaceAll]);
CC:=CodeConstructor;
CD:=CodeDestructor;
CU:=CodeUsage;
CS:=CodeStopOnError;
CO:=CodeCheckOptions;
finally
Free;
end;
MainFile:=AProject.CreateProjectFile('project1.lpr');
MainFile.IsPartOfProject:=true;
AProject.AddFile(MainFile,false);
AProject.MainFileID:=0;
AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
AProject.LazCompilerOptions.TargetFilename:='project1';
// create program source
NewSource:=TStringList.Create;
NewSource.Add('program Project1;');
NewSource.Add('');
NewSource.Add('{$mode objfpc}{$H+}');
NewSource.Add('');
NewSource.Add('uses');
NewSource.Add(' {$IFDEF UNIX}{$IFDEF UseCThreads}');
NewSource.Add(' cthreads,');
NewSource.Add(' {$ENDIF}{$ENDIF}');
NewSource.Add(' Classes, SysUtils, CustApp');
NewSource.Add(' { you can add units after this };');
NewSource.Add('');
NewSource.Add('type');
NewSource.Add('');
NewSource.Add(' { '+C+' }');
NewSource.Add('');
NewSource.Add(' '+C+' = class(TCustomApplication)');
NewSource.Add(' protected');
NewSource.Add(' procedure DoRun; override;');
NewSource.Add(' public');
If CC or CS then
NewSource.Add(' constructor Create(TheOwner: TComponent); override;');
if CD then
NewSource.Add(' destructor Destroy; override;');
if CU then
NewSource.Add(' procedure WriteHelp; virtual;');
NewSource.Add(' end;');
NewSource.Add('');
NewSource.Add('{ '+C+' }');
NewSource.Add('');
NewSource.Add('procedure '+C+'.DoRun;');
NewSource.Add('var');
NewSource.Add(' ErrorMsg: String;');
NewSource.Add('begin');
if CO then
begin
NewSource.Add(' // quick check parameters');
NewSource.Add(' ErrorMsg:=CheckOptions(''h'',''help'');');
NewSource.Add(' if ErrorMsg<>'''' then begin');
NewSource.Add(' ShowException(Exception.Create(ErrorMsg));');
NewSource.Add(' Terminate;');
NewSource.Add(' Exit;');
NewSource.Add(' end;');
NewSource.Add('');
end;
If CU then
begin
NewSource.Add(' // parse parameters');
NewSource.Add(' if HasOption(''h'',''help'') then begin');
NewSource.Add(' WriteHelp;');
NewSource.Add(' Terminate;');
NewSource.Add(' Exit;');
NewSource.Add(' end;');
end;
NewSource.Add('');
NewSource.Add(' { add your program here }');
NewSource.Add('');
NewSource.Add(' // stop program loop');
NewSource.Add(' Terminate;');
NewSource.Add('end;');
NewSource.Add('');
If CC or CS then
begin
NewSource.Add('constructor '+C+'.Create(TheOwner: TComponent);');
NewSource.Add('begin');
NewSource.Add(' inherited Create(TheOwner);');
If CS then
NewSource.Add(' StopOnException:=True;');
NewSource.Add('end;');
NewSource.Add('');
end;
If CD then
begin
NewSource.Add('destructor '+C+'.Destroy;');
NewSource.Add('begin');
NewSource.Add(' inherited Destroy;');
NewSource.Add('end;');
NewSource.Add('');
end;
If CU then
begin
NewSource.Add('procedure '+C+'.WriteHelp;');
NewSource.Add('begin');
NewSource.Add(' { add your help code here }');
NewSource.Add(' writeln(''Usage: '',ExeName,'' -h'');');
NewSource.Add('end;');
NewSource.Add('');
end;
NewSource.Add('var');
NewSource.Add(' Application: '+C+';');
NewSource.Add('begin');
NewSource.Add(' Application:='+C+'.Create(nil);');
If (T<>'') then
NewSource.Add(' Application.Title:='''+T+''';');
NewSource.Add(' Application.Run;');
NewSource.Add(' Application.Free;');
NewSource.Add('end.');
NewSource.Add('');
AProject.MainFile.SetSourceText(NewSource.Text);
NewSource.Free;
end;
function TProjectConsoleApplicationDescriptor.CreateStartFiles(
AProject: TLazProject): TModalResult;
begin
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
[ofProjectLoading,ofRegularFile]);
end;
{ TUCDComponentProperty } { TUCDComponentProperty }
constructor TUCDComponentProperty.Create(const SrcPath, DestPath: string); constructor TUCDComponentProperty.Create(const SrcPath, DestPath: string);
@ -6609,5 +6112,6 @@ end;
initialization initialization
RegisterIDEOptionsGroup(GroupProject, TProject); RegisterIDEOptionsGroup(GroupProject, TProject);
RegisterIDEOptionsGroup(GroupCompiler, TProjectCompilerOptions); RegisterIDEOptionsGroup(GroupCompiler, TProjectCompilerOptions);
end. end.

View File

@ -38,8 +38,9 @@ interface
uses uses
Classes, SysUtils, Laz_XMLCfg, Classes, SysUtils, Laz_XMLCfg,
Forms, SynRegExpr, FileUtil, LCLProc, IDEProcs, Controls, Forms, SynRegExpr, FileUtil, LCLProc,
ProjectIntf, PublishModule, SrcEditorIntf; ProjectIntf, PublishModule, SrcEditorIntf, LazIDEIntf,
frmCustomApplicationOptions, IDEProcs, LazarusIDEStrConsts;
type type
TOnLoadSaveFilename = procedure(var Filename:string; Load:boolean) of object; TOnLoadSaveFilename = procedure(var Filename:string; Load:boolean) of object;
@ -300,6 +301,73 @@ type
write SetSaveClosedEditorFilesInfo; write SetSaveClosedEditorFilesInfo;
end; end;
//----------------------------------------------------------------------------
{ TProjectApplicationDescriptor }
TProjectApplicationDescriptor = class(TProjectDescriptor)
public
constructor Create; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
function InitProject(AProject: TLazProject): TModalResult; override;
function CreateStartFiles(AProject: TLazProject): TModalResult; override;
end;
{ TProjectProgramDescriptor }
TProjectProgramDescriptor = class(TProjectDescriptor)
public
constructor Create; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
function InitProject(AProject: TLazProject): TModalResult; override;
function CreateStartFiles(AProject: TLazProject): TModalResult; override;
end;
{ TProjectConsoleApplicationDescriptor }
TProjectConsoleApplicationDescriptor = class(TProjectDescriptor)
public
constructor Create; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
function InitProject(AProject: TLazProject): TModalResult; override;
function CreateStartFiles(AProject: TLazProject): TModalResult; override;
end;
{ TProjectLibraryDescriptor }
TProjectLibraryDescriptor = class(TProjectDescriptor)
public
constructor Create; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
function InitProject(AProject: TLazProject): TModalResult; override;
function CreateStartFiles(AProject: TLazProject): TModalResult; override;
end;
{ TProjectManualProgramDescriptor }
TProjectManualProgramDescriptor = class(TProjectDescriptor)
private
FAddMainSource: boolean;
public
constructor Create; override;
function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override;
function InitProject(AProject: TLazProject): TModalResult; override;
function CreateStartFiles(AProject: TLazProject): TModalResult; override;
property AddMainSource: boolean read FAddMainSource write FAddMainSource;
end;
{ TProjectEmptyProgramDescriptor }
TProjectEmptyProgramDescriptor = class(TProjectManualProgramDescriptor)
public
constructor Create; override;
end;
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -1178,6 +1246,436 @@ begin
Descriptor.Release; Descriptor.Release;
end; end;
{ TProjectProgramDescriptor }
constructor TProjectProgramDescriptor.Create;
begin
inherited Create;
Name:=ProjDescNameProgram;
Flags:=Flags-[pfMainUnitHasCreateFormStatements,pfMainUnitHasTitleStatement]
+[pfUseDefaultCompilerOptions];
end;
function TProjectProgramDescriptor.GetLocalizedName: string;
begin
Result:=lisProgram;
end;
function TProjectProgramDescriptor.GetLocalizedDescription: string;
begin
Result:=Format(lisProgramAFreepascalProgramTheProgramFileIsAutomatic, [#13]);
end;
function TProjectProgramDescriptor.InitProject(AProject: TLazProject
): TModalResult;
var
le: String;
NewSource: String;
MainFile: TLazProjectFile;
begin
Result:=inherited InitProject(AProject);
MainFile:=AProject.CreateProjectFile('project1.lpr');
MainFile.IsPartOfProject:=true;
AProject.AddFile(MainFile,false);
AProject.MainFileID:=0;
// create program source
le:=LineEnding;
NewSource:='program Project1;'+le
+le
+'{$mode objfpc}{$H+}'+le
+le
+'uses'+le
+' {$IFDEF UNIX}{$IFDEF UseCThreads}'+le
+' cthreads,'+le
+' {$ENDIF}{$ENDIF}'+le
+' Classes'+le
+' { you can add units after this };'+le
+le
+'begin'+le
+'end.'+le
+le;
AProject.MainFile.SetSourceText(NewSource);
AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
AProject.LazCompilerOptions.TargetFilename:='project1';
end;
function TProjectProgramDescriptor.CreateStartFiles(AProject: TLazProject
): TModalResult;
begin
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
[ofProjectLoading,ofRegularFile]);
end;
{ TProjectApplicationDescriptor }
constructor TProjectApplicationDescriptor.Create;
begin
inherited Create;
Name:=ProjDescNameApplication;
Flags:=Flags+[pfUseDefaultCompilerOptions];
end;
function TProjectApplicationDescriptor.GetLocalizedName: string;
begin
Result:=dlgPOApplication;
end;
function TProjectApplicationDescriptor.GetLocalizedDescription: string;
begin
Result:=Format(lisApplicationAGraphicalLclFreepascalProgramTheProgra, [#13]);
end;
function TProjectApplicationDescriptor.InitProject(
AProject: TLazProject): TModalResult;
var
le: string;
NewSource: String;
MainFile: TLazProjectFile;
begin
Result:=inherited InitProject(AProject);
MainFile:=AProject.CreateProjectFile('project1.lpr');
MainFile.IsPartOfProject:=true;
AProject.AddFile(MainFile,false);
AProject.MainFileID:=0;
// create program source
le:=LineEnding;
NewSource:='program Project1;'+le
+le
+'{$mode objfpc}{$H+}'+le
+le
+'uses'+le
+' {$IFDEF UNIX}{$IFDEF UseCThreads}'+le
+' cthreads,'+le
+' {$ENDIF}{$ENDIF}'+le
+' Interfaces, // this includes the LCL widgetset'+le
+' Forms'+le
+' { you can add units after this };'+le
+le
+'begin'+le
+' Application.Initialize;'+le
+' Application.Run;'+le
+'end.'+le
+le;
AProject.MainFile.SetSourceText(NewSource);
// add lcl pp/pas dirs to source search path
AProject.AddPackageDependency('LCL');
AProject.LazCompilerOptions.Win32GraphicApp:=true;
AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
AProject.LazCompilerOptions.TargetFilename:='project1';
end;
function TProjectApplicationDescriptor.CreateStartFiles(AProject: TLazProject
): TModalResult;
begin
Result:=LazarusIDE.DoNewEditorFile(FileDescriptorForm,'','',
[nfIsPartOfProject,nfOpenInEditor,nfCreateDefaultSrc]);
end;
{ TProjectManualProgramDescriptor }
constructor TProjectManualProgramDescriptor.Create;
begin
inherited Create;
VisibleInNewDialog:=false;
Name:=ProjDescNameCustomProgram;
Flags:=Flags-[pfMainUnitHasUsesSectionForAllUnits,
pfMainUnitHasCreateFormStatements,
pfMainUnitHasTitleStatement]
+[pfUseDefaultCompilerOptions];
FAddMainSource:=true;
end;
function TProjectManualProgramDescriptor.GetLocalizedName: string;
begin
Result:=lisCustomProgram;
end;
function TProjectManualProgramDescriptor.GetLocalizedDescription: string;
begin
Result:=Format(lisCustomProgramAFreepascalProgram, [#13]);
end;
function TProjectManualProgramDescriptor.InitProject(AProject: TLazProject
): TModalResult;
var
le: string;
NewSource: String;
MainFile: TLazProjectFile;
begin
Result:=inherited InitProject(AProject);
if AddMainSource then begin
MainFile:=AProject.CreateProjectFile('project1.pas');
MainFile.IsPartOfProject:=true;
AProject.AddFile(MainFile,false);
AProject.MainFileID:=0;
// create program source
le:=LineEnding;
NewSource:='program Project1;'+le
+le
+'{$mode objfpc}{$H+}'+le
+le
+'uses'+le
+' Classes, SysUtils'+le
+' { you can add units after this };'+le
+le
+'begin'+le
+'end.'+le
+le;
AProject.MainFile.SetSourceText(NewSource);
end;
end;
function TProjectManualProgramDescriptor.CreateStartFiles(AProject: TLazProject
): TModalResult;
begin
if AProject.MainFile<>nil then
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
[ofProjectLoading,ofRegularFile]);
end;
{ TProjectEmptyProgramDescriptor }
constructor TProjectEmptyProgramDescriptor.Create;
begin
inherited Create;
FAddMainSource:=false;
end;
{ TProjectLibraryDescriptor }
constructor TProjectLibraryDescriptor.Create;
begin
inherited Create;
Name:=ProjDescNameLibrary;
Flags:=Flags-[pfMainUnitHasCreateFormStatements,pfMainUnitHasTitleStatement]
+[pfUseDefaultCompilerOptions];
end;
function TProjectLibraryDescriptor.GetLocalizedName: string;
begin
Result:=lisPckOptsLibrary;
end;
function TProjectLibraryDescriptor.GetLocalizedDescription: string;
begin
Result:= Format(lisLibraryAFreepascalLibraryDllUnderWindowsSoUnderLin, [#13]);
end;
function TProjectLibraryDescriptor.InitProject(AProject: TLazProject
): TModalResult;
var
le: String;
NewSource: String;
MainFile: TLazProjectFile;
begin
Result:=inherited InitProject(AProject);
MainFile:=AProject.CreateProjectFile('project1.lpr');
MainFile.IsPartOfProject:=true;
AProject.AddFile(MainFile,false);
AProject.MainFileID:=0;
AProject.LazCompilerOptions.ExecutableType:=cetLibrary;
// create program source
le:=LineEnding;
NewSource:='library Project1;'+le
+le
+'{$mode objfpc}{$H+}'+le
+le
+'uses'+le
+' Classes'+le
+' { you can add units after this };'+le
+le
+'begin'+le
+'end.'+le
+le;
AProject.MainFile.SetSourceText(NewSource);
AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
AProject.LazCompilerOptions.TargetFilename:='project1';
end;
function TProjectLibraryDescriptor.CreateStartFiles(AProject: TLazProject
): TModalResult;
begin
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
[ofProjectLoading,ofRegularFile]);
end;
{ TProjectConsoleApplicationDescriptor }
constructor TProjectConsoleApplicationDescriptor.Create;
begin
inherited Create;
Name:=ProjDescNameConsoleApplication;
Flags:=Flags-[pfMainUnitHasCreateFormStatements,pfMainUnitHasTitleStatement]
+[pfUseDefaultCompilerOptions];
end;
function TProjectConsoleApplicationDescriptor.GetLocalizedName: string;
begin
Result:=lisConsoleApplication;
end;
function TProjectConsoleApplicationDescriptor.GetLocalizedDescription: string;
begin
Result:=GetLocalizedName+#13
+lisFreepascalProgramUsingTCustomApplicationToEasilyCh;
end;
function TProjectConsoleApplicationDescriptor.InitProject(AProject: TLazProject
): TModalResult;
var
NewSource: TStringList;
MainFile: TLazProjectFile;
C, T : String;
CC,CD,CU,CS, CO : Boolean;
begin
Result:=inherited InitProject(AProject);
If Result<>mrOk then
Exit;
With TCustomApplicationOptionsForm.Create(Application) do
try
Result:=ShowModal;
If Result<>mrOk then
Exit;
C:=Trim(AppClassName);
T:=StringReplace(Title,'''','''''',[rfReplaceAll]);
CC:=CodeConstructor;
CD:=CodeDestructor;
CU:=CodeUsage;
CS:=CodeStopOnError;
CO:=CodeCheckOptions;
finally
Free;
end;
MainFile:=AProject.CreateProjectFile('project1.lpr');
MainFile.IsPartOfProject:=true;
AProject.AddFile(MainFile,false);
AProject.MainFileID:=0;
AProject.LazCompilerOptions.UnitOutputDirectory:='lib'+PathDelim+'$(TargetCPU)-$(TargetOS)';
AProject.LazCompilerOptions.TargetFilename:='project1';
// create program source
NewSource:=TStringList.Create;
NewSource.Add('program Project1;');
NewSource.Add('');
NewSource.Add('{$mode objfpc}{$H+}');
NewSource.Add('');
NewSource.Add('uses');
NewSource.Add(' {$IFDEF UNIX}{$IFDEF UseCThreads}');
NewSource.Add(' cthreads,');
NewSource.Add(' {$ENDIF}{$ENDIF}');
NewSource.Add(' Classes, SysUtils, CustApp');
NewSource.Add(' { you can add units after this };');
NewSource.Add('');
NewSource.Add('type');
NewSource.Add('');
NewSource.Add(' { '+C+' }');
NewSource.Add('');
NewSource.Add(' '+C+' = class(TCustomApplication)');
NewSource.Add(' protected');
NewSource.Add(' procedure DoRun; override;');
NewSource.Add(' public');
If CC or CS then
NewSource.Add(' constructor Create(TheOwner: TComponent); override;');
if CD then
NewSource.Add(' destructor Destroy; override;');
if CU then
NewSource.Add(' procedure WriteHelp; virtual;');
NewSource.Add(' end;');
NewSource.Add('');
NewSource.Add('{ '+C+' }');
NewSource.Add('');
NewSource.Add('procedure '+C+'.DoRun;');
NewSource.Add('var');
NewSource.Add(' ErrorMsg: String;');
NewSource.Add('begin');
if CO then
begin
NewSource.Add(' // quick check parameters');
NewSource.Add(' ErrorMsg:=CheckOptions(''h'',''help'');');
NewSource.Add(' if ErrorMsg<>'''' then begin');
NewSource.Add(' ShowException(Exception.Create(ErrorMsg));');
NewSource.Add(' Terminate;');
NewSource.Add(' Exit;');
NewSource.Add(' end;');
NewSource.Add('');
end;
If CU then
begin
NewSource.Add(' // parse parameters');
NewSource.Add(' if HasOption(''h'',''help'') then begin');
NewSource.Add(' WriteHelp;');
NewSource.Add(' Terminate;');
NewSource.Add(' Exit;');
NewSource.Add(' end;');
end;
NewSource.Add('');
NewSource.Add(' { add your program here }');
NewSource.Add('');
NewSource.Add(' // stop program loop');
NewSource.Add(' Terminate;');
NewSource.Add('end;');
NewSource.Add('');
If CC or CS then
begin
NewSource.Add('constructor '+C+'.Create(TheOwner: TComponent);');
NewSource.Add('begin');
NewSource.Add(' inherited Create(TheOwner);');
If CS then
NewSource.Add(' StopOnException:=True;');
NewSource.Add('end;');
NewSource.Add('');
end;
If CD then
begin
NewSource.Add('destructor '+C+'.Destroy;');
NewSource.Add('begin');
NewSource.Add(' inherited Destroy;');
NewSource.Add('end;');
NewSource.Add('');
end;
If CU then
begin
NewSource.Add('procedure '+C+'.WriteHelp;');
NewSource.Add('begin');
NewSource.Add(' { add your help code here }');
NewSource.Add(' writeln(''Usage: '',ExeName,'' -h'');');
NewSource.Add('end;');
NewSource.Add('');
end;
NewSource.Add('var');
NewSource.Add(' Application: '+C+';');
NewSource.Add('begin');
NewSource.Add(' Application:='+C+'.Create(nil);');
If (T<>'') then
NewSource.Add(' Application.Title:='''+T+''';');
NewSource.Add(' Application.Run;');
NewSource.Add(' Application.Free;');
NewSource.Add('end.');
NewSource.Add('');
AProject.MainFile.SetSourceText(NewSource.Text);
NewSource.Free;
end;
function TProjectConsoleApplicationDescriptor.CreateStartFiles(
AProject: TLazProject): TModalResult;
begin
Result:=LazarusIDE.DoOpenEditorFile(AProject.MainFile.Filename,-1,-1,
[ofProjectLoading,ofRegularFile]);
end;
initialization initialization
LazProjectFileDescriptors:=nil; LazProjectFileDescriptors:=nil;

View File

@ -2659,7 +2659,9 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TControl.SetHint(const Value: TTranslateString); procedure TControl.SetHint(const Value: TTranslateString);
begin begin
if FHint <> Value then FHint := Value; if FHint = Value then exit;
FHint := Value;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------