From 8ee1876b6e3ec276bb0076f81cb2342dfd09bcf6 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 20 Feb 2006 22:46:02 +0000 Subject: [PATCH] implemented compiler options ExecutableType git-svn-id: trunk@8787 - --- ide/compileroptions.pp | 36 ++++++++++++++++++++++++++++++++- ide/include/darwin/lazconf.inc | 5 +++++ ide/include/freebsd/lazconf.inc | 5 +++++ ide/include/netbsd/lazconf.inc | 5 +++++ ide/project.pp | 1 + ideintf/projectintf.pas | 27 +++++++++++++++++++++++-- 6 files changed, 76 insertions(+), 3 deletions(-) diff --git a/ide/compileroptions.pp b/ide/compileroptions.pp index f6822cafb6..9337294cb1 100644 --- a/ide/compileroptions.pp +++ b/ide/compileroptions.pp @@ -295,6 +295,7 @@ type Flags: TCompilerCmdLineOptions): String; virtual; function GetXMLConfigPath: String; virtual; function CreateTargetFilename(const MainSourceFileName: string): string; virtual; + function GetTargetFileExt: string; virtual; procedure GetInheritedCompilerOptions(var OptionsList: TList); virtual; function GetOwnerName: string; virtual; function GetInheritedOption(Option: TInheritedCompilerOption; @@ -1064,6 +1065,9 @@ begin PassLinkerOptions := XMLConfigFile.GetValue(p+'Options/PassLinkerOptions/Value', false); LinkerOptions := f(XMLConfigFile.GetValue(p+'Options/LinkerOptions/Value', '')); Win32GraphicApp := XMLConfigFile.GetValue(p+'Options/Win32/GraphicApplication/Value', false); + ExecutableType := CompilationExecutableTypeNameToType( + XMLConfigFile.GetValue(p+'Options/ExecutableType/Value','')); + //DebugLn('TBaseCompilerOptions.LoadTheCompilerOptions ',CompilationExecutableTypeNames[ExecutableType]); { Messages } p:=Path+'Other/'; @@ -1210,6 +1214,10 @@ begin XMLConfigFile.SetDeleteValue(p+'Options/PassLinkerOptions/Value', PassLinkerOptions,false); XMLConfigFile.SetDeleteValue(p+'Options/LinkerOptions/Value', LinkerOptions,''); XMLConfigFile.SetDeleteValue(p+'Options/Win32/GraphicApplication/Value', Win32GraphicApp,false); + XMLConfigFile.SetDeleteValue(p+'Options/ExecutableType/Value', + CompilationExecutableTypeNames[ExecutableType], + CompilationExecutableTypeNames[cetProgram]); + //DebugLn('TBaseCompilerOptions.SaveCompilerOptions ',CompilationExecutableTypeNames[ExecutableType]); { Messages } p:=Path+'Other/'; @@ -1286,7 +1294,7 @@ function TBaseCompilerOptions.CreateTargetFilename( Ext: String; begin if (ExtractFileName(Result)='') or (ExtractFileExt(Result)<>'') then exit; - Ext:=GetDefaultExecutableExt; + Ext:=GetTargetFileExt; if Ext<>'' then begin Result:=Result+Ext; exit; @@ -1321,6 +1329,29 @@ begin AppendDefaultExt; end; +function TBaseCompilerOptions.GetTargetFileExt: string; +begin + case ExecutableType of + cetProgram: + begin + if CompareText(fTargetOS, 'win32') = 0 then + Result:='.exe' + else + Result:=GetDefaultExecutableExt; + end; + cetLibrary: + begin + if CompareText(fTargetOS, 'win32') = 0 then + Result:='.dll' + else + Result:=GetDefaultLibraryExt; + end; + else + RaiseGDBException(''); + end; + //DebugLn('TBaseCompilerOptions.GetTargetFileExt ',Result); +end; + procedure TBaseCompilerOptions.GetInheritedCompilerOptions( var OptionsList: TList); begin @@ -2225,6 +2256,7 @@ begin fPassLinkerOpt := false; LinkerOptions := ''; Win32GraphicApp := false; + ExecutableType := cetProgram; // messages fShowErrors := true; @@ -2329,6 +2361,7 @@ begin fPassLinkerOpt := CompOpts.fPassLinkerOpt; LinkerOptions := CompOpts.fLinkerOptions; Win32GraphicApp := CompOpts.Win32GraphicApp; + ExecutableType := CompOpts.ExecutableType; // Messages fShowErrors := CompOpts.fShowErrors; @@ -2423,6 +2456,7 @@ begin and (fPassLinkerOpt = CompOpts.fPassLinkerOpt) and (fLinkerOptions = CompOpts.fLinkerOptions) and (FWin32GraphicApp = CompOpts.FWin32GraphicApp) + and (FExecutableType = CompOpts.FExecutableType) // messages and (fShowErrors = CompOpts.fShowErrors) diff --git a/ide/include/darwin/lazconf.inc b/ide/include/darwin/lazconf.inc index cdbb2d64b1..b8d700b691 100644 --- a/ide/include/darwin/lazconf.inc +++ b/ide/include/darwin/lazconf.inc @@ -42,6 +42,11 @@ begin Result:='darwin'; end; +function GetDefaultLibraryExt: string; +begin + Result:='.dynlib'; +end; + procedure IfDirectoryExistsAdd(const Directory: string; List: TStrings); begin if DirPathExists(Directory) then List.Add(Directory); diff --git a/ide/include/freebsd/lazconf.inc b/ide/include/freebsd/lazconf.inc index faf891d564..3c93092cb3 100644 --- a/ide/include/freebsd/lazconf.inc +++ b/ide/include/freebsd/lazconf.inc @@ -46,6 +46,11 @@ procedure GetDefaultLCLLibPaths(List: TStrings); begin end; +function GetDefaultLibraryExt: string; +begin + Result:='.so'; +end; + {$I ../unix/lazbaseconf.inc} diff --git a/ide/include/netbsd/lazconf.inc b/ide/include/netbsd/lazconf.inc index bd33d4d62d..bb1cc4b32b 100644 --- a/ide/include/netbsd/lazconf.inc +++ b/ide/include/netbsd/lazconf.inc @@ -46,6 +46,11 @@ procedure GetDefaultLCLLibPaths(List: TStrings); begin end; +function GetDefaultLibraryExt: string; +begin + Result:='.so'; +end; + {$I ../unix/lazbaseconf.inc} diff --git a/ide/project.pp b/ide/project.pp index 0d728204bb..b367844b59 100644 --- a/ide/project.pp +++ b/ide/project.pp @@ -4258,6 +4258,7 @@ begin MainFile.IsPartOfProject:=true; AProject.AddFile(MainFile,false); AProject.MainFileID:=0; + AProject.LazCompilerOptions.ExecutableType:=cetLibrary; // create program source le:=LineEnding; diff --git a/ideintf/projectintf.pas b/ideintf/projectintf.pas index cfa10af8ad..ecfd7f9875 100644 --- a/ideintf/projectintf.pas +++ b/ideintf/projectintf.pas @@ -46,7 +46,12 @@ type cgcFasterCode, cgcSmallerCode ); - + + TCompilationExecutableType = ( + cetProgram, + cetLibrary + ); + { TLazCompilerOptions } TLazCompilerOptions = class(TPersistent) @@ -113,6 +118,7 @@ type fPassLinkerOpt: Boolean; fLinkerOptions: String; FWin32GraphicApp: boolean; + FExecutableType: TCompilationExecutableType; // Messages: fShowErrors: Boolean; @@ -221,6 +227,8 @@ type property PassLinkerOptions: Boolean read fPassLinkerOpt write fPassLinkerOpt; property LinkerOptions: String read fLinkerOptions write SetLinkerOptions; property Win32GraphicApp: boolean read FWin32GraphicApp write FWin32GraphicApp; + property ExecutableType: TCompilationExecutableType + read FExecutableType write FExecutableType; // messages: property ShowErrors: Boolean read fShowErrors write fShowErrors; @@ -602,9 +610,16 @@ const 'None' ); + CompilationExecutableTypeNames: array[TCompilationExecutableType] of string =( + 'Program', + 'Library' + ); + + function ProjectFlagsToStr(Flags: TProjectFlags): string; function StrToProjectSessionStorage(const s: string): TProjectSessionStorage; - +function CompilationExecutableTypeNameToType(const s: string + ): TCompilationExecutableType; procedure RegisterProjectFileDescriptor(FileDesc: TProjectFileDescriptor); procedure RegisterProjectDescriptor(ProjDesc: TProjectDescriptor); @@ -710,6 +725,14 @@ begin Result:=pssInProjectInfo; end; +function CompilationExecutableTypeNameToType(const s: string + ): TCompilationExecutableType; +begin + for Result:=Low(TCompilationExecutableType) to High(TCompilationExecutableType) + do if CompareText(s,CompilationExecutableTypeNames[Result])=0 then exit; + Result:=cetProgram; +end; + { TProjectFileDescriptor } procedure TProjectFileDescriptor.SetResourceClass(