From 00b45080cac5a6605f0e67418b9e476cf06b0368 Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 6 Sep 2013 13:55:32 +0000 Subject: [PATCH] IDE: package editor: disable Compile button if package has no commands git-svn-id: trunk@42639 - --- ide/compileroptions.pp | 19 +++++++++++++++++++ packager/packageeditor.pas | 8 +++++--- packager/packagesystem.pas | 6 ++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/ide/compileroptions.pp b/ide/compileroptions.pp index 6cd69f1979..d4bf57b746 100644 --- a/ide/compileroptions.pp +++ b/ide/compileroptions.pp @@ -350,6 +350,7 @@ type procedure IncreaseChangeStamp; property OnChanged: TNotifyEvent read FOnChanged write FOnChanged; function GetParsedCommand: string; // resolved macros + function HasCommands: boolean; // true if there is something to execute public property Owner: TObject read FOwner; property Command: string read FCommand write SetCommand; @@ -536,6 +537,7 @@ type function GetDefaultMainSourceFileName: string; virtual; function CanBeDefaulForProject: boolean; virtual; function NeedsLinkerOpts: boolean; + function HasCommands: boolean; // true if there is at least one commad to execute function GetEffectiveTargetOS: string; override; function GetEffectiveTargetCPU: string; override; function GetEffectiveLCLWidgetType: string; override; @@ -2052,6 +2054,16 @@ begin Result:=not (ccloNoLinkerOpts in fDefaultMakeOptionsFlags); end; +function TBaseCompilerOptions.HasCommands: boolean; +begin + Result:=true; + if CreateMakefileOnBuild then exit; + if CompilerPath<>'' then exit; + if ExecuteBefore.HasCommands then exit; + if ExecuteAfter.HasCommands then exit; + Result:=false; +end; + function TBaseCompilerOptions.GetEffectiveTargetOS: string; var Vars: TCTCfgScriptVariables; @@ -4252,6 +4264,13 @@ begin Result:=FParsedCommand; end; +function TCompilationToolOptions.HasCommands: boolean; +begin + Result:=true; + if GetParsedCommand<>'' then exit; + Result:=false; +end; + { TIDEBuildMacro } procedure TIDEBuildMacro.SetIdentifier(const AValue: string); diff --git a/packager/packageeditor.pas b/packager/packageeditor.pas index 08ba0606fd..164c5656f1 100644 --- a/packager/packageeditor.pas +++ b/packager/packageeditor.pas @@ -31,12 +31,14 @@ interface uses // LCL FCL - Classes, SysUtils, Forms, Controls, StdCtrls, ComCtrls, Buttons, Graphics, LCLType, LCLProc, Menus, Dialogs, FileUtil, + Classes, SysUtils, Forms, Controls, StdCtrls, ComCtrls, Buttons, Graphics, + LCLType, LCLProc, Menus, Dialogs, FileUtil, contnrs, // IDEIntf CodeTools IDEImagesIntf, MenuIntf, ExtCtrls, LazIDEIntf, ProjectIntf, CodeToolsStructs, FormEditingIntf, TreeFilterEdit, PackageIntf, - IDEDialogs, IDEHelpIntf, IDEOptionsIntf, IDEProcs, LazarusIDEStrConsts, IDEDefs, CompilerOptions, ComponentReg, + IDEDialogs, IDEHelpIntf, IDEOptionsIntf, IDEProcs, LazarusIDEStrConsts, + IDEDefs, CompilerOptions, ComponentReg, PackageDefs, AddToPackageDlg, PkgVirtualUnitEditor, MissingPkgFilesDlg, PackageSystem, CleanPkgDeps; @@ -1703,7 +1705,7 @@ begin SaveBitBtn.Enabled:=(not LazPackage.ReadOnly) and (LazPackage.IsVirtual or LazPackage.Modified); - CompileBitBtn.Enabled:=(not LazPackage.IsVirtual); + CompileBitBtn.Enabled:=(not LazPackage.IsVirtual) and LazPackage.CompilerOptions.HasCommands; AddBitBtn.Enabled:=not LazPackage.ReadOnly; RemoveBitBtn.Enabled:=(not LazPackage.ReadOnly) and (not Removed) diff --git a/packager/packagesystem.pas b/packager/packagesystem.pas index 6b0ddc75d5..e4e07dd315 100644 --- a/packager/packagesystem.pas +++ b/packager/packagesystem.pas @@ -3373,6 +3373,12 @@ begin end; end; + if not APackage.CompilerOptions.HasCommands then begin + // package provides no compilation + Result:=mrOk; + exit; + end; + // check if compilation is needed and if a clean build is needed NeedBuildAllFlag:=false; Note:='';