lazbuild: apply verbosity to compiler invocation

git-svn-id: trunk@39453 -
This commit is contained in:
mattias 2012-12-06 15:36:36 +00:00
parent 60fdc1bfd9
commit 9849a7034c
3 changed files with 34 additions and 30 deletions

View File

@ -40,7 +40,7 @@ interface
uses uses
Classes, SysUtils, Process, LCLProc, Forms, Controls, FileUtil, InfoBuild, Classes, SysUtils, Process, LCLProc, Forms, Controls, FileUtil, InfoBuild,
LazarusIDEStrConsts, CompilerOptions, Project, OutputFilter, UTF8Process, LazarusIDEStrConsts, CompilerOptions, Project, OutputFilter, UTF8Process,
IDEMsgIntf, LazIDEIntf, ProjectIntf; IDEMsgIntf, LazIDEIntf, ProjectIntf, CompOptsIntf;
type type
TOnCmdLineCreate = procedure(var CmdLine: string; var Abort:boolean) TOnCmdLineCreate = procedure(var CmdLine: string; var Abort:boolean)
@ -136,6 +136,7 @@ begin
FASyncResult:= mrNone; FASyncResult:= mrNone;
FFinishedCallback := aFinishedCallback; FFinishedCallback := aFinishedCallback;
{$ENDIF} {$ENDIF}
if ConsoleVerbosity>=0 then
DebugLn('TCompiler.Compile WorkingDir="',WorkingDir,'" CompilerFilename="',CompilerFilename,'" CompilerParams="',CompilerParams,'"'); DebugLn('TCompiler.Compile WorkingDir="',WorkingDir,'" CompilerFilename="',CompilerFilename,'" CompilerParams="',CompilerParams,'"');
// if we want to show the compile progress, it's now time to show the dialog // if we want to show the compile progress, it's now time to show the dialog
@ -179,6 +180,7 @@ begin
exit; exit;
end; end;
end; end;
if ConsoleVerbosity>=0 then
DebugLn('[TCompiler.Compile] CmdLine="',CmdLine,'"'); DebugLn('[TCompiler.Compile] CmdLine="',CmdLine,'"');
try try
@ -229,12 +231,14 @@ begin
exit; exit;
end; end;
on e: Exception do begin on e: Exception do begin
if ConsoleVerbosity>=-1 then
DebugLn('[TCompiler.Compile] exception "',E.Message,'"'); DebugLn('[TCompiler.Compile] exception "',E.Message,'"');
WriteError(E.Message); WriteError(E.Message);
Result:=mrCancel; Result:=mrCancel;
exit; exit;
end; end;
end; end;
if ConsoleVerbosity>=0 then
DebugLn('[TCompiler.Compile] end'); DebugLn('[TCompiler.Compile] end');
end; end;

View File

@ -64,7 +64,6 @@ type
FSkipDependencies: boolean; FSkipDependencies: boolean;
fInitialized: boolean; fInitialized: boolean;
fInitResult: boolean; fInitResult: boolean;
FVerbosity: integer;
fWidgetsetOverride: String; fWidgetsetOverride: String;
// external tools // external tools
procedure OnExtToolFreeOutputFilter({%H-}OutputFilter: TOutputFilter; procedure OnExtToolFreeOutputFilter({%H-}OutputFilter: TOutputFilter;
@ -165,8 +164,6 @@ type
property CompilerOverride: String read fCompilerOverride write fCompilerOverride; property CompilerOverride: String read fCompilerOverride write fCompilerOverride;
property LazarusDirOverride: String read fLazarusDirOverride write fLazarusDirOverride; property LazarusDirOverride: String read fLazarusDirOverride write fLazarusDirOverride;
property BuildModeOverride: String read FBuildModeOverride write FBuildModeOverride; property BuildModeOverride: String read FBuildModeOverride write FBuildModeOverride;
property Verbosity: integer read FVerbosity write FVerbosity; // 0=normal, -1=quiet, 1=verbose, 2=very verbose
end; end;
var var
@ -476,7 +473,7 @@ begin
if i<0 then if i<0 then
begin begin
debugln(['ERROR: IDE build mode "'+BuildModeOverride+'" not found']); debugln(['ERROR: IDE build mode "'+BuildModeOverride+'" not found']);
if Verbosity>=-2 then begin if ConsoleVerbosity>=-2 then begin
debugln; debugln;
debugln('Available IDE build modes:'); debugln('Available IDE build modes:');
for i:=0 to BuildLazProfiles.Count-1 do for i:=0 to BuildLazProfiles.Count-1 do
@ -494,7 +491,7 @@ begin
CurProf:=BuildLazProfiles[i]; CurProf:=BuildLazProfiles[i];
BuildLazProfiles.CurrentIndex:=i; BuildLazProfiles.CurrentIndex:=i;
end; end;
if Verbosity>=0 then if ConsoleVerbosity>=0 then
debugln(['Building Lazarus IDE with profile "',CurProf.Name,'"']); debugln(['Building Lazarus IDE with profile "',CurProf.Name,'"']);
if (Length(OSOverride) <> 0) then if (Length(OSOverride) <> 0) then
@ -526,7 +523,7 @@ begin
TargetDir:=CurProf.TargetDirectory; TargetDir:=CurProf.TargetDirectory;
IDEMacros.SubstituteMacros(TargetDir); IDEMacros.SubstituteMacros(TargetDir);
if not ForceDirectory(TargetDir) then begin if not ForceDirectory(TargetDir) then begin
if Verbosity>=-1 then if ConsoleVerbosity>=-1 then
DebugLn('WARNING: failed creating IDE target directory "',TargetDir,'" (TLazBuildApplication.BuildLazarusIDE)'); DebugLn('WARNING: failed creating IDE target directory "',TargetDir,'" (TLazBuildApplication.BuildLazarusIDE)');
exit; exit;
end; end;
@ -541,7 +538,7 @@ begin
Flags+[blfDontBuild], Flags+[blfDontBuild],
ProfileChanged); ProfileChanged);
if CurResult<>mrOk then begin if CurResult<>mrOk then begin
if Verbosity>=-1 then if ConsoleVerbosity>=-1 then
DebugLn('TLazBuildApplication.BuildLazarusIDE: Clean all failed.'); DebugLn('TLazBuildApplication.BuildLazarusIDE: Clean all failed.');
exit; exit;
end; end;
@ -550,7 +547,7 @@ begin
// save configs for 'make' // save configs for 'make'
CurResult:=PackageGraph.SaveAutoInstallConfig; CurResult:=PackageGraph.SaveAutoInstallConfig;
if CurResult<>mrOk then begin if CurResult<>mrOk then begin
if Verbosity>=-1 then if ConsoleVerbosity>=-1 then
DebugLn('TLazBuildApplication.BuildLazarusIDE: failed saving IDE make config files.'); DebugLn('TLazBuildApplication.BuildLazarusIDE: failed saving IDE make config files.');
exit; exit;
end; end;
@ -558,7 +555,7 @@ begin
// compile auto install static packages // compile auto install static packages
if not CompileAutoInstallPackages(BuildLazProfiles.Current.IdeBuildMode<>bmBuild) if not CompileAutoInstallPackages(BuildLazProfiles.Current.IdeBuildMode<>bmBuild)
then begin then begin
if Verbosity>=-1 then if ConsoleVerbosity>=-1 then
DebugLn('TLazBuildApplication.BuildLazarusIDE: Compile AutoInstall Packages failed.'); DebugLn('TLazBuildApplication.BuildLazarusIDE: Compile AutoInstall Packages failed.');
exit; exit;
end; end;
@ -571,7 +568,7 @@ begin
CurResult:=SaveIDEMakeOptions(BuildLazProfiles.Current,GlobalMacroList, CurResult:=SaveIDEMakeOptions(BuildLazProfiles.Current,GlobalMacroList,
PkgOptions,Flags+[blfBackupOldExe]); PkgOptions,Flags+[blfBackupOldExe]);
if CurResult<>mrOk then begin if CurResult<>mrOk then begin
if Verbosity>=-1 then if ConsoleVerbosity>=-1 then
DebugLn('TLazBuildApplication.BuildLazarusIDE: failed saving idemake.cfg'); DebugLn('TLazBuildApplication.BuildLazarusIDE: failed saving idemake.cfg');
exit; exit;
end; end;
@ -584,7 +581,7 @@ begin
Flags+[blfUseMakeIDECfg,blfOnlyIDE], Flags+[blfUseMakeIDECfg,blfOnlyIDE],
ProfileChanged); ProfileChanged);
if CurResult<>mrOk then begin if CurResult<>mrOk then begin
if Verbosity>=-1 then if ConsoleVerbosity>=-1 then
DebugLn('TLazBuildApplication.BuildLazarusIDE: Building IDE failed.'); DebugLn('TLazBuildApplication.BuildLazarusIDE: Building IDE failed.');
exit; exit;
end; end;
@ -733,7 +730,7 @@ begin
if NewBuildMode=nil then if NewBuildMode=nil then
begin begin
debugln([Format(lisERRORInvalidBuildMode, [BuildModeOverride])]); debugln([Format(lisERRORInvalidBuildMode, [BuildModeOverride])]);
if Verbosity>=0 then begin if ConsoleVerbosity>=0 then begin
debugln; debugln;
if Project1.BuildModes.Count>1 then if Project1.BuildModes.Count>1 then
begin begin
@ -816,7 +813,7 @@ begin
// regenerate resources // regenerate resources
if not Project1.ProjResources.Regenerate(SrcFileName, False, True, '') then if not Project1.ProjResources.Regenerate(SrcFileName, False, True, '') then
begin begin
if Verbosity>=-1 then if ConsoleVerbosity>=-1 then
DebugLn('TMainIDE.DoSaveProject Project1.Resources.Regenerate failed'); DebugLn('TMainIDE.DoSaveProject Project1.Resources.Regenerate failed');
end; end;
@ -968,7 +965,7 @@ begin
end; end;
PackageName:=Package.Name; PackageName:=Package.Name;
// set it as (static) autoinstall: select for installation // set it as (static) autoinstall: select for installation
if Verbosity>=0 then if ConsoleVerbosity>=0 then
debugln(['adding package "'+PkgFilename+'" to install list of IDE']); debugln(['adding package "'+PkgFilename+'" to install list of IDE']);
if MiscellaneousOptions.BuildLazProfiles.StaticAutoInstallPackages.IndexOf(PackageName)<0 then if MiscellaneousOptions.BuildLazProfiles.StaticAutoInstallPackages.IndexOf(PackageName)<0 then
MiscellaneousOptions.BuildLazProfiles.StaticAutoInstallPackages.Add(PackageName); MiscellaneousOptions.BuildLazProfiles.StaticAutoInstallPackages.Add(PackageName);
@ -990,7 +987,7 @@ begin
fInitResult:=false; fInitResult:=false;
fInitialized:=true; fInitialized:=true;
if Verbosity>=0 then if ConsoleVerbosity>=0 then
debugln(['primary config path: ',GetPrimaryConfigPath]); debugln(['primary config path: ',GetPrimaryConfigPath]);
CreatePrimaryConfigPath; CreatePrimaryConfigPath;
@ -1029,7 +1026,7 @@ begin
fLazarusDirInCfg:=LazarusDirectory; fLazarusDirInCfg:=LazarusDirectory;
if Application.HasOption('language') then begin if Application.HasOption('language') then begin
if Verbosity>=0 then if ConsoleVerbosity>=0 then
debugln('Note: overriding language with command line: ', debugln('Note: overriding language with command line: ',
Application.GetOptionValue('language')); Application.GetOptionValue('language'));
EnvironmentOptions.LanguageID:=Application.GetOptionValue('language'); EnvironmentOptions.LanguageID:=Application.GetOptionValue('language');
@ -1048,7 +1045,7 @@ begin
+SetDirSeparators('packager/registration/fcl.lpk')) +SetDirSeparators('packager/registration/fcl.lpk'))
then begin then begin
CheckLazarusDirectoryQuality(EnvironmentOptions.GetParsedLazarusDirectory,Note); CheckLazarusDirectoryQuality(EnvironmentOptions.GetParsedLazarusDirectory,Note);
if Verbosity>=-1 then if ConsoleVerbosity>=-1 then
debugln(['Error: invalid Lazarus directory "'+EnvironmentOptions.LazarusDirectory+'": '+Note]); debugln(['Error: invalid Lazarus directory "'+EnvironmentOptions.LazarusDirectory+'": '+Note]);
Terminate; Terminate;
end; end;
@ -1116,7 +1113,7 @@ begin
if (not StoreLazDir) and (not StoreCompPath) then exit; if (not StoreLazDir) and (not StoreCompPath) then exit;
try try
if Verbosity>=-1 then if ConsoleVerbosity>=-1 then
begin begin
dbgout('storing'); dbgout('storing');
if StoreLazDir then if StoreLazDir then
@ -1245,7 +1242,7 @@ begin
begin begin
// Required argument // Required argument
NeedArg:=true; NeedArg:=true;
if Verbosity>=-1 then if ConsoleVerbosity>=-1 then
debugln(['P ',P,' J ',J,' ',O[J],' ',l,' Havearg ',HaveArg]); debugln(['P ',P,' J ',J,' ',O[J],' ',l,' Havearg ',HaveArg]);
If ((P+1)=Length(ShortOptions)) or (Shortoptions[P+2]<>':') Then If ((P+1)=Length(ShortOptions)) or (Shortoptions[P+2]<>':') Then
If (J<L) or not haveArg then // Must be last in multi-opt !! If (J<L) or not haveArg then // Must be last in multi-opt !!
@ -1313,7 +1310,7 @@ begin
// except packages to be added the IDE install list. // except packages to be added the IDE install list.
for i:=0 to Files.Count-1 do begin for i:=0 to Files.Count-1 do begin
if not BuildFile(Files[i]) then begin if not BuildFile(Files[i]) then begin
if Verbosity>=-1 then if ConsoleVerbosity>=-1 then
debugln('Failed building ',Files[i]); debugln('Failed building ',Files[i]);
ExitCode := ErrorBuildFailed; ExitCode := ErrorBuildFailed;
exit; exit;
@ -1323,7 +1320,7 @@ begin
// Add user-requested packages to IDE install list: // Add user-requested packages to IDE install list:
if AddPackage then begin if AddPackage then begin
if not AddPackagesToInstallList(Files) then begin if not AddPackagesToInstallList(Files) then begin
if Verbosity>=-1 then if ConsoleVerbosity>=-1 then
debugln('Failed adding package(s) ',Files.Text); debugln('Failed adding package(s) ',Files.Text);
ExitCode := ErrorBuildFailed; ExitCode := ErrorBuildFailed;
exit; exit;
@ -1332,7 +1329,7 @@ begin
if BuildIDE then begin if BuildIDE then begin
if not BuildLazarusIDE then begin if not BuildLazarusIDE then begin
if Verbosity>=-1 then if ConsoleVerbosity>=-1 then
debugln('Failed building Lazarus IDE'); debugln('Failed building Lazarus IDE');
ExitCode := ErrorBuildFailed; ExitCode := ErrorBuildFailed;
exit; exit;
@ -1368,13 +1365,13 @@ begin
exit; exit;
end; end;
// verbosity // ConsoleVerbosity
for i:=1 to ParamCount do begin for i:=1 to ParamCount do begin
p:=ParamStr(i); p:=ParamStr(i);
if p='--verbose' then if p='--verbose' then
inc(fVerbosity) inc(ConsoleVerbosity)
else if (p='-q') or (p='quiet=') then else if (p='-q') or (p='quiet=') then
dec(fVerbosity); dec(ConsoleVerbosity);
end; end;
Options:=TStringList.Create; Options:=TStringList.Create;

View File

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