mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-04 07:31:46 +01:00
IDEint: DoBuildFile: added parameter Filename to compile an arbitrary file
git-svn-id: trunk@50442 -
This commit is contained in:
parent
b1ae15362f
commit
ad07bf2767
@ -20,6 +20,55 @@ uses
|
||||
IDEOptionsIntf, CompOptsIntf, ProjectIntf,
|
||||
IDEExternToolIntf, SrcEditorIntf, IDEWindowIntf;
|
||||
|
||||
type
|
||||
TIDEDirective = (
|
||||
idedNone,
|
||||
idedBuildCommand, // Filename plus params to build the file
|
||||
// default is '$(CompPath) $(EdFile)'
|
||||
idedBuildWorkingDir,// Working directory for building. Default is the
|
||||
// directory of the file
|
||||
idedBuildScan, // Flags controlling what messages should be scanned for
|
||||
// during building. See TIDEDirBuildScanFlag.
|
||||
idedRunCommand, // Filename plus params to run the file
|
||||
// default is '$NameOnly($(EdFile))'
|
||||
idedRunWorkingDir, // Working directory for building. Default is the
|
||||
// directory of the file
|
||||
idedRunFlags // Flags for run. See TIDEDirRunFlag
|
||||
);
|
||||
TIDEDirectives = set of TIDEDirective;
|
||||
|
||||
TIDEDirBuildScanFlag = (
|
||||
idedbsfNone,
|
||||
idedbsfFPC, // scan for FPC messages. FPC+ means on (default) and FPC- off.
|
||||
idedbsfMake // scan for MAKE messages. MAKE- means on (default) and MAKE- off.
|
||||
);
|
||||
TIDEDirBuildScanFlags = set of TIDEDirBuildScanFlag;
|
||||
|
||||
TIDEDirRunFlag = (
|
||||
idedrfNone,
|
||||
idedrfBuildBeforeRun // BUILD+ means on (default), BUILD- means off
|
||||
);
|
||||
TIDEDirRunFlags = set of TIDEDirRunFlag;
|
||||
const
|
||||
IDEDirectiveNames: array[TIDEDirective] of string = (
|
||||
'',
|
||||
'BuildCommand',
|
||||
'BuildWorkingDir',
|
||||
'BuildScan',
|
||||
'RunCommand',
|
||||
'RunWorkingDir',
|
||||
'RunFlags'
|
||||
);
|
||||
IDEDirBuildScanFlagNames: array[TIDEDirBuildScanFlag] of string = (
|
||||
'',
|
||||
'FPC',
|
||||
'MAKE'
|
||||
);
|
||||
IDEDirRunFlagNames: array[TIDEDirRunFlag] of string = (
|
||||
'',
|
||||
'BUILD'
|
||||
);
|
||||
|
||||
type
|
||||
// open file flags
|
||||
// Normally you don't need to pass any flags.
|
||||
@ -285,7 +334,9 @@ type
|
||||
procedure DoDropFiles(Sender: TObject; const FileNames: array of String;
|
||||
WindowIndex: integer = -1); virtual; abstract;
|
||||
function DoConfigureBuildFile: TModalResult; virtual; abstract;
|
||||
function DoBuildFile({%H-}ShowAbort: Boolean): TModalResult; virtual; abstract;
|
||||
function DoBuildFile({%H-}ShowAbort: Boolean;
|
||||
Filename: string = '' // if empty use active source editor file
|
||||
): TModalResult; virtual; abstract;
|
||||
function DoRunFile: TModalResult; virtual; abstract;
|
||||
|
||||
// project
|
||||
|
||||
@ -10,38 +10,9 @@ uses
|
||||
BasicCodeTools,
|
||||
IDEHelpIntf,
|
||||
IDEProcs, InputHistory, LazarusIDEStrConsts, EnvironmentOpts, TransferMacros,
|
||||
MacroDefIntf, IDEUtils;
|
||||
MacroDefIntf, IDEUtils, LazIDEIntf;
|
||||
|
||||
type
|
||||
TIDEDirective = (
|
||||
idedNone,
|
||||
idedBuildCommand, // Filename plus params to build the file
|
||||
// default is '$(CompPath) $(EdFile)'
|
||||
idedBuildWorkingDir,// Working directory for building. Default is the
|
||||
// directory of the file
|
||||
idedBuildScan, // Flags controlling what messages should be scanned for
|
||||
// during building. See TIDEDirBuildScanFlag.
|
||||
idedRunCommand, // Filename plus params to run the file
|
||||
// default is '$NameOnly($(EdFile))'
|
||||
idedRunWorkingDir, // Working directory for building. Default is the
|
||||
// directory of the file
|
||||
idedRunFlags // Flags for run. See TIDEDirRunFlag
|
||||
);
|
||||
TIDEDirectives = set of TIDEDirective;
|
||||
|
||||
TIDEDirBuildScanFlag = (
|
||||
idedbsfNone,
|
||||
idedbsfFPC, // scan for FPC messages. FPC+ means on (default) and FPC- off.
|
||||
idedbsfMake // scan for MAKE messages. MAKE- means on (default) and MAKE- off.
|
||||
);
|
||||
TIDEDirBuildScanFlags = set of TIDEDirBuildScanFlag;
|
||||
|
||||
TIDEDirRunFlag = (
|
||||
idedrfNone,
|
||||
idedrfBuildBeforeRun // BUILD+ means on (default), BUILD- means off
|
||||
);
|
||||
TIDEDirRunFlags = set of TIDEDirRunFlag;
|
||||
|
||||
|
||||
{ TMacroSelectionBox }
|
||||
|
||||
@ -125,25 +96,6 @@ const
|
||||
IDEDirDefaultRunCommand = '$MakeExe($(EdFile))';
|
||||
IDEDirRunFlagDefValues = [idedrfBuildBeforeRun];
|
||||
|
||||
IDEDirectiveNames: array[TIDEDirective] of string = (
|
||||
'',
|
||||
'BuildCommand',
|
||||
'BuildWorkingDir',
|
||||
'BuildScan',
|
||||
'RunCommand',
|
||||
'RunWorkingDir',
|
||||
'RunFlags'
|
||||
);
|
||||
IDEDirBuildScanFlagNames: array[TIDEDirBuildScanFlag] of string = (
|
||||
'',
|
||||
'FPC',
|
||||
'MAKE'
|
||||
);
|
||||
IDEDirRunFlagNames: array[TIDEDirRunFlag] of string = (
|
||||
'',
|
||||
'BUILD'
|
||||
);
|
||||
|
||||
var
|
||||
IDEDirectiveSpecialChars: string;
|
||||
|
||||
|
||||
49
ide/main.pp
49
ide/main.pp
@ -817,10 +817,10 @@ type
|
||||
function DoExampleManager: TModalResult; override;
|
||||
function DoBuildLazarus(Flags: TBuildLazarusFlags): TModalResult; override;
|
||||
function DoBuildAdvancedLazarus(ProfileNames: TStringList): TModalResult;
|
||||
function DoBuildFile({%H-}ShowAbort: Boolean): TModalResult; override;
|
||||
function DoBuildFile({%H-}ShowAbort: Boolean; Filename: string = ''): TModalResult; override;
|
||||
function DoRunFile: TModalResult; override;
|
||||
function DoConfigureBuildFile: TModalResult; override;
|
||||
function GetIDEDirectives(AnUnitInfo: TUnitInfo;
|
||||
function GetIDEDirectives(aFilename: string;
|
||||
DirectiveList: TStrings): TModalResult;
|
||||
function FilterIDEDirective(Tool: TStandardCodeTool;
|
||||
StartPos, {%H-}EndPos: integer): boolean;
|
||||
@ -7266,7 +7266,8 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TMainIDE.DoBuildFile(ShowAbort: Boolean): TModalResult;
|
||||
function TMainIDE.DoBuildFile(ShowAbort: Boolean; Filename: string
|
||||
): TModalResult;
|
||||
var
|
||||
ActiveSrcEdit: TSourceEditor;
|
||||
ActiveUnitInfo: TUnitInfo;
|
||||
@ -7277,13 +7278,19 @@ var
|
||||
ProgramFilename: string;
|
||||
Params: string;
|
||||
ExtTool: TIDEExternalToolOptions;
|
||||
Filename: String;
|
||||
OldToolStatus: TIDEToolStatus;
|
||||
begin
|
||||
Result:=mrCancel;
|
||||
if ToolStatus<>itNone then exit;
|
||||
ActiveSrcEdit:=nil;
|
||||
if not BeginCodeTool(ActiveSrcEdit,ActiveUnitInfo,[]) then exit;
|
||||
ActiveUnitInfo:=nil;
|
||||
if Filename='' then begin
|
||||
if not BeginCodeTool(ActiveSrcEdit,ActiveUnitInfo,[]) then exit;
|
||||
Filename:=ActiveUnitInfo.Filename;
|
||||
end else begin
|
||||
Filename:=TrimAndExpandFilename(Filename);
|
||||
if Filename='' then exit;
|
||||
end;
|
||||
Result:=DoSaveProject([]);
|
||||
if Result<>mrOk then exit;
|
||||
if ExternalTools.RunningCount=0 then
|
||||
@ -7292,7 +7299,7 @@ begin
|
||||
OldToolStatus:=ToolStatus;
|
||||
ToolStatus:=itBuilder;
|
||||
try
|
||||
Result:=GetIDEDirectives(ActiveUnitInfo,DirectiveList);
|
||||
Result:=GetIDEDirectives(Filename,DirectiveList);
|
||||
if Result<>mrOk then exit;
|
||||
|
||||
// get values from directive list
|
||||
@ -7301,7 +7308,7 @@ begin
|
||||
IDEDirectiveNames[idedBuildWorkingDir],
|
||||
'');
|
||||
if BuildWorkingDir='' then
|
||||
BuildWorkingDir:=ExtractFilePath(ActiveUnitInfo.Filename);
|
||||
BuildWorkingDir:=ExtractFilePath(Filename);
|
||||
if not GlobalMacroList.SubstituteStr(BuildWorkingDir) then begin
|
||||
Result:=mrCancel;
|
||||
exit;
|
||||
@ -7331,7 +7338,7 @@ begin
|
||||
|
||||
ExtTool:=TIDEExternalToolOptions.Create;
|
||||
try
|
||||
ExtTool.Title:='Build File '+ActiveUnitInfo.Filename;
|
||||
ExtTool.Title:='Build File '+Filename;
|
||||
ExtTool.WorkingDirectory:=BuildWorkingDir;
|
||||
ExtTool.CmdLineParams:=Params;
|
||||
ExtTool.Executable:=ProgramFilename;
|
||||
@ -7381,7 +7388,7 @@ begin
|
||||
end;
|
||||
DirectiveList:=TStringList.Create;
|
||||
try
|
||||
Result:=GetIDEDirectives(ActiveUnitInfo,DirectiveList);
|
||||
Result:=GetIDEDirectives(ActiveUnitInfo.Filename,DirectiveList);
|
||||
if Result<>mrOk then exit;
|
||||
|
||||
if ActiveUnitInfo.Source.LineCount>0 then
|
||||
@ -7460,7 +7467,7 @@ begin
|
||||
end;
|
||||
DirectiveList:=TStringList.Create;
|
||||
try
|
||||
Result:=GetIDEDirectives(ActiveUnitInfo,DirectiveList);
|
||||
Result:=GetIDEDirectives(ActiveUnitInfo.Filename,DirectiveList);
|
||||
if Result<>mrOk then exit;
|
||||
|
||||
BuildFileDialog:=TBuildFileDialog.Create(nil);
|
||||
@ -7510,23 +7517,29 @@ begin
|
||||
Result:=mrOk;
|
||||
end;
|
||||
|
||||
function TMainIDE.GetIDEDirectives(AnUnitInfo: TUnitInfo;
|
||||
DirectiveList: TStrings): TModalResult;
|
||||
function TMainIDE.GetIDEDirectives(aFilename: string; DirectiveList: TStrings
|
||||
): TModalResult;
|
||||
var
|
||||
CodeResult: Boolean;
|
||||
AnUnitInfo: TUnitInfo;
|
||||
Code: TCodeBuffer;
|
||||
begin
|
||||
Result:=mrCancel;
|
||||
if FilenameIsPascalSource(AnUnitInfo.Filename) then begin
|
||||
if FilenameIsPascalSource(aFilename) then begin
|
||||
// parse source for IDE directives (i.e. % comments)
|
||||
CodeResult:=CodeToolBoss.GetIDEDirectives(AnUnitInfo.Source,DirectiveList,@FilterIDEDirective);
|
||||
if not CodeResult then begin
|
||||
Result:=LoadCodeBuffer(Code,aFilename,[lbfUpdateFromDisk],false);
|
||||
if Result<>mrOk then exit;
|
||||
if not CodeToolBoss.GetIDEDirectives(Code,DirectiveList,@FilterIDEDirective)
|
||||
then begin
|
||||
DoJumpToCodeToolBossError;
|
||||
exit;
|
||||
end;
|
||||
end else begin
|
||||
end else if Project1<>nil then begin
|
||||
AnUnitInfo:=Project1.UnitInfoWithFilename(aFilename);
|
||||
if AnUnitInfo=nil then exit;
|
||||
StringToStringList(AnUnitInfo.CustomData['IDEDirectives'],DirectiveList);
|
||||
//DebugLn(['TMainIDE.GetIDEDirectives ',dbgstr(DirectiveList.Text)]);
|
||||
end;
|
||||
end else
|
||||
exit;
|
||||
Result:=mrOk;
|
||||
end;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user