IDE: added parameters --verbose, --quiet, when building IDE or project and when quit, give message when already building

git-svn-id: trunk@47590 -
This commit is contained in:
mattias 2015-02-04 22:30:54 +00:00
parent ea7686e0d4
commit bee2faeb7b
13 changed files with 120 additions and 53 deletions

View File

@ -440,9 +440,6 @@ type
procedure SetAlternativeCompile(const Command: string; ScanFPCMsgs: boolean); virtual; abstract; // disable normal compile and call this instead
end;
var
ConsoleVerbosity: integer = 0; // 0=normal, -1=quiet, 1=verbose, 2=very verbose
implementation
{ TLazBuildMacros }

View File

@ -45,9 +45,9 @@ uses
ProjectIntf, MacroIntf, IDEDialogs, IDEExternToolIntf,
CompOptsIntf, LazIDEIntf, MacroDefIntf, IDEMsgIntf,
// IDE
LazarusIDEStrConsts, DialogProcs, IDEProcs, CodeToolsOptions, InputHistory,
EditDefineTree, ProjectResources, MiscOptions, LazConf, EnvironmentOpts,
TransferMacros, CompilerOptions,
IDECmdLine, LazarusIDEStrConsts, DialogProcs, IDEProcs, CodeToolsOptions,
InputHistory, EditDefineTree, ProjectResources, MiscOptions, LazConf,
EnvironmentOpts, TransferMacros, CompilerOptions,
ExtTools, etMakeMsgParser, etFPCMsgParser,
Compiler, FPCSrcScan, PackageDefs, PackageSystem, Project, ProjectIcon,
ModeMatrixOpts, BaseBuildManager, ApplicationBundle;

View File

@ -40,7 +40,7 @@ interface
uses
Classes, SysUtils, Process, LCLProc, Forms, Controls, contnrs, strutils, FileUtil,
IDEExternToolIntf, IDEMsgIntf, CompOptsIntf, LazIDEIntf,
LazarusIDEStrConsts, CompilerOptions, Project,
IDECmdLine, LazarusIDEStrConsts, CompilerOptions, Project,
DefineTemplates, TransferMacros, EnvironmentOpts, LazFileUtils;
type

View File

@ -38,7 +38,7 @@ uses
CompOptsIntf, MacroIntf,
FileProcs, KeywordFuncLists, CodeToolsFPCMsgs, CodeToolsStructs, CodeCache,
CodeToolManager, DirectoryCacher, BasicCodeTools, DefineTemplates, SourceLog,
LazarusIDEStrConsts, EnvironmentOpts, LazConf, TransferMacros,
IDECmdLine, LazarusIDEStrConsts, EnvironmentOpts, LazConf, TransferMacros,
etMakeMsgParser;
const

View File

@ -44,7 +44,7 @@ uses
IDEExternToolIntf, BaseIDEIntf, MacroIntf, IDEMsgIntf, IDEDialogs,
CompOptsIntf, PackageIntf, LazIDEIntf,
// IDE
TransferMacros, LazarusIDEStrConsts;
IDECmdLine, TransferMacros, LazarusIDEStrConsts;
type
TLMVToolState = (

View File

@ -80,6 +80,8 @@ function ParamsAndCfgCount: Integer;
function ParamsAndCfgStr(Idx: Integer): String;
procedure ResetParamsAndCfg;
var
ConsoleVerbosity: integer = 0; // 0=normal, -1=quiet, 1=verbose, 2=very verbose
implementation

View File

@ -40,7 +40,7 @@ unit IDEGuiCmdLine;
interface
uses
Classes, SysUtils, FileUtil, lazutf8classes, LazConf, LCLProc,
Classes, SysUtils, math, FileUtil, lazutf8classes, LazConf, LCLProc,
LazarusIDEStrConsts, IDECmdLine;
procedure ParseGuiCmdLineParams(var SkipAutoLoadingLastProject,
@ -171,7 +171,11 @@ begin
else if ParamIsOption(i, StartedByStartLazarusOpt) then
StartedByStartLazarus := true
else if ParamIsOption(i, EnableRemoteControlOpt) then
EnableRemoteControl := true;
EnableRemoteControl := true
else if ParamIsOption(i, '--verbose') then
ConsoleVerbosity:=Max(1,ConsoleVerbosity+1)
else if ParamIsOption(i, '--quiet') then
ConsoleVerbosity:=Min(0,ConsoleVerbosity-1);
end;
end;

View File

@ -121,6 +121,8 @@ resourcestring
lisRunButtonHint = 'Run';
lisPause = 'Pause';
lisStop = 'Stop';
lisBuilding = 'Building';
lisTheIDEIsStillBuilding = 'The IDE is still building.';
lisLess = 'Less';
lisMore = 'More';
lisMoreSub = 'More >>';
@ -3139,6 +3141,7 @@ resourcestring
lisKMCleanUpAndBuild = 'Clean up and build';
lisKMBuildManyModes = 'Build many modes';
lisKMAbortBuilding = 'Abort building';
lisContinueBuilding = 'Continue building';
lisKMRunProgram = 'Run program';
lisKMPauseProgram = 'Pause program';
lisKMViewProjectOptions = 'View project options';
@ -5129,6 +5132,10 @@ resourcestring
+'list of installed packages (combine with --build-ide to rebuild IDE).';
lisBuildIDEWithPackages = 'build IDE with packages';
lisShowVersionAndExit = 'show version and exit';
lisBeLessVerboseCanBeGivenMultipleTimes = 'be less verbose, can be given '
+'multiple times';
lisBeMoreVerboseCanBeGivenMultipleTimes = 'be more verbose, can be given '
+'multiple times';
lisOverrideTheProjectOperatingSystemEGWin32LinuxDefau = '%soverride the '
+'project operating system. e.g. win32 linux. default: %s';
lisOverrideTheProjectWidgetsetEGGtkGtk2QtWin32CarbonD = '%soverride the '

View File

@ -1591,8 +1591,8 @@ begin
writeln('-d or --skip-dependencies ', UTF8ToConsole(lisDoNotCompileDependencies));
writeln('--build-ide=<options> ', UTF8ToConsole(lisBuildIDEWithPackages));
writeln('-v or --version ', UTF8ToConsole(lisShowVersionAndExit));
writeln('-q or --quiet ', UTF8ToConsole('be less verbose, can be given multiple times'));
writeln('--verbose ', UTF8ToConsole('be more verbose, can be given multiple times'));
writeln('-q or --quiet ', UTF8ToConsole(lisBeLessVerboseCanBeGivenMultipleTimes));
writeln('--verbose ', UTF8ToConsole(lisBeMoreVerboseCanBeGivenMultipleTimes));
writeln('');
writeln('--add-package');

View File

@ -781,7 +781,7 @@ type
function DoBuildProject(const AReason: TCompileReason;
Flags: TProjectBuildFlags): TModalResult; override;
function UpdateProjectPOFile(AProject: TProject): TModalResult;
function DoAbortBuild: TModalResult;
function DoAbortBuild(Interactive: boolean): TModalResult;
procedure DoCompile;
procedure DoQuickCompile;
function DoInitProjectRun: TModalResult; override;
@ -1068,6 +1068,8 @@ begin
AddHelp(['--help or -? ', listhisHelpMessage]);
AddHelp(['']);
AddHelp(['-v or --version ', lisShowVersionAndExit]);
AddHelp(['--quiet ', lisBeLessVerboseCanBeGivenMultipleTimes]);
AddHelp(['--verbose ', lisBeMoreVerboseCanBeGivenMultipleTimes]);
AddHelp(['']);
AddHelp([ShowSetupDialogOptLong]);
AddHelp([BreakString(space+lisShowSetupDialogForMostImportantSettings, 75, 22)]);
@ -1973,9 +1975,11 @@ begin
CanClose := False;
SourceFileMgr.CheckingFilesOnDisk := True;
try
if (ToolStatus = itExiting) then exit;
// stop debugging/compiling/...
if (ToolStatus = itExiting)
or not DoResetToolStatus([rfInteractive, rfCloseOnDone]) then exit;
if DoAbortBuild(true)<>mrOk then exit;
if not DoResetToolStatus([rfInteractive, rfCloseOnDone]) then exit;
// check foreign windows
if not CloseQueryIDEWindows then exit;
@ -3288,7 +3292,7 @@ begin
ecBuild: DoBuildProject(crBuild, [pbfCleanCompile]);
ecCleanUpAndBuild: mnuCleanUpAndBuildProjectClicked(nil);
ecQuickCompile: DoQuickCompile;
ecAbortBuild: DoAbortBuild;
ecAbortBuild: DoAbortBuild(false);
ecBuildFile: DoBuildFile(false);
ecRunFile: DoRunFile;
ecJumpToPrevError: DoJumpToNextError(false);
@ -4319,7 +4323,7 @@ end;
procedure TMainIDE.mnuAbortBuildProjectClicked(Sender: TObject);
Begin
DoAbortBuild;
DoAbortBuild(false);
end;
procedure TMainIDE.mnuRunProjectClicked(Sender: TObject);
@ -4673,7 +4677,8 @@ begin
if (Index<0)
or (Index>=ExternalUserTools.Count)
then exit;
IDEMessagesWindow.Clear;
if ExternalTools.RunningCount=0 then
IDEMessagesWindow.Clear;
DoRunExternalTool(Index,false);
end;
@ -5595,9 +5600,17 @@ var
begin
Result:=mrOk;
CurResult:=DoCallModalFunctionHandler(lihtSavingAll);
if CurResult=mrAbort then exit(mrAbort);
if CurResult=mrAbort then begin
if ConsoleVerbosity>0 then
debugln(['TMainIDE.DoSaveAll DoCallModalFunctionHandler(lihtSavingAll) failed']);
exit(mrAbort);
end;
if CurResult<>mrOk then Result:=mrCancel;
CurResult:=DoSaveProject(Flags);
if CurResult<>mrOK then begin
if ConsoleVerbosity>0 then
debugln(['TMainIDE.DoSaveAll DoSaveProject failed']);
end;
SaveEnvironment(true);
SaveIncludeLinks;
PkgBoss.SaveSettings;
@ -5605,8 +5618,14 @@ begin
if CurResult=mrAbort then exit(mrAbort);
if CurResult<>mrOk then Result:=mrCancel;
CurResult:=DoCallModalFunctionHandler(lihtSavedAll);
if CurResult=mrAbort then exit(mrAbort);
if CurResult<>mrOk then Result:=mrCancel;
if CurResult<>mrOK then begin
if ConsoleVerbosity>0 then
debugln(['TMainIDE.DoSaveAll DoCallModalFunctionHandler(lihtSavedAll) failed']);
end;
if CurResult=mrAbort then
Result:=mrAbort
else if CurResult<>mrOk then
Result:=mrCancel;
UpdateSaveMenuItemsAndButtons(true);
end;
@ -6363,10 +6382,9 @@ begin
if Project1=nil then exit(mrOk);
Result:=mrCancel;
if not (ToolStatus in [itNone,itDebugger]) then begin
{$IFDEF VerboseSaveForBuild}
DebugLn('TMainIDE.DoSaveForBuild ToolStatus disallows it');
{$ENDIF}
if not (ToolStatus in [itNone,itDebugger,itBuilder]) then begin
if ConsoleVerbosity>0 then
DebugLn('TMainIDE.DoSaveForBuild ToolStatus forbids it: ',dbgs(ToolStatus));
Result:=mrAbort;
exit;
end;
@ -6376,10 +6394,6 @@ begin
end;
// save all files
{$IFDEF VerboseSaveForBuild}
DebugLn('TMainIDE.DoSaveForBuild Project1.IsVirtual=',dbgs(Project1.IsVirtual));
{$ENDIF}
if not Project1.IsVirtual then
Result:=DoSaveAll([sfCheckAmbiguousFiles])
else
@ -6387,13 +6401,15 @@ begin
Project1.ProjResources.DoBeforeBuild(AReason, Project1.IsVirtual);
Project1.UpdateExecutableType;
if Result<>mrOk then begin
{$IFDEF VerboseSaveForBuild}
DebugLn('TMainIDE.DoSaveForBuild project saving failed');
{$ENDIF}
if ConsoleVerbosity>0 then
DebugLn('TMainIDE.DoSaveForBuild project saving failed');
exit;
end;
Result:=PkgBoss.DoSaveAllPackages([]);
if Result<>mrOK then
if ConsoleVerbosity>0 then
debugln(['TMainIDE.DoSaveForBuild PkgBoss.DoSaveAllPackages failed']);
end;
function TMainIDE.DoSaveProjectToTestDirectory(Flags: TSaveFlags): TModalResult;
@ -6451,6 +6467,7 @@ end;
function TMainIDE.QuitIDE: boolean;
begin
Result:=true;
if Project1=nil then
EnvironmentOptions.LastSavedProjectFile:=RestoreProjectClosed;
MainIDEBar.OnCloseQuery(Self, Result);
@ -6511,6 +6528,11 @@ var
IsComplete: Boolean;
StartTime: TDateTime;
begin
if DoAbortBuild(true)<>mrOK then begin
debugln(['TMainIDE.DoBuildProject DoAbortBuild failed']);
exit(mrCancel);
end;
Result:=SourceFileMgr.PrepareForCompileWithMsg;
if Result<>mrOk then begin
debugln(['TMainIDE.DoBuildProject PrepareForCompile failed']);
@ -6795,9 +6817,23 @@ begin
Result:=mrOk;
end;
function TMainIDE.DoAbortBuild: TModalResult;
function TMainIDE.DoAbortBuild(Interactive: boolean): TModalResult;
begin
Result:=mrOk;
if ExternalTools.RunningCount=0 then exit;
// IDE code is currently running a build process
// we cannot continue, while some IDE code is waiting for the processes
// => exit this event (no matter if the processes are stopped or not)
Result:=mrCancel;
if Interactive then
begin
if IDEQuestionDialog(lisBuilding, lisTheIDEIsStillBuilding,
mtConfirmation, [mrAbort, lisKMAbortBuilding, mrNo, lisContinueBuilding])
<> mrAbort
then
exit;
end;
AbortBuild;
end;
@ -7143,6 +7179,7 @@ var
CompiledUnitExt: String;
FPCVersion, FPCRelease, FPCPatch: integer;
PkgCompileFlags: TPkgCompileFlags;
OldToolStatus: TIDEToolStatus;
begin
if ToolStatus<>itNone then begin
IDEMessageDialog(lisNotNow,lisYouCanNotBuildLazarusWhileDebuggingOrCompiling,
@ -7151,6 +7188,8 @@ begin
exit;
end;
if DoAbortBuild(true)<>mrOK then exit;
Result:=DoSaveAll([sfDoNotSaveVirtualFiles]);
if Result<>mrOk then begin
DebugLn('TMainIDE.DoBuildLazarus: failed because saving failed');
@ -7159,8 +7198,11 @@ begin
if fBuilder=Nil then
fBuilder:=TLazarusBuilder.Create;
IDEMessagesWindow.Clear;
if ExternalTools.RunningCount=0 then
IDEMessagesWindow.Clear;
fBuilder.ProfileChanged:=false;
OldToolStatus:=ToolStatus;
ToolStatus:=itBuilder;
with MiscellaneousOptions do
try
MainBuildBoss.SetBuildTargetIDE;
@ -7182,9 +7224,9 @@ begin
end;
// compile auto install static packages
Result:=PkgBoss.DoCompileAutoInstallPackages(PkgCompileFlags,false);
Result:=PkgBoss.DoCompileAutoInstallPackages(PkgCompileFlags+[pcfDoNotSaveEditorFiles],false);
if Result<>mrOk then begin
DebugLn('TMainIDE.DoBuildLazarus: Compile AutoInstall Packages failed.');
DebugLn('TMainIDE.DoBuildLazarusSub: Compile AutoInstall Packages failed.');
exit;
end;
@ -7234,6 +7276,7 @@ begin
finally
MainBuildBoss.SetBuildTargetProject1(true);
DoCheckFilesOnDisk;
ToolStatus:=OldToolStatus;
end;
end;
@ -7322,7 +7365,8 @@ begin
if not BeginCodeTool(ActiveSrcEdit,ActiveUnitInfo,[]) then exit;
Result:=DoSaveProject([]);
if Result<>mrOk then exit;
IDEMessagesWindow.Clear;
if ExternalTools.RunningCount=0 then
IDEMessagesWindow.Clear;
DirectiveList:=TStringList.Create;
OldToolStatus:=ToolStatus;
ToolStatus:=itBuilder;
@ -7691,7 +7735,7 @@ begin
if MainBuildBoss.CompilerOnDiskChanged then
MainBuildBoss.RescanCompilerDefines(false,false,false,false);
if IDEMessagesWindow<>nil then
if (IDEMessagesWindow<>nil) and (ExternalTools.RunningCount=0) then
IDEMessagesWindow.Clear;
end;

View File

@ -61,15 +61,16 @@ uses
SrcEditorIntf, MenuIntf, LazIDEIntf, PackageIntf, IDEHelpIntf, IDEImagesIntf,
IDEWindowIntf, ProjectIntf, MacroDefIntf,
// IDE units
IDEDialogs, LazarusIDEStrConsts, IDECommands, CompOptsIntf, EditorOptions,
EnvironmentOpts, WordCompletion, FindReplaceDialog, IDEProcs, IDEOptionDefs,
IDEHelpManager, MacroPromptDlg, TransferMacros, CodeContextForm,
SrcEditHintFrm, etMessagesWnd, etSrcEditMarks, InputHistory,
IDECmdLine, IDEDialogs, LazarusIDEStrConsts, IDECommands, CompOptsIntf,
EditorOptions, EnvironmentOpts, WordCompletion, FindReplaceDialog, IDEProcs,
IDEOptionDefs, IDEHelpManager, MacroPromptDlg, TransferMacros,
CodeContextForm, SrcEditHintFrm, etMessagesWnd, etSrcEditMarks, InputHistory,
CodeMacroPrompt, CodeTemplatesDlg, CodeToolsOptions,
SortSelectionDlg, EncloseSelectionDlg, ConDef, InvertAssignTool,
SourceEditProcs, SourceMarks, CharacterMapDlg, SearchFrm,
FPDocHints, EditorMacroListViewer,
DbgIntfBaseTypes, DbgIntfDebuggerBase, BaseDebugManager, Debugger, MainIntf, GotoFrm;
DbgIntfBaseTypes, DbgIntfDebuggerBase, BaseDebugManager, Debugger, MainIntf,
GotoFrm;
type
TSourceNotebook = class;

View File

@ -58,9 +58,9 @@ uses
// package registration
LazarusPackageIntf,
// IDE
LazarusIDEStrConsts, EnvironmentOpts, IDEProcs, LazConf, TransferMacros,
DialogProcs, IDETranslations, CompilerOptions, PackageLinks, PackageDefs,
ComponentReg, ProjectIntf;
LazarusIDEStrConsts, IDECmdLine, EnvironmentOpts, IDEProcs, LazConf,
TransferMacros, DialogProcs, IDETranslations, CompilerOptions, PackageLinks,
PackageDefs, ComponentReg, ProjectIntf;
const
MakefileCompileVersion = 2;

View File

@ -57,8 +57,8 @@ uses
IDEExternToolIntf,
PropEdits, MacroIntf, LazIDEIntf, IDEMsgIntf,
// IDE
LazarusIDEStrConsts, IDEProcs, ObjectLists, DialogProcs, IDECommands,
IDEOptionDefs, EnvironmentOpts, MiscOptions, InputHistory,
IDECmdLine, LazarusIDEStrConsts, IDEProcs, ObjectLists, DialogProcs,
IDECommands, IDEOptionDefs, EnvironmentOpts, MiscOptions, InputHistory,
Project, ComponentReg, OldCustomCompDlg, PackageEditor, AddToPackageDlg,
PackageDefs, PackageLinks, PackageSystem, OpenInstalledPkgDlg,
PkgGraphExplorer, BrokenDependenciesDlg, CompilerOptions,
@ -5866,13 +5866,21 @@ begin
// check consistency
Result:=CheckPackageGraphForCompilation(nil,Dependencies,
EnvironmentOptions.GetParsedLazarusDirectory,false);
if Result<>mrOk then exit;
if Result<>mrOk then begin
if ConsoleVerbosity>0 then
debugln(['TPkgManager.DoCompileAutoInstallPackages CheckPackageGraphForCompilation failed']);
exit;
end;
//DebugLn(['TPkgManager.DoCompileAutoInstallPackages LCLUnitPath=',PackageGraph.LCLPackage.CompilerOptions.GetUnitPath(true)]);
// save all open files
if not (pcfDoNotSaveEditorFiles in Flags) then begin
Result:=MainIDE.DoSaveForBuild(crCompile);
if Result<>mrOk then exit;
if Result<>mrOk then begin
if ConsoleVerbosity>0 then
debugln(['TPkgManager.DoCompileAutoInstallPackages MainIDE.DoSaveForBuild failed']);
exit;
end;
end;
// compile all auto install dependencies
@ -5881,8 +5889,12 @@ begin
CompilePolicy:=pupOnRebuildingAll;
Result:=PackageGraph.CompileRequiredPackages(nil,Dependencies,false,
CompilePolicy);
if Result<>mrOk then exit;
if Result<>mrOk then begin
if ConsoleVerbosity>0 then
debugln(['TPkgManager.DoCompileAutoInstallPackages PackageGraph.CompileRequiredPackages failed']);
exit;
end;
finally
if OnlyBase then
FreeDependencyList(Dependencies,pdlRequires);