mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 20:21:04 +02:00
IDE: now auto appending library file extension for libraries, bug #10624
git-svn-id: trunk@15947 -
This commit is contained in:
parent
c9aebb8a74
commit
fb2f6ebefd
@ -1400,7 +1400,7 @@ begin
|
|||||||
else
|
else
|
||||||
RaiseGDBException('');
|
RaiseGDBException('');
|
||||||
end;
|
end;
|
||||||
//DebugLn('TBaseCompilerOptions.GetTargetFileExt ',Result);
|
//DebugLn('TBaseCompilerOptions.GetTargetFileExt ',Result,' ',dbgs(ord(ExecutableType)),' ',fTargetOS);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBaseCompilerOptions.GetInheritedCompilerOptions(
|
procedure TBaseCompilerOptions.GetInheritedCompilerOptions(
|
||||||
|
@ -260,6 +260,11 @@ begin
|
|||||||
Result:='.dll'
|
Result:='.dll'
|
||||||
else if CompareText(TargetOS, 'darwin') = 0 then
|
else if CompareText(TargetOS, 'darwin') = 0 then
|
||||||
Result:='.dylib'
|
Result:='.dylib'
|
||||||
|
else if (CompareText(TargetOS, 'linux') = 0)
|
||||||
|
or (CompareText(TargetOS, 'freebsd') = 0)
|
||||||
|
or (CompareText(TargetOS, 'openbsd') = 0)
|
||||||
|
or (CompareText(TargetOS, 'netbsd') = 0) then
|
||||||
|
Result:='.so'
|
||||||
else
|
else
|
||||||
Result:='';
|
Result:='';
|
||||||
end;
|
end;
|
||||||
|
65
ide/main.pp
65
ide/main.pp
@ -3550,6 +3550,7 @@ var
|
|||||||
begin
|
begin
|
||||||
frmCompilerOptions:=TfrmCompilerOptions.Create(nil);
|
frmCompilerOptions:=TfrmCompilerOptions.Create(nil);
|
||||||
try
|
try
|
||||||
|
Project1.UpdateExecutableType;
|
||||||
NewCaption:=Project1.Title;
|
NewCaption:=Project1.Title;
|
||||||
if NewCaption='' then
|
if NewCaption='' then
|
||||||
NewCaption:=ExtractFilenameOnly(Project1.ProjectInfoFile);
|
NewCaption:=ExtractFilenameOnly(Project1.ProjectInfoFile);
|
||||||
@ -5208,6 +5209,7 @@ var
|
|||||||
Ext, NewProgramName, LPIFilename, ACaption, AText: string;
|
Ext, NewProgramName, LPIFilename, ACaption, AText: string;
|
||||||
PreReadBuf: TCodeBuffer;
|
PreReadBuf: TCodeBuffer;
|
||||||
LoadFlags: TLoadBufferFlags;
|
LoadFlags: TLoadBufferFlags;
|
||||||
|
SourceType: String;
|
||||||
begin
|
begin
|
||||||
Handled:=false;
|
Handled:=false;
|
||||||
Ext:=lowercase(ExtractFileExt(AFilename));
|
Ext:=lowercase(ExtractFileExt(AFilename));
|
||||||
@ -5229,35 +5231,39 @@ begin
|
|||||||
|
|
||||||
// check if unit is a program
|
// check if unit is a program
|
||||||
if ([ofProjectLoading,ofRegularFile]*Flags=[])
|
if ([ofProjectLoading,ofRegularFile]*Flags=[])
|
||||||
and FilenameIsPascalSource(AFilename)
|
and FilenameIsPascalSource(AFilename) then begin
|
||||||
and (CodeToolBoss.GetSourceType(PreReadBuf,false)='PROGRAM') then begin
|
SourceType:=CodeToolBoss.GetSourceType(PreReadBuf,false);
|
||||||
NewProgramName:=CodeToolBoss.GetSourceName(PreReadBuf,false);
|
if (SysUtils.CompareText(SourceType,'PROGRAM')=0)
|
||||||
if NewProgramName<>'' then begin
|
or (SysUtils.CompareText(SourceType,'LIBRARY')=0)
|
||||||
// source is a program
|
then begin
|
||||||
// either this is a lazarus project
|
NewProgramName:=CodeToolBoss.GetSourceName(PreReadBuf,false);
|
||||||
// or it is not yet a lazarus project ;)
|
if NewProgramName<>'' then begin
|
||||||
LPIFilename:=ChangeFileExt(AFilename,'.lpi');
|
// source is a program
|
||||||
if FileExists(LPIFilename) then begin
|
// either this is a lazarus project
|
||||||
if QuestionDlg(lisProjectInfoFileDetected,
|
// or it is not yet a lazarus project ;)
|
||||||
Format(lisTheFileSeemsToBeTheProgramFileOfAnExistingLazarusP, [
|
LPIFilename:=ChangeFileExt(AFilename,'.lpi');
|
||||||
AFilename]), mtConfirmation,
|
if FileExists(LPIFilename) then begin
|
||||||
[mrOk, lisOpenProject2, mrCancel, lisOpenTheFileAsNormalSource], 0)
|
if QuestionDlg(lisProjectInfoFileDetected,
|
||||||
=mrOk then
|
Format(lisTheFileSeemsToBeTheProgramFileOfAnExistingLazarusP, [
|
||||||
begin
|
AFilename]), mtConfirmation,
|
||||||
Result:=DoOpenProjectFile(LPIFilename,[]);
|
[mrOk, lisOpenProject2, mrCancel, lisOpenTheFileAsNormalSource], 0)
|
||||||
Handled:=true;
|
=mrOk then
|
||||||
exit;
|
begin
|
||||||
end;
|
Result:=DoOpenProjectFile(LPIFilename,[]);
|
||||||
end else begin
|
Handled:=true;
|
||||||
AText:=Format(lisTheFileSeemsToBeAProgramCloseCurrentProject, ['"',
|
exit;
|
||||||
AFilename, '"', #13, #13]);
|
end;
|
||||||
ACaption:=lisProgramDetected;
|
end else begin
|
||||||
if MessageDlg(ACaption, AText, mtConfirmation,
|
AText:=Format(lisTheFileSeemsToBeAProgramCloseCurrentProject, ['"',
|
||||||
[mbYes, mbNo], 0)=mrYes then
|
AFilename, '"', #13, #13]);
|
||||||
begin
|
ACaption:=lisProgramDetected;
|
||||||
Result:=DoCreateProjectForProgram(PreReadBuf);
|
if MessageDlg(ACaption, AText, mtConfirmation,
|
||||||
Handled:=true;
|
[mbYes, mbNo], 0)=mrYes then
|
||||||
exit;
|
begin
|
||||||
|
Result:=DoCreateProjectForProgram(PreReadBuf);
|
||||||
|
Handled:=true;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -8918,6 +8924,7 @@ begin
|
|||||||
Result:=DoSaveAll([sfCheckAmbiguousFiles])
|
Result:=DoSaveAll([sfCheckAmbiguousFiles])
|
||||||
else
|
else
|
||||||
Result:=DoSaveProjectToTestDirectory([sfSaveNonProjectFiles]);
|
Result:=DoSaveProjectToTestDirectory([sfSaveNonProjectFiles]);
|
||||||
|
Project1.UpdateExecutableType;
|
||||||
if Result<>mrOk then begin
|
if Result<>mrOk then begin
|
||||||
{$IFDEF VerboseSaveForBuild}
|
{$IFDEF VerboseSaveForBuild}
|
||||||
DebugLn('TMainIDE.DoSaveForBuild project saving failed');
|
DebugLn('TMainIDE.DoSaveForBuild project saving failed');
|
||||||
|
@ -648,6 +648,7 @@ type
|
|||||||
procedure SetSessionStorage(const AValue: TProjectSessionStorage); override;
|
procedure SetSessionStorage(const AValue: TProjectSessionStorage); override;
|
||||||
procedure SetModified(const AValue: boolean); override;
|
procedure SetModified(const AValue: boolean); override;
|
||||||
procedure SetSessionModified(const AValue: boolean); override;
|
procedure SetSessionModified(const AValue: boolean); override;
|
||||||
|
procedure SetExecutableType(const AValue: TProjectExecutableType); override;
|
||||||
protected
|
protected
|
||||||
// special unit lists
|
// special unit lists
|
||||||
procedure AddToList(AnUnitInfo: TUnitInfo; ListType: TUnitInfoList);
|
procedure AddToList(AnUnitInfo: TUnitInfo; ListType: TUnitInfoList);
|
||||||
@ -678,7 +679,8 @@ type
|
|||||||
function ReadProject(const NewProjectInfoFile: string): TModalResult;
|
function ReadProject(const NewProjectInfoFile: string): TModalResult;
|
||||||
function WriteProject(ProjectWriteFlags: TProjectWriteFlags;
|
function WriteProject(ProjectWriteFlags: TProjectWriteFlags;
|
||||||
const OverrideProjectInfoFile: string): TModalResult;
|
const OverrideProjectInfoFile: string): TModalResult;
|
||||||
|
procedure UpdateExecutableType; override;
|
||||||
|
|
||||||
// title
|
// title
|
||||||
function GetDefaultTitle: string;
|
function GetDefaultTitle: string;
|
||||||
function TitleIsDefault(Fuzzy: boolean = false): boolean;
|
function TitleIsDefault(Fuzzy: boolean = false): boolean;
|
||||||
@ -2214,6 +2216,35 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TProject.UpdateExecutableType;
|
||||||
|
|
||||||
|
function GetMainSourceType: string;
|
||||||
|
var
|
||||||
|
AnUnitInfo: TUnitInfo;
|
||||||
|
begin
|
||||||
|
Result:='';
|
||||||
|
if MainUnitID<0 then exit;
|
||||||
|
AnUnitInfo:=Units[MainUnitID];
|
||||||
|
if AnUnitInfo.Source=nil then exit;
|
||||||
|
Result:=CodeToolBoss.GetSourceType(AnUnitInfo.Source,false);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
SourceType: String;
|
||||||
|
begin
|
||||||
|
SourceType:=GetMainSourceType;
|
||||||
|
if SysUtils.CompareText(SourceType,'Program')=0 then
|
||||||
|
ExecutableType:=petProgram
|
||||||
|
else if SysUtils.CompareText(SourceType,'Library')=0 then
|
||||||
|
ExecutableType:=petLibrary
|
||||||
|
else if SysUtils.CompareText(SourceType,'Unit')=0 then
|
||||||
|
ExecutableType:=petUnit
|
||||||
|
else if SysUtils.CompareText(SourceType,'Package')=0 then
|
||||||
|
ExecutableType:=petPackage
|
||||||
|
else
|
||||||
|
ExecutableType:=petNone;
|
||||||
|
end;
|
||||||
|
|
||||||
function TProject.GetDefaultTitle: string;
|
function TProject.GetDefaultTitle: string;
|
||||||
begin
|
begin
|
||||||
Result:=ExtractFilenameOnly(ProjectInfoFile);
|
Result:=ExtractFilenameOnly(ProjectInfoFile);
|
||||||
@ -2849,6 +2880,15 @@ begin
|
|||||||
inherited SetSessionModified(AValue);
|
inherited SetSessionModified(AValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TProject.SetExecutableType(const AValue: TProjectExecutableType);
|
||||||
|
begin
|
||||||
|
inherited SetExecutableType(AValue);
|
||||||
|
case ExecutableType of
|
||||||
|
petLibrary: CompilerOptions.ExecutableType:=cetLibrary;
|
||||||
|
else CompilerOptions.ExecutableType:=cetProgram;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TProject.UnitCount:integer;
|
function TProject.UnitCount:integer;
|
||||||
begin
|
begin
|
||||||
Result:=FUnitList.Count;
|
Result:=FUnitList.Count;
|
||||||
|
@ -641,7 +641,7 @@ begin
|
|||||||
if CodeBuffer=nil then exit;
|
if CodeBuffer=nil then exit;
|
||||||
SourceKeyWord:=CodeToolBoss.GetSourceType(CodeBuffer,false);
|
SourceKeyWord:=CodeToolBoss.GetSourceType(CodeBuffer,false);
|
||||||
for ASrcType:=Low(TUnitNodeSourceType) to High(TUnitNodeSourceType) do
|
for ASrcType:=Low(TUnitNodeSourceType) to High(TUnitNodeSourceType) do
|
||||||
if AnsiCompareText(SourceKeyWord,UnitNodeSourceTypeNames[ASrcType])=0
|
if CompareText(SourceKeyWord,UnitNodeSourceTypeNames[ASrcType])=0
|
||||||
then
|
then
|
||||||
FSourceType:=ASrcType;
|
FSourceType:=ASrcType;
|
||||||
if TreeNode<>nil then begin
|
if TreeNode<>nil then begin
|
||||||
|
@ -528,10 +528,19 @@ type
|
|||||||
);
|
);
|
||||||
TProjectFileSearchFlags = set of TProjectFileSearchFlag;
|
TProjectFileSearchFlags = set of TProjectFileSearchFlag;
|
||||||
|
|
||||||
|
TProjectExecutableType = (
|
||||||
|
petNone,
|
||||||
|
petProgram,
|
||||||
|
petLibrary,
|
||||||
|
petPackage,
|
||||||
|
petUnit
|
||||||
|
);
|
||||||
|
|
||||||
TLazProject = class(TPersistent)
|
TLazProject = class(TPersistent)
|
||||||
private
|
private
|
||||||
FCustomData: TStringToStringTree;
|
FCustomData: TStringToStringTree;
|
||||||
FCustomSessionData: TStringToStringTree;
|
FCustomSessionData: TStringToStringTree;
|
||||||
|
FExecutableType: TProjectExecutableType;
|
||||||
FLazCompilerOptions: TLazCompilerOptions;
|
FLazCompilerOptions: TLazCompilerOptions;
|
||||||
fModified: boolean;
|
fModified: boolean;
|
||||||
FProjectSessionFile: string;
|
FProjectSessionFile: string;
|
||||||
@ -555,6 +564,7 @@ type
|
|||||||
procedure SetSessionStorage(const AValue: TProjectSessionStorage); virtual;
|
procedure SetSessionStorage(const AValue: TProjectSessionStorage); virtual;
|
||||||
procedure SetModified(const AValue: boolean); virtual;
|
procedure SetModified(const AValue: boolean); virtual;
|
||||||
procedure SetSessionModified(const AValue: boolean); virtual;
|
procedure SetSessionModified(const AValue: boolean); virtual;
|
||||||
|
procedure SetExecutableType(const AValue: TProjectExecutableType); virtual;
|
||||||
public
|
public
|
||||||
constructor Create(ProjectDescription: TProjectDescriptor); virtual;
|
constructor Create(ProjectDescription: TProjectDescriptor); virtual;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -570,6 +580,7 @@ type
|
|||||||
procedure ClearModifieds(ClearUnits: boolean);
|
procedure ClearModifieds(ClearUnits: boolean);
|
||||||
function FindFile(const AFilename: string;
|
function FindFile(const AFilename: string;
|
||||||
SearchFlags: TProjectFileSearchFlags): TLazProjectFile; virtual; abstract;
|
SearchFlags: TProjectFileSearchFlags): TLazProjectFile; virtual; abstract;
|
||||||
|
procedure UpdateExecutableType; virtual; abstract;
|
||||||
public
|
public
|
||||||
property MainFileID: Integer read GetMainFileID write SetMainFileID;
|
property MainFileID: Integer read GetMainFileID write SetMainFileID;
|
||||||
property Files[Index: integer]: TLazProjectFile read GetFiles;
|
property Files[Index: integer]: TLazProjectFile read GetFiles;
|
||||||
@ -577,6 +588,8 @@ type
|
|||||||
property MainFile: TLazProjectFile read GetMainFile;
|
property MainFile: TLazProjectFile read GetMainFile;
|
||||||
property Title: String read fTitle write SetTitle;
|
property Title: String read fTitle write SetTitle;
|
||||||
property Flags: TProjectFlags read FFlags write SetFlags;
|
property Flags: TProjectFlags read FFlags write SetFlags;
|
||||||
|
property ExecutableType: TProjectExecutableType read FExecutableType
|
||||||
|
write SetExecutableType;// read from MainFile, not saved to lpi
|
||||||
property LazCompilerOptions: TLazCompilerOptions read FLazCompilerOptions
|
property LazCompilerOptions: TLazCompilerOptions read FLazCompilerOptions
|
||||||
write SetLazCompilerOptions;
|
write SetLazCompilerOptions;
|
||||||
property ProjectInfoFile: string
|
property ProjectInfoFile: string
|
||||||
@ -1122,17 +1135,25 @@ begin
|
|||||||
Modified:=true;
|
Modified:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLazProject.SetExecutableType(const AValue: TProjectExecutableType);
|
||||||
|
begin
|
||||||
|
if FExecutableType=AValue then exit;
|
||||||
|
FExecutableType:=AValue;
|
||||||
|
Modified:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TLazProject.SetLazCompilerOptions(const AValue: TLazCompilerOptions);
|
procedure TLazProject.SetLazCompilerOptions(const AValue: TLazCompilerOptions);
|
||||||
begin
|
begin
|
||||||
if FLazCompilerOptions=AValue then exit;
|
if FLazCompilerOptions=AValue then exit;
|
||||||
FLazCompilerOptions:=AValue;
|
FLazCompilerOptions:=AValue;
|
||||||
|
Modified:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLazProject.SetTitle(const AValue: String);
|
procedure TLazProject.SetTitle(const AValue: String);
|
||||||
begin
|
begin
|
||||||
if fTitle=AValue then exit;
|
if fTitle=AValue then exit;
|
||||||
Modified:=true;
|
|
||||||
fTitle:=AValue;
|
fTitle:=AValue;
|
||||||
|
Modified:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TLazProject.Create(ProjectDescription: TProjectDescriptor);
|
constructor TLazProject.Create(ProjectDescription: TProjectDescriptor);
|
||||||
|
Loading…
Reference in New Issue
Block a user