implemented publish package

git-svn-id: trunk@4147 -
This commit is contained in:
mattias 2003-05-12 13:11:34 +00:00
parent dfa8265f07
commit 2007425c74
12 changed files with 237 additions and 302 deletions

View File

@ -42,6 +42,12 @@
<UsageOptions> <UsageOptions>
<UnitPath Value="$(PkgOutDir)"/> <UnitPath Value="$(PkgOutDir)"/>
</UsageOptions> </UsageOptions>
<PublishOptions>
<Version Value="2"/>
<DestinationDirectory Value="$(TestDir)/publishedpackage/"/>
<CommandAfter Value="/bin/tar -cz -C $(TestDir) -f /tmp/gtkopengl.tgz gtkopengl/"/>
<UseExcludeFileFilter Value="True"/>
</PublishOptions>
</Package> </Package>
<CompilerOptions> <CompilerOptions>
<SearchPaths> <SearchPaths>

View File

@ -68,6 +68,7 @@ type
function Push(const Entry: string): integer; function Push(const Entry: string): integer;
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string); procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string); procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure AppendEntry(const Entry: string);
public public
property Name: string read FName write SetName; property Name: string read FName write SetName;
property MaxCount: integer read FMaxCount write SetMaxCount; property MaxCount: integer read FMaxCount write SetMaxCount;
@ -482,6 +483,12 @@ begin
SaveRecentList(XMLConfig,Self,Path); SaveRecentList(XMLConfig,Self,Path);
end; end;
procedure THistoryList.AppendEntry(const Entry: string);
begin
if (Count<MaxCount) and (IndexOf(Entry)<0) then
Add(Entry);
end;
{ THistoryLists } { THistoryLists }
function THistoryLists.GetItems(Index: integer): THistoryList; function THistoryLists.GetItems(Index: integer): THistoryList;

View File

@ -166,29 +166,29 @@ const
ecBuildLazarus = ecUserFirst + 408; ecBuildLazarus = ecUserFirst + 408;
// project menu // project menu
ecNewProject = ecUserFirst + 700; ecNewProject = ecUserFirst + 500;
ecNewProjectFromFile = ecUserFirst + 701; ecNewProjectFromFile = ecUserFirst + 501;
ecOpenProject = ecUserFirst + 702; ecOpenProject = ecUserFirst + 502;
ecSaveProject = ecUserFirst + 703; ecSaveProject = ecUserFirst + 503;
ecSaveProjectAs = ecUserFirst + 704; ecSaveProjectAs = ecUserFirst + 504;
ecPublishProject = ecUserFirst + 705; ecPublishProject = ecUserFirst + 505;
ecProjectInspector = ecUserFirst + 706; ecProjectInspector = ecUserFirst + 506;
ecAddCurUnitToProj = ecUserFirst + 707; ecAddCurUnitToProj = ecUserFirst + 507;
ecRemoveFromProj = ecUserFirst + 708; ecRemoveFromProj = ecUserFirst + 508;
ecViewProjectSource = ecUserFirst + 709; ecViewProjectSource = ecUserFirst + 509;
ecViewProjectTodos = ecUserFirst + 710; ecViewProjectTodos = ecUserFirst + 510;
ecProjectOptions = ecUserFirst + 711; ecProjectOptions = ecUserFirst + 511;
// components menu // components menu
ecOpenPackage = ecUserFirst + 900; ecOpenPackage = ecUserFirst + 600;
ecOpenPackageFile = ecUserFirst + 901; ecOpenPackageFile = ecUserFirst + 601;
ecAddCurUnitToPkg = ecUserFirst + 902; ecAddCurUnitToPkg = ecUserFirst + 603;
ecPackageGraph = ecUserFirst + 903; ecPackageGraph = ecUserFirst + 604;
ecConfigCustomComps = ecUserFirst + 904; ecConfigCustomComps = ecUserFirst + 605;
// tools menu // tools menu
ecExtToolFirst = ecUserFirst + 500; ecExtToolFirst = ecUserFirst + 700;
ecExtToolLast = ecUserFirst + 599; ecExtToolLast = ecUserFirst + 799;
// option commmands // option commmands
ecRunParameters = ecUserFirst + 800; ecRunParameters = ecUserFirst + 800;

View File

@ -107,6 +107,7 @@ resourcestring
lisMenuNewOther = 'New ...'; lisMenuNewOther = 'New ...';
lisMenuOpen = 'Open'; lisMenuOpen = 'Open';
lisMenuRevert = 'Revert'; lisMenuRevert = 'Revert';
lisPkgEditPublishPackage = 'Publish Package';
lisMenuOpenRecent = 'Open Recent'; lisMenuOpenRecent = 'Open Recent';
lisMenuSave = 'Save'; lisMenuSave = 'Save';
lisMenuSaveAs = 'Save As'; lisMenuSaveAs = 'Save As';
@ -330,7 +331,7 @@ resourcestring
+'directory'; +'directory';
lisUnableToCleanUpPleaseCheckPermissions = 'Unable to clean up %s%s%s.%' lisUnableToCleanUpPleaseCheckPermissions = 'Unable to clean up %s%s%s.%'
+'sPlease check permissions.'; +'sPlease check permissions.';
lisCommandAfterPublishingProject = 'Command after publishing project'; lisCommandAfterPublishingModule = 'Command after publishing module';
lisUnableToAddToProjectBecauseThereIsAlreadyAUnitWith = 'Unable to add %s ' lisUnableToAddToProjectBecauseThereIsAlreadyAUnitWith = 'Unable to add %s '
+'to project, because there is already a unit with the same name in the ' +'to project, because there is already a unit with the same name in the '
+'Project.'; +'Project.';
@ -2041,6 +2042,9 @@ resourcestring
lisPkgEditTheFileIsCurrentlyNotInTheUnitpathOfThePackage = 'The file %s%s%s%' lisPkgEditTheFileIsCurrentlyNotInTheUnitpathOfThePackage = 'The file %s%s%s%'
+'sis currently not in the unitpath of the package.%s%sAdd %s%s%s to ' +'sis currently not in the unitpath of the package.%s%sAdd %s%s%s to '
+'UnitPath?'; +'UnitPath?';
lisPkgEditRevertPackage = 'Revert package?';
lisPkgEditDoYouReallyWantToForgetAllChangesToPackageAnd = 'Do you really '
+'want to forget all changes to package %s and reload it from file?';
// package options dialog // package options dialog
lisPckOptsUsage = 'Usage'; lisPckOptsUsage = 'Usage';

View File

@ -43,7 +43,7 @@ uses
Classes, LCLType, LCLLinux, StdCtrls, Buttons, Menus, ComCtrls, SysUtils, Classes, LCLType, LCLLinux, StdCtrls, Buttons, Menus, ComCtrls, SysUtils,
Controls, Graphics, ExtCtrls, Dialogs, FileCtrl, Forms, CodeToolManager, Controls, Graphics, ExtCtrls, Dialogs, FileCtrl, Forms, CodeToolManager,
CodeCache, AVL_Tree, SynEditKeyCmds, LazConf, LazarusIDEStrConsts, CodeCache, AVL_Tree, SynEditKeyCmds, LazConf, LazarusIDEStrConsts,
ProjectDefs, Project, BuildLazDialog, Compiler, ProjectDefs, Project, PublishModule, BuildLazDialog, Compiler,
{$IFDEF EnablePkgs} {$IFDEF EnablePkgs}
ComponentReg, ComponentReg,
{$ELSE} {$ELSE}
@ -384,6 +384,9 @@ type
function DoBuildLazarus(Flags: TBuildLazarusFlags): TModalResult; virtual; abstract; function DoBuildLazarus(Flags: TBuildLazarusFlags): TModalResult; virtual; abstract;
function DoSaveForBuild: TModalResult; virtual; abstract; function DoSaveForBuild: TModalResult; virtual; abstract;
function DoCheckFilesOnDisk: TModalResult; virtual; abstract; function DoCheckFilesOnDisk: TModalResult; virtual; abstract;
function DoPublishModul(Options: TPublishModuleOptions;
const SrcDirectory, DestDirectory: string
): TModalResult; virtual; abstract;
function DoCheckAmbigiousSources(const AFilename: string; function DoCheckAmbigiousSources(const AFilename: string;
Compiling: boolean): TModalResult; virtual; Compiling: boolean): TModalResult; virtual;
function DoCheckCreatingFile(const AFilename: string; function DoCheckCreatingFile(const AFilename: string;

View File

@ -315,6 +315,7 @@ type
CheckIfAllowed: boolean; var Allowed: boolean); CheckIfAllowed: boolean; var Allowed: boolean);
procedure SetFlags(const AValue: TProjectFlags); procedure SetFlags(const AValue: TProjectFlags);
procedure SetMainUnitID(const AValue: Integer); procedure SetMainUnitID(const AValue: Integer);
procedure SetModified(const AValue: boolean);
procedure SetProjectInfoFile(const NewFilename: string); procedure SetProjectInfoFile(const NewFilename: string);
procedure SetTargetFilename(const NewTargetFilename: string); procedure SetTargetFilename(const NewTargetFilename: string);
procedure SetUnits(Index:integer; AUnitInfo: TUnitInfo); procedure SetUnits(Index:integer; AUnitInfo: TUnitInfo);
@ -445,7 +446,7 @@ type
property MainFilename: String read GetMainFilename; property MainFilename: String read GetMainFilename;
property MainUnitID: Integer read fMainUnitID write SetMainUnitID; property MainUnitID: Integer read fMainUnitID write SetMainUnitID;
property MainUnitInfo: TUnitInfo read GetMainUnitInfo; property MainUnitInfo: TUnitInfo read GetMainUnitInfo;
property Modified: boolean read fModified write fModified; property Modified: boolean read fModified write SetModified;
property OnBeginUpdate: TNotifyEvent read FOnBeginUpdate write FOnBeginUpdate; property OnBeginUpdate: TNotifyEvent read FOnBeginUpdate write FOnBeginUpdate;
property OnEndUpdate: TEndUpdateProjectEvent read FOnEndUpdate write FOnEndUpdate; property OnEndUpdate: TEndUpdateProjectEvent read FOnEndUpdate write FOnEndUpdate;
property OnFileBackup: TOnFileBackup read fOnFileBackup write fOnFileBackup; property OnFileBackup: TOnFileBackup read fOnFileBackup write fOnFileBackup;
@ -1140,7 +1141,7 @@ begin
fModified := false; fModified := false;
fProjectInfoFile := ''; fProjectInfoFile := '';
UpdateProjectDirectory; UpdateProjectDirectory;
fPublishOptions:=TPublishProjectOptions.Create; fPublishOptions:=TPublishProjectOptions.Create(Self);
fRunParameterOptions:=TRunParamsOptions.Create; fRunParameterOptions:=TRunParamsOptions.Create;
fTargetFileExt := DefaultTargetFileExt; fTargetFileExt := DefaultTargetFileExt;
fTitle := ''; fTitle := '';
@ -1626,6 +1627,13 @@ begin
end; end;
end; end;
procedure TProject.SetModified(const AValue: boolean);
begin
if AValue=Modified then exit;
fModified:=AValue;
if not fModified then PublishOptions.Modified:=false;
end;
procedure TProject.SetUnits(Index:integer; AUnitInfo: TUnitInfo); procedure TProject.SetUnits(Index:integer; AUnitInfo: TUnitInfo);
begin begin
if AUnitInfo<>TUnitInfo(fUnitList[Index]) then begin if AUnitInfo<>TUnitInfo(fUnitList[Index]) then begin
@ -2653,6 +2661,9 @@ end.
{ {
$Log$ $Log$
Revision 1.118 2003/05/12 13:11:34 mattias
implemented publish package
Revision 1.117 2003/05/02 10:28:59 mattias Revision 1.117 2003/05/02 10:28:59 mattias
improved file checking improved file checking

View File

@ -37,7 +37,7 @@ unit ProjectDefs;
interface interface
uses uses
Classes, SysUtils, Laz_XMLCfg, IDEProcs, SynRegExpr, FileCtrl; Classes, SysUtils, Laz_XMLCfg, IDEProcs, SynRegExpr, FileCtrl, PublishModule;
type type
TOnLoadSaveFilename = procedure(var Filename:string; Load:boolean) of object; TOnLoadSaveFilename = procedure(var Filename:string; Load:boolean) of object;
@ -296,69 +296,18 @@ type
{ TPublishProjectOptions } { TPublishProjectOptions }
TPublishProjectOptions = class TPublishProjectOptions = class(TPublishModuleOptions)
private private
FCommandAfter: string;
FDestinationDirectory: string;
FExcludeFileFilter: string;
FExcludeFilterRegExpr: TRegExpr;
FExcludeFilterSimpleSyntax: boolean;
FExcludeFilterValid: boolean;
FIgnoreBinaries: boolean;
FIncludeFileFilter: string;
FIncludeFilterRegExpr: TRegExpr;
FIncludeFilterSimpleSyntax: boolean;
FIncludeFilterValid: boolean;
FSaveClosedEditorFilesInfo: boolean; FSaveClosedEditorFilesInfo: boolean;
FSaveEditorInfoOfNonProjectFiles: boolean; FSaveEditorInfoOfNonProjectFiles: boolean;
FUseExcludeFileFilter: boolean;
FUseIncludeFileFilter: boolean;
procedure SetCommandAfter(const AValue: string);
procedure SetDestinationDirectory(const AValue: string);
procedure SetExcludeFileFilter(const AValue: string);
procedure SetExcludeFilterSimpleSyntax(const AValue: boolean);
procedure SetIgnoreBinaries(const AValue: boolean);
procedure SetIncludeFileFilter(const AValue: string);
procedure SetIncludeFilterSimpleSyntax(const AValue: boolean);
procedure SetSaveClosedEditorFilesInfo(const AValue: boolean); procedure SetSaveClosedEditorFilesInfo(const AValue: boolean);
procedure SetSaveEditorInfoOfNonProjectFiles(const AValue: boolean); procedure SetSaveEditorInfoOfNonProjectFiles(const AValue: boolean);
procedure SetUseExcludeFileFilter(const AValue: boolean);
procedure SetUseIncludeFileFilter(const AValue: boolean);
procedure UpdateIncludeFilter;
procedure UpdateExcludeFilter;
public public
constructor Create; procedure LoadDefaults; override;
destructor Destroy; override; procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const APath: string); override;
procedure Clear; procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const APath: string); override;
procedure LoadDefaults;
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const APath: string);
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const APath: string);
function FileCanBePublished(const AFilename: string): boolean;
function WriteFlags: TProjectWriteFlags; function WriteFlags: TProjectWriteFlags;
public public
// destination
property DestinationDirectory: string
read FDestinationDirectory write SetDestinationDirectory;
property CommandAfter: string read FCommandAfter write SetCommandAfter;
// file filter
property IgnoreBinaries: boolean read FIgnoreBinaries write SetIgnoreBinaries;
property UseIncludeFileFilter: boolean
read FUseIncludeFileFilter write SetUseIncludeFileFilter;
property IncludeFilterSimpleSyntax: boolean
read FIncludeFilterSimpleSyntax write SetIncludeFilterSimpleSyntax;
property IncludeFileFilter: string
read FIncludeFileFilter write SetIncludeFileFilter;
property IncludeFilterValid: boolean read FIncludeFilterValid;
property UseExcludeFileFilter: boolean
read FUseExcludeFileFilter write SetUseExcludeFileFilter;
property ExcludeFilterSimpleSyntax: boolean
read FExcludeFilterSimpleSyntax write SetExcludeFilterSimpleSyntax;
property ExcludeFileFilter: string
read FExcludeFileFilter write SetExcludeFileFilter;
property ExcludeFilterValid: boolean read FExcludeFilterValid;
// project info // project info
property SaveEditorInfoOfNonProjectFiles: boolean property SaveEditorInfoOfNonProjectFiles: boolean
read FSaveEditorInfoOfNonProjectFiles read FSaveEditorInfoOfNonProjectFiles
@ -372,7 +321,6 @@ type
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
const const
PublishProjectOptsVersion = 2;
DefPublProjIncFilter = '*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)'; DefPublProjIncFilter = '*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)';
DefPublProjExcFilter = '*.(bak|ppu|ppw|o|so);*~;backup'; DefPublProjExcFilter = '*.(bak|ppu|ppw|o|so);*~;backup';
@ -1043,54 +991,6 @@ end;
{ TPublishProjectOptions } { TPublishProjectOptions }
procedure TPublishProjectOptions.SetCommandAfter(const AValue: string);
begin
if FCommandAfter=AValue then exit;
FCommandAfter:=AValue;
end;
procedure TPublishProjectOptions.SetDestinationDirectory(const AValue: string);
begin
if FDestinationDirectory=AValue then exit;
FDestinationDirectory:=AValue;
end;
procedure TPublishProjectOptions.SetExcludeFileFilter(const AValue: string);
begin
if FExcludeFileFilter=AValue then exit;
FExcludeFileFilter:=AValue;
UpdateExcludeFilter;
end;
procedure TPublishProjectOptions.SetExcludeFilterSimpleSyntax(
const AValue: boolean);
begin
if FExcludeFilterSimpleSyntax=AValue then exit;
FExcludeFilterSimpleSyntax:=AValue;
UpdateExcludeFilter;
end;
procedure TPublishProjectOptions.SetIgnoreBinaries(const AValue: boolean);
begin
if FIgnoreBinaries=AValue then exit;
FIgnoreBinaries:=AValue;
end;
procedure TPublishProjectOptions.SetIncludeFileFilter(const AValue: string);
begin
if FIncludeFileFilter=AValue then exit;
FIncludeFileFilter:=AValue;
UpdateIncludeFilter;
end;
procedure TPublishProjectOptions.SetIncludeFilterSimpleSyntax(
const AValue: boolean);
begin
if FIncludeFilterSimpleSyntax=AValue then exit;
FIncludeFilterSimpleSyntax:=AValue;
UpdateIncludeFilter;
end;
procedure TPublishProjectOptions.SetSaveClosedEditorFilesInfo( procedure TPublishProjectOptions.SetSaveClosedEditorFilesInfo(
const AValue: boolean); const AValue: boolean);
begin begin
@ -1105,121 +1005,28 @@ begin
FSaveEditorInfoOfNonProjectFiles:=AValue; FSaveEditorInfoOfNonProjectFiles:=AValue;
end; end;
procedure TPublishProjectOptions.SetUseExcludeFileFilter(const AValue: boolean
);
begin
if FUseExcludeFileFilter=AValue then exit;
FUseExcludeFileFilter:=AValue;
end;
procedure TPublishProjectOptions.SetUseIncludeFileFilter(const AValue: boolean
);
begin
if FUseIncludeFileFilter=AValue then exit;
FUseIncludeFileFilter:=AValue;
end;
procedure TPublishProjectOptions.UpdateIncludeFilter;
var
Expr: string;
begin
if FIncludeFilterRegExpr=nil then
FIncludeFilterRegExpr:=TRegExpr.Create;
if IncludeFilterSimpleSyntax then
Expr:=SimpleSyntaxToRegExpr(FIncludeFileFilter)
else
Expr:=FIncludeFileFilter;
try
FIncludeFilterRegExpr.Expression:=Expr;
FIncludeFilterValid:=true;
except
on E: Exception do begin
writeln('Invalid Include File Expression ',Expr,' ',E.Message);
FIncludeFilterValid:=false;
end;
end;
end;
procedure TPublishProjectOptions.UpdateExcludeFilter;
var
Expr: string;
begin
if FExcludeFilterRegExpr=nil then
FExcludeFilterRegExpr:=TRegExpr.Create;
if ExcludeFilterSimpleSyntax then
Expr:=SimpleSyntaxToRegExpr(FExcludeFileFilter)
else
Expr:=FExcludeFileFilter;
try
FExcludeFilterRegExpr.Expression:=Expr;
FExcludeFilterValid:=true;
except
on E: Exception do begin
writeln('Invalid Exclude File Expression ',Expr,' ',E.Message);
FExcludeFilterValid:=false;
end;
end;
end;
constructor TPublishProjectOptions.Create;
begin
LoadDefaults;
end;
destructor TPublishProjectOptions.Destroy;
begin
Clear;
FIncludeFilterRegExpr.Free;
FExcludeFilterRegExpr.Free;
inherited Destroy;
end;
procedure TPublishProjectOptions.Clear;
begin
LoadDefaults;
end;
procedure TPublishProjectOptions.LoadDefaults; procedure TPublishProjectOptions.LoadDefaults;
begin begin
FDestinationDirectory:='$(TestDir)/publishedproject/'; inherited LoadDefaults;
FCommandAfter:=''; DestinationDirectory:='$(TestDir)/publishedproject/';
CommandAfter:='';
UseIncludeFileFilter:=true; UseIncludeFileFilter:=true;
IncludeFilterSimpleSyntax:=true; IncludeFilterSimpleSyntax:=true;
IncludeFileFilter:=DefPublProjIncFilter; IncludeFileFilter:=DefPublProjIncFilter;
UseExcludeFileFilter:=false; UseExcludeFileFilter:=false;
ExcludeFilterSimpleSyntax:=true; ExcludeFilterSimpleSyntax:=true;
ExcludeFileFilter:=DefPublProjExcFilter; ExcludeFileFilter:=DefPublProjExcFilter;
FSaveClosedEditorFilesInfo:=false; SaveClosedEditorFilesInfo:=false;
FSaveEditorInfoOfNonProjectFiles:=false; SaveEditorInfoOfNonProjectFiles:=false;
end; end;
procedure TPublishProjectOptions.LoadFromXMLConfig(XMLConfig: TXMLConfig; procedure TPublishProjectOptions.LoadFromXMLConfig(XMLConfig: TXMLConfig;
const APath: string); const APath: string);
var //var
XMLVersion: integer; // XMLVersion: integer;
begin begin
LoadDefaults; inherited LoadFromXMLConfig(XMLConfig,APath);
XMLVersion:=XMLConfig.GetValue(APath+'Version/Value',0); //XMLVersion:=XMLConfig.GetValue(APath+'Version/Value',0);
FDestinationDirectory:=XMLConfig.GetValue(APath+'DestinationDirectory/Value',
DestinationDirectory);
FCommandAfter:=XMLConfig.GetValue(APath+'CommandAfter/Value',CommandAfter);
IgnoreBinaries:=XMLConfig.GetValue(APath+'IgnoreBinaries/Value',IgnoreBinaries);
UseIncludeFileFilter:=XMLConfig.GetValue(APath+'UseIncludeFileFilter/Value',
UseIncludeFileFilter);
IncludeFilterSimpleSyntax:=
XMLConfig.GetValue(APath+'IncludeFilterSimpleSyntax/Value',
IncludeFilterSimpleSyntax);
if XMLVersion>=2 then
IncludeFileFilter:=XMLConfig.GetValue(APath+'IncludeFileFilter/Value',
IncludeFileFilter);
UseExcludeFileFilter:=XMLConfig.GetValue(APath+'UseExcludeFileFilter/Value',
UseExcludeFileFilter);
ExcludeFilterSimpleSyntax:=
XMLConfig.GetValue(APath+'ExcludeFilterSimpleSyntax/Value',
ExcludeFilterSimpleSyntax);
if XMLVersion>=2 then
ExcludeFileFilter:=XMLConfig.GetValue(APath+'ExcludeFileFilter/Value',
ExcludeFileFilter);
FSaveClosedEditorFilesInfo:=XMLConfig.GetValue( FSaveClosedEditorFilesInfo:=XMLConfig.GetValue(
APath+'SaveClosedEditorFilesInfo/Value',SaveClosedEditorFilesInfo); APath+'SaveClosedEditorFilesInfo/Value',SaveClosedEditorFilesInfo);
FSaveEditorInfoOfNonProjectFiles:=XMLConfig.GetValue( FSaveEditorInfoOfNonProjectFiles:=XMLConfig.GetValue(
@ -1230,51 +1037,13 @@ end;
procedure TPublishProjectOptions.SaveToXMLConfig(XMLConfig: TXMLConfig; procedure TPublishProjectOptions.SaveToXMLConfig(XMLConfig: TXMLConfig;
const APath: string); const APath: string);
begin begin
XMLConfig.SetValue(APath+'Version/Value',PublishProjectOptsVersion); inherited SaveToXMLConfig(XMLConfig,APath);
XMLConfig.SetValue(APath+'DestinationDirectory/Value',DestinationDirectory);
XMLConfig.SetDeleteValue(APath+'CommandAfter/Value',CommandAfter,'');
XMLConfig.SetDeleteValue(APath+'IgnoreBinaries/Value',IgnoreBinaries,true);
XMLConfig.SetDeleteValue(APath+'UseIncludeFileFilter/Value',
UseIncludeFileFilter,true);
XMLConfig.SetDeleteValue(APath+'IncludeFilterSimpleSyntax/Value',
IncludeFilterSimpleSyntax,true);
XMLConfig.SetDeleteValue(APath+'IncludeFileFilter/Value',
IncludeFileFilter,DefPublProjIncFilter);
XMLConfig.SetDeleteValue(APath+'UseExcludeFileFilter/Value',
UseExcludeFileFilter,false);
XMLConfig.SetDeleteValue(APath+'ExcludeFilterSimpleSyntax/Value',
ExcludeFilterSimpleSyntax,true);
XMLConfig.SetDeleteValue(APath+'ExcludeFileFilter/Value',
ExcludeFileFilter,DefPublProjExcFilter);
XMLConfig.SetDeleteValue(APath+'SaveClosedEditorFilesInfo/Value', XMLConfig.SetDeleteValue(APath+'SaveClosedEditorFilesInfo/Value',
SaveClosedEditorFilesInfo,false); SaveClosedEditorFilesInfo,false);
XMLConfig.SetDeleteValue(APath+'SaveEditorInfoOfNonProjectFiles/Value', XMLConfig.SetDeleteValue(APath+'SaveEditorInfoOfNonProjectFiles/Value',
SaveEditorInfoOfNonProjectFiles,false); SaveEditorInfoOfNonProjectFiles,false);
end; end;
function TPublishProjectOptions.FileCanBePublished(
const AFilename: string): boolean;
begin
Result:=false;
// check include filter
if UseIncludeFileFilter
and (FIncludeFilterRegExpr<>nil)
and (not FIncludeFilterRegExpr.Exec(ExtractFilename(AFilename))) then
exit;
// check exclude filter
if UseExcludeFileFilter
and (FExcludeFilterRegExpr<>nil)
and (FExcludeFilterRegExpr.Exec(ExtractFilename(AFilename))) then
exit;
// check binaries
if IgnoreBinaries and (not FileIsText(AFilename)) then exit;
Result:=true;
end;
function TPublishProjectOptions.WriteFlags: TProjectWriteFlags; function TPublishProjectOptions.WriteFlags: TProjectWriteFlags;
begin begin
Result:=[]; Result:=[];

View File

@ -27,6 +27,7 @@
Abstract: Abstract:
- TPublishProjectDialog - TPublishProjectDialog
The dialog for TPublishModuleOptions to publish projects and packages.
} }
unit PublishProjectDlg; unit PublishProjectDlg;
@ -37,8 +38,8 @@ interface
uses uses
Classes, SysUtils, Forms, Controls, Graphics, LResources, Buttons, StdCtrls, Classes, SysUtils, Forms, Controls, Graphics, LResources, Buttons, StdCtrls,
ProjectDefs, IDEOptionDefs, IDEProcs, InputHistory, Dialogs, ProjectDefs, PackageDefs, PublishModule, IDEOptionDefs, IDEProcs,
LazarusIDEStrConsts; InputHistory, Dialogs, LazarusIDEStrConsts;
type type
{ TPublishProjectDialog } { TPublishProjectDialog }
@ -80,30 +81,30 @@ type
procedure PublishProjectDialogResize(Sender: TObject); procedure PublishProjectDialogResize(Sender: TObject);
procedure SaveSettingsButtonClick(Sender: TObject); procedure SaveSettingsButtonClick(Sender: TObject);
private private
FOptions: TPublishProjectOptions; FOptions: TPublishModuleOptions;
procedure SetComboBox(AComboBox: TComboBox; const NewText: string; procedure SetComboBox(AComboBox: TComboBox; const NewText: string;
MaxItemCount: integer); MaxItemCount: integer);
procedure LoadHistoryLists; procedure LoadHistoryLists;
procedure SaveHistoryLists; procedure SaveHistoryLists;
procedure SetOptions(const AValue: TPublishProjectOptions); procedure SetOptions(const AValue: TPublishModuleOptions);
function CheckFilter: boolean; function CheckFilter: boolean;
public public
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
procedure LoadFromOptions(SrcOpts: TPublishProjectOptions); procedure LoadFromOptions(SrcOpts: TPublishModuleOptions);
procedure SaveToOptions(DestOpts: TPublishProjectOptions); procedure SaveToOptions(DestOpts: TPublishModuleOptions);
property Options: TPublishProjectOptions read FOptions write SetOptions; property Options: TPublishModuleOptions read FOptions write SetOptions;
end; end;
function ShowPublishProjectDialog( function ShowPublishProjectDialog(
PublishOptions: TPublishProjectOptions): TModalResult; PublishOptions: TPublishModuleOptions): TModalResult;
implementation implementation
function ShowPublishProjectDialog( function ShowPublishProjectDialog(
PublishOptions: TPublishProjectOptions): TModalResult; PublishOptions: TPublishModuleOptions): TModalResult;
var var
PublishProjectDialog: TPublishProjectDialog; PublishProjectDialog: TPublishProjectDialog;
begin begin
@ -217,17 +218,15 @@ var
begin begin
// destination directories // destination directories
List:=InputHistories.HistoryLists.GetList(hlPublishProjectDestDirs,true); List:=InputHistories.HistoryLists.GetList(hlPublishProjectDestDirs,true);
if List.Count=0 then begin List.AppendEntry('$(TestDir)/publishedproject/');
List.Add('$(TestDir)/publishedproject/'); List.AppendEntry('$(TestDir)/publishedpackage/');
List.Add('$(ProjectDir)/published/'); List.AppendEntry('$(ProjectDir)/published/');
end;
DestDirComboBox.Items.Assign(List); DestDirComboBox.Items.Assign(List);
// command after // command after
List:=InputHistories.HistoryLists.GetList(hlPublishProjectCommandsAfter,true); List:=InputHistories.HistoryLists.GetList(hlPublishProjectCommandsAfter,true);
if List.Count=0 then begin List.AppendEntry('/bin/tar czf project.tgz -C $(TestDir) publishedproject');
List.Add('/bin/tar czf $MakeFile($(ProjPublishDir)).tgz $(ProjPublishDir)'); List.AppendEntry('/bin/tar czf package.tgz -C $(TestDir) publishedpackage');
end;
CommandAfterCombobox.Items.Assign(List); CommandAfterCombobox.Items.Assign(List);
// file filter // file filter
@ -265,7 +264,7 @@ begin
ExcludeFilterCombobox.Items); ExcludeFilterCombobox.Items);
end; end;
procedure TPublishProjectDialog.SetOptions(const AValue: TPublishProjectOptions procedure TPublishProjectDialog.SetOptions(const AValue: TPublishModuleOptions
); );
begin begin
if FOptions=AValue then exit; if FOptions=AValue then exit;
@ -307,8 +306,10 @@ begin
inherited Destroy; inherited Destroy;
end; end;
procedure TPublishProjectDialog.LoadFromOptions(SrcOpts: TPublishProjectOptions procedure TPublishProjectDialog.LoadFromOptions(SrcOpts: TPublishModuleOptions
); );
var
ProjSrcOpts: TPublishProjectOptions;
begin begin
// destination // destination
SetComboBox(DestDirComboBox,SrcOpts.DestinationDirectory,20); SetComboBox(DestDirComboBox,SrcOpts.DestinationDirectory,20);
@ -324,14 +325,22 @@ begin
SetComboBox(ExcludeFilterCombobox,SrcOpts.ExcludeFileFilter,20); SetComboBox(ExcludeFilterCombobox,SrcOpts.ExcludeFileFilter,20);
// project info // project info
SaveEditorInfoOfNonProjectFilesCheckbox.Checked:= if SrcOpts is TPublishProjectOptions then begin
SrcOpts.SaveEditorInfoOfNonProjectFiles; ProjSrcOpts:=TPublishProjectOptions(SrcOpts);
SaveClosedEditorFilesInfoCheckbox.Checked:= SaveEditorInfoOfNonProjectFilesCheckbox.Checked:=
SrcOpts.SaveClosedEditorFilesInfo; ProjSrcOpts.SaveEditorInfoOfNonProjectFiles;
SaveClosedEditorFilesInfoCheckbox.Checked:=
ProjSrcOpts.SaveClosedEditorFilesInfo;
ProjectInfoGroupbox.Enabled:=true;
end else begin
ProjectInfoGroupbox.Enabled:=false;
end;
end; end;
procedure TPublishProjectDialog.SaveToOptions(DestOpts: TPublishProjectOptions procedure TPublishProjectDialog.SaveToOptions(DestOpts: TPublishModuleOptions
); );
var
ProjDestOpts: TPublishProjectOptions;
begin begin
// destination // destination
DestOpts.DestinationDirectory:=DestDirComboBox.Text; DestOpts.DestinationDirectory:=DestDirComboBox.Text;
@ -347,10 +356,13 @@ begin
DestOpts.ExcludeFileFilter:=ExcludeFilterCombobox.Text; DestOpts.ExcludeFileFilter:=ExcludeFilterCombobox.Text;
// project info // project info
DestOpts.SaveEditorInfoOfNonProjectFiles:= if DestOpts is TPublishProjectOptions then begin
SaveEditorInfoOfNonProjectFilesCheckbox.Checked; ProjDestOpts:=TPublishProjectOptions(DestOpts);
DestOpts.SaveClosedEditorFilesInfo:= ProjDestOpts.SaveEditorInfoOfNonProjectFiles:=
SaveClosedEditorFilesInfoCheckbox.Checked; SaveEditorInfoOfNonProjectFilesCheckbox.Checked;
ProjDestOpts.SaveClosedEditorFilesInfo:=
SaveClosedEditorFilesInfoCheckbox.Checked;
end;
end; end;
initialization initialization

View File

@ -407,7 +407,7 @@ end;
function TTransferMacroList.MF_Path(const Filename:string; function TTransferMacroList.MF_Path(const Filename:string;
var Abort: boolean):string; var Abort: boolean):string;
begin begin
Result:=ExtractFilePath(Filename); Result:=TrimFilename(ExtractFilePath(Filename));
end; end;
function TTransferMacroList.MF_Name(const Filename:string; function TTransferMacroList.MF_Name(const Filename:string;
@ -431,6 +431,7 @@ begin
Result:=Filename; Result:=Filename;
if (Result<>'') and (Result[length(Result)]<>PathDelim) then if (Result<>'') and (Result[length(Result)]<>PathDelim) then
Result:=Result+PathDelim; Result:=Result+PathDelim;
Result:=TrimFilename(Result);
end; end;
function TTransferMacroList.MF_MakeFile(const Filename: string; function TTransferMacroList.MF_MakeFile(const Filename: string;
@ -445,6 +446,9 @@ begin
inc(ChompLen); inc(ChompLen);
if ChompLen>0 then if ChompLen>0 then
Result:=LeftStr(Result,length(Filename)-ChompLen); Result:=LeftStr(Result,length(Filename)-ChompLen);
writeln('TTransferMacroList.MF_MakeFile A "',Result,'"');
Result:=TrimFilename(Result);
writeln('TTransferMacroList.MF_MakeFile B "',Result,'"');
end; end;
function TTransferMacroList.MF_Trim(const Filename: string; var Abort: boolean function TTransferMacroList.MF_Trim(const Filename: string; var Abort: boolean

View File

@ -48,7 +48,7 @@ uses
Classes, SysUtils, LCLProc, LResources, Graphics, Laz_XMLCfg, AVL_Tree, Classes, SysUtils, LCLProc, LResources, Graphics, Laz_XMLCfg, AVL_Tree,
DefineTemplates, CodeToolManager, EditDefineTree, CompilerOptions, Forms, DefineTemplates, CodeToolManager, EditDefineTree, CompilerOptions, Forms,
FileCtrl, LazarusIDEStrConsts, IDEProcs, ComponentReg, TransferMacros, FileCtrl, LazarusIDEStrConsts, IDEProcs, ComponentReg, TransferMacros,
FileReferenceList; FileReferenceList, PublishModule;
type type
TLazPackage = class; TLazPackage = class;
@ -334,7 +334,20 @@ type
property Version: TPkgVersion read FVersion; property Version: TPkgVersion read FVersion;
property IDAsString: string read FIDAsString; property IDAsString: string read FIDAsString;
end; end;
{ TPublishPackageOptions }
TPublishPackageOptions = class(TPublishModuleOptions)
private
FLazPackage: TLazPackage;
protected
procedure DoOnModifyChange; override;
public
constructor Create(TheLazPackage: TLazPackage);
function GetDefaultDestinationDir: string; override;
property LazPackage: TLazPackage read FLazPackage;
end;
{ TLazPackageDefineTemplates } { TLazPackageDefineTemplates }
@ -459,6 +472,7 @@ type
FOutputStateFile: string; FOutputStateFile: string;
FPackageEditor: TBasePackageEditor; FPackageEditor: TBasePackageEditor;
FPackageType: TLazPackageType; FPackageType: TLazPackageType;
fPublishOptions: TPublishPackageOptions;
FRemovedFiles: TList; // TList of TPkgFile FRemovedFiles: TList; // TList of TPkgFile
FRegistered: boolean; FRegistered: boolean;
FSourceDirectories: TFileReferenceList; FSourceDirectories: TFileReferenceList;
@ -619,6 +633,8 @@ type
write SetPackageType; write SetPackageType;
property UserReadOnly: boolean read FUserReadOnly write SetUserReadOnly; property UserReadOnly: boolean read FUserReadOnly write SetUserReadOnly;
property FileReadOnly: boolean read FFileReadOnly write SetFileReadOnly; property FileReadOnly: boolean read FFileReadOnly write SetFileReadOnly;
property PublishOptions: TPublishPackageOptions
read fPublishOptions write fPublishOptions;
property Registered: boolean read FRegistered write SetRegistered; property Registered: boolean read FRegistered write SetRegistered;
property RemovedFilesCount: integer read GetRemovedCount; property RemovedFilesCount: integer read GetRemovedCount;
property RemovedFiles[Index: integer]: TPkgFile read GetRemovedFiles; property RemovedFiles[Index: integer]: TPkgFile read GetRemovedFiles;
@ -1763,6 +1779,8 @@ begin
else else
Exclude(FFlags,lpfModified); Exclude(FFlags,lpfModified);
Exclude(FFlags,lpfSkipSaving); Exclude(FFlags,lpfSkipSaving);
if not AValue then
PublishOptions.Modified:=false;
end; end;
procedure TLazPackage.SetName(const AValue: string); procedure TLazPackage.SetName(const AValue: string);
@ -1804,6 +1822,7 @@ begin
FUsageOptions:=TPkgAdditionalCompilerOptions.Create(Self); FUsageOptions:=TPkgAdditionalCompilerOptions.Create(Self);
FUsageOptions.ParsedOpts.OnLocalSubstitute:=@SubstitutePkgMacro; FUsageOptions.ParsedOpts.OnLocalSubstitute:=@SubstitutePkgMacro;
FDefineTemplates:=TLazPackageDefineTemplates.Create(Self); FDefineTemplates:=TLazPackageDefineTemplates.Create(Self);
fPublishOptions:=TPublishPackageOptions.Create(Self);
Clear; Clear;
end; end;
@ -1811,6 +1830,7 @@ destructor TLazPackage.Destroy;
begin begin
Include(FFlags,lpfDestroying); Include(FFlags,lpfDestroying);
Clear; Clear;
FreeAndNil(fPublishOptions);
FreeAndNil(FDefineTemplates); FreeAndNil(FDefineTemplates);
FreeAndNil(FRemovedFiles); FreeAndNil(FRemovedFiles);
FreeAndNil(FFiles); FreeAndNil(FFiles);
@ -1869,6 +1889,7 @@ begin
FPackageType:=lptRunAndDesignTime; FPackageType:=lptRunAndDesignTime;
FRegistered:=false; FRegistered:=false;
FUsageOptions.Clear; FUsageOptions.Clear;
fPublishOptions.Clear;
UpdateSourceDirectories; UpdateSourceDirectories;
// set some nice start values // set some nice start values
if not (lpfDestroying in FFlags) then begin if not (lpfDestroying in FFlags) then begin
@ -1977,6 +1998,7 @@ begin
LoadPkgDependencyList(XMLConfig,Path+'RequiredPkgs/', LoadPkgDependencyList(XMLConfig,Path+'RequiredPkgs/',
FFirstRequiredDependency,pdlRequires,Self,false); FFirstRequiredDependency,pdlRequires,Self,false);
FUsageOptions.LoadFromXMLConfig(XMLConfig,Path+'UsageOptions/'); FUsageOptions.LoadFromXMLConfig(XMLConfig,Path+'UsageOptions/');
fPublishOptions.LoadFromXMLConfig(XMLConfig,Path+'PublishOptions/');
EndUpdate; EndUpdate;
Modified:=false; Modified:=false;
UnlockModified; UnlockModified;
@ -2023,6 +2045,7 @@ begin
SavePkgDependencyList(XMLConfig,Path+'RequiredPkgs/', SavePkgDependencyList(XMLConfig,Path+'RequiredPkgs/',
FFirstRequiredDependency,pdlRequires); FFirstRequiredDependency,pdlRequires);
FUsageOptions.SaveToXMLConfig(XMLConfig,Path+'UsageOptions/'); FUsageOptions.SaveToXMLConfig(XMLConfig,Path+'UsageOptions/');
fPublishOptions.SaveToXMLConfig(XMLConfig,Path+'PublishOptions/');
Modified:=false; Modified:=false;
end; end;
@ -2978,6 +3001,24 @@ begin
Result:=nil; Result:=nil;
end; end;
{ TPublishPackageOptions }
procedure TPublishPackageOptions.DoOnModifyChange;
begin
if Modified then LazPackage.Modified:=true;
end;
constructor TPublishPackageOptions.Create(TheLazPackage: TLazPackage);
begin
FLazPackage:=TheLazPackage;
inherited Create(FLazPackage);
end;
function TPublishPackageOptions.GetDefaultDestinationDir: string;
begin
Result:='$(TestDir)/publishedpackage/';
end;
initialization initialization
PackageDependencies:=TAVLTree.Create(@ComparePkgDependencyNames); PackageDependencies:=TAVLTree.Create(@ComparePkgDependencyNames);

View File

@ -54,6 +54,8 @@ type
SaveAs: boolean): TModalResult of object; SaveAs: boolean): TModalResult of object;
TOnRevertPackage = TOnRevertPackage =
function(Sender: TObject; APackage: TLazPackage): TModalResult of object; function(Sender: TObject; APackage: TLazPackage): TModalResult of object;
TOnPublishPackage =
function(Sender: TObject; APackage: TLazPackage): TModalResult of object;
TOnCompilePackage = TOnCompilePackage =
function(Sender: TObject; APackage: TLazPackage; function(Sender: TObject; APackage: TLazPackage;
CompileClean, CompileRequired: boolean): TModalResult of object; CompileClean, CompileRequired: boolean): TModalResult of object;
@ -135,6 +137,7 @@ type
procedure PackageEditorFormClose(Sender: TObject; var Action: TCloseAction); procedure PackageEditorFormClose(Sender: TObject; var Action: TCloseAction);
procedure PackageEditorFormCloseQuery(Sender: TObject; var CanClose: boolean); procedure PackageEditorFormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure PackageEditorFormResize(Sender: TObject); procedure PackageEditorFormResize(Sender: TObject);
procedure PublishClick(Sender: TObject);
procedure ReAddMenuItemClick(Sender: TObject); procedure ReAddMenuItemClick(Sender: TObject);
procedure RegisteredListBoxDrawItem(Control: TWinControl; Index: Integer; procedure RegisteredListBoxDrawItem(Control: TWinControl; Index: Integer;
ARect: TRect; State: TOwnerDrawState); ARect: TRect; State: TOwnerDrawState);
@ -173,6 +176,7 @@ type
procedure DoSave(SaveAs: boolean); procedure DoSave(SaveAs: boolean);
procedure DoCompile(CompileClean, CompileRequired: boolean); procedure DoCompile(CompileClean, CompileRequired: boolean);
procedure DoRevert; procedure DoRevert;
procedure DoPublishProject;
public public
property LazPackage: TLazPackage read FLazPackage write SetLazPackage; property LazPackage: TLazPackage read FLazPackage write SetLazPackage;
end; end;
@ -193,6 +197,7 @@ type
FOnInstallPackage: TOnInstallPackage; FOnInstallPackage: TOnInstallPackage;
FOnOpenFile: TOnOpenFile; FOnOpenFile: TOnOpenFile;
FOnOpenPackage: TOnOpenPackage; FOnOpenPackage: TOnOpenPackage;
FOnPublishPackage: TOnPublishPackage;
FOnRevertPackage: TOnRevertPackage; FOnRevertPackage: TOnRevertPackage;
FOnSavePackage: TOnSavePackage; FOnSavePackage: TOnSavePackage;
FOnUninstallPackage: TOnUninstallPackage; FOnUninstallPackage: TOnUninstallPackage;
@ -219,6 +224,7 @@ type
const Params: TAddToPkgResult): TModalResult; const Params: TAddToPkgResult): TModalResult;
function SavePackage(APackage: TLazPackage; SaveAs: boolean): TModalResult; function SavePackage(APackage: TLazPackage; SaveAs: boolean): TModalResult;
function RevertPackage(APackage: TLazPackage): TModalResult; function RevertPackage(APackage: TLazPackage): TModalResult;
function PublishPackage(APackage: TLazPackage): TModalResult;
function CompilePackage(APackage: TLazPackage; function CompilePackage(APackage: TLazPackage;
CompileClean,CompileRequired: boolean): TModalResult; CompileClean,CompileRequired: boolean): TModalResult;
procedure UpdateAllEditors; procedure UpdateAllEditors;
@ -243,6 +249,8 @@ type
write FOnSavePackage; write FOnSavePackage;
property OnRevertPackage: TOnRevertPackage read FOnRevertPackage property OnRevertPackage: TOnRevertPackage read FOnRevertPackage
write FOnRevertPackage; write FOnRevertPackage;
property OnPublishPackage: TOnPublishPackage read FOnPublishPackage
write FOnPublishPackage;
property OnCompilePackage: TOnCompilePackage read FOnCompilePackage property OnCompilePackage: TOnCompilePackage read FOnCompilePackage
write FOnCompilePackage; write FOnCompilePackage;
property OnInstallPackage: TOnInstallPackage read FOnInstallPackage property OnInstallPackage: TOnInstallPackage read FOnInstallPackage
@ -339,6 +347,11 @@ begin
FilePropsGroupBox.SetBounds(x,y,w,h); FilePropsGroupBox.SetBounds(x,y,w,h);
end; end;
procedure TPackageEditorForm.PublishClick(Sender: TObject);
begin
DoPublishProject;
end;
procedure TPackageEditorForm.ReAddMenuItemClick(Sender: TObject); procedure TPackageEditorForm.ReAddMenuItemClick(Sender: TObject);
var var
PkgFile: TPkgFile; PkgFile: TPkgFile;
@ -459,7 +472,10 @@ begin
AddPopupMenuItem(lisMenuSave, @SaveBitBtnClick, SaveBitBtn.Enabled); AddPopupMenuItem(lisMenuSave, @SaveBitBtnClick, SaveBitBtn.Enabled);
AddPopupMenuItem(lisMenuSaveAs, @SaveAsClick, not LazPackage.AutoCreated); AddPopupMenuItem(lisMenuSaveAs, @SaveAsClick, not LazPackage.AutoCreated);
AddPopupMenuItem(lisMenuRevert, @RevertClick, not LazPackage.AutoCreated); AddPopupMenuItem(lisMenuRevert, @RevertClick, (not LazPackage.AutoCreated) and
FileExists(LazPackage.Filename));
AddPopupMenuItem(lisPkgEditPublishPackage, @PublishClick,
(not LazPackage.AutoCreated) and (LazPackage.HasDirectory));
AddPopupMenuItem('-',nil,true); AddPopupMenuItem('-',nil,true);
AddPopupMenuItem(lisPckEditCompile, @CompileBitBtnClick, CompileBitBtn.Enabled AddPopupMenuItem(lisPckEditCompile, @CompileBitBtnClick, CompileBitBtn.Enabled
); );
@ -1637,10 +1653,21 @@ end;
procedure TPackageEditorForm.DoRevert; procedure TPackageEditorForm.DoRevert;
begin begin
if MessageDlg(lisPkgEditRevertPackage,
Format(lisPkgEditDoYouReallyWantToForgetAllChangesToPackageAnd, [
LazPackage.IDAsString]),
mtConfirmation,[mbYes,mbNo],0)<>mrYes
then exit;
PackageEditors.RevertPackage(LazPackage); PackageEditors.RevertPackage(LazPackage);
UpdateAll; UpdateAll;
end; end;
procedure TPackageEditorForm.DoPublishProject;
begin
PackageEditors.PublishPackage(LazPackage);
UpdateAll;
end;
constructor TPackageEditorForm.Create(TheOwner: TComponent); constructor TPackageEditorForm.Create(TheOwner: TComponent);
begin begin
inherited Create(TheOwner); inherited Create(TheOwner);
@ -1936,6 +1963,12 @@ begin
Result:=OnRevertPackage(Self,APackage); Result:=OnRevertPackage(Self,APackage);
end; end;
function TPackageEditors.PublishPackage(APackage: TLazPackage): TModalResult;
begin
if Assigned(OnPublishPackage) then
Result:=OnPublishPackage(Self,APackage);
end;
{ TPackageEditorLayout } { TPackageEditorLayout }
constructor TPackageEditorLayout.Create; constructor TPackageEditorLayout.Create;

View File

@ -52,7 +52,7 @@ uses
PackageSystem, OpenInstalledPkgDlg, PkgGraphExplorer, BrokenDependenciesDlg, PackageSystem, OpenInstalledPkgDlg, PkgGraphExplorer, BrokenDependenciesDlg,
CompilerOptions, ExtToolDialog, ExtToolEditDlg, EditDefineTree, CompilerOptions, ExtToolDialog, ExtToolEditDlg, EditDefineTree,
BuildLazDialog, DefineTemplates, LazConf, ProjectInspector, ComponentPalette, BuildLazDialog, DefineTemplates, LazConf, ProjectInspector, ComponentPalette,
UnitEditor, AddFileToAPackageDlg, LazarusPackageIntf, UnitEditor, AddFileToAPackageDlg, LazarusPackageIntf, PublishProjectDlg,
BasePkgManager, MainBar; BasePkgManager, MainBar;
type type
@ -68,6 +68,8 @@ type
APackage: TLazPackage; const Filename: string): TModalResult; APackage: TLazPackage; const Filename: string): TModalResult;
function OnPackageEditorInstallPackage(Sender: TObject; function OnPackageEditorInstallPackage(Sender: TObject;
APackage: TLazPackage): TModalResult; APackage: TLazPackage): TModalResult;
function OnPackageEditorPublishPackage(Sender: TObject;
APackage: TLazPackage): TModalResult;
function OnPackageEditorRevertPackage(Sender: TObject; APackage: TLazPackage function OnPackageEditorRevertPackage(Sender: TObject; APackage: TLazPackage
): TModalResult; ): TModalResult;
function OnPackageEditorUninstallPackage(Sender: TObject; function OnPackageEditorUninstallPackage(Sender: TObject;
@ -149,6 +151,7 @@ type
// files // files
function GetDefaultSaveDirectoryForFile(const Filename: string): string; override; function GetDefaultSaveDirectoryForFile(const Filename: string): string; override;
function GetPublishPackageDir(APackage: TLazPackage): string;
function OnRenameFile(const OldFilename, function OnRenameFile(const OldFilename,
NewFilename: string): TModalResult; override; NewFilename: string): TModalResult; override;
@ -197,6 +200,8 @@ type
): TModalResult; override; ): TModalResult; override;
function DoSaveAutoInstallConfig: TModalResult; override; function DoSaveAutoInstallConfig: TModalResult; override;
function DoGetIDEInstallPackageOptions: string; override; function DoGetIDEInstallPackageOptions: string; override;
function DoPublishPackage(APackage: TLazPackage; Flags: TPkgSaveFlags;
ShowDialog: boolean): TModalResult;
end; end;
implementation implementation
@ -350,10 +355,17 @@ begin
Result:=DoInstallPackage(APackage); Result:=DoInstallPackage(APackage);
end; end;
function TPkgManager.OnPackageEditorPublishPackage(Sender: TObject;
APackage: TLazPackage): TModalResult;
begin
Result:=DoPublishPackage(APackage,[],true);
end;
function TPkgManager.OnPackageEditorRevertPackage(Sender: TObject; function TPkgManager.OnPackageEditorRevertPackage(Sender: TObject;
APackage: TLazPackage): TModalResult; APackage: TLazPackage): TModalResult;
begin begin
if APackage.AutoCreated or (not FilenameIsAbsolute(APackage.Filename)) then if APackage.AutoCreated or (not FilenameIsAbsolute(APackage.Filename))
or (not FileExists(APackage.Filename)) then
exit; exit;
Result:=DoOpenPackageFile(APackage.Filename,[pofRevert]); Result:=DoOpenPackageFile(APackage.Filename,[pofRevert]);
end; end;
@ -1249,6 +1261,7 @@ begin
PackageEditors.OnFreeEditor:=@OnPackageEditorFreeEditor; PackageEditors.OnFreeEditor:=@OnPackageEditorFreeEditor;
PackageEditors.OnSavePackage:=@OnPackageEditorSavePackage; PackageEditors.OnSavePackage:=@OnPackageEditorSavePackage;
PackageEditors.OnRevertPackage:=@OnPackageEditorRevertPackage; PackageEditors.OnRevertPackage:=@OnPackageEditorRevertPackage;
PackageEditors.OnPublishPackage:=@OnPackageEditorPublishPackage;
PackageEditors.OnCompilePackage:=@OnPackageEditorCompilePackage; PackageEditors.OnCompilePackage:=@OnPackageEditorCompilePackage;
PackageEditors.OnInstallPackage:=@OnPackageEditorInstallPackage; PackageEditors.OnInstallPackage:=@OnPackageEditorInstallPackage;
PackageEditors.OnUninstallPackage:=@OnPackageEditorUninstallPackage; PackageEditors.OnUninstallPackage:=@OnPackageEditorUninstallPackage;
@ -1341,6 +1354,20 @@ begin
Result:=APackage.Directory; Result:=APackage.Directory;
end; end;
function TPkgManager.GetPublishPackageDir(APackage: TLazPackage): string;
begin
Result:=APackage.PublishOptions.DestinationDirectory;
if MainIDE.MacroList.SubstituteStr(Result) then begin
if FilenameIsAbsolute(Result) then begin
Result:=AppendPathDelim(TrimFilename(Result));
end else begin
Result:='';
end;
end else begin
Result:='';
end;
end;
procedure TPkgManager.LoadInstalledPackages; procedure TPkgManager.LoadInstalledPackages;
begin begin
IDEComponentPalette.BeginUpdate(true); IDEComponentPalette.BeginUpdate(true);
@ -2405,6 +2432,24 @@ begin
AddOption('-FE'+TargetDir);} AddOption('-FE'+TargetDir);}
end; end;
function TPkgManager.DoPublishPackage(APackage: TLazPackage;
Flags: TPkgSaveFlags; ShowDialog: boolean): TModalResult;
begin
// show the publish dialog
if ShowDialog then begin
Result:=ShowPublishProjectDialog(APackage.PublishOptions);
if Result<>mrOk then exit;
end;
// save package
Result:=DoSavePackage(APackage,Flags);
if Result<>mrOk then exit;
// publish package
Result:=MainIDE.DoPublishModul(APackage.PublishOptions,APackage.Directory,
GetPublishPackageDir(APackage));
end;
function TPkgManager.OnProjectInspectorOpen(Sender: TObject): boolean; function TPkgManager.OnProjectInspectorOpen(Sender: TObject): boolean;
var var
Dependency: TPkgDependency; Dependency: TPkgDependency;