mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-11 20:39:15 +02:00
IDE: Fix Before-tool execution, simplify project build. Issue #29773, patch from Martok.
git-svn-id: trunk@51874 -
This commit is contained in:
parent
1845a2deef
commit
7b55f8c8e6
@ -142,11 +142,9 @@ type
|
|||||||
// build project flags
|
// build project flags
|
||||||
// Normally you don't need to pass any flags.
|
// Normally you don't need to pass any flags.
|
||||||
TProjectBuildFlag = (
|
TProjectBuildFlag = (
|
||||||
pbfCleanCompile, // append -B to the compiler options
|
|
||||||
pbfDoNotCompileDependencies,
|
pbfDoNotCompileDependencies,
|
||||||
pbfDoNotCompileProject,
|
pbfDoNotCompileProject,
|
||||||
pbfCompileDependenciesClean,
|
pbfCompileDependenciesClean,
|
||||||
pbfOnlyIfNeeded,
|
|
||||||
pbfDoNotSaveEditorFiles,
|
pbfDoNotSaveEditorFiles,
|
||||||
pbfSkipLinking,
|
pbfSkipLinking,
|
||||||
pbfSkipAssembler,
|
pbfSkipAssembler,
|
||||||
|
@ -1324,7 +1324,7 @@ end;
|
|||||||
function TIDECompileTarget.ProjectAction(AAction: TPGTargetAction;
|
function TIDECompileTarget.ProjectAction(AAction: TPGTargetAction;
|
||||||
StartBuildMode: string): TPGActionResult;
|
StartBuildMode: string): TPGActionResult;
|
||||||
var
|
var
|
||||||
F: TProjectBuildFlags;
|
R: TCompileReason;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
aMode: TPGBuildMode;
|
aMode: TPGBuildMode;
|
||||||
aProject: TLazProject;
|
aProject: TLazProject;
|
||||||
@ -1361,9 +1361,9 @@ begin
|
|||||||
// save project
|
// save project
|
||||||
if LazarusIDE.DoSaveProject([])<>mrOk then exit;
|
if LazarusIDE.DoSaveProject([])<>mrOk then exit;
|
||||||
|
|
||||||
F:=[];
|
R:= crCompile;
|
||||||
if (AAction=taCompileClean) then
|
if (AAction=taCompileClean) then
|
||||||
Include(F,pbfCleanCompile);
|
R:= crBuild;
|
||||||
if BuildModeCount>1 then begin
|
if BuildModeCount>1 then begin
|
||||||
i:=0;
|
i:=0;
|
||||||
if StartBuildMode<>'' then begin
|
if StartBuildMode<>'' then begin
|
||||||
@ -1383,7 +1383,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
// compile project in active buildmode
|
// compile project in active buildmode
|
||||||
if LazarusIDE.DoBuildProject(crCompile,F)<>mrOk then
|
if LazarusIDE.DoBuildProject(R,[])<>mrOk then
|
||||||
exit;
|
exit;
|
||||||
if (StartBuildMode<>'') and (AAction<>taCompileFromHere) then
|
if (StartBuildMode<>'') and (AAction<>taCompileFromHere) then
|
||||||
exit(arOK);
|
exit(arOK);
|
||||||
@ -1391,7 +1391,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
// compile default buildmode
|
// compile default buildmode
|
||||||
if LazarusIDE.DoBuildProject(crCompile,F)<>mrOk then
|
if LazarusIDE.DoBuildProject(R,[])<>mrOk then
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
Result:=arOK;
|
Result:=arOK;
|
||||||
|
54
ide/main.pp
54
ide/main.pp
@ -3248,7 +3248,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
ecDetach: DebugBoss.Detach;
|
ecDetach: DebugBoss.Detach;
|
||||||
ecBuild: DoBuildProject(crBuild, [pbfCleanCompile]);
|
ecBuild: DoBuildProject(crBuild, []);
|
||||||
ecCleanUpAndBuild: mnuCleanUpAndBuildProjectClicked(nil);
|
ecCleanUpAndBuild: mnuCleanUpAndBuildProjectClicked(nil);
|
||||||
ecQuickCompile: DoQuickCompile;
|
ecQuickCompile: DoQuickCompile;
|
||||||
ecAbortBuild: DoAbortBuild(false);
|
ecAbortBuild: DoAbortBuild(false);
|
||||||
@ -4166,7 +4166,7 @@ end;
|
|||||||
|
|
||||||
procedure TMainIDE.mnuBuildProjectClicked(Sender: TObject);
|
procedure TMainIDE.mnuBuildProjectClicked(Sender: TObject);
|
||||||
Begin
|
Begin
|
||||||
DoBuildProject(crBuild,[pbfCleanCompile]);
|
DoBuildProject(crBuild,[]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.mnuQuickCompileProjectClicked(Sender: TObject);
|
procedure TMainIDE.mnuQuickCompileProjectClicked(Sender: TObject);
|
||||||
@ -6446,6 +6446,7 @@ var
|
|||||||
WorkingDir: String;
|
WorkingDir: String;
|
||||||
CompilerParams: String;
|
CompilerParams: String;
|
||||||
NeedBuildAllFlag: Boolean;
|
NeedBuildAllFlag: Boolean;
|
||||||
|
NoBuildNeeded: Boolean;
|
||||||
UnitOutputDirectory: String;
|
UnitOutputDirectory: String;
|
||||||
TargetExeName: String;
|
TargetExeName: String;
|
||||||
TargetExeDirectory: String;
|
TargetExeDirectory: String;
|
||||||
@ -6557,17 +6558,20 @@ begin
|
|||||||
// check if build is needed (only if we will call the compiler)
|
// check if build is needed (only if we will call the compiler)
|
||||||
// and check if a 'build all' is needed
|
// and check if a 'build all' is needed
|
||||||
NeedBuildAllFlag:=false;
|
NeedBuildAllFlag:=false;
|
||||||
|
NoBuildNeeded:= false;
|
||||||
aCompileHint:='';
|
aCompileHint:='';
|
||||||
if (AReason in Project1.CompilerOptions.CompileReasons) then begin
|
if (AReason in Project1.CompilerOptions.CompileReasons) then begin
|
||||||
Result:=MainBuildBoss.DoCheckIfProjectNeedsCompilation(Project1,
|
Result:=MainBuildBoss.DoCheckIfProjectNeedsCompilation(Project1,
|
||||||
NeedBuildAllFlag,aCompileHint);
|
NeedBuildAllFlag,aCompileHint);
|
||||||
if (pbfOnlyIfNeeded in Flags)
|
if (AReason = crRun)
|
||||||
and (not (pfAlwaysBuild in Project1.Flags)) then begin
|
and (not (pfAlwaysBuild in Project1.Flags)) then begin
|
||||||
if Result=mrNo then begin
|
if Result=mrNo then begin
|
||||||
debugln(['Error: (lazarus) [TMainIDE.DoBuildProject] MainBuildBoss.DoCheckIfProjectNeedsCompilation nothing to be done']);
|
debugln(['Error: (lazarus) [TMainIDE.DoBuildProject] MainBuildBoss.DoCheckIfProjectNeedsCompilation nothing to be done']);
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
exit;
|
// continue for now, check if 'Before' tool is required
|
||||||
end;
|
NoBuildNeeded:= true;
|
||||||
|
end
|
||||||
|
else
|
||||||
if Result<>mrYes then
|
if Result<>mrYes then
|
||||||
begin
|
begin
|
||||||
debugln(['Error: (lazarus) [TMainIDE.DoBuildProject] MainBuildBoss.DoCheckIfProjectNeedsCompilation failed']);
|
debugln(['Error: (lazarus) [TMainIDE.DoBuildProject] MainBuildBoss.DoCheckIfProjectNeedsCompilation failed']);
|
||||||
@ -6578,6 +6582,26 @@ begin
|
|||||||
if aCompileHint<>'' then
|
if aCompileHint<>'' then
|
||||||
aCompileHint:='Compile Reason: '+aCompileHint;
|
aCompileHint:='Compile Reason: '+aCompileHint;
|
||||||
|
|
||||||
|
// execute compilation tool 'Before'
|
||||||
|
if not (pbfSkipTools in Flags) then begin
|
||||||
|
ToolBefore:=TProjectCompilationToolOptions(
|
||||||
|
Project1.CompilerOptions.ExecuteBefore);
|
||||||
|
if (AReason in ToolBefore.CompileReasons) then begin
|
||||||
|
Result:=Project1.CompilerOptions.ExecuteBefore.Execute(
|
||||||
|
Project1.ProjectDirectory, lisProject2+lisExecutingCommandBefore,
|
||||||
|
aCompileHint);
|
||||||
|
if Result<>mrOk then
|
||||||
|
begin
|
||||||
|
debugln(['Error: (lazarus) [TMainIDE.DoBuildProject] CompilerOptions.ExecuteBefore.Execute failed']);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// leave if no further action is needed
|
||||||
|
if NoBuildNeeded then
|
||||||
|
exit;
|
||||||
|
|
||||||
// create unit output directory
|
// create unit output directory
|
||||||
UnitOutputDirectory:=Project1.CompilerOptions.GetUnitOutPath(false);
|
UnitOutputDirectory:=Project1.CompilerOptions.GetUnitOutPath(false);
|
||||||
if Project1.IsVirtual and (not FilenameIsAbsolute(UnitOutputDirectory)) then
|
if Project1.IsVirtual and (not FilenameIsAbsolute(UnitOutputDirectory)) then
|
||||||
@ -6638,22 +6662,6 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// execute compilation tool 'Before'
|
|
||||||
if not (pbfSkipTools in Flags) then begin
|
|
||||||
ToolBefore:=TProjectCompilationToolOptions(
|
|
||||||
Project1.CompilerOptions.ExecuteBefore);
|
|
||||||
if (AReason in ToolBefore.CompileReasons) then begin
|
|
||||||
Result:=Project1.CompilerOptions.ExecuteBefore.Execute(
|
|
||||||
Project1.ProjectDirectory, lisProject2+lisExecutingCommandBefore,
|
|
||||||
aCompileHint);
|
|
||||||
if Result<>mrOk then
|
|
||||||
begin
|
|
||||||
debugln(['Error: (lazarus) [TMainIDE.DoBuildProject] CompilerOptions.ExecuteBefore.Execute failed']);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if (AReason in Project1.CompilerOptions.CompileReasons)
|
if (AReason in Project1.CompilerOptions.CompileReasons)
|
||||||
and (not (pbfDoNotCompileProject in Flags)) then begin
|
and (not (pbfDoNotCompileProject in Flags)) then begin
|
||||||
try
|
try
|
||||||
@ -6678,7 +6686,7 @@ begin
|
|||||||
StartTime:=Now;
|
StartTime:=Now;
|
||||||
Result:=TheCompiler.Compile(Project1,
|
Result:=TheCompiler.Compile(Project1,
|
||||||
WorkingDir,CompilerFilename,CompilerParams,
|
WorkingDir,CompilerFilename,CompilerParams,
|
||||||
(pbfCleanCompile in Flags) or NeedBuildAllFlag,
|
(AReason = crBuild) or NeedBuildAllFlag,
|
||||||
pbfSkipLinking in Flags,
|
pbfSkipLinking in Flags,
|
||||||
pbfSkipAssembler in Flags,aCompileHint);
|
pbfSkipAssembler in Flags,aCompileHint);
|
||||||
if ConsoleVerbosity>=0 then
|
if ConsoleVerbosity>=0 then
|
||||||
@ -6830,7 +6838,7 @@ begin
|
|||||||
// Build project first
|
// Build project first
|
||||||
if ConsoleVerbosity>0 then
|
if ConsoleVerbosity>0 then
|
||||||
debugln('Hint: (lazarus) TMainIDE.DoInitProjectRun Check build ...');
|
debugln('Hint: (lazarus) TMainIDE.DoInitProjectRun Check build ...');
|
||||||
if DoBuildProject(crRun,[pbfOnlyIfNeeded]) <> mrOk then
|
if DoBuildProject(crRun,[]) <> mrOk then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
// Check project build
|
// Check project build
|
||||||
|
Loading…
Reference in New Issue
Block a user