IDE/lazbuild: simplified TestBuildDirectory, when checking if project needs compile check if target file exists

git-svn-id: trunk@48406 -
This commit is contained in:
mattias 2015-03-17 13:30:53 +00:00
parent a6a61ddf51
commit 7760e5b734
11 changed files with 54 additions and 114 deletions

View File

@ -64,7 +64,6 @@ type
function GetProjectPublishDir: string; virtual; abstract; function GetProjectPublishDir: string; virtual; abstract;
function GetProjectTargetFilename(aProject: TProject): string; virtual; abstract; function GetProjectTargetFilename(aProject: TProject): string; virtual; abstract;
function GetProjectUsesAppBundle: Boolean; virtual; abstract; function GetProjectUsesAppBundle: Boolean; virtual; abstract;
function GetTestProjectFilename(aProject: TProject): string; virtual; abstract;
function GetTestUnitFilename(AnUnitInfo: TUnitInfo): string; virtual; abstract; function GetTestUnitFilename(AnUnitInfo: TUnitInfo): string; virtual; abstract;
function GetTestBuildDirectory: string; virtual; abstract; function GetTestBuildDirectory: string; virtual; abstract;
function IsTestUnitFilename(const AFilename: string): boolean; virtual; abstract; function IsTestUnitFilename(const AFilename: string): boolean; virtual; abstract;

View File

@ -188,7 +188,6 @@ type
function GetProjectPublishDir: string; override; function GetProjectPublishDir: string; override;
function GetProjectTargetFilename(aProject: TProject): string; override; function GetProjectTargetFilename(aProject: TProject): string; override;
function GetProjectUsesAppBundle: Boolean; override; function GetProjectUsesAppBundle: Boolean; override;
function GetTestProjectFilename(aProject: TProject): string; override;
function GetTestUnitFilename(AnUnitInfo: TUnitInfo): string; override; function GetTestUnitFilename(AnUnitInfo: TUnitInfo): string; override;
function GetTestBuildDirectory: string; override; function GetTestBuildDirectory: string; override;
function IsTestUnitFilename(const AFilename: string): boolean; override; function IsTestUnitFilename(const AFilename: string): boolean; override;
@ -682,15 +681,8 @@ begin
if aProject=nil then exit; if aProject=nil then exit;
Result:=aProject.RunParameterOptions.HostApplicationFilename; Result:=aProject.RunParameterOptions.HostApplicationFilename;
GlobalMacroList.SubstituteStr(Result); GlobalMacroList.SubstituteStr(Result);
if Result='' then begin if (Result='') and (aProject.MainUnitID>=0) then begin
if aProject.IsVirtual then Result := aProject.CompilerOptions.CreateTargetFilename;
Result:=GetTestProjectFilename(aProject)
else begin
if aProject.MainUnitID>=0 then begin
Result :=
aProject.CompilerOptions.CreateTargetFilename(aProject.MainFilename);
end;
end;
end; end;
end; end;
@ -701,24 +693,6 @@ begin
and (GetTargetOS = 'darwin') and Project1.UseAppBundle; and (GetTargetOS = 'darwin') and Project1.UseAppBundle;
end; end;
function TBuildManager.GetTestProjectFilename(aProject: TProject): string;
var
TestDir: String;
begin
Result:='';
if aProject=nil then exit;
if (aProject.MainUnitID<0) then exit;
Result:=GetTestUnitFilename(aProject.MainUnitInfo);
if Result='' then exit;
Result:=aProject.CompilerOptions.CreateTargetFilename(Result);
if Result='' then exit;
if (not FilenameIsAbsolute(Result)) then begin
TestDir:=GetTestBuildDirectory;
if TestDir='' then exit;
Result:=TestDir+Result;
end;
end;
function TBuildManager.GetTestUnitFilename(AnUnitInfo: TUnitInfo): string; function TBuildManager.GetTestUnitFilename(AnUnitInfo: TUnitInfo): string;
var var
TestDir: String; TestDir: String;
@ -1123,6 +1097,7 @@ var
AnUnitInfo: TUnitInfo; AnUnitInfo: TUnitInfo;
LFMFilename: String; LFMFilename: String;
IcoRes: TProjectIcon; IcoRes: TProjectIcon;
aTargetFilename: String;
function EditorFileHasChanged: boolean; function EditorFileHasChanged: boolean;
begin begin
@ -1174,7 +1149,7 @@ begin
//DebugLn(['TBuildManager.DoCheckIfProjectNeedsCompilation CompilerFilename="',CompilerFilename,'" CompilerPath="',AProject.CompilerOptions.CompilerPath,'"']); //DebugLn(['TBuildManager.DoCheckIfProjectNeedsCompilation CompilerFilename="',CompilerFilename,'" CompilerPath="',AProject.CompilerOptions.CompilerPath,'"']);
// Note: use absolute paths, because some external tools resolve symlinked directories // Note: use absolute paths, because some external tools resolve symlinked directories
CompilerParams := CompilerParams :=
AProject.CompilerOptions.MakeOptionsString(SrcFilename,[ccloAbsolutePaths]) AProject.CompilerOptions.MakeOptionsString([ccloAbsolutePaths])
+ ' ' + PrepareCmdLineOption(SrcFilename); + ' ' + PrepareCmdLineOption(SrcFilename);
//DebugLn('TBuildManager.DoCheckIfProjectNeedsCompilation WorkingDir="',WorkingDir,'" SrcFilename="',SrcFilename,'" CompilerFilename="',CompilerFilename,'" CompilerParams="',CompilerParams,'"'); //DebugLn('TBuildManager.DoCheckIfProjectNeedsCompilation WorkingDir="',WorkingDir,'" SrcFilename="',SrcFilename,'" CompilerFilename="',CompilerFilename,'" CompilerParams="',CompilerParams,'"');
@ -1334,6 +1309,16 @@ begin
exit(mrYes); exit(mrYes);
end; end;
// check target file
aTargetFilename:=AProject.CompilerOptions.CreateTargetFilename;
debugln(['TBuildManager.DoCheckIfProjectNeedsCompilation aTargetFilename=',aTargetFilename]);
if (aTargetFilename<>'') and not FileExistsCached(aTargetFilename) then begin
if ConsoleVerbosity>=0 then
debugln(['TBuildManager.DoCheckIfProjectNeedsCompilation missing target file "',aTargetFilename,'"']);
Note+='Project''s target file "'+aTargetFilename+'" is missing.';
exit(mrYes);
end;
Result:=mrNo; Result:=mrNo;
end; end;
@ -1621,12 +1606,7 @@ begin
Result := False; Result := False;
if Project1.MainUnitInfo = nil then if Project1.MainUnitInfo = nil then
Exit; Exit;
if Project1.IsVirtual then TargetExeName := Project1.CompilerOptions.CreateTargetFilename;
TargetExeName := GetTestBuildDirectory +
ExtractFilename(Project1.MainUnitInfo.Filename)
else
TargetExeName := Project1.CompilerOptions.CreateTargetFilename(
Project1.MainFilename);
if not (CreateApplicationBundle(TargetExeName, Project1.GetTitle, True) in if not (CreateApplicationBundle(TargetExeName, Project1.GetTitle, True) in
[mrOk, mrIgnore]) then [mrOk, mrIgnore]) then

View File

@ -327,7 +327,7 @@ begin
end; end;
try try
// create compiler command line options // create compiler command line options
CmdLineParams:=Options.MakeOptionsString(BogusFilename, CmdLineParams:=Options.MakeOptionsString(
[ccloAddVerboseAll,ccloDoNotAppendOutFileOption,ccloAbsolutePaths]) [ccloAddVerboseAll,ccloDoNotAppendOutFileOption,ccloAbsolutePaths])
+' '+BogusFilename; +' '+BogusFilename;
CompileTool:=ExternalToolList.Add(dlgCCOTestToolCompilingEmptyFile); CompileTool:=ExternalToolList.Add(dlgCCOTestToolCompilingEmptyFile);

View File

@ -278,7 +278,7 @@ var
TargetFilename: String; TargetFilename: String;
begin begin
Result:=mrCancel; Result:=mrCancel;
if ConsoleVerbosity>=0 then if ConsoleVerbosity>=1 then
DebugLn('TCompiler.Compile WorkingDir="',WorkingDir,'" CompilerFilename="',CompilerFilename,'" CompilerParams="',CompilerParams,'"'); DebugLn('TCompiler.Compile WorkingDir="',WorkingDir,'" CompilerFilename="',CompilerFilename,'" CompilerParams="',CompilerParams,'"');
try try
@ -323,8 +323,7 @@ begin
if TargetCPU<>GetCompiledTargetCPU then if TargetCPU<>GetCompiledTargetCPU then
Title+=Format(lisCPU, [TargetCPU]); Title+=Format(lisCPU, [TargetCPU]);
TargetFilename:=AProject.GetShortFilename( TargetFilename:=AProject.GetShortFilename(
AProject.CompilerOptions.CreateTargetFilename(AProject.MainFilename), AProject.CompilerOptions.CreateTargetFilename,false);
false);
if TargetFilename<>'' then if TargetFilename<>'' then
Title+=Format(lisTarget2, [TargetFilename]); Title+=Format(lisTarget2, [TargetFilename]);

View File

@ -486,12 +486,10 @@ type
procedure SetAlternativeCompile(const Command: string; ScanFPCMsgs: boolean); override; procedure SetAlternativeCompile(const Command: string; ScanFPCMsgs: boolean); override;
function MakeOptionsString(Flags: TCompilerCmdLineOptions): String; function MakeOptionsString(Flags: TCompilerCmdLineOptions): String; virtual;
function MakeOptionsString(const MainSourceFileName: string;
Flags: TCompilerCmdLineOptions): String; virtual;
function GetSyntaxOptionsString: string; virtual; function GetSyntaxOptionsString: string; virtual;
function CreatePPUFilename(const SourceFileName: string): string; override; function CreatePPUFilename(const SourceFileName: string): string; override;
function CreateTargetFilename(const MainSourceFileName: string): string; virtual; function CreateTargetFilename: string; virtual;
function GetTargetFileExt: string; virtual; function GetTargetFileExt: string; virtual;
function GetTargetFilePrefix: string; virtual; function GetTargetFilePrefix: string; virtual;
procedure GetInheritedCompilerOptions(var OptionsList: TFPList // list of TAdditionalCompilerOptions procedure GetInheritedCompilerOptions(var OptionsList: TFPList // list of TAdditionalCompilerOptions
@ -1903,8 +1901,7 @@ end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
TBaseCompilerOptions CreateTargetFilename TBaseCompilerOptions CreateTargetFilename
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TBaseCompilerOptions.CreateTargetFilename( function TBaseCompilerOptions.CreateTargetFilename: string;
const MainSourceFileName: string): string;
procedure AppendDefaultExt; procedure AppendDefaultExt;
var var
@ -1952,13 +1949,20 @@ function TBaseCompilerOptions.CreateTargetFilename(
var var
UnitOutDir: String; UnitOutDir: String;
OutFilename: String; OutFilename: String;
Dir: String;
begin begin
Result:=TargetFilename; Result:=TargetFilename;
if Assigned(ParsedOpts.OnLocalSubstitute) then if Result='' then
begin begin
Result:=ParsedOpts.OnLocalSubstitute(Result,false); // the compiler cuts off the source extension
TargetFilename:=ExtractFileNameOnly(GetDefaultMainSourceFileName);
end else begin end else begin
Result:=ParseString(ParsedOpts,Result,false); if Assigned(ParsedOpts.OnLocalSubstitute) then
begin
Result:=ParsedOpts.OnLocalSubstitute(Result,false);
end else begin
Result:=ParseString(ParsedOpts,Result,false);
end;
end; end;
if (Result<>'') and FilenameIsAbsolute(Result) then begin if (Result<>'') and FilenameIsAbsolute(Result) then begin
// fully specified target filename // fully specified target filename
@ -1971,9 +1975,13 @@ begin
if UnitOutDir='' then if UnitOutDir='' then
UnitOutDir:=BaseDirectory; UnitOutDir:=BaseDirectory;
Result:=AppendPathDelim(UnitOutDir)+ExtractFileName(Result); Result:=AppendPathDelim(UnitOutDir)+ExtractFileName(Result);
end else begin end else if BaseDirectory<>'' then begin
// the program is put relative to the base directory // the program is put relative to the base directory
Result:=CreateAbsolutePath(Result,BaseDirectory); Result:=CreateAbsolutePath(Result,BaseDirectory);
end else begin
// put into test directory
Dir:=EnvironmentOptions.GetParsedTestBuildDirectory;
Result:=CreateAbsolutePath(Result,Dir);
end; end;
end else begin end else begin
// no target given => put into unit output directory // no target given => put into unit output directory
@ -1981,7 +1989,9 @@ begin
UnitOutDir:=GetUnitOutPath(false); UnitOutDir:=GetUnitOutPath(false);
if UnitOutDir='' then if UnitOutDir='' then
UnitOutDir:=BaseDirectory; UnitOutDir:=BaseDirectory;
OutFilename:=ExtractFileNameOnly(MainSourceFileName); if UnitOutDir='' then
UnitOutDir:=EnvironmentOptions.GetParsedTestBuildDirectory;
OutFilename:=ExtractFileNameOnly(GetDefaultMainSourceFileName);
//debugln('TBaseCompilerOptions.CreateTargetFilename MainSourceFileName=',MainSourceFileName,' OutFilename=',OutFilename,' TargetFilename=',TargetFilename,' UnitOutDir=',UnitOutDir); //debugln('TBaseCompilerOptions.CreateTargetFilename MainSourceFileName=',MainSourceFileName,' OutFilename=',OutFilename,' TargetFilename=',TargetFilename,' UnitOutDir=',UnitOutDir);
Result:=CreateAbsolutePath(OutFilename,UnitOutDir); Result:=CreateAbsolutePath(OutFilename,UnitOutDir);
end; end;
@ -2434,15 +2444,6 @@ begin
Result:=ShortenSearchPath(Result,BaseDirectory,BaseDirectory); Result:=ShortenSearchPath(Result,BaseDirectory,BaseDirectory);
end; end;
{------------------------------------------------------------------------------
TBaseCompilerOptions MakeOptionsString
------------------------------------------------------------------------------}
function TBaseCompilerOptions.MakeOptionsString(
Flags: TCompilerCmdLineOptions): String;
begin
Result:=MakeOptionsString(GetDefaultMainSourceFileName,Flags);
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
function TBaseCompilerOptions.MakeOptionsString( function TBaseCompilerOptions.MakeOptionsString(
const MainSourceFilename: string; const MainSourceFilename: string;
@ -2451,7 +2452,7 @@ end;
Get all the options and create a string that can be passed to the compiler Get all the options and create a string that can be passed to the compiler
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TBaseCompilerOptions.MakeOptionsString( function TBaseCompilerOptions.MakeOptionsString(
const MainSourceFileName: string; Flags: TCompilerCmdLineOptions): String; Flags: TCompilerCmdLineOptions): String;
var var
switches, tempsw, t: String; switches, tempsw, t: String;
InhLinkerOpts: String; InhLinkerOpts: String;
@ -2487,10 +2488,6 @@ var
end; end;
begin begin
CurMainSrcFile:=MainSourceFileName;
if CurMainSrcFile='' then
CurMainSrcFile:=GetDefaultMainSourceFileName;
switches := ''; switches := '';
{ options of fpc 2.7.1 : { options of fpc 2.7.1 :
@ -3057,12 +3054,13 @@ begin
{ * -o to define the target file name. { * -o to define the target file name.
* -FE if the target file name is not in the project directory (where the lpi file is) * -FE if the target file name is not in the project directory (where the lpi file is)
* -FU if the unit output directory is not empty } * -FU if the unit output directory is not empty }
CurMainSrcFile:=GetDefaultMainSourceFileName;
//DebugLn(['TBaseCompilerOptions.MakeOptionsString ',DbgSName(Self),' ',ccloDoNotAppendOutFileOption in Flags,' TargetFilename="',TargetFilename,'" CurMainSrcFile="',CurMainSrcFile,'" CurOutputDir="',CurOutputDir,'"']); //DebugLn(['TBaseCompilerOptions.MakeOptionsString ',DbgSName(Self),' ',ccloDoNotAppendOutFileOption in Flags,' TargetFilename="',TargetFilename,'" CurMainSrcFile="',CurMainSrcFile,'" CurOutputDir="',CurOutputDir,'"']);
if (not (ccloDoNotAppendOutFileOption in Flags)) if (not (ccloDoNotAppendOutFileOption in Flags))
and (not (ccloNoMacroParams in Flags)) and (not (ccloNoMacroParams in Flags))
and ((TargetFilename<>'') or (CurMainSrcFile<>'') or (CurOutputDir<>'')) then and ((TargetFilename<>'') or (CurMainSrcFile<>'') or (CurOutputDir<>'')) then
begin begin
NewTargetFilename := CreateTargetFilename(CurMainSrcFile); NewTargetFilename := CreateTargetFilename;
if (NewTargetFilename<>'') then if (NewTargetFilename<>'') then
begin begin
if not (ccloAbsolutePaths in Flags) then if not (ccloAbsolutePaths in Flags) then
@ -3922,6 +3920,8 @@ function TParsedCompilerOptions.DoParseOption(const OptionText: string;
Result:=GetParsedPIValue(pcosBaseDir) Result:=GetParsedPIValue(pcosBaseDir)
else else
Result:=GetParsedValue(pcosBaseDir); Result:=GetParsedValue(pcosBaseDir);
if Result='' then
Result:=EnvironmentOptions.GetParsedTestBuildDirectory;
end; end;
procedure MakeFilenameAbsolute(var aFilename: string); procedure MakeFilenameAbsolute(var aFilename: string);

View File

@ -86,8 +86,7 @@ begin
TargetExeName := LazarusIDE.GetTestBuildDirectory + TargetExeName := LazarusIDE.GetTestBuildDirectory +
ExtractFilename(AProject.MainUnitInfo.Filename) ExtractFilename(AProject.MainUnitInfo.Filename)
else else
TargetExeName := AProject.CompilerOptions.CreateTargetFilename( TargetExeName := AProject.CompilerOptions.CreateTargetFilename;
AProject.MainFilename);
if not (CreateApplicationBundle(TargetExeName, AProject.GetTitle, True) in if not (CreateApplicationBundle(TargetExeName, AProject.GetTitle, True) in
[mrOk, mrIgnore]) then [mrOk, mrIgnore]) then

View File

@ -57,11 +57,11 @@
<Unit2> <Unit2>
<Filename Value="basebuildmanager.pas"/> <Filename Value="basebuildmanager.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="BaseBuildManager"/>
</Unit2> </Unit2>
<Unit3> <Unit3>
<Filename Value="idecmdline.pas"/> <Filename Value="idecmdline.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="IDECmdLine"/>
</Unit3> </Unit3>
</Units> </Units>
</ProjectOptions> </ProjectOptions>

View File

@ -86,8 +86,6 @@ type
// project // project
procedure OnProjectChangeInfoFile(TheProject: TProject); procedure OnProjectChangeInfoFile(TheProject: TProject);
procedure OnProjectGetTestDirectory({%H-}TheProject: TProject; out
TestDir: string);
// dialogs // dialogs
function OnIDEMessageDialog(const aCaption, aMsg: string; function OnIDEMessageDialog(const aCaption, aMsg: string;
@ -317,12 +315,6 @@ begin
Project1.ProjectDirectory) Project1.ProjectDirectory)
end; end;
procedure TLazBuildApplication.OnProjectGetTestDirectory(TheProject: TProject;
out TestDir: string);
begin
TestDir:=BuildBoss.GetTestBuildDirectory;
end;
function TLazBuildApplication.OnIDEMessageDialog(const aCaption, aMsg: string; function TLazBuildApplication.OnIDEMessageDialog(const aCaption, aMsg: string;
DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; const HelpKeyword: string DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; const HelpKeyword: string
): Integer; ): Integer;
@ -802,7 +794,7 @@ var
Error(ErrorBuildFailed,'Unable to create project unit output directory '+UnitOutputDirectory); Error(ErrorBuildFailed,'Unable to create project unit output directory '+UnitOutputDirectory);
// create target output directory // create target output directory
TargetExeName := Project1.CompilerOptions.CreateTargetFilename(Project1.MainFilename); TargetExeName := Project1.CompilerOptions.CreateTargetFilename;
TargetExeDir := ExtractFilePath(TargetExeName); TargetExeDir := ExtractFilePath(TargetExeName);
if not ForceDirectory(TargetExeDir) then if not ForceDirectory(TargetExeDir) then
Error(ErrorBuildFailed,'Unable to create project target directory '+TargetExeDir); Error(ErrorBuildFailed,'Unable to create project target directory '+TargetExeDir);
@ -834,7 +826,7 @@ var
CompilerFilename:=Project1.GetCompilerFilename; CompilerFilename:=Project1.GetCompilerFilename;
//DebugLn(['TLazBuildApplication.BuildProject CompilerFilename="',CompilerFilename,'" CompilerPath="',Project1.CompilerOptions.CompilerPath,'"']); //DebugLn(['TLazBuildApplication.BuildProject CompilerFilename="',CompilerFilename,'" CompilerPath="',Project1.CompilerOptions.CompilerPath,'"']);
// CompileHint: use absolute paths, same as TBuildManager.DoCheckIfProjectNeedsCompilation // CompileHint: use absolute paths, same as TBuildManager.DoCheckIfProjectNeedsCompilation
CompilerParams:=Project1.CompilerOptions.MakeOptionsString(SrcFilename,[ccloAbsolutePaths]) CompilerParams:=Project1.CompilerOptions.MakeOptionsString([ccloAbsolutePaths])
+' '+PrepareCmdLineOption(SrcFilename); +' '+PrepareCmdLineOption(SrcFilename);
NeedBuildAllFlag:=false; NeedBuildAllFlag:=false;
@ -842,7 +834,7 @@ var
if (crCompile in Project1.CompilerOptions.CompileReasons) then begin if (crCompile in Project1.CompilerOptions.CompileReasons) then begin
// check if project is already uptodate // check if project is already uptodate
SubResult:=MainBuildBoss.DoCheckIfProjectNeedsCompilation(Project1, SubResult:=MainBuildBoss.DoCheckIfProjectNeedsCompilation(Project1,
NeedBuildAllFlag,CompileHint); NeedBuildAllFlag,CompileHint);
if (not BuildAll) if (not BuildAll)
and (not (pfAlwaysBuild in Project1.Flags)) then begin and (not (pfAlwaysBuild in Project1.Flags)) then begin
if SubResult=mrNo then begin if SubResult=mrNo then begin
@ -976,7 +968,6 @@ begin
Result.MainProject:=true; Result.MainProject:=true;
Result.OnFileBackup:=@BuildBoss.BackupFile; Result.OnFileBackup:=@BuildBoss.BackupFile;
Result.OnGetTestDirectory:=@OnProjectGetTestDirectory;
Result.OnChangeProjectInfoFile:=@OnProjectChangeInfoFile; Result.OnChangeProjectInfoFile:=@OnProjectChangeInfoFile;
finally finally

View File

@ -691,7 +691,6 @@ type
XMLConfig: TXMLConfig; Merge: boolean); XMLConfig: TXMLConfig; Merge: boolean);
procedure OnSaveProjectInfoToXMLConfig(TheProject: TProject; procedure OnSaveProjectInfoToXMLConfig(TheProject: TProject;
XMLConfig: TXMLConfig; WriteFlags: TProjectWriteFlags); XMLConfig: TXMLConfig; WriteFlags: TProjectWriteFlags);
procedure OnProjectGetTestDirectory(TheProject: TProject; out TestDir: string);
procedure OnProjectChangeInfoFile(TheProject: TProject); procedure OnProjectChangeInfoFile(TheProject: TProject);
procedure OnSaveProjectUnitSessionInfo(AUnitInfo: TUnitInfo); procedure OnSaveProjectUnitSessionInfo(AUnitInfo: TUnitInfo);
public public
@ -5683,12 +5682,6 @@ begin
EditorMacroListViewer.SaveProjectSpecificInfo(XMLConfig, WriteFlags); EditorMacroListViewer.SaveProjectSpecificInfo(XMLConfig, WriteFlags);
end; end;
procedure TMainIDE.OnProjectGetTestDirectory(TheProject: TProject; out TestDir: string);
begin
if TheProject=nil then ;
TestDir:=GetTestBuildDirectory;
end;
procedure TMainIDE.OnProjectChangeInfoFile(TheProject: TProject); procedure TMainIDE.OnProjectChangeInfoFile(TheProject: TProject);
begin begin
if (Project1=nil) or (TheProject<>Project1) then exit; if (Project1=nil) or (TheProject<>Project1) then exit;
@ -6283,7 +6276,6 @@ begin
Result.OnLoadProjectInfo:=@OnLoadProjectInfoFromXMLConfig; Result.OnLoadProjectInfo:=@OnLoadProjectInfoFromXMLConfig;
Result.OnSaveProjectInfo:=@OnSaveProjectInfoToXMLConfig; Result.OnSaveProjectInfo:=@OnSaveProjectInfoToXMLConfig;
Result.OnSaveUnitSessionInfo:=@OnSaveProjectUnitSessionInfo; Result.OnSaveUnitSessionInfo:=@OnSaveProjectUnitSessionInfo;
Result.OnGetTestDirectory:=@OnProjectGetTestDirectory;
Result.OnChangeProjectInfoFile:=@OnProjectChangeInfoFile; Result.OnChangeProjectInfoFile:=@OnProjectChangeInfoFile;
Result.IDEOptions.OnBeforeRead:=@DoProjectOptionsBeforeRead; Result.IDEOptions.OnBeforeRead:=@DoProjectOptionsBeforeRead;
Result.IDEOptions.OnAfterWrite:=@DoProjectOptionsAfterWrite; Result.IDEOptions.OnAfterWrite:=@DoProjectOptionsAfterWrite;
@ -6813,9 +6805,7 @@ begin
end; end;
// create target output directory // create target output directory
TargetExeName := Project1.CompilerOptions.CreateTargetFilename(Project1.MainFilename); TargetExeName := Project1.CompilerOptions.CreateTargetFilename;
if Project1.IsVirtual and (not FilenameIsAbsolute(TargetExeName)) then
TargetExeName := GetTestBuildDirectory + TargetExeName;
TargetExeDirectory:=ExtractFilePath(TargetExeName); TargetExeDirectory:=ExtractFilePath(TargetExeName);
if (FilenameIsAbsolute(TargetExeDirectory)) if (FilenameIsAbsolute(TargetExeDirectory))
and (not DirPathExistsCached(TargetExeDirectory)) then begin and (not DirPathExistsCached(TargetExeDirectory)) then begin
@ -6883,7 +6873,7 @@ begin
CompilerFilename:=Project1.GetCompilerFilename; CompilerFilename:=Project1.GetCompilerFilename;
// Hint: use absolute paths, because some external tools resolve symlinked directories // Hint: use absolute paths, because some external tools resolve symlinked directories
CompilerParams := CompilerParams :=
Project1.CompilerOptions.MakeOptionsString(SrcFilename,[ccloAbsolutePaths]) Project1.CompilerOptions.MakeOptionsString([ccloAbsolutePaths])
+ ' ' + PrepareCmdLineOption(SrcFilename); + ' ' + PrepareCmdLineOption(SrcFilename);
// write state file, to avoid building clean every time // write state file, to avoid building clean every time
Result:=Project1.SaveStateFile(CompilerFilename,CompilerParams,false); Result:=Project1.SaveStateFile(CompilerFilename,CompilerParams,false);

View File

@ -76,8 +76,6 @@ type
Merge: boolean) of object; Merge: boolean) of object;
TOnSaveProjectInfo = procedure(TheProject: TProject; TOnSaveProjectInfo = procedure(TheProject: TProject;
XMLConfig: TXMLConfig; WriteFlags: TProjectWriteFlags) of object; XMLConfig: TXMLConfig; WriteFlags: TProjectWriteFlags) of object;
TOnProjectGetTestDirectory = procedure(TheProject: TProject;
out TestDir: string) of object;
TOnChangeProjectInfoFile = procedure(TheProject: TProject) of object; TOnChangeProjectInfoFile = procedure(TheProject: TProject) of object;
TOnSaveUnitSessionInfoInfo = procedure(AUnitInfo: TUnitInfo) of object; TOnSaveUnitSessionInfoInfo = procedure(AUnitInfo: TUnitInfo) of object;
@ -752,7 +750,6 @@ type
FOnChangeProjectInfoFile: TOnChangeProjectInfoFile; FOnChangeProjectInfoFile: TOnChangeProjectInfoFile;
FOnEndUpdate: TEndUpdateProjectEvent; FOnEndUpdate: TEndUpdateProjectEvent;
fOnFileBackup: TOnFileBackup; fOnFileBackup: TOnFileBackup;
FOnGetTestDirectory: TOnProjectGetTestDirectory;
FOnLoadProjectInfo: TOnLoadProjectInfo; FOnLoadProjectInfo: TOnLoadProjectInfo;
FOnSaveProjectInfo: TOnSaveProjectInfo; FOnSaveProjectInfo: TOnSaveProjectInfo;
FOnSaveUnitSessionInfo: TOnSaveUnitSessionInfoInfo; FOnSaveUnitSessionInfo: TOnSaveUnitSessionInfoInfo;
@ -1026,7 +1023,6 @@ type
function GetOutputDirectory: string; function GetOutputDirectory: string;
function GetCompilerFilename: string; function GetCompilerFilename: string;
function GetStateFilename: string; function GetStateFilename: string;
function GetTestDirectory: string;
function GetCompileSourceFilename: string; function GetCompileSourceFilename: string;
procedure AutoAddOutputDirToIncPath; procedure AutoAddOutputDirToIncPath;
@ -1096,8 +1092,6 @@ type
write FOnChangeProjectInfoFile; write FOnChangeProjectInfoFile;
property OnEndUpdate: TEndUpdateProjectEvent read FOnEndUpdate write FOnEndUpdate; property OnEndUpdate: TEndUpdateProjectEvent read FOnEndUpdate write FOnEndUpdate;
property OnFileBackup: TOnFileBackup read fOnFileBackup write fOnFileBackup; property OnFileBackup: TOnFileBackup read fOnFileBackup write fOnFileBackup;
property OnGetTestDirectory: TOnProjectGetTestDirectory read FOnGetTestDirectory
write FOnGetTestDirectory;
property OnLoadProjectInfo: TOnLoadProjectInfo read FOnLoadProjectInfo property OnLoadProjectInfo: TOnLoadProjectInfo read FOnLoadProjectInfo
write FOnLoadProjectInfo; write FOnLoadProjectInfo;
property OnSaveProjectInfo: TOnSaveProjectInfo read FOnSaveProjectInfo property OnSaveProjectInfo: TOnSaveProjectInfo read FOnSaveProjectInfo
@ -4822,10 +4816,7 @@ end;
function TProject.GetOutputDirectory: string; function TProject.GetOutputDirectory: string;
begin begin
if IsVirtual then Result:=CompilerOptions.ParsedOpts.GetParsedValue(pcosOutputDir);
Result:=GetTestDirectory
else
Result:=CompilerOptions.ParsedOpts.GetParsedValue(pcosOutputDir);
end; end;
function TProject.GetCompilerFilename: string; function TProject.GetCompilerFilename: string;
@ -4841,14 +4832,6 @@ begin
Result:=AppendPathDelim(Result)+ChangeFileExt(GetCompileSourceFilename,'.compiled'); Result:=AppendPathDelim(Result)+ChangeFileExt(GetCompileSourceFilename,'.compiled');
end; end;
function TProject.GetTestDirectory: string;
begin
if Assigned(OnGetTestDirectory) then
OnGetTestDirectory(Self,Result)
else
Result:=GetCurrentDirUTF8;
end;
function TProject.GetCompileSourceFilename: string; function TProject.GetCompileSourceFilename: string;
begin begin
if MainUnitID<0 then if MainUnitID<0 then

View File

@ -370,7 +370,7 @@ type
function GetOwnerName: string; override; function GetOwnerName: string; override;
procedure InvalidateOptions; procedure InvalidateOptions;
function GetDefaultMainSourceFileName: string; override; function GetDefaultMainSourceFileName: string; override;
function CreateTargetFilename(const {%H-}MainSourceFileName: string): string; override; function CreateTargetFilename: string; override;
function HasCompilerCommand: boolean; override; function HasCompilerCommand: boolean; override;
procedure LoadFromXMLConfig(AXMLConfig: TXMLConfig; const Path: string); override; procedure LoadFromXMLConfig(AXMLConfig: TXMLConfig; const Path: string); override;
@ -4161,8 +4161,7 @@ begin
Result:=inherited GetDefaultMainSourceFileName; Result:=inherited GetDefaultMainSourceFileName;
end; end;
function TPkgCompilerOptions.CreateTargetFilename( function TPkgCompilerOptions.CreateTargetFilename: string;
const MainSourceFileName: string): string;
begin begin
Result:=''; Result:='';
end; end;