mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-03 20:43:40 +01:00
IDE+startlazarus: use same working directory, needed for passing relative file names as command line parameters
git-svn-id: trunk@37880 -
This commit is contained in:
parent
e990255441
commit
f32f0ea635
@ -4,7 +4,7 @@ unit LazLoggerBase;
|
||||
(*
|
||||
- All globas variables, initialization and finalization uses TObject instead
|
||||
of TLazLogger.
|
||||
This means, usinc the unit, without calling any of the functions, will not
|
||||
This means, using the unit, without calling any of the functions, will not
|
||||
make any reference to the classes, and they should be smart-linked away.
|
||||
*)
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ interface
|
||||
type
|
||||
(* IntN types : *)
|
||||
(* *)
|
||||
(* These types are used as a way to garantee the size of some *)
|
||||
(* These types are used as a way to guarantee the size of some *)
|
||||
(* specific integers. *)
|
||||
(* *)
|
||||
(* Of course, they are equivalent to Short, UShort, Long, etc .. *)
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
# assumes a fpcdocs checkout where "fixdocs.sh" has been succesfully run.
|
||||
# on 1.7GHz Core2 laptop single thread 6:26 minutes. Don't be impatient :-)
|
||||
|
||||
set -e
|
||||
|
||||
# set to path to FPC docs dir. Default assume it is on the same level as the lazarus checkout
|
||||
if [ -z "$FPCDocDir" ]; then
|
||||
FPCDocDir=../../../fpcdocs
|
||||
@ -19,8 +21,8 @@ exit 1
|
||||
fi
|
||||
|
||||
export HTMLFMT=chm
|
||||
sh build_lazutils_html.sh fpdoc `pwd`/locallclfooter.xml $FPCDocDirEXP 1>lazutilsoutput.log 2>lazutilserror.log
|
||||
sh build_lcl_html.sh fpdoc `pwd`/locallclfooter.xml $FPCDocDirEXP 1>lcloutput.log 2>lclerror.log
|
||||
bash build_lazutils_html.sh fpdoc `pwd`/locallclfooter.xml $FPCDocDirEXP 1>lazutilsoutput.log 2>lazutilserror.log
|
||||
bash build_lcl_html.sh fpdoc `pwd`/locallclfooter.xml $FPCDocDirEXP 1>lcloutput.log 2>lclerror.log
|
||||
|
||||
# end.
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ unit IDECmdLine;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LazConf, LCLProc;
|
||||
Classes, SysUtils, FileUtil, LazFileUtils, LazConf, LCLProc;
|
||||
|
||||
const
|
||||
ShowSetupDialogOptLong='--setup';
|
||||
@ -55,10 +55,11 @@ const
|
||||
LanguageOpt='--language=';
|
||||
LazarusDirOpt ='--lazarusdir=';
|
||||
|
||||
procedure ParseCommandLine(aCmdLineParams : TStrings; out IDEPid : Integer;
|
||||
procedure ParseCommandLine(aCmdLineParams: TStrings; out IDEPid : Integer;
|
||||
out ShowSplashScreen: boolean);
|
||||
function GetCommandLineParameters(aCmdLineParams : TStrings;
|
||||
isStartLazarus : Boolean = False) : String;
|
||||
function GetCommandLineParameters(aCmdLineParams: TStrings;
|
||||
isStartLazarus: Boolean = False) : string;
|
||||
function ExtractPrimaryConfigPath(aCmdLineParams: TStrings): string;
|
||||
|
||||
function IsHelpRequested : Boolean;
|
||||
function IsVersionRequested : boolean;
|
||||
@ -71,8 +72,6 @@ procedure ParseNoGuiCmdLineParams;
|
||||
|
||||
function ExtractCmdLineFilenames : TStrings;
|
||||
|
||||
function GetLazarusDirectory : String;
|
||||
|
||||
implementation
|
||||
|
||||
procedure ParseCommandLine(aCmdLineParams: TStrings; out IDEPid: Integer; out
|
||||
@ -101,29 +100,22 @@ begin
|
||||
end;
|
||||
end
|
||||
else if ParamIsOption(i, NoSplashScreenOptLong) or
|
||||
ParamIsOption(i, NoSplashScreenOptShort) then
|
||||
begin
|
||||
ShowSplashScreen := false;
|
||||
end
|
||||
else
|
||||
ParamIsOption(i, NoSplashScreenOptShort) then
|
||||
begin
|
||||
ShowSplashScreen := false;
|
||||
end
|
||||
else begin
|
||||
// Do not add file to the parameter list
|
||||
if not (Copy(Param,1,1) = '-') and (FileExistsUTF8(ExpandFileNameUTF8(Param))) then
|
||||
begin
|
||||
// pass these parameters to Lazarus
|
||||
|
||||
if LeftStr(Param,length(PrimaryConfPathOptShort))=PrimaryConfPathOptShort
|
||||
then begin
|
||||
SetPrimaryConfigPath(copy(Param,length(PrimaryConfPathOptShort)+1,length(Param)));
|
||||
end;
|
||||
|
||||
// Do not add file to the parameter list
|
||||
if not (Copy(Param,1,1) = '-') and (FileExistsUTF8(ExpandFileNameUTF8(Param))) then
|
||||
begin
|
||||
DebugLn('%s is a file', [Param]);
|
||||
continue;
|
||||
end;
|
||||
|
||||
DebugLn('Adding "%s" as a parameter', [Param]);
|
||||
aCmdLineParams.Add(Param);
|
||||
DebugLn('%s is a file', [Param]);
|
||||
continue;
|
||||
end;
|
||||
|
||||
// pass these parameters to Lazarus
|
||||
DebugLn('Adding "%s" as a parameter', [Param]);
|
||||
aCmdLineParams.Add(Param);
|
||||
end;
|
||||
end;
|
||||
// make sure that command line parameters are still
|
||||
// double quoted, if they contain spaces
|
||||
@ -146,6 +138,25 @@ begin
|
||||
Result := Result + ' ' + aCmdLineParams[i];
|
||||
end;
|
||||
|
||||
function ExtractPrimaryConfigPath(aCmdLineParams: TStrings): string;
|
||||
|
||||
procedure GetParam(Param, Prefix: string; var Value: string);
|
||||
begin
|
||||
if LeftStr(Param,length(Prefix))=Prefix then
|
||||
Value:=copy(Param,length(Prefix)+1,length(Param));
|
||||
end;
|
||||
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Result:='';
|
||||
for i:=0 to aCmdLineParams.Count-1 do
|
||||
begin
|
||||
GetParam(aCmdLineParams[i],PrimaryConfPathOptLong,Result);
|
||||
GetParam(aCmdLineParams[i],PrimaryConfPathOptShort,Result);
|
||||
end;
|
||||
end;
|
||||
|
||||
function IsHelpRequested : Boolean;
|
||||
var
|
||||
i: integer;
|
||||
@ -244,10 +255,5 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetLazarusDirectory : String;
|
||||
begin
|
||||
Result := ExtractFileDir(ParamStrUTF8(0));
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
||||
@ -222,13 +222,23 @@ procedure TLazarusManager.Initialize;
|
||||
var
|
||||
CmdLineFiles: TStrings;
|
||||
i: integer;
|
||||
PCP: String;
|
||||
begin
|
||||
FShowSplashOption:=true;
|
||||
SplashForm := nil;
|
||||
|
||||
// get command line parameters
|
||||
FCmdLineParams := TStringList.Create;
|
||||
ParseCommandLine(FCmdLineParams, FLazarusPID, FShowSplashOption);
|
||||
if FShowSplashOption then
|
||||
ShowSplash;
|
||||
|
||||
// set primary config path
|
||||
PCP:=ExtractPrimaryConfigPath(FCmdLineParams);
|
||||
if PCP<>'' then
|
||||
SetPrimaryConfigPath(PCP);
|
||||
|
||||
// get command line files
|
||||
CmdLineFiles := ExtractCmdLineFilenames;
|
||||
if CmdLineFiles<>nil then
|
||||
begin
|
||||
|
||||
11
ide/main.pp
11
ide/main.pp
@ -1119,6 +1119,7 @@ implementation
|
||||
|
||||
|
||||
var
|
||||
ParamBaseDirectory: string = '';
|
||||
SkipAutoLoadingLastProject: boolean = false;
|
||||
StartedByStartLazarus: boolean = false;
|
||||
ShowSetupDialog: boolean = false;
|
||||
@ -1203,6 +1204,7 @@ var
|
||||
ConfFileName: String;
|
||||
Cfg: TXMLConfig;
|
||||
begin
|
||||
ParamBaseDirectory:=GetCurrentDirUTF8;
|
||||
StartedByStartLazarus:=false;
|
||||
SkipAutoLoadingLastProject:=false;
|
||||
EnableRemoteControl:=false;
|
||||
@ -12488,17 +12490,18 @@ const
|
||||
begin
|
||||
StartLazProcess := TProcessUTF8.Create(nil);
|
||||
try
|
||||
// TODO: use the target directory, where the new startlazarus is
|
||||
StartLazProcess.CurrentDirectory := GetLazarusDirectory;
|
||||
// use the same working directory as the IDE, so that all relative file
|
||||
// names in parameters still work
|
||||
StartLazProcess.CurrentDirectory := ParamBaseDirectory;
|
||||
//DebugLn('Parsing commandLine: ');
|
||||
Params := TStringList.Create;
|
||||
ParseCommandLine(Params, Dummy, Unused);
|
||||
//DebugLn('Done parsing CommandLine');
|
||||
{$ifndef darwin}
|
||||
ExeName := AppendPathDelim(StartLazProcess.CurrentDirectory) +
|
||||
ExeName := AppendPathDelim(EnvironmentOptions.GetParsedLazarusDirectory) +
|
||||
'startlazarus' + GetExecutableExt;
|
||||
{$else}
|
||||
ExeName := ExpandUNCFileNameUTF8(StartLazProcess.CurrentDirectory);
|
||||
ExeName := ExpandUNCFileNameUTF8(EnvironmentOptions.GetParsedLazarusDirectory);
|
||||
ExeName := AppendPathDelim( ExtractFilePath(ExeName) ) +
|
||||
DarwinStartlazBundlePath + 'startlazarus' + GetExecutableExt;
|
||||
{$endif}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user