IDE: Move func param TargetFilename to private var in TLazarusBuilder.

git-svn-id: trunk@44038 -
This commit is contained in:
juha 2014-02-13 15:53:06 +00:00
parent e29c075ca4
commit cb0accad1a

View File

@ -154,12 +154,12 @@ type
TLazarusBuilder = class TLazarusBuilder = class
private private
UpdateRevisionInc: boolean; fUpdateRevInc: boolean;
fTargetFilename: string;
function CreateIDEMakeOptions(Profile: TBuildLazarusProfile; function CreateIDEMakeOptions(Profile: TBuildLazarusProfile;
Macros: TTransferMacroList; const PackageOptions: string; Macros: TTransferMacroList; const PackageOptions: string;
Flags: TBuildLazarusFlags; out ExtraOptions: string; Flags: TBuildLazarusFlags; out ExtraOptions: string;
out OutputDirRedirected: boolean; out OutputDirRedirected: boolean): TModalResult;
out TargetFilename: string): TModalResult;
function IsWriteProtected(Profile: TBuildLazarusProfile): Boolean; function IsWriteProtected(Profile: TBuildLazarusProfile): Boolean;
public public
function ShowConfigureBuildLazarusDlg(AProfiles: TBuildLazarusProfiles): TModalResult; function ShowConfigureBuildLazarusDlg(AProfiles: TBuildLazarusProfiles): TModalResult;
@ -370,7 +370,6 @@ var
OutputDirRedirected: boolean; OutputDirRedirected: boolean;
IdeBuildMode: TIdeBuildMode; IdeBuildMode: TIdeBuildMode;
Dir: String; Dir: String;
LazExeFilename: string;
Cmd: String; Cmd: String;
begin begin
Result:=mrCancel; Result:=mrCancel;
@ -466,8 +465,7 @@ begin
// append extra Profile // append extra Profile
ExtraOptions:=''; ExtraOptions:='';
Result:=CreateIDEMakeOptions(Profile,Macros,PackageOptions,Flags, Result:=CreateIDEMakeOptions(Profile,Macros,PackageOptions,Flags,
ExtraOptions,OutputDirRedirected, ExtraOptions,OutputDirRedirected);
LazExeFilename);
if Result<>mrOk then exit; if Result<>mrOk then exit;
if (not OutputDirRedirected) if (not OutputDirRedirected)
@ -476,7 +474,7 @@ begin
if ExtraOptions<>'' then if ExtraOptions<>'' then
EnvironmentOverrides.Values['OPT'] := ExtraOptions; EnvironmentOverrides.Values['OPT'] := ExtraOptions;
if not UpdateRevisionInc then begin if not fUpdateRevInc then begin
CheckRevisionInc; CheckRevisionInc;
EnvironmentOverrides.Values['USESVN2REVISIONINC'] := '0'; EnvironmentOverrides.Values['USESVN2REVISIONINC'] := '0';
end; end;
@ -487,7 +485,7 @@ begin
ApplyCleanOnce; ApplyCleanOnce;
if Result<>mrOk then begin if Result<>mrOk then begin
// build failed: restore backup of lazarus.exe // build failed: restore backup of lazarus.exe
RestoreBackup(LazExeFilename); RestoreBackup(fTargetFilename);
exit; exit;
end; end;
end; end;
@ -505,8 +503,7 @@ end;
function TLazarusBuilder.CreateIDEMakeOptions(Profile: TBuildLazarusProfile; function TLazarusBuilder.CreateIDEMakeOptions(Profile: TBuildLazarusProfile;
Macros: TTransferMacroList; const PackageOptions: string; Macros: TTransferMacroList; const PackageOptions: string;
Flags: TBuildLazarusFlags; out ExtraOptions: string; Flags: TBuildLazarusFlags; out ExtraOptions: string;
out OutputDirRedirected: boolean; out OutputDirRedirected: boolean): TModalResult;
out TargetFilename: string): TModalResult;
procedure BackupExe(var ExeFilename: string); procedure BackupExe(var ExeFilename: string);
var var
@ -599,7 +596,7 @@ var
begin begin
Result:=mrOk; Result:=mrOk;
OutputDirRedirected:=false; OutputDirRedirected:=false;
UpdateRevisionInc:=Profile.UpdateRevisionInc; fUpdateRevInc:=Profile.UpdateRevisionInc;
// create extra Profile // create extra Profile
ExtraOptions:=Profile.ExtraOptions; ExtraOptions:=Profile.ExtraOptions;
@ -638,7 +635,7 @@ begin
// The target directory is writable, the lazarus.o file can be created. // The target directory is writable, the lazarus.o file can be created.
// Otherwise: Don't touch the target filename. // Otherwise: Don't touch the target filename.
TargetFilename:=''; fTargetFilename:='';
UnitOutDir:=''; UnitOutDir:='';
TargetDirectory:=''; TargetDirectory:='';
CodeToolBoss.FPCDefinesCache.ConfigCaches.GetDefaultCompilerTarget( CodeToolBoss.FPCDefinesCache.ConfigCaches.GetDefaultCompilerTarget(
@ -693,7 +690,7 @@ begin
// Case 3. the lazarus directory is not writable // Case 3. the lazarus directory is not writable
// lazarus.exe to <primary config dir>/bin/ // lazarus.exe to <primary config dir>/bin/
// ppu files to <primary config dir>/units/<TargetCPU>-<TargetOS>/<LCLWidgetType> // ppu files to <primary config dir>/units/<TargetCPU>-<TargetOS>/<LCLWidgetType>
UpdateRevisionInc:=false; fUpdateRevInc:=false;
TargetDirectory:=AppendPathDelim(GetPrimaryConfigPath)+'bin'; TargetDirectory:=AppendPathDelim(GetPrimaryConfigPath)+'bin';
debugln('CreateBuildLazarusOptions LazDir readonly NewTargetDirectory=',TargetDirectory); debugln('CreateBuildLazarusOptions LazDir readonly NewTargetDirectory=',TargetDirectory);
UnitOutDir:=AppendPathDelim(GetPrimaryConfigPath)+'units' UnitOutDir:=AppendPathDelim(GetPrimaryConfigPath)+'units'
@ -712,17 +709,17 @@ begin
end; end;
end; end;
// compute targetfilename // compute TargetFilename
if not FilenameIsAbsolute(TargetDirectory) then if not FilenameIsAbsolute(TargetDirectory) then
TargetDirectory:= TargetDirectory:=
TrimFilename(AppendPathDelim(EnvironmentOptions.GetParsedLazarusDirectory)+TargetDirectory); TrimFilename(AppendPathDelim(EnvironmentOptions.GetParsedLazarusDirectory)+TargetDirectory);
if TargetFilename='' then if fTargetFilename='' then
TargetFilename:='lazarus'+GetExecutableExt(TargetOS); fTargetFilename:='lazarus'+GetExecutableExt(TargetOS);
if not FilenameIsAbsolute(TargetFilename) then if not FilenameIsAbsolute(fTargetFilename) then
TargetFilename:=TrimFilename(AppendPathDelim(TargetDirectory)+TargetFilename); fTargetFilename:=TrimFilename(AppendPathDelim(TargetDirectory)+fTargetFilename);
// backup old exe // backup old exe
BackupExe(TargetFilename); BackupExe(fTargetFilename);
// check if target file is default // check if target file is default
NewTargetDirectoryIsDefault:= NewTargetDirectoryIsDefault:=
@ -730,7 +727,7 @@ begin
ChompPathDelim(TargetDirectory))=0; ChompPathDelim(TargetDirectory))=0;
NewTargetFilenameIsDefault:=NewTargetDirectoryIsDefault; NewTargetFilenameIsDefault:=NewTargetDirectoryIsDefault;
if NewTargetFilenameIsDefault then begin if NewTargetFilenameIsDefault then begin
CurTargetFilename:=CreateRelativePath(TargetFilename,TargetDirectory); CurTargetFilename:=CreateRelativePath(fTargetFilename,TargetDirectory);
NewTargetFilenameIsDefault:=CurTargetFilename=DefaultTargetFilename; NewTargetFilenameIsDefault:=CurTargetFilename=DefaultTargetFilename;
end; end;
@ -751,7 +748,7 @@ begin
if (Profile.TargetPlatform in [lpCarbon,lpCocoa]) if (Profile.TargetPlatform in [lpCarbon,lpCocoa])
and (not NewTargetDirectoryIsDefault) and (not NewTargetDirectoryIsDefault)
and (DirectoryIsWritableCached(TargetDirectory)) then begin and (DirectoryIsWritableCached(TargetDirectory)) then begin
CurTargetFilename:=TargetFilename; CurTargetFilename:=fTargetFilename;
BundleDir:=ChangeFileExt(CurTargetFilename,'.app'); BundleDir:=ChangeFileExt(CurTargetFilename,'.app');
//debugln(['CreateBuildLazarusOptions checking bundle ',BundleDir]); //debugln(['CreateBuildLazarusOptions checking bundle ',BundleDir]);
if not FileExistsCached(BundleDir) then begin if not FileExistsCached(BundleDir) then begin
@ -795,7 +792,7 @@ begin
// Note: FPC automatically changes the last extension (append or replace) // Note: FPC automatically changes the last extension (append or replace)
// For example under linux, where executables don't need any extension // For example under linux, where executables don't need any extension
// fpc removes the last extension of the -o option. // fpc removes the last extension of the -o option.
AppendExtraOption('-o'+TargetFilename); AppendExtraOption('-o'+fTargetFilename);
end; end;
// add package Profile for IDE // add package Profile for IDE
@ -811,8 +808,7 @@ var
ExOptions, LazExeFilename: String; ExOptions, LazExeFilename: String;
ModRes: TModalResult; ModRes: TModalResult;
begin begin
ModRes := CreateIDEMakeOptions(Profile, GlobalMacroList, '', [], ExOptions, ModRes := CreateIDEMakeOptions(Profile, GlobalMacroList, '', [], ExOptions, Result);
Result, LazExeFilename);
if not (ModRes in [mrOk,mrIgnore]) then if not (ModRes in [mrOk,mrIgnore]) then
Result := True; Result := True;
end; end;
@ -875,11 +871,10 @@ var
fs: TFileStreamUTF8; fs: TFileStreamUTF8;
OptionsAsText: String; OptionsAsText: String;
OutputDirRedirected: boolean; OutputDirRedirected: boolean;
LazExeFilename: string;
begin begin
ExOptions:=''; ExOptions:='';
Result:=CreateIDEMakeOptions(Profile, Macros, PackageOptions, Result:=CreateIDEMakeOptions(Profile, Macros, PackageOptions,
Flags, ExOptions, OutputDirRedirected, LazExeFilename); Flags, ExOptions, OutputDirRedirected);
if Result<>mrOk then exit; if Result<>mrOk then exit;
Filename:=GetMakeIDEConfigFilename; Filename:=GetMakeIDEConfigFilename;
try try