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>
<UnitPath Value="$(PkgOutDir)"/>
</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>
<CompilerOptions>
<SearchPaths>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -37,7 +37,7 @@ unit ProjectDefs;
interface
uses
Classes, SysUtils, Laz_XMLCfg, IDEProcs, SynRegExpr, FileCtrl;
Classes, SysUtils, Laz_XMLCfg, IDEProcs, SynRegExpr, FileCtrl, PublishModule;
type
TOnLoadSaveFilename = procedure(var Filename:string; Load:boolean) of object;
@ -296,69 +296,18 @@ type
{ TPublishProjectOptions }
TPublishProjectOptions = class
TPublishProjectOptions = class(TPublishModuleOptions)
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;
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 SetSaveEditorInfoOfNonProjectFiles(const AValue: boolean);
procedure SetUseExcludeFileFilter(const AValue: boolean);
procedure SetUseIncludeFileFilter(const AValue: boolean);
procedure UpdateIncludeFilter;
procedure UpdateExcludeFilter;
public
constructor Create;
destructor Destroy; override;
procedure Clear;
procedure LoadDefaults;
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const APath: string);
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const APath: string);
function FileCanBePublished(const AFilename: string): boolean;
procedure LoadDefaults; override;
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const APath: string); override;
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const APath: string); override;
function WriteFlags: TProjectWriteFlags;
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
property SaveEditorInfoOfNonProjectFiles: boolean
read FSaveEditorInfoOfNonProjectFiles
@ -372,7 +321,6 @@ type
//---------------------------------------------------------------------------
const
PublishProjectOptsVersion = 2;
DefPublProjIncFilter = '*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)';
DefPublProjExcFilter = '*.(bak|ppu|ppw|o|so);*~;backup';
@ -1043,54 +991,6 @@ end;
{ 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(
const AValue: boolean);
begin
@ -1105,121 +1005,28 @@ begin
FSaveEditorInfoOfNonProjectFiles:=AValue;
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;
begin
FDestinationDirectory:='$(TestDir)/publishedproject/';
FCommandAfter:='';
inherited LoadDefaults;
DestinationDirectory:='$(TestDir)/publishedproject/';
CommandAfter:='';
UseIncludeFileFilter:=true;
IncludeFilterSimpleSyntax:=true;
IncludeFileFilter:=DefPublProjIncFilter;
UseExcludeFileFilter:=false;
ExcludeFilterSimpleSyntax:=true;
ExcludeFileFilter:=DefPublProjExcFilter;
FSaveClosedEditorFilesInfo:=false;
FSaveEditorInfoOfNonProjectFiles:=false;
SaveClosedEditorFilesInfo:=false;
SaveEditorInfoOfNonProjectFiles:=false;
end;
procedure TPublishProjectOptions.LoadFromXMLConfig(XMLConfig: TXMLConfig;
const APath: string);
var
XMLVersion: integer;
//var
// XMLVersion: integer;
begin
LoadDefaults;
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);
inherited LoadFromXMLConfig(XMLConfig,APath);
//XMLVersion:=XMLConfig.GetValue(APath+'Version/Value',0);
FSaveClosedEditorFilesInfo:=XMLConfig.GetValue(
APath+'SaveClosedEditorFilesInfo/Value',SaveClosedEditorFilesInfo);
FSaveEditorInfoOfNonProjectFiles:=XMLConfig.GetValue(
@ -1230,51 +1037,13 @@ end;
procedure TPublishProjectOptions.SaveToXMLConfig(XMLConfig: TXMLConfig;
const APath: string);
begin
XMLConfig.SetValue(APath+'Version/Value',PublishProjectOptsVersion);
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);
inherited SaveToXMLConfig(XMLConfig,APath);
XMLConfig.SetDeleteValue(APath+'SaveClosedEditorFilesInfo/Value',
SaveClosedEditorFilesInfo,false);
XMLConfig.SetDeleteValue(APath+'SaveEditorInfoOfNonProjectFiles/Value',
SaveEditorInfoOfNonProjectFiles,false);
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;
begin
Result:=[];

View File

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

View File

@ -407,7 +407,7 @@ end;
function TTransferMacroList.MF_Path(const Filename:string;
var Abort: boolean):string;
begin
Result:=ExtractFilePath(Filename);
Result:=TrimFilename(ExtractFilePath(Filename));
end;
function TTransferMacroList.MF_Name(const Filename:string;
@ -431,6 +431,7 @@ begin
Result:=Filename;
if (Result<>'') and (Result[length(Result)]<>PathDelim) then
Result:=Result+PathDelim;
Result:=TrimFilename(Result);
end;
function TTransferMacroList.MF_MakeFile(const Filename: string;
@ -445,6 +446,9 @@ begin
inc(ChompLen);
if ChompLen>0 then
Result:=LeftStr(Result,length(Filename)-ChompLen);
writeln('TTransferMacroList.MF_MakeFile A "',Result,'"');
Result:=TrimFilename(Result);
writeln('TTransferMacroList.MF_MakeFile B "',Result,'"');
end;
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,
DefineTemplates, CodeToolManager, EditDefineTree, CompilerOptions, Forms,
FileCtrl, LazarusIDEStrConsts, IDEProcs, ComponentReg, TransferMacros,
FileReferenceList;
FileReferenceList, PublishModule;
type
TLazPackage = class;
@ -334,7 +334,20 @@ type
property Version: TPkgVersion read FVersion;
property IDAsString: string read FIDAsString;
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 }
@ -459,6 +472,7 @@ type
FOutputStateFile: string;
FPackageEditor: TBasePackageEditor;
FPackageType: TLazPackageType;
fPublishOptions: TPublishPackageOptions;
FRemovedFiles: TList; // TList of TPkgFile
FRegistered: boolean;
FSourceDirectories: TFileReferenceList;
@ -619,6 +633,8 @@ type
write SetPackageType;
property UserReadOnly: boolean read FUserReadOnly write SetUserReadOnly;
property FileReadOnly: boolean read FFileReadOnly write SetFileReadOnly;
property PublishOptions: TPublishPackageOptions
read fPublishOptions write fPublishOptions;
property Registered: boolean read FRegistered write SetRegistered;
property RemovedFilesCount: integer read GetRemovedCount;
property RemovedFiles[Index: integer]: TPkgFile read GetRemovedFiles;
@ -1763,6 +1779,8 @@ begin
else
Exclude(FFlags,lpfModified);
Exclude(FFlags,lpfSkipSaving);
if not AValue then
PublishOptions.Modified:=false;
end;
procedure TLazPackage.SetName(const AValue: string);
@ -1804,6 +1822,7 @@ begin
FUsageOptions:=TPkgAdditionalCompilerOptions.Create(Self);
FUsageOptions.ParsedOpts.OnLocalSubstitute:=@SubstitutePkgMacro;
FDefineTemplates:=TLazPackageDefineTemplates.Create(Self);
fPublishOptions:=TPublishPackageOptions.Create(Self);
Clear;
end;
@ -1811,6 +1830,7 @@ destructor TLazPackage.Destroy;
begin
Include(FFlags,lpfDestroying);
Clear;
FreeAndNil(fPublishOptions);
FreeAndNil(FDefineTemplates);
FreeAndNil(FRemovedFiles);
FreeAndNil(FFiles);
@ -1869,6 +1889,7 @@ begin
FPackageType:=lptRunAndDesignTime;
FRegistered:=false;
FUsageOptions.Clear;
fPublishOptions.Clear;
UpdateSourceDirectories;
// set some nice start values
if not (lpfDestroying in FFlags) then begin
@ -1977,6 +1998,7 @@ begin
LoadPkgDependencyList(XMLConfig,Path+'RequiredPkgs/',
FFirstRequiredDependency,pdlRequires,Self,false);
FUsageOptions.LoadFromXMLConfig(XMLConfig,Path+'UsageOptions/');
fPublishOptions.LoadFromXMLConfig(XMLConfig,Path+'PublishOptions/');
EndUpdate;
Modified:=false;
UnlockModified;
@ -2023,6 +2045,7 @@ begin
SavePkgDependencyList(XMLConfig,Path+'RequiredPkgs/',
FFirstRequiredDependency,pdlRequires);
FUsageOptions.SaveToXMLConfig(XMLConfig,Path+'UsageOptions/');
fPublishOptions.SaveToXMLConfig(XMLConfig,Path+'PublishOptions/');
Modified:=false;
end;
@ -2978,6 +3001,24 @@ begin
Result:=nil;
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
PackageDependencies:=TAVLTree.Create(@ComparePkgDependencyNames);

View File

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

View File

@ -52,7 +52,7 @@ uses
PackageSystem, OpenInstalledPkgDlg, PkgGraphExplorer, BrokenDependenciesDlg,
CompilerOptions, ExtToolDialog, ExtToolEditDlg, EditDefineTree,
BuildLazDialog, DefineTemplates, LazConf, ProjectInspector, ComponentPalette,
UnitEditor, AddFileToAPackageDlg, LazarusPackageIntf,
UnitEditor, AddFileToAPackageDlg, LazarusPackageIntf, PublishProjectDlg,
BasePkgManager, MainBar;
type
@ -68,6 +68,8 @@ type
APackage: TLazPackage; const Filename: string): TModalResult;
function OnPackageEditorInstallPackage(Sender: TObject;
APackage: TLazPackage): TModalResult;
function OnPackageEditorPublishPackage(Sender: TObject;
APackage: TLazPackage): TModalResult;
function OnPackageEditorRevertPackage(Sender: TObject; APackage: TLazPackage
): TModalResult;
function OnPackageEditorUninstallPackage(Sender: TObject;
@ -149,6 +151,7 @@ type
// files
function GetDefaultSaveDirectoryForFile(const Filename: string): string; override;
function GetPublishPackageDir(APackage: TLazPackage): string;
function OnRenameFile(const OldFilename,
NewFilename: string): TModalResult; override;
@ -197,6 +200,8 @@ type
): TModalResult; override;
function DoSaveAutoInstallConfig: TModalResult; override;
function DoGetIDEInstallPackageOptions: string; override;
function DoPublishPackage(APackage: TLazPackage; Flags: TPkgSaveFlags;
ShowDialog: boolean): TModalResult;
end;
implementation
@ -350,10 +355,17 @@ begin
Result:=DoInstallPackage(APackage);
end;
function TPkgManager.OnPackageEditorPublishPackage(Sender: TObject;
APackage: TLazPackage): TModalResult;
begin
Result:=DoPublishPackage(APackage,[],true);
end;
function TPkgManager.OnPackageEditorRevertPackage(Sender: TObject;
APackage: TLazPackage): TModalResult;
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;
Result:=DoOpenPackageFile(APackage.Filename,[pofRevert]);
end;
@ -1249,6 +1261,7 @@ begin
PackageEditors.OnFreeEditor:=@OnPackageEditorFreeEditor;
PackageEditors.OnSavePackage:=@OnPackageEditorSavePackage;
PackageEditors.OnRevertPackage:=@OnPackageEditorRevertPackage;
PackageEditors.OnPublishPackage:=@OnPackageEditorPublishPackage;
PackageEditors.OnCompilePackage:=@OnPackageEditorCompilePackage;
PackageEditors.OnInstallPackage:=@OnPackageEditorInstallPackage;
PackageEditors.OnUninstallPackage:=@OnPackageEditorUninstallPackage;
@ -1341,6 +1354,20 @@ begin
Result:=APackage.Directory;
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;
begin
IDEComponentPalette.BeginUpdate(true);
@ -2405,6 +2432,24 @@ begin
AddOption('-FE'+TargetDir);}
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;
var
Dependency: TPkgDependency;