IDEIntf: Package.BuildMethod added

IDEIntf: UseFPMakeWhenPossible added
IDE: It is now possible to compile Lazarus-packages using FPMake.

git-svn-id: trunk@59610 -
This commit is contained in:
joost 2018-11-19 19:40:09 +00:00
parent fde5f24937
commit 910d2f1319
12 changed files with 255 additions and 17 deletions

2
.gitattributes vendored
View File

@ -1502,6 +1502,8 @@ components/fppkg/src/fppkg_mainfrm.lrj svneol=native#text/plain
components/fppkg/src/fppkg_mainfrm.pas svneol=native#text/plain
components/fppkg/src/fppkg_optionsfrm.lfm svneol=native#text/plain
components/fppkg/src/fppkg_optionsfrm.pas svneol=native#text/plain
components/fppkg/src/fppkg_packageoptionsfrm.lfm svneol=native#text/plain
components/fppkg/src/fppkg_packageoptionsfrm.pas svneol=native#text/pascal
components/fppkg/src/fppkgpackagemanager.lpk svneol=native#text/plain
components/fppkg/src/fppkgpackagemanager.pas svneol=native#text/plain
components/fppkg/src/fppkgworkerthread.pas svneol=native#text/plain

View File

@ -56,6 +56,7 @@ type
private
FInstallFPMakeDependencies: Boolean;
FConfFileName: string;
FUseFPMakeWhenPossible: Boolean;
function GetConfFileName: string;
public
class function GetGroupCaption: string; override;
@ -65,12 +66,14 @@ type
procedure DoAfterWrite(Restore: boolean); override;
published
property InstallFPMakeDependencies: Boolean read FInstallFPMakeDependencies write FInstallFPMakeDependencies;
property UseFPMakeWhenPossible: Boolean read FUseFPMakeWhenPossible write FUseFPMakeWhenPossible;
end;
{ TFppkgEnvironmentOptionsFrame }
TFppkgEnvironmentOptionsFrame = class(TAbstractIDEOptionsEditor)
cbInstallDependencies: TCheckBox;
cbUseFPMakeWhenPossible: TCheckBox;
public
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
@ -117,6 +120,7 @@ var
begin
FppkgOptions := AOptions as TFppkgEnvironmentOptions;
cbInstallDependencies.Checked := FppkgOptions.InstallFPMakeDependencies;
cbUseFPMakeWhenPossible.Checked := FppkgOptions.UseFPMakeWhenPossible;
end;
procedure TFppkgEnvironmentOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions);
@ -125,6 +129,7 @@ var
begin
FppkgOptions := AOptions as TFppkgEnvironmentOptions;
FppkgOptions.InstallFPMakeDependencies := cbInstallDependencies.Checked;
FppkgOptions.UseFPMakeWhenPossible := cbUseFPMakeWhenPossible.Checked;
end;
class function TFppkgEnvironmentOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
@ -168,6 +173,7 @@ begin
try
XMLConfig.Filename := GetConfFileName;
InstallFPMakeDependencies := XMLConfig.GetValue('InstallDependencies/Value',False);
UseFPMakeWhenPossible := XMLConfig.GetValue('UseFPMakeWhenPossible/Value',False);
finally
XMLConfig.Free;
end;
@ -187,6 +193,7 @@ begin
try
XMLConfig.Filename:=GetConfFileName;
XMLConfig.SetValue('InstallDependencies/Value',InstallFPMakeDependencies);
XMLConfig.SetValue('UseFPMakeWhenPossible/Value',UseFPMakeWhenPossible);
XMLConfig.Flush;
finally

View File

@ -17,6 +17,7 @@ type
TFppkgInterfaceEx = class(TFppkgInterface)
protected
function GetInstallFPMakeDependencies: Boolean; override;
function GetUseFPMakeWhenPossible: Boolean; override;
end;
implementation
@ -28,6 +29,11 @@ begin
Result := TFppkgEnvironmentOptions(TFppkgEnvironmentOptions.GetInstance).InstallFPMakeDependencies;
end;
function TFppkgInterfaceEx.GetUseFPMakeWhenPossible: Boolean;
begin
Result := TFppkgEnvironmentOptions(TFppkgEnvironmentOptions.GetInstance).UseFPMakeWhenPossible;
end;
initialization
FppkgInterface := TFppkgInterfaceEx.Create;
finalization

View File

@ -0,0 +1,55 @@
object FppkgPackageOptionsFrm: TFppkgPackageOptionsFrm
Left = 0
Height = 240
Top = 0
Width = 320
ClientHeight = 240
ClientWidth = 320
TabOrder = 0
DesignLeft = 831
DesignTop = 330
object gbBuildMethod: TGroupBox
Left = 0
Height = 240
Top = 0
Width = 320
Align = alClient
Caption = 'Build method'
ClientHeight = 220
ClientWidth = 318
TabOrder = 0
object Panel1: TPanel
Left = 3
Height = 42
Top = 3
Width = 312
Align = alTop
BorderSpacing.Around = 3
BevelOuter = bvNone
ClientHeight = 42
ClientWidth = 312
TabOrder = 0
object cbBuildMethod: TComboBox
Left = 88
Height = 42
Top = 0
Width = 224
Align = alRight
ItemHeight = 0
Style = csDropDownList
TabOrder = 0
end
object Label1: TLabel
Left = 3
Height = 36
Top = 3
Width = 55
Align = alLeft
BorderSpacing.Around = 3
Caption = 'Package'
Layout = tlCenter
ParentColor = False
end
end
end
end

View File

@ -0,0 +1,94 @@
unit fppkg_packageoptionsfrm;
{$mode objfpc}{$H+}
interface
uses
Classes,
SysUtils,
Forms,
Controls,
StdCtrls,
ExtCtrls,
PackageIntf,
IDEOptEditorIntf,
IDEOptionsIntf;
type
{ TFppkgPackageOptionsFrm }
TFppkgPackageOptionsFrm = class(TAbstractIDEOptionsEditor)
cbBuildMethod: TComboBox;
gbBuildMethod: TGroupBox;
Label1: TLabel;
Panel1: TPanel;
protected
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
public
end;
implementation
var
FppkgPackageOptionID: integer = 500;
{$R *.lfm}
resourcestring
lisFppkgPckOptsTitle = 'Build method';
lisFppkgPckOptsBuildMethod = 'Supported build methods';
lisFppkgBuildMethodFPMake = 'FPMake';
lisFppkgBuildMethodLazarus = 'Lazbuild';
lisFppkgBuildMethodBoth = 'Both';
{ TFppkgPackageOptionsFrm }
function TFppkgPackageOptionsFrm.GetTitle: String;
begin
Result := lisFppkgPckOptsTitle;
end;
procedure TFppkgPackageOptionsFrm.Setup(ADialog: TAbstractOptionsEditorDialog);
begin
gbBuildMethod.Caption := lisFppkgPckOptsBuildMethod;
cbBuildMethod.Items.Clear;
cbBuildMethod.Items.Add(lisFppkgBuildMethodLazarus);
cbBuildMethod.Items.Add(lisFppkgBuildMethodFPMake);
cbBuildMethod.Items.Add(lisFppkgBuildMethodBoth);
end;
procedure TFppkgPackageOptionsFrm.ReadSettings(AOptions: TAbstractIDEOptions);
var
LazPackage: TIDEPackage;
begin
LazPackage := (AOptions as TAbstractPackageIDEOptions).Package;
cbBuildMethod.ItemIndex := Ord(LazPackage.BuildMethod);
end;
procedure TFppkgPackageOptionsFrm.WriteSettings(AOptions: TAbstractIDEOptions);
var
LazPackage: TIDEPackage;
begin
LazPackage := (AOptions as TAbstractPackageIDEOptions).Package;
LazPackage.BuildMethod := TBuildMethod(cbBuildMethod.ItemIndex);
end;
class function TFppkgPackageOptionsFrm.SupportedOptionsClass: TAbstractIDEOptionsClass;
begin
Result := TAbstractPackageIDEOptions;
end;
initialization
RegisterIDEOptionsEditor(GroupPackage, TFppkgPackageOptionsFrm, FppkgPackageOptionID);
end.

View File

@ -19,7 +19,7 @@
<Description Value="A packagemanager based on FPC's fppkg"/>
<License Value="GPL"/>
<Version Minor="1"/>
<Files Count="12">
<Files Count="13">
<Item1>
<Filename Value="lazfppkgmanagerintf.pas"/>
<HasRegisterProc Value="True"/>
@ -70,6 +70,10 @@
<Filename Value="fppkg_interface.pas"/>
<UnitName Value="fppkg_interface"/>
</Item12>
<Item13>
<Filename Value="fppkg_packageoptionsfrm.pas"/>
<UnitName Value="fppkg_packageoptionsfrm"/>
</Item13>
</Files>
<i18n>
<EnableI18N Value="True"/>

View File

@ -9,7 +9,8 @@ interface
uses
lazfppkgmanagerintf, fppkg_const, fppkg_details, fppkg_mainfrm, fppkg_optionsfrm, laz_pkgrepos,
FppkgWorkerThread, Fppkg_EnvironmentOptions, Fppkg_Interface, LazarusPackageIntf;
FppkgWorkerThread, Fppkg_EnvironmentOptions, Fppkg_Interface, fppkg_packageoptionsfrm,
LazarusPackageIntf;
implementation

View File

@ -9,11 +9,16 @@ uses
SysUtils;
type
{ TFppkgInterface }
TFppkgInterface = class
protected
function GetUseFPMakeWhenPossible: Boolean; virtual; abstract;
function GetInstallFPMakeDependencies: Boolean; virtual; abstract;
public
property InstallFPMakeDependencies: Boolean read GetInstallFPMakeDependencies;
property UseFPMakeWhenPossible: Boolean read GetUseFPMakeWhenPossible;
end;
var
@ -21,5 +26,7 @@ var
implementation
{ TFppkgInterface }
end.

View File

@ -20,7 +20,7 @@ uses
// LazUtils
LazConfigStorage, LazMethodList, LazLoggerBase, UITypes,
// IdeIntf
NewItemIntf, ProjPackIntf, PackageDependencyIntf;
NewItemIntf, ProjPackIntf, PackageDependencyIntf, IDEOptionsIntf;
const
PkgDescGroupName = 'Package';
@ -148,6 +148,13 @@ type
pitDynamic
);
// FPMake/Lazarus build mode
TBuildMethod = (
bmLazarus,
bmFPMake,
bmBoth
);
{ TIDEPackage }
TIDEPackage = class(TLazPackageID)
@ -157,6 +164,7 @@ type
FChangeStamp: integer;
FCustomOptions: TConfigStorage;
FPackageType: TLazPackageType;
FBuildMethod: TBuildMethod;
function GetDirectoryExpanded: string; virtual; abstract;
function GetFileCount: integer; virtual; abstract;
function GetPkgFiles(Index: integer): TLazPackageFile; virtual; abstract;
@ -188,6 +196,7 @@ type
property Modified: boolean read GetModified write SetModified;
property RemovedFilesCount: integer read GetRemovedCount;
property RemovedFiles[Index: integer]: TLazPackageFile read GetRemovedPkgFiles;
property BuildMethod: TBuildMethod read FBuildMethod write FBuildMethod;
end;
type
@ -395,6 +404,14 @@ type
property ChangeStamp: Int64 read FChangeStamp;
end;
TAbstractPackageIDEOptions = class(TAbstractIDEOptions)
protected
function GetPackage: TIDEPackage; virtual; abstract;
public
property Package: TIDEPackage read GetPackage;
end;
var
PackageDescriptors: TPackageDescriptors; // will be set by the IDE
PackageGraphInterface: TPackageGraphInterface; // must be set along with PackageSystem.PackageGraph

View File

@ -39,9 +39,18 @@ uses
StdCtrls, ExtCtrls,
// CodeTools
BasicCodeTools, FileProcs, CodeToolManager, CodeToolsConfig, CodeCache,
PackageIntf,
// IDE
LazConf;
const
SBuildMethod: array[TBuildMethod] of string = (
'Lazarus',
'FPMake',
'Both'
);
function StringToBuildMethod(const BuildMethod: string): TBuildMethod;
// file operations
function BackupFileForWrite(const Filename, BackupFilename: string): boolean;
function CreateEmptyFile(const Filename: string): boolean;
@ -683,6 +692,16 @@ begin
end;
end;
function StringToBuildMethod(const BuildMethod: string): TBuildMethod;
begin
if BuildMethod=SBuildMethod[bmFPMake] then
result := bmFPMake
else if BuildMethod=SBuildMethod[bmBoth] then
result := bmBoth
else
result := bmLazarus;
end;
function ChompEndNumber(const s: string): string;
var
NewLen: Integer;

View File

@ -478,9 +478,11 @@ type
{ TPackageIDEOptions }
TPackageIDEOptions = class(TAbstractIDEOptions)
TPackageIDEOptions = class(TAbstractPackageIDEOptions)
private
FPackage: TLazPackage;
protected
function GetPackage: TIDEPackage; override;
public
constructor Create(APackage: TLazPackage);
destructor Destroy; override;
@ -2068,6 +2070,11 @@ end;
{ TPackageIDEOptions }
function TPackageIDEOptions.GetPackage: TIDEPackage;
begin
Result := FPackage;
end;
constructor TPackageIDEOptions.Create(APackage: TLazPackage);
begin
inherited Create;
@ -2807,6 +2814,8 @@ begin
Name:=XMLConfig.GetValue(Path+'Name/Value','');
FPackageType:=LazPackageTypeIdentToType(XMLConfig.GetValue(Path+'Type/Value',
LazPackageTypeIdents[lptRunTime]));
FBuildMethod:=StringToBuildMethod(XMLConfig.GetValue(Path+'BuildMethod/Value',
SBuildMethod[bmLazarus]));
FAddToProjectUsesSection:=XMLConfig.GetValue(Path+'AddToProjectUsesSection/Value',
FileVersion<4); // since version 4 the default is false
FAuthor:=XMLConfig.GetValue(Path+'Author/Value','');
@ -2897,6 +2906,8 @@ begin
XMLConfig.SetDeleteValue(Path+'Name/Value',Name,'');
XMLConfig.SetDeleteValue(Path+'Type/Value',LazPackageTypeIdents[FPackageType],
LazPackageTypeIdents[lptRunTime]);
XMLConfig.SetDeleteValue(Path+'BuildMethod/Value',SBuildMethod[FBuildMethod],
SBuildMethod[bmLazarus]);
XMLConfig.SetDeleteValue(Path+'AddToProjectUsesSection/Value',
FAddToProjectUsesSection,false);
XMLConfig.SetDeleteValue(Path+'Author/Value',FAuthor,'');

View File

@ -3953,6 +3953,7 @@ begin
// add dependencies between packages
aDependency:=CurPkg.FirstRequiredDependency;
// ToDo: Add fpmake-dependencies!
while aDependency<>nil do begin
RequiredBuildItem:=PkgToBuildItem(aDependency.RequiredPackage);
aDependency:=aDependency.NextRequiresDependency;
@ -4070,6 +4071,7 @@ var
WorkingDir: String;
ToolTitle: String;
ExtToolData: TLazPkgGraphExtToolData;
BuildMethod: TBuildMethod;
begin
Result:=mrCancel;
@ -4164,7 +4166,7 @@ begin
end;
// create fpmake.pp
if ((pcfCreateFpmakeFile in Flags)
if ((pcfCreateFpmakeFile in Flags) or (APackage.BuildMethod in [bmBoth, bmFPMake])
or (APackage.CompilerOptions.CreateMakefileOnBuild)) then begin
Result:=WriteFpmake(APackage);
if Result<>mrOk then begin
@ -4198,23 +4200,36 @@ begin
if (not APackage.CompilerOptions.SkipCompiler)
and (not (pcfDoNotCompilePackage in Flags)) then begin
CompilerFilename:=APackage.GetCompilerFilename;
// change compiler parameters for compiling clean
CompilerParams:=GetPackageCompilerParams(APackage);
EffectiveCompilerParams:=CompilerParams;
if (pcfCleanCompile in Flags) or NeedBuildAllFlag then begin
if EffectiveCompilerParams<>'' then
EffectiveCompilerParams:='-B '+EffectiveCompilerParams
BuildMethod:=APackage.BuildMethod;
if BuildMethod=bmBoth then begin
if Assigned(FppkgInterface) and FppkgInterface.UseFPMakeWhenPossible then
BuildMethod:=bmFPMake
else
EffectiveCompilerParams:='-B';
BuildMethod:=bmLazarus;
end;
if BuildMethod=bmLazarus then begin
CompilerFilename:=APackage.GetCompilerFilename;
// change compiler parameters for compiling clean
CompilerParams:=GetPackageCompilerParams(APackage);
EffectiveCompilerParams:=CompilerParams;
if (pcfCleanCompile in Flags) or NeedBuildAllFlag then begin
if EffectiveCompilerParams<>'' then
EffectiveCompilerParams:='-B '+EffectiveCompilerParams
else
EffectiveCompilerParams:='-B';
end;
WarnSuspiciousCompilerOptions('Compile checks','package '+APackage.IDAsString+':',CompilerParams);
end else begin
CompilerFilename:='fppkg';
EffectiveCompilerParams:='install -b';
end;
WarnSuspiciousCompilerOptions('Compile checks','package '+APackage.IDAsString+':',CompilerParams);
PkgCompileTool:=ExternalToolList.Add(Format(lisPkgMangCompilePackage, [APackage.IDAsString]));
ExtToolData:=TLazPkgGraphExtToolData.Create(IDEToolCompilePackage,
APackage.Name,APackage.Filename);
PkgCompileTool:=ExternalToolList.Add(Format(lisPkgMangCompilePackage, [APackage.IDAsString]));
PkgCompileTool.Data:=ExtToolData;
PkgCompileTool.FreeData:=true;
if BuildItem<>nil then