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