mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-23 16:59:29 +01:00
IDE: build lazarus: warn if directory is not writable
git-svn-id: trunk@22748 -
This commit is contained in:
parent
d2ba61eceb
commit
6e03051421
@ -46,8 +46,9 @@ uses
|
|||||||
LResources, Laz_XMLCfg, InterfaceBase, Themes, ComCtrls,
|
LResources, Laz_XMLCfg, InterfaceBase, Themes, ComCtrls,
|
||||||
LazarusIDEStrConsts, TransferMacros, LazConf, IDEProcs, DialogProcs,
|
LazarusIDEStrConsts, TransferMacros, LazConf, IDEProcs, DialogProcs,
|
||||||
IDEWindowIntf, IDEMsgIntf, InputHistory, ExtToolDialog, ExtToolEditDlg,
|
IDEWindowIntf, IDEMsgIntf, InputHistory, ExtToolDialog, ExtToolEditDlg,
|
||||||
|
EnvironmentOpts,
|
||||||
{$IFDEF win32}
|
{$IFDEF win32}
|
||||||
EnvironmentOpts, CodeToolManager, // added for windres workaround
|
CodeToolManager, // added for windres workaround
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
ApplicationBundle, CompilerOptions, IDEContextHelpEdit;
|
ApplicationBundle, CompilerOptions, IDEContextHelpEdit;
|
||||||
|
|
||||||
@ -260,7 +261,8 @@ function BuildLazarus(Options: TBuildLazarusOptions;
|
|||||||
function CreateBuildLazarusOptions(Options: TBuildLazarusOptions;
|
function CreateBuildLazarusOptions(Options: TBuildLazarusOptions;
|
||||||
ItemIndex: integer; Macros: TTransferMacroList;
|
ItemIndex: integer; Macros: TTransferMacroList;
|
||||||
const PackageOptions: string; Flags: TBuildLazarusFlags;
|
const PackageOptions: string; Flags: TBuildLazarusFlags;
|
||||||
var ExtraOptions: string; out DisableSvn2RevisionInc: boolean): TModalResult;
|
var ExtraOptions: string; out DisableSvn2RevisionInc: boolean;
|
||||||
|
out OutputDirRedirected: boolean): TModalResult;
|
||||||
function SaveIDEMakeOptions(Options: TBuildLazarusOptions;
|
function SaveIDEMakeOptions(Options: TBuildLazarusOptions;
|
||||||
Macros: TTransferMacroList;
|
Macros: TTransferMacroList;
|
||||||
const PackageOptions: string; Flags: TBuildLazarusFlags): TModalResult;
|
const PackageOptions: string; Flags: TBuildLazarusFlags): TModalResult;
|
||||||
@ -323,6 +325,17 @@ function BuildLazarus(Options: TBuildLazarusOptions;
|
|||||||
ExternalTools: TExternalToolList; Macros: TTransferMacroList;
|
ExternalTools: TExternalToolList; Macros: TTransferMacroList;
|
||||||
const PackageOptions, CompilerPath, MakePath: string;
|
const PackageOptions, CompilerPath, MakePath: string;
|
||||||
Flags: TBuildLazarusFlags): TModalResult;
|
Flags: TBuildLazarusFlags): TModalResult;
|
||||||
|
|
||||||
|
function CheckDirectoryWritable(Dir: string): boolean;
|
||||||
|
begin
|
||||||
|
if DirectoryIsWritableCached(Dir) then exit(true);
|
||||||
|
Result:=false;
|
||||||
|
MessageDlg(lisBuildingLazarusFailed,
|
||||||
|
Format(lisThisSetOfOptionsToBuildLazarusIsNotSupportedByThis, [#13, '"',
|
||||||
|
Dir, '"', #13]),
|
||||||
|
mtError,[mbCancel],0);
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
Tool: TExternalToolOptions;
|
Tool: TExternalToolOptions;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
@ -330,7 +343,8 @@ var
|
|||||||
ExtraOptions, LinkerAddition: String;
|
ExtraOptions, LinkerAddition: String;
|
||||||
DisableSvn2RevisionInc: boolean;
|
DisableSvn2RevisionInc: boolean;
|
||||||
CurMakeMode: TMakeMode;
|
CurMakeMode: TMakeMode;
|
||||||
|
WorkingDirectory: String;
|
||||||
|
OutputDirRedirected: boolean;
|
||||||
begin
|
begin
|
||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
|
|
||||||
@ -365,9 +379,12 @@ begin
|
|||||||
// clean up
|
// clean up
|
||||||
if Options.CleanAll
|
if Options.CleanAll
|
||||||
and ([blfDontClean,blfOnlyIDE]*Flags=[]) then begin
|
and ([blfDontClean,blfOnlyIDE]*Flags=[]) then begin
|
||||||
|
WorkingDirectory:=EnvironmentOptions.LazarusDirectory;
|
||||||
|
if not CheckDirectoryWritable(WorkingDirectory) then exit(mrCancel);
|
||||||
|
|
||||||
// clean lazarus source directories
|
// clean lazarus source directories
|
||||||
Tool.Title:=lisCleanLazarusSource;
|
Tool.Title:=lisCleanLazarusSource;
|
||||||
Tool.WorkingDirectory:='$(LazarusDir)';
|
Tool.WorkingDirectory:=WorkingDirectory;
|
||||||
Tool.CmdLineParams:='cleanlaz';
|
Tool.CmdLineParams:='cleanlaz';
|
||||||
// append target OS
|
// append target OS
|
||||||
if Options.TargetOS<>'' then
|
if Options.TargetOS<>'' then
|
||||||
@ -383,6 +400,10 @@ begin
|
|||||||
for i:=0 to Options.Count-1 do begin
|
for i:=0 to Options.Count-1 do begin
|
||||||
// build item
|
// build item
|
||||||
CurItem:=Options.Items[i];
|
CurItem:=Options.Items[i];
|
||||||
|
|
||||||
|
WorkingDirectory:=TrimFilename(EnvironmentOptions.LazarusDirectory
|
||||||
|
+PathDelim+CurItem.Directory);
|
||||||
|
|
||||||
// calculate make mode
|
// calculate make mode
|
||||||
CurMakeMode:=CurItem.MakeMode;
|
CurMakeMode:=CurItem.MakeMode;
|
||||||
if (blfOnlyIDE in Flags) then begin
|
if (blfOnlyIDE in Flags) then begin
|
||||||
@ -407,14 +428,19 @@ begin
|
|||||||
Tool.Title:=CurItem.Description;
|
Tool.Title:=CurItem.Description;
|
||||||
if (CurItem=Options.ItemIDE) and (blfWithoutLinkingIDE in Flags) then
|
if (CurItem=Options.ItemIDE) and (blfWithoutLinkingIDE in Flags) then
|
||||||
Tool.Title:=lisCompileIDEWithoutLinking;
|
Tool.Title:=lisCompileIDEWithoutLinking;
|
||||||
Tool.WorkingDirectory:='$(LazarusDir)'+PathDelim+CurItem.Directory;
|
Tool.WorkingDirectory:=WorkingDirectory;
|
||||||
Tool.CmdLineParams:=CurItem.Commands[CurMakeMode];
|
Tool.CmdLineParams:=CurItem.Commands[CurMakeMode];
|
||||||
// append extra options
|
// append extra options
|
||||||
ExtraOptions:='';
|
ExtraOptions:='';
|
||||||
Result:=CreateBuildLazarusOptions(Options,i,Macros,PackageOptions,Flags,
|
Result:=CreateBuildLazarusOptions(Options,i,Macros,PackageOptions,Flags,
|
||||||
ExtraOptions,DisableSvn2RevisionInc);
|
ExtraOptions,DisableSvn2RevisionInc,
|
||||||
|
OutputDirRedirected);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
|
|
||||||
|
if (not OutputDirRedirected)
|
||||||
|
and (not CheckDirectoryWritable(WorkingDirectory)) then
|
||||||
|
exit(mrCancel);
|
||||||
|
|
||||||
// add Linker options for wigdet set
|
// add Linker options for wigdet set
|
||||||
LinkerAddition := LCLWidgetLinkerAddition[Options.LCLPlatform];
|
LinkerAddition := LCLWidgetLinkerAddition[Options.LCLPlatform];
|
||||||
if LinkerAddition <> '' then
|
if LinkerAddition <> '' then
|
||||||
@ -448,7 +474,8 @@ end;
|
|||||||
function CreateBuildLazarusOptions(Options: TBuildLazarusOptions;
|
function CreateBuildLazarusOptions(Options: TBuildLazarusOptions;
|
||||||
ItemIndex: integer; Macros: TTransferMacroList;
|
ItemIndex: integer; Macros: TTransferMacroList;
|
||||||
const PackageOptions: string; Flags: TBuildLazarusFlags;
|
const PackageOptions: string; Flags: TBuildLazarusFlags;
|
||||||
var ExtraOptions: string; out DisableSvn2RevisionInc: boolean): TModalResult;
|
var ExtraOptions: string; out DisableSvn2RevisionInc: boolean;
|
||||||
|
out OutputDirRedirected: boolean): TModalResult;
|
||||||
|
|
||||||
function RemoveProfilerOption(const ExtraOptions: string): string;
|
function RemoveProfilerOption(const ExtraOptions: string): string;
|
||||||
var
|
var
|
||||||
@ -498,14 +525,15 @@ var
|
|||||||
BundleDir: String;
|
BundleDir: String;
|
||||||
begin
|
begin
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
CurItem:=Options.Items[ItemIndex];
|
|
||||||
DisableSvn2RevisionInc:=false;
|
DisableSvn2RevisionInc:=false;
|
||||||
|
OutputDirRedirected:=false;
|
||||||
|
CurItem:=Options.Items[ItemIndex];
|
||||||
|
|
||||||
// create extra options
|
// create extra options
|
||||||
ExtraOptions:=Options.ExtraOptions;
|
ExtraOptions:=Options.ExtraOptions;
|
||||||
|
|
||||||
if CurItem=Options.ItemIDE then begin
|
if CurItem=Options.ItemIDE then begin
|
||||||
|
DebugLn(['CreateBuildLazarusOptions AAA1']);
|
||||||
// check for special IDE config file
|
// check for special IDE config file
|
||||||
if (blfUseMakeIDECfg in Flags) then begin
|
if (blfUseMakeIDECfg in Flags) then begin
|
||||||
MakeIDECfgFilename:=GetMakeIDEConfigFilename;
|
MakeIDECfgFilename:=GetMakeIDEConfigFilename;
|
||||||
@ -523,8 +551,7 @@ begin
|
|||||||
// for $IFDEF.
|
// for $IFDEF.
|
||||||
if pos(' ',MakeIDECfgFilename)>0 then
|
if pos(' ',MakeIDECfgFilename)>0 then
|
||||||
MakeIDECfgFilename:=ExtractShortPathNameUTF8(MakeIDECfgFilename);
|
MakeIDECfgFilename:=ExtractShortPathNameUTF8(MakeIDECfgFilename);
|
||||||
ExtraOptions:='@'+MakeIDECfgFilename;
|
AppendExtraOption('@'+MakeIDECfgFilename);
|
||||||
exit;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
// check if linking should be skipped
|
// check if linking should be skipped
|
||||||
@ -631,6 +658,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
OutputDirRedirected:=NewTargetDirectory<>'';
|
||||||
|
|
||||||
// create apple bundle if needed
|
// create apple bundle if needed
|
||||||
//debugln(['CreateBuildLazarusOptions NewTargetDirectory=',NewTargetDirectory]);
|
//debugln(['CreateBuildLazarusOptions NewTargetDirectory=',NewTargetDirectory]);
|
||||||
if (Options.LCLPlatform in [lpCarbon,lpCocoa])
|
if (Options.LCLPlatform in [lpCarbon,lpCocoa])
|
||||||
@ -744,11 +773,13 @@ var
|
|||||||
fs: TFileStream;
|
fs: TFileStream;
|
||||||
OptionsAsText: String;
|
OptionsAsText: String;
|
||||||
DisableSvn2RevisionInc: boolean;
|
DisableSvn2RevisionInc: boolean;
|
||||||
|
OutputDirRedirected: boolean;
|
||||||
begin
|
begin
|
||||||
ExtraOptions:='';
|
ExtraOptions:='';
|
||||||
Result:=CreateBuildLazarusOptions(Options,Options.IndexOf(Options.ItemIDE),
|
Result:=CreateBuildLazarusOptions(Options,Options.IndexOf(Options.ItemIDE),
|
||||||
Macros,PackageOptions,Flags,
|
Macros,PackageOptions,Flags,
|
||||||
ExtraOptions,DisableSvn2RevisionInc);
|
ExtraOptions,DisableSvn2RevisionInc,
|
||||||
|
OutputDirRedirected);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
Filename:=GetMakeIDEConfigFilename;
|
Filename:=GetMakeIDEConfigFilename;
|
||||||
try
|
try
|
||||||
|
|||||||
@ -93,6 +93,8 @@ function CreateSymlinkInteractive(const LinkFilename, TargetFilename: string;
|
|||||||
ErrorButtons: TMsgDlgButtons): TModalResult;
|
ErrorButtons: TMsgDlgButtons): TModalResult;
|
||||||
function ForceDirectoryInteractive(Directory: string;
|
function ForceDirectoryInteractive(Directory: string;
|
||||||
ErrorButtons: TMsgDlgButtons): TModalResult;
|
ErrorButtons: TMsgDlgButtons): TModalResult;
|
||||||
|
function CheckDirectoryIsWritable(const Filename: string;
|
||||||
|
ErrorButtons: TMsgDlgButtons): TModalResult;
|
||||||
function DeleteFileInteractive(const Filename: string;
|
function DeleteFileInteractive(const Filename: string;
|
||||||
ErrorButtons: TMsgDlgButtons): TModalResult;
|
ErrorButtons: TMsgDlgButtons): TModalResult;
|
||||||
function SaveStringToFile(const Filename, Content: string;
|
function SaveStringToFile(const Filename, Content: string;
|
||||||
@ -553,6 +555,18 @@ begin
|
|||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function CheckDirectoryIsWritable(const Filename: string;
|
||||||
|
ErrorButtons: TMsgDlgButtons): TModalResult;
|
||||||
|
begin
|
||||||
|
Result:=mrOk;
|
||||||
|
while not DirectoryIsWritable(Filename) do begin
|
||||||
|
Result:=IDEMessageDialog(lisDirectoryNotWritable,
|
||||||
|
Format(lisTheDirectoryIsNotWritable, ['"', Filename, '"']),
|
||||||
|
mtError,ErrorButtons+[mbCancel]);
|
||||||
|
if Result<>mrRetry then exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function DeleteFileInteractive(const Filename: string;
|
function DeleteFileInteractive(const Filename: string;
|
||||||
ErrorButtons: TMsgDlgButtons): TModalResult;
|
ErrorButtons: TMsgDlgButtons): TModalResult;
|
||||||
begin
|
begin
|
||||||
|
|||||||
@ -4535,6 +4535,13 @@ resourcestring
|
|||||||
lisAProjectUnitCanNotBeUsedByOtherPackagesProjects = 'A project unit can '
|
lisAProjectUnitCanNotBeUsedByOtherPackagesProjects = 'A project unit can '
|
||||||
+'not be used by other packages/projects';
|
+'not be used by other packages/projects';
|
||||||
lisShowGlyphsFor = 'Show Glyphs for:';
|
lisShowGlyphsFor = 'Show Glyphs for:';
|
||||||
|
lisDirectoryNotWritable = 'Directory not writable';
|
||||||
|
lisTheDirectoryIsNotWritable = 'The directory %s%s%s is not writable.';
|
||||||
|
lisBuildingLazarusFailed = 'Building Lazarus failed';
|
||||||
|
lisThisSetOfOptionsToBuildLazarusIsNotSupportedByThis = 'This set of '
|
||||||
|
+'options to build Lazarus is not supported by this installation.%sThe '
|
||||||
|
+'directory %s%s%s is not writable.%sSee the Lazarus website for other '
|
||||||
|
+'ways to install Lazarus.';
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user