mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 06:20:17 +02:00
Converter: Add thread support, insert cthreads in main unit's uses section.
git-svn-id: trunk@29066 -
This commit is contained in:
parent
769e36bac2
commit
d80fadfa54
@ -146,6 +146,7 @@ type
|
|||||||
// Units that are found and will be added to project and converted.
|
// Units that are found and will be added to project and converted.
|
||||||
fUnitsToAddToProject: TStringList;
|
fUnitsToAddToProject: TStringList;
|
||||||
fSettings: TConvertSettings;
|
fSettings: TConvertSettings;
|
||||||
|
fUseThreads: boolean; // The project/package uses TThread.
|
||||||
function ConvertSub: TModalResult;
|
function ConvertSub: TModalResult;
|
||||||
procedure CleanUpCompilerOptionsSearchPaths(Options: TBaseCompilerOptions);
|
procedure CleanUpCompilerOptionsSearchPaths(Options: TBaseCompilerOptions);
|
||||||
procedure SetCompilerModeForDefineTempl(DefTempl: TDefineTemplate);
|
procedure SetCompilerModeForDefineTempl(DefTempl: TDefineTemplate);
|
||||||
@ -464,6 +465,7 @@ end;
|
|||||||
|
|
||||||
destructor TConvertDelphiUnit.Destroy;
|
destructor TConvertDelphiUnit.Destroy;
|
||||||
begin
|
begin
|
||||||
|
fUsedUnitsTool.Free;
|
||||||
fCTLink.Free;
|
fCTLink.Free;
|
||||||
if fOwnerConverter=nil then
|
if fOwnerConverter=nil then
|
||||||
fSettings.Free;
|
fSettings.Free;
|
||||||
@ -676,7 +678,6 @@ begin
|
|||||||
if Assigned(fUsedUnitsTool) then begin
|
if Assigned(fUsedUnitsTool) then begin
|
||||||
Result:=fUsedUnitsTool.Convert;
|
Result:=fUsedUnitsTool.Convert;
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
FreeAndNil(fUsedUnitsTool);
|
|
||||||
end;
|
end;
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
@ -782,6 +783,7 @@ constructor TConvertDelphiPBase.Create(const AFilename, ADescription: string);
|
|||||||
begin
|
begin
|
||||||
fOrigPFilename:=AFilename;
|
fOrigPFilename:=AFilename;
|
||||||
fIsConsoleApp:=False; // Default = GUI app.
|
fIsConsoleApp:=False; // Default = GUI app.
|
||||||
|
fUseThreads:=True; // For testing.
|
||||||
fUnitSearchPaths:=TStringList.Create;
|
fUnitSearchPaths:=TStringList.Create;
|
||||||
fUnitSearchPaths.Delimiter:=';';
|
fUnitSearchPaths.Delimiter:=';';
|
||||||
fUnitSearchPaths.StrictDelimiter:=True;
|
fUnitSearchPaths.StrictDelimiter:=True;
|
||||||
@ -1463,8 +1465,13 @@ begin
|
|||||||
Result:=ConvertOne(CurUnitInfo);
|
Result:=ConvertOne(CurUnitInfo);
|
||||||
if Result<>mrOK then Break;
|
if Result<>mrOK then Break;
|
||||||
end;
|
end;
|
||||||
if Result=mrOK then
|
if Result=mrOK then begin
|
||||||
|
if fUseThreads then begin
|
||||||
|
Result:=fMainUnitConverter.fUsedUnitsTool.AddThreadSupport;
|
||||||
|
if Result<>mrOK then exit;
|
||||||
|
end;
|
||||||
Result:=ConvertAllFormFiles(ConvUnits);
|
Result:=ConvertAllFormFiles(ConvUnits);
|
||||||
|
end;
|
||||||
finally
|
finally
|
||||||
ConvUnits.Free; // Owns and frees converter objects.
|
ConvUnits.Free; // Owns and frees converter objects.
|
||||||
end;
|
end;
|
||||||
|
@ -121,6 +121,7 @@ type
|
|||||||
function Convert: TModalResult;
|
function Convert: TModalResult;
|
||||||
procedure MoveMissingToComment(AAllCommentedUnits: TStrings);
|
procedure MoveMissingToComment(AAllCommentedUnits: TStrings);
|
||||||
procedure AddUnitIfNeeded(AUnitName: string);
|
procedure AddUnitIfNeeded(AUnitName: string);
|
||||||
|
function AddThreadSupport: TModalResult;
|
||||||
public
|
public
|
||||||
property MainUsedUnits: TUsedUnits read fMainUsedUnits;
|
property MainUsedUnits: TUsedUnits read fMainUsedUnits;
|
||||||
property ImplUsedUnits: TUsedUnits read fImplUsedUnits;
|
property ImplUsedUnits: TUsedUnits read fImplUsedUnits;
|
||||||
@ -629,6 +630,25 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TUsedUnitsTool.AddThreadSupport: TModalResult;
|
||||||
|
// AddUnitToSpecificUsesSection would insert cthreads in the beginning automatically
|
||||||
|
// It doesn't work with {$IFDEF UNIX} directive -> use UsesInsertPolicy.
|
||||||
|
var
|
||||||
|
OldPolicy: TUsesInsertPolicy;
|
||||||
|
begin
|
||||||
|
Result:=mrCancel;
|
||||||
|
with fCTLink do
|
||||||
|
try
|
||||||
|
OldPolicy:=SrcCache.BeautifyCodeOptions.UsesInsertPolicy;
|
||||||
|
SrcCache.BeautifyCodeOptions.UsesInsertPolicy:=uipFirst;
|
||||||
|
if not CodeTool.AddUnitToSpecificUsesSection(fMainUsedUnits.fUsesSection,
|
||||||
|
'{$IFDEF UNIX}cthreads{$ENDIF}', '', SrcCache) then exit;
|
||||||
|
finally
|
||||||
|
SrcCache.BeautifyCodeOptions.UsesInsertPolicy:=OldPolicy;
|
||||||
|
end;
|
||||||
|
Result:=mrOK;
|
||||||
|
end;
|
||||||
|
|
||||||
function TUsedUnitsTool.GetMissingUnitCount: integer;
|
function TUsedUnitsTool.GetMissingUnitCount: integer;
|
||||||
begin
|
begin
|
||||||
Result:=fMainUsedUnits.fMissingUnits.Count+fImplUsedUnits.fMissingUnits.Count;
|
Result:=fMainUsedUnits.fMissingUnits.Count+fImplUsedUnits.fMissingUnits.Count;
|
||||||
|
Loading…
Reference in New Issue
Block a user