lazbuild: stop if project compiler empty

This commit is contained in:
mattias 2022-04-14 21:49:46 +02:00
parent 49222b1e9d
commit 441e150345
3 changed files with 20 additions and 4 deletions

View File

@ -57,6 +57,9 @@ uses
Compiler, FPCSrcScan, PackageDefs, PackageSystem, Project, ProjectIcon,
ModeMatrixOpts, BaseBuildManager, ApplicationBundle, RunParamsOpts;
const
cInvalidCompiler = 'InvalidCompiler';
type
{ TBuildManager }
@ -717,8 +720,14 @@ begin
Result:=''
else if (Pos('$',Result)<1) and (FilenameIsAbsolute(Result)) then
Result:=TrimFilename(Result)
else
else begin
Result:=FBuildTarget.GetCompilerFilename;
if Result='' then
begin
Result:=cInvalidCompiler;
debugln(['Error: (lazarus) [TBuildManager.GetCompilerFilename] invalid compiler "',Opts.CompilerPath,'"']);
end;
end;
//debugln(['TBuildManager.GetCompilerFilename project compiler="',Result,'"']);
end;
end;
@ -2823,7 +2832,7 @@ var
LCLTargetChanged: Boolean;
CompilerTargetOS: string;
CompilerTargetCPU: string;
CompQueryOptions: String;
CompQueryOptions, CompilerFilename: String;
begin
{$IFDEF VerboseDefaultCompilerTarget}
debugln(['TBuildManager.SetBuildTarget TargetOS="',TargetOS,'" TargetCPU="',TargetCPU,'" LCLWidgetType="',LCLWidgetType,'"']);
@ -2864,8 +2873,12 @@ begin
else if fTargetOS<>'' then
CompQueryOptions:='-T'+GetFPCTargetOS(fTargetOS);
// Note: resolving the comiler filename requires macros
CompilerFilename:=GetCompilerFilename;
if CompilerFilename=cInvalidCompiler then
exit;
CodeToolBoss.CompilerDefinesCache.ConfigCaches.GetDefaultCompilerTarget(
GetCompilerFilename,CompQueryOptions,CompilerTargetOS,CompilerTargetCPU);
CompilerFilename,CompQueryOptions,CompilerTargetOS,CompilerTargetCPU);
if fTargetOS='' then
fTargetOS:=CompilerTargetOS;
if fTargetOS='' then

View File

@ -366,7 +366,7 @@ end;
procedure TCompiler.WriteError(const Msg: string);
begin
DebugLn('TCompiler.WriteError ',Msg);
DebugLn(Msg,' [TCompiler.WriteError]');
if IDEMessagesWindow<>nil then
IDEMessagesWindow.AddCustomMessage(mluError,Msg);
end;

View File

@ -868,6 +868,9 @@ var
CompilerFilename := CompilerOverride
else
CompilerFilename:=Project1.GetCompilerFilename;
if CompilerFilename='' then
Error(ErrorBuildFailed,'invalid compiler "'+Project1.CompilerOptions.CompilerPath+'"');
//DebugLn(['TLazBuildApplication.BuildProject CompilerFilename="',CompilerFilename,'" CompilerPath="',Project1.CompilerOptions.CompilerPath,'"']);
// CompileHint: use absolute paths, same as TBuildManager.DoCheckIfProjectNeedsCompilation
CompilerParams:=Project1.CompilerOptions.MakeOptionsString([ccloAbsolutePaths])