mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 20:59:08 +02:00
Converter: refactor so that IsMainFile is set before it is used.
git-svn-id: trunk@29495 -
This commit is contained in:
parent
f26b21daea
commit
8cf2c6b279
@ -162,13 +162,12 @@ type
|
|||||||
protected
|
protected
|
||||||
function CreateInstance: TModalResult; virtual; abstract;
|
function CreateInstance: TModalResult; virtual; abstract;
|
||||||
function CreateMainSourceFile: TModalResult; virtual;
|
function CreateMainSourceFile: TModalResult; virtual;
|
||||||
function ScanMainSourceFile: TModalResult; virtual;
|
|
||||||
function ConvertMainSourceFile: TModalResult; virtual;
|
function ConvertMainSourceFile: TModalResult; virtual;
|
||||||
function FindAllUnits: TModalResult; virtual; abstract;
|
function FindAllUnits: TModalResult; virtual; abstract;
|
||||||
function ConvertAllUnits: TModalResult; virtual; abstract;
|
function ConvertAllUnits: TModalResult; virtual; abstract;
|
||||||
function ExtractOptionsFromDelphiSource: TModalResult; virtual; abstract;
|
function ExtractOptionsFromDelphiSource: TModalResult; virtual; abstract;
|
||||||
// The following protected funcs are needed only because Project and LazPackage
|
// The following protected funcs are needed only because
|
||||||
// don't inherit from the same class.
|
// Project and LazPackage don't inherit from the same class.
|
||||||
function GetCompOpts: TBaseCompilerOptions; virtual; abstract;
|
function GetCompOpts: TBaseCompilerOptions; virtual; abstract;
|
||||||
function GetCustomDefines: TDefineTemplate; virtual; abstract;
|
function GetCustomDefines: TDefineTemplate; virtual; abstract;
|
||||||
procedure CustomDefinesChanged; virtual; abstract;
|
procedure CustomDefinesChanged; virtual; abstract;
|
||||||
@ -202,7 +201,6 @@ type
|
|||||||
protected
|
protected
|
||||||
function CreateInstance: TModalResult; override;
|
function CreateInstance: TModalResult; override;
|
||||||
function CreateMainSourceFile: TModalResult; override;
|
function CreateMainSourceFile: TModalResult; override;
|
||||||
function ScanMainSourceFile: TModalResult; override;
|
|
||||||
function ConvertMainSourceFile: TModalResult; override;
|
function ConvertMainSourceFile: TModalResult; override;
|
||||||
function FindAllUnits: TModalResult; override;
|
function FindAllUnits: TModalResult; override;
|
||||||
function ConvertAllUnits: TModalResult; override;
|
function ConvertAllUnits: TModalResult; override;
|
||||||
@ -535,11 +533,8 @@ begin
|
|||||||
fCTLink.AskAboutError:=Assigned(fOwnerConverter);
|
fCTLink.AskAboutError:=Assigned(fOwnerConverter);
|
||||||
// Create a toold for missing units.
|
// Create a toold for missing units.
|
||||||
fUsedUnitsTool:=TUsedUnitsTool.Create(fCTLink, fOrigUnitFilename);
|
fUsedUnitsTool:=TUsedUnitsTool.Create(fCTLink, fOrigUnitFilename);
|
||||||
if Assigned(fOwnerConverter) then begin
|
if Assigned(fOwnerConverter) then
|
||||||
fUsedUnitsTool.CheckPackDepEvent:=@fOwnerConverter.CheckPackageDependency;
|
fUsedUnitsTool.CheckPackDepEvent:=@fOwnerConverter.CheckPackageDependency;
|
||||||
fUsedUnitsTool.IsMainFile:=fOwnerConverter.MainName=fLazUnitFilename;
|
|
||||||
fUsedUnitsTool.IsConsoleApp:=fOwnerConverter.fIsConsoleApp;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TConvertDelphiUnit.FixLfmFilename(ADfmFilename: string): TModalResult;
|
function TConvertDelphiUnit.FixLfmFilename(ADfmFilename: string): TModalResult;
|
||||||
@ -862,9 +857,6 @@ begin
|
|||||||
|
|
||||||
RemoveNonExistingFiles(false);
|
RemoveNonExistingFiles(false);
|
||||||
CleanUpCompilerOptionsSearchPaths(CompOpts);
|
CleanUpCompilerOptionsSearchPaths(CompOpts);
|
||||||
// Scan LPR file for directives. Sets fIsConsoleApp flag.
|
|
||||||
Result:=ScanMainSourceFile;
|
|
||||||
if Result<>mrOK then exit;
|
|
||||||
// LCL dependency is added automatically later for GUI applications.
|
// LCL dependency is added automatically later for GUI applications.
|
||||||
// AddPackageDependency('LCL');
|
// AddPackageDependency('LCL');
|
||||||
// ToDo: make an option to add NoGUI to Project.CompilerOptions.LCLWidgetType.
|
// ToDo: make an option to add NoGUI to Project.CompilerOptions.LCLWidgetType.
|
||||||
@ -1205,11 +1197,6 @@ begin
|
|||||||
Result:=mrOK; // Do nothing. Overridden in project.
|
Result:=mrOK; // Do nothing. Overridden in project.
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TConvertDelphiPBase.ScanMainSourceFile: TModalResult;
|
|
||||||
begin
|
|
||||||
Result:=mrOK; // Do nothing. Overridden in project.
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TConvertDelphiPBase.ConvertMainSourceFile: TModalResult;
|
function TConvertDelphiPBase.ConvertMainSourceFile: TModalResult;
|
||||||
begin
|
begin
|
||||||
Result:=mrOK; // Do nothing. Overridden in project.
|
Result:=mrOK; // Do nothing. Overridden in project.
|
||||||
@ -1271,6 +1258,7 @@ function TConvertDelphiProject.CreateMainSourceFile: TModalResult;
|
|||||||
// adds the .lpr as main unit to the project, if not already done
|
// adds the .lpr as main unit to the project, if not already done
|
||||||
var
|
var
|
||||||
MainUnitInfo: TUnitInfo;
|
MainUnitInfo: TUnitInfo;
|
||||||
|
ConvTool: TConvDelphiCodeTool;
|
||||||
begin
|
begin
|
||||||
// Converter for main LPR file.
|
// Converter for main LPR file.
|
||||||
fMainUnitConverter:=TConvertDelphiUnit.Create(Self,fOrigPFilename,[]);
|
fMainUnitConverter:=TConvertDelphiUnit.Create(Self,fOrigPFilename,[]);
|
||||||
@ -1291,25 +1279,20 @@ begin
|
|||||||
// replace main unit in project
|
// replace main unit in project
|
||||||
LazProject.MainUnitInfo.Source:=fMainUnitConverter.fPascalBuffer;
|
LazProject.MainUnitInfo.Source:=fMainUnitConverter.fPascalBuffer;
|
||||||
end;
|
end;
|
||||||
Result:=LazarusIDE.DoOpenEditorFile(fMainUnitConverter.fLazUnitFilename,0,0,[ofQuiet]);
|
// Scan LPR file for directives. Sets fIsConsoleApp flag.
|
||||||
if Result<>mrOK then exit;
|
ConvTool:=TConvDelphiCodeTool.Create(fMainUnitConverter.fCTLink);
|
||||||
Result:=mrOk;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TConvertDelphiProject.ScanMainSourceFile: TModalResult;
|
|
||||||
var
|
|
||||||
CTLink: TCodeToolLink;
|
|
||||||
ConvTool: TConvDelphiCodeTool;
|
|
||||||
begin
|
|
||||||
Result:=mrOK;
|
|
||||||
CTLink:=TCodeToolLink.Create(fMainUnitConverter.fPascalBuffer);
|
|
||||||
ConvTool:=TConvDelphiCodeTool.Create(CTLink);
|
|
||||||
try
|
try
|
||||||
fIsConsoleApp:=ConvTool.FindApptypeConsole;
|
fIsConsoleApp:=ConvTool.FindApptypeConsole;
|
||||||
finally
|
finally
|
||||||
ConvTool.Free;
|
ConvTool.Free;
|
||||||
CTLink.Free;
|
|
||||||
end;
|
end;
|
||||||
|
with fMainUnitConverter do begin
|
||||||
|
fUsedUnitsTool.IsMainFile:=MainName=fLazUnitFilename;
|
||||||
|
fUsedUnitsTool.IsConsoleApp:=fIsConsoleApp;
|
||||||
|
Result:=LazarusIDE.DoOpenEditorFile(fLazUnitFilename,0,0,[ofQuiet]);
|
||||||
|
if Result<>mrOK then exit;
|
||||||
|
end;
|
||||||
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TConvertDelphiProject.ConvertMainSourceFile: TModalResult;
|
function TConvertDelphiProject.ConvertMainSourceFile: TModalResult;
|
||||||
|
Loading…
Reference in New Issue
Block a user