mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-06 14:00:14 +02:00
MG: implemented run parameters: wd, launching app, sys vars
git-svn-id: trunk@1513 -
This commit is contained in:
parent
7d44c1a838
commit
18de98b2ef
@ -457,7 +457,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TOIPropertyGrid.WMSize(var Msg: TLMSize);
|
||||
procedure TOIPropertyGrid.WMSize(var Msg: TWMSize);
|
||||
begin
|
||||
inherited;
|
||||
UpdateScrollBar;
|
||||
|
@ -32,6 +32,8 @@ function CompareFilenames(const Filename1, Filename2: string): integer;
|
||||
function AppendPathDelim(const Path: string): string;
|
||||
function SearchFileInPath(const Filename, BasePath, SearchPath,
|
||||
Delimiter: string): string;
|
||||
procedure SplitCmdLine(const CmdLine: string;
|
||||
var ProgramFilename, Params: string);
|
||||
|
||||
// XMLConfig
|
||||
procedure LoadRecentList(XMLConfig: TXMLConfig; List: TStringList;
|
||||
@ -304,4 +306,21 @@ begin
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
procedure SplitCmdLine(const CmdLine: string;
|
||||
var ProgramFilename, Params: string);
|
||||
var p: integer;
|
||||
begin
|
||||
p:=1;
|
||||
while (p<=length(CmdLine)) and (CmdLine[p]>' ') do begin
|
||||
if (CmdLine[p] in ['/','\']) and (CmdLine[p]<>PathDelim) then begin
|
||||
// skip special char
|
||||
inc(p);
|
||||
end;
|
||||
inc(p);
|
||||
end;
|
||||
ProgramFilename:=LeftStr(CmdLine,p-1);
|
||||
while (p<=length(CmdLine)) and (CmdLine[p]<=' ') do inc(p);
|
||||
Params:=RightStr(CmdLine,length(CmdLine)-p+1);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
78
ide/main.pp
78
ide/main.pp
@ -468,6 +468,7 @@ type
|
||||
function GetProjectTargetFilename: string;
|
||||
function GetTestProjectFilename: string;
|
||||
function GetTestUnitFilename(AnUnitInfo: TUnitInfo): string;
|
||||
function GetRunCommandLine: string;
|
||||
procedure OnMacroSubstitution(TheMacro: TTransferMacro; var s:string;
|
||||
var Handled, Abort: boolean);
|
||||
function OnMacroPromptFunction(const s:string; var Abort: boolean):string;
|
||||
@ -666,7 +667,7 @@ begin
|
||||
Glyph := SelectionPointerPixmap;
|
||||
Visible := True;
|
||||
Flat := True;
|
||||
GroupIndex:= 1;
|
||||
GroupIndex:= 1;
|
||||
Down := True;
|
||||
Name := 'GlobalMouseSpeedButton'+IntToStr(PageCount);
|
||||
Hint := 'Selection tool';
|
||||
@ -824,6 +825,10 @@ begin
|
||||
'save all modified files',nil,[tmfInteractive]));
|
||||
MacroList.Add(TTransferMacro.Create('TargetFile','',
|
||||
'Target filename of project',nil,[]));
|
||||
MacroList.Add(TTransferMacro.Create('TargetCmdLine','',
|
||||
'Target filename + params',nil,[]));
|
||||
MacroList.Add(TTransferMacro.Create('RunCmdLine','',
|
||||
'Launching target command line',nil,[]));
|
||||
MacroList.OnSubstitution:=@OnMacroSubstitution;
|
||||
|
||||
// TWatchesDlg
|
||||
@ -4063,7 +4068,8 @@ end;
|
||||
|
||||
function TMainIDE.DoInitProjectRun: TModalResult;
|
||||
var
|
||||
ProgramFilename: String;
|
||||
ProgramFilename, LaunchingCmdLine, LaunchingApplication,
|
||||
LaunchingParams: String;
|
||||
begin
|
||||
if ToolStatus = itDebugger
|
||||
then begin
|
||||
@ -4088,9 +4094,12 @@ begin
|
||||
ProgramFilename := GetProjectTargetFilename;
|
||||
if not FileExists(ProgramFilename)
|
||||
then begin
|
||||
MessageDlg('File not found', Format('No program file "%s" found!', [ProgramFilename]), mtError, [mbCancel], 0);
|
||||
MessageDlg('File not found',
|
||||
Format('No program file "%s" found!', [ProgramFilename]), mtError,
|
||||
[mbCancel], 0);
|
||||
Exit;
|
||||
end;
|
||||
LaunchingCmdLine:=GetRunCommandLine;
|
||||
|
||||
// Setup debugger
|
||||
case EnvironmentOptions.DebuggerType of
|
||||
@ -4098,16 +4107,20 @@ begin
|
||||
if (FDebugger = nil)
|
||||
and (DoInitDebugger <> mrOk)
|
||||
then Exit;
|
||||
FDebugger.FileName := ProgramFilename;
|
||||
FDebugger.Arguments := ''; //TODO: get arguments
|
||||
SplitCmdLine(LaunchingCmdLine,LaunchingApplication,LaunchingParams);
|
||||
FDebugger.FileName := LaunchingApplication;
|
||||
FDebugger.Arguments := LaunchingParams;
|
||||
// ToDo: set working directory
|
||||
end;
|
||||
else
|
||||
// Temp solution, in futer it will be run by dummy debugger
|
||||
// Temp solution, in future it will be run by dummy debugger
|
||||
try
|
||||
CheckIfFileIsExecutable(ProgramFilename);
|
||||
FRunProcess := TProcess.Create(nil);
|
||||
FRunProcess.CommandLine := ProgramFilename;
|
||||
FRunProcess.Options:= [poUsePipes, poNoConsole];
|
||||
FRunProcess.CommandLine := LaunchingCmdLine;
|
||||
FRunProcess.CurrentDirectory:=
|
||||
Project.RunParameterOptions.WorkingDirectory;
|
||||
FRunProcess.Options:= [poNoConsole];
|
||||
FRunProcess.ShowWindow := swoNone;
|
||||
except
|
||||
on e: Exception do
|
||||
@ -4795,6 +4808,16 @@ begin
|
||||
end else if MacroName='targetfile' then begin
|
||||
Handled:=true;
|
||||
s:=GetProjectTargetFilename;
|
||||
end else if MacroName='targetcmdline' then begin
|
||||
Handled:=true;
|
||||
s:=Project.RunParameterOptions.CmdLineParams;
|
||||
if s='' then
|
||||
s:=GetProjectTargetFilename
|
||||
else
|
||||
s:=GetProjectTargetFilename+' '+s;
|
||||
end else if MacroName='runcmdline' then begin
|
||||
Handled:=true;
|
||||
s:=GetRunCommandLine;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -4930,13 +4953,16 @@ function TMainIDE.GetProjectTargetFilename: string;
|
||||
begin
|
||||
Result:='';
|
||||
if Project=nil then exit;
|
||||
if Project.IsVirtual then
|
||||
Result:=GetTestProjectFilename
|
||||
else begin
|
||||
if Project.MainUnit>=0 then begin
|
||||
Result:=
|
||||
Project.CompilerOptions.CreateTargetFilename(
|
||||
Project.Units[Project.MainUnit].Filename)
|
||||
Result:=Project.RunParameterOptions.HostApplicationFilename;
|
||||
if Result='' then begin
|
||||
if Project.IsVirtual then
|
||||
Result:=GetTestProjectFilename
|
||||
else begin
|
||||
if Project.MainUnit>=0 then begin
|
||||
Result:=
|
||||
Project.CompilerOptions.CreateTargetFilename(
|
||||
Project.Units[Project.MainUnit].Filename)
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -4962,7 +4988,24 @@ begin
|
||||
Result:=ExtractFilename(AnUnitInfo.Filename);
|
||||
if Result='' then exit;
|
||||
Result:=TestDir+Result;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TMainIDE.GetRunCommandLine: string;
|
||||
begin
|
||||
Result:=Project.RunParameterOptions.LaunchingApplicationPathPlusParams;
|
||||
if Result='' then begin
|
||||
Result:=Project.RunParameterOptions.CmdLineParams;
|
||||
if MacroList.SubstituteStr(Result) then begin
|
||||
if Result='' then
|
||||
Result:=GetProjectTargetFilename
|
||||
else
|
||||
Result:=GetProjectTargetFilename+' '+Result;
|
||||
end else
|
||||
Result:='';
|
||||
end else begin
|
||||
if not MacroList.SubstituteStr(Result) then Result:='';
|
||||
end;
|
||||
end;
|
||||
|
||||
function TMainIDE.FindUnitFile(const AFilename: string): string;
|
||||
var
|
||||
@ -6242,6 +6285,9 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.245 2002/03/14 14:39:39 lazarus
|
||||
MG: implemented run parameters: wd, launching app, sys vars
|
||||
|
||||
Revision 1.244 2002/03/12 23:55:34 lazarus
|
||||
MWE:
|
||||
* More delphi compatibility added/updated to TListView
|
||||
|
@ -38,13 +38,13 @@ uses
|
||||
MemCheck,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, Controls, Forms, Buttons, StdCtrls, ComCtrls, Dialogs,
|
||||
ExtCtrls, LResources, XMLCfg, DOS, IDEProcs;
|
||||
ExtCtrls, LResources, XMLCfg, DOS, IDEProcs, SysVarUserOverrideDlg;
|
||||
|
||||
{ The xml format version:
|
||||
When the format changes (new values, changed formats) we can distinguish old
|
||||
files and are able to convert them.
|
||||
}
|
||||
const RunParamsOptionsVersion = '1.0';
|
||||
const RunParamsOptionsVersion = '1';
|
||||
|
||||
type
|
||||
{
|
||||
@ -119,7 +119,7 @@ type
|
||||
CancelButton: TButton;
|
||||
procedure OkButtonClick(Sender: TObject);
|
||||
procedure CancelButtonClick(Sender: TObject);
|
||||
procedure HostApplicationEditClick(Sender: TObject);
|
||||
procedure HostApplicationBrowseBtnClick(Sender: TObject);
|
||||
procedure WorkingDirectoryBtnClick(Sender: TObject);
|
||||
procedure UserOverridesAddButtonClick(Sender: TObject);
|
||||
procedure UserOverridesEditButtonClick(Sender: TObject);
|
||||
@ -144,6 +144,11 @@ function ShowRunParamsOptsDlg(RunParamsOptions: TRunParamsOptions):TModalResult;
|
||||
implementation
|
||||
|
||||
|
||||
const
|
||||
DefaultLauncherApplication =
|
||||
'/usr/X11R6/bin/xterm -T ''Lazarus Run Output'''
|
||||
+' -e bash -i -c ''$(TargetCmdLine)''';
|
||||
|
||||
function ShowRunParamsOptsDlg(RunParamsOptions: TRunParamsOptions):TModalResult;
|
||||
var
|
||||
RunParamsOptsForm: TRunParamsOptsDlg;
|
||||
@ -181,7 +186,7 @@ begin
|
||||
fHostApplicationFilename:='';
|
||||
fCmdLineParams:='';
|
||||
fUseLaunchingApplication:=false;
|
||||
fLaunchingApplicationPathPlusParams:='';
|
||||
fLaunchingApplicationPathPlusParams:=DefaultLauncherApplication;
|
||||
fWorkingDirectory:='';
|
||||
fDisplay:=':0';
|
||||
|
||||
@ -219,6 +224,8 @@ begin
|
||||
fLaunchingApplicationPathPlusParams:=XMLConfig.GetValue(
|
||||
Path+'RunParams/local/LaunchingApplication/PathPlusParams',
|
||||
fLaunchingApplicationPathPlusParams);
|
||||
if (fLaunchingApplicationPathPlusParams='') then
|
||||
fLaunchingApplicationPathPlusParams:=DefaultLauncherApplication;
|
||||
fWorkingDirectory:=XMLConfig.GetValue(
|
||||
Path+'RunParams/local/WorkingDirectory/Value',
|
||||
fWorkingDirectory);
|
||||
@ -358,7 +365,7 @@ begin
|
||||
Parent:=HostApplicationGroupBox;
|
||||
SetBounds(HostApplicationEdit.Left+HostApplicationEdit.Width+2,5,25,25);
|
||||
Caption:='...';
|
||||
HostApplicationEdit.OnClick:=@HostApplicationEditClick;
|
||||
HostApplicationBrowseBtn.OnClick:=@HostApplicationBrowseBtnClick;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
@ -482,12 +489,14 @@ begin
|
||||
Top:=5;
|
||||
Width:=Parent.ClientWidth-17;
|
||||
Height:=Parent.ClientHeight-28;
|
||||
Columns.BeginUpdate;
|
||||
Columns.Clear;
|
||||
Columns.Updating := true;
|
||||
Columns.Add('Variable');
|
||||
Columns.Add('Value');
|
||||
Columns.Add;
|
||||
Columns.Add;
|
||||
Columns[0].Caption:='Variable';
|
||||
Columns[0].Width:=130;
|
||||
Columns.Updating := False;
|
||||
Columns[0].Width:=130;
|
||||
Columns.EndUpdate;
|
||||
ViewStyle := vsReport;
|
||||
Sorted := true;
|
||||
Visible:=true;
|
||||
@ -511,12 +520,14 @@ begin
|
||||
Top:=5;
|
||||
Width:=Parent.ClientWidth-17;
|
||||
Height:=Parent.ClientHeight-68;
|
||||
Columns.BeginUpdate;
|
||||
Columns.Clear;
|
||||
Columns.Updating := true;
|
||||
Columns.Add('Variable');
|
||||
Columns.Add('Value');
|
||||
Columns.Add;
|
||||
Columns.Add;
|
||||
Columns[0].Caption:='Variable';
|
||||
Columns[0].Width:=130;
|
||||
Columns.Updating := False;
|
||||
Columns[1].Caption:='Value';
|
||||
Columns.EndUpdate;
|
||||
ViewStyle := vsReport;
|
||||
Sorted := true;
|
||||
Visible:=true;
|
||||
@ -527,10 +538,11 @@ begin
|
||||
Name:='UserOverridesAddButton';
|
||||
Parent:=UserOverridesGroupBox;
|
||||
Left:=5;
|
||||
Top:=Parent.ClientWidth-Height-28;
|
||||
Top:=Parent.ClientHeight-Height-28;
|
||||
Width:=100;
|
||||
Caption:='Add';
|
||||
OnClick:=@UserOverridesAddButtonClick;
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
@ -543,6 +555,7 @@ begin
|
||||
Width:=100;
|
||||
Caption:='Edit';
|
||||
OnClick:=@UserOverridesEditButtonClick;
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
@ -555,6 +568,7 @@ begin
|
||||
Width:=100;
|
||||
Caption:='Delete';
|
||||
OnClick:=@UserOverridesDeleteButtonClick;
|
||||
Enabled:=false;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
@ -580,7 +594,7 @@ begin
|
||||
ModalResult:=mrCancel;
|
||||
end;
|
||||
|
||||
procedure TRunParamsOptsDlg.HostApplicationEditClick(Sender: TObject);
|
||||
procedure TRunParamsOptsDlg.HostApplicationBrowseBtnClick(Sender: TObject);
|
||||
var OpenDialog: TOpenDialog;
|
||||
begin
|
||||
OpenDialog:=TOpenDialog.Create(Self);
|
||||
@ -621,8 +635,14 @@ begin
|
||||
end;
|
||||
|
||||
procedure TRunParamsOptsDlg.UserOverridesAddButtonClick(Sender: TObject);
|
||||
var Variable, Value: string;
|
||||
begin
|
||||
Variable:='';
|
||||
Value:='';
|
||||
if ShowSysVarUserOverrideDialog(Variable,Value)=mrOk then begin
|
||||
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRunParamsOptsDlg.UserOverridesEditButtonClick(Sender: TObject);
|
||||
@ -638,12 +658,13 @@ end;
|
||||
procedure TRunParamsOptsDlg.SaveToOptions;
|
||||
begin
|
||||
// local
|
||||
fOptions.HostApplicationFilename:=HostApplicationEdit.Text;
|
||||
fOptions.CmdLineParams:=CmdLineParametersEdit.Text;
|
||||
fOptions.HostApplicationFilename:=Trim(HostApplicationEdit.Text);
|
||||
fOptions.CmdLineParams:=Trim(CmdLineParametersEdit.Text);
|
||||
fOptions.UseLaunchingApplication:=UseLaunchingApplicationCheckBox.Checked;
|
||||
fOptions.LaunchingApplicationPathPlusParams:=UseLaunchingApplicationEdit.Text;
|
||||
fOptions.WorkingDirectory:=WorkingDirectoryEdit.Text;
|
||||
fOptions.Display:=DisplayEdit.Text;
|
||||
fOptions.LaunchingApplicationPathPlusParams:=
|
||||
Trim(UseLaunchingApplicationEdit.Text);
|
||||
fOptions.WorkingDirectory:=Trim(WorkingDirectoryEdit.Text);
|
||||
fOptions.Display:=Trim(DisplayEdit.Text);
|
||||
|
||||
// environment
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user