IDE: added macros for namespaces

git-svn-id: trunk@54758 -
This commit is contained in:
mattias 2017-04-27 14:34:53 +00:00
parent e87f70b765
commit 871ae7e6b9
5 changed files with 155 additions and 17 deletions

View File

@ -278,6 +278,7 @@ type
function GetIncludePaths: String; virtual; abstract; function GetIncludePaths: String; virtual; abstract;
function GetLibraryPaths: String; virtual; abstract; function GetLibraryPaths: String; virtual; abstract;
function GetModified: boolean; virtual; function GetModified: boolean; virtual;
function GetNamespaces: String; virtual; abstract;
function GetObjectPath: string; virtual; abstract; function GetObjectPath: string; virtual; abstract;
function GetSrcPath: string; virtual; abstract; function GetSrcPath: string; virtual; abstract;
function GetUnitOutputDir: string; virtual; abstract; function GetUnitOutputDir: string; virtual; abstract;
@ -290,6 +291,7 @@ type
procedure SetLibraryPaths(const AValue: String); virtual; abstract; procedure SetLibraryPaths(const AValue: String); virtual; abstract;
procedure SetLinkerOptions(const AValue: String); virtual; abstract; procedure SetLinkerOptions(const AValue: String); virtual; abstract;
procedure SetModified(const AValue: boolean); virtual; abstract; procedure SetModified(const AValue: boolean); virtual; abstract;
procedure SetNamespaces(const AValue: String); virtual; abstract;
procedure SetObjectPath(const AValue: string); virtual; abstract; procedure SetObjectPath(const AValue: string); virtual; abstract;
procedure SetSrcPath(const AValue: string); virtual; abstract; procedure SetSrcPath(const AValue: string); virtual; abstract;
procedure SetTargetCPU(const AValue: string); virtual; abstract; procedure SetTargetCPU(const AValue: string); virtual; abstract;
@ -321,6 +323,7 @@ type
function GetUnitPath(RelativeToBaseDir: boolean; function GetUnitPath(RelativeToBaseDir: boolean;
Parsed: TCompilerOptionsParseType = coptParsed; Parsed: TCompilerOptionsParseType = coptParsed;
WithBaseDir: boolean = true): string; virtual; abstract; WithBaseDir: boolean = true): string; virtual; abstract;
function GetNamespacesParsed(Parsed: TCompilerOptionsParseType = coptParsed): string; virtual; abstract;
function GetIncludePath(RelativeToBaseDir: boolean; function GetIncludePath(RelativeToBaseDir: boolean;
Parsed: TCompilerOptionsParseType = coptParsed; Parsed: TCompilerOptionsParseType = coptParsed;
WithBaseDir: boolean = true): string; virtual; abstract; WithBaseDir: boolean = true): string; virtual; abstract;
@ -341,6 +344,7 @@ type
property IncludePath: String read GetIncludePaths write SetIncludePaths; // alias IncPath property IncludePath: String read GetIncludePaths write SetIncludePaths; // alias IncPath
property Libraries: String read GetLibraryPaths write SetLibraryPaths; // alias LibraryPath property Libraries: String read GetLibraryPaths write SetLibraryPaths; // alias LibraryPath
property OtherUnitFiles: String read GetUnitPaths write SetUnitPaths; // alias UnitPath property OtherUnitFiles: String read GetUnitPaths write SetUnitPaths; // alias UnitPath
property Namespaces: String read GetNamespaces write SetNamespaces;
property ObjectPath: string read GetObjectPath write SetObjectPath; property ObjectPath: string read GetObjectPath write SetObjectPath;
property SrcPath: string read GetSrcPath write SetSrcPath; // alias SrcPath property SrcPath: string read GetSrcPath write SetSrcPath; // alias SrcPath
property DebugPath: string read GetDebugPath write SetDebugPath; property DebugPath: string read GetDebugPath write SetDebugPath;

View File

@ -116,6 +116,8 @@ type
var {%H-}Abort: boolean): string; var {%H-}Abort: boolean): string;
function MacroFuncProjIncPath(const {%H-}Param: string; const {%H-}Data: PtrInt; function MacroFuncProjIncPath(const {%H-}Param: string; const {%H-}Data: PtrInt;
var {%H-}Abort: boolean): string; var {%H-}Abort: boolean): string;
function MacroFuncProjNamespaces(const {%H-}Param: string; const {%H-}Data: PtrInt;
var {%H-}Abort: boolean): string;
function MacroFuncProjOutDir(const {%H-}Param: string; const {%H-}Data: PtrInt; function MacroFuncProjOutDir(const {%H-}Param: string; const {%H-}Data: PtrInt;
var {%H-}Abort: boolean): string; var {%H-}Abort: boolean): string;
function MacroFuncProjPath(const {%H-}Param: string; const {%H-}Data: PtrInt; function MacroFuncProjPath(const {%H-}Param: string; const {%H-}Data: PtrInt;
@ -147,6 +149,7 @@ type
function MacroFuncFallbackOutputRoot(const {%H-}Param: string; const {%H-}Data: PtrInt; function MacroFuncFallbackOutputRoot(const {%H-}Param: string; const {%H-}Data: PtrInt;
var {%H-}Abort: boolean): string; var {%H-}Abort: boolean): string;
function CTMacroFuncProjectNamespaces(Data: Pointer): boolean;
function CTMacroFuncProjectUnitPath(Data: Pointer): boolean; function CTMacroFuncProjectUnitPath(Data: Pointer): boolean;
function CTMacroFuncProjectIncPath(Data: Pointer): boolean; function CTMacroFuncProjectIncPath(Data: Pointer): boolean;
function CTMacroFuncProjectSrcPath(Data: Pointer): boolean; function CTMacroFuncProjectSrcPath(Data: Pointer): boolean;
@ -406,6 +409,8 @@ begin
lisLaunchingCmdLine,@MacroFuncRunCmdLine,[])); lisLaunchingCmdLine,@MacroFuncRunCmdLine,[]));
GlobalMacroList.Add(TTransferMacro.Create('ProjPublishDir','', GlobalMacroList.Add(TTransferMacro.Create('ProjPublishDir','',
lisPublishProjDir,@MacroFuncProjPublishDir,[])); lisPublishProjDir,@MacroFuncProjPublishDir,[]));
GlobalMacroList.Add(TTransferMacro.Create('ProjNamespaces','',
lisProjectNamespaces,@MacroFuncProjNamespaces,[]));
GlobalMacroList.Add(TTransferMacro.Create('ProjUnitPath','', GlobalMacroList.Add(TTransferMacro.Create('ProjUnitPath','',
lisProjectUnitPath,@MacroFuncProjUnitPath,[])); lisProjectUnitPath,@MacroFuncProjUnitPath,[]));
GlobalMacroList.Add(TTransferMacro.Create('ProjIncPath','', GlobalMacroList.Add(TTransferMacro.Create('ProjIncPath','',
@ -436,6 +441,8 @@ begin
lisLAZVer, @MacroFuncLazVer, [])); lisLAZVer, @MacroFuncLazVer, []));
// codetools macro functions // codetools macro functions
CodeToolBoss.DefineTree.MacroFunctions.AddExtended(
'PROJECTNAMESPACES',nil,@CTMacroFuncProjectNamespaces);
CodeToolBoss.DefineTree.MacroFunctions.AddExtended( CodeToolBoss.DefineTree.MacroFunctions.AddExtended(
'PROJECTUNITPATH',nil,@CTMacroFuncProjectUnitPath); 'PROJECTUNITPATH',nil,@CTMacroFuncProjectUnitPath);
CodeToolBoss.DefineTree.MacroFunctions.AddExtended( CodeToolBoss.DefineTree.MacroFunctions.AddExtended(
@ -474,6 +481,7 @@ begin
tr('TargetCmdLine',lisTargetFilenamePlusParams); tr('TargetCmdLine',lisTargetFilenamePlusParams);
tr('RunCmdLine',lisLaunchingCmdLine); tr('RunCmdLine',lisLaunchingCmdLine);
tr('ProjPublishDir',lisPublishProjDir); tr('ProjPublishDir',lisPublishProjDir);
tr('ProjNamespaces',lisProjectNamespaces);
tr('ProjUnitPath',lisProjectUnitPath); tr('ProjUnitPath',lisProjectUnitPath);
tr('ProjIncPath',lisProjectIncPath); tr('ProjIncPath',lisProjectIncPath);
tr('ProjSrcPath',lisProjectSrcPath); tr('ProjSrcPath',lisProjectSrcPath);
@ -1972,6 +1980,8 @@ begin
Result:=Project1.CompilerOptions.GetSrcPath(false) Result:=Project1.CompilerOptions.GetSrcPath(false)
else if SysUtils.CompareText(Param,'IncPath')=0 then else if SysUtils.CompareText(Param,'IncPath')=0 then
Result:=Project1.CompilerOptions.GetIncludePath(false) Result:=Project1.CompilerOptions.GetIncludePath(false)
else if SysUtils.CompareText(Param,'Namespaces')=0 then
Result:=Project1.CompilerOptions.GetNamespacesParsed
else if SysUtils.CompareText(Param,'UnitPath')=0 then else if SysUtils.CompareText(Param,'UnitPath')=0 then
Result:=Project1.CompilerOptions.GetUnitPath(false) Result:=Project1.CompilerOptions.GetUnitPath(false)
else if SysUtils.CompareText(Param,'InfoFile')=0 then else if SysUtils.CompareText(Param,'InfoFile')=0 then
@ -2209,6 +2219,15 @@ begin
Result:=''; Result:='';
end; end;
function TBuildManager.MacroFuncProjNamespaces(const Param: string;
const Data: PtrInt; var Abort: boolean): string;
begin
if Project1<>nil then
Result:=Project1.CompilerOptions.GetNamespacesParsed()
else
Result:='';
end;
function TBuildManager.MacroFuncProjSrcPath(const Param: string; function TBuildManager.MacroFuncProjSrcPath(const Param: string;
const Data: PtrInt; var Abort: boolean): string; const Data: PtrInt; var Abort: boolean): string;
begin begin
@ -2259,6 +2278,18 @@ begin
Result:=FindDefaultMakePath; Result:=FindDefaultMakePath;
end; end;
function TBuildManager.CTMacroFuncProjectNamespaces(Data: Pointer): boolean;
var
FuncData: PReadFunctionData;
begin
FuncData:=PReadFunctionData(Data);
Result:=false;
if Project1<>nil then begin
FuncData^.Result:=Project1.CompilerOptions.GetNamespacesParsed();
Result:=true;
end;
end;
function TBuildManager.CTMacroFuncProjectUnitPath(Data: Pointer): boolean; function TBuildManager.CTMacroFuncProjectUnitPath(Data: Pointer): boolean;
var var
FuncData: PReadFunctionData; FuncData: PReadFunctionData;

View File

@ -46,7 +46,7 @@ uses
// LCL // LCL
InterfaceBase, Forms, Controls, LCLProc, InterfaceBase, Forms, Controls, LCLProc,
// LazUtils // LazUtils
FileUtil, LazFileUtils, LazUTF8, Laz2_XMLCfg, Laz2_DOM, FileUtil, LazFileUtils, LazUTF8, Laz2_XMLCfg, Laz2_DOM, LazUtilities,
// CodeTools // CodeTools
FileProcs, DefineTemplates, CodeToolsCfgScript, CodeToolManager, FileProcs, DefineTemplates, CodeToolsCfgScript, CodeToolManager,
KeywordFuncLists, BasicCodeTools, KeywordFuncLists, BasicCodeTools,
@ -155,6 +155,7 @@ type
TInheritedCompilerOption = ( TInheritedCompilerOption = (
icoNone, icoNone,
icoUnitPath, icoUnitPath,
icoNamespaces,
icoIncludePath, icoIncludePath,
icoObjectPath, icoObjectPath,
icoLibraryPath, icoLibraryPath,
@ -177,6 +178,7 @@ type
pcosNone, pcosNone,
pcosBaseDir, // the base directory for the relative paths (only auto created packages can have macros in the BaseDir) pcosBaseDir, // the base directory for the relative paths (only auto created packages can have macros in the BaseDir)
pcosUnitPath, // search path for pascal units pcosUnitPath, // search path for pascal units
pcosNamespaces, // namespaces
pcosIncludePath, // search path for pascal include files pcosIncludePath, // search path for pascal include files
pcosObjectPath, // search path for .o files pcosObjectPath, // search path for .o files
pcosLibraryPath, // search path for libraries pcosLibraryPath, // search path for libraries
@ -204,6 +206,7 @@ const
'', '',
'', '',
'UnitPath', 'UnitPath',
'Namespaces',
'IncPath', 'IncPath',
'ObjectPath', 'ObjectPath',
'LibraryPath', 'LibraryPath',
@ -219,6 +222,7 @@ const
'', '',
'', '',
'UsageUnitPath', 'UsageUnitPath',
'UsageNamespaces',
'UsageIncPath', 'UsageIncPath',
'UsageObjectPath', 'UsageObjectPath',
'UsageLibraryPath', 'UsageLibraryPath',
@ -234,6 +238,7 @@ const
TParsedCompilerOptString = ( TParsedCompilerOptString = (
pcosNone, pcosNone,
pcosUnitPath, // icoUnitPath, pcosUnitPath, // icoUnitPath,
pcosNamespaces, // icoNamespaces,
pcosIncludePath, // icoIncludePath, pcosIncludePath, // icoIncludePath,
pcosObjectPath, // icoObjectPath, pcosObjectPath, // icoObjectPath,
pcosLibraryPath, // icoLibraryPath, pcosLibraryPath, // icoLibraryPath,
@ -443,6 +448,7 @@ type
function GetDebugPath: string; override; function GetDebugPath: string; override;
function GetIncludePaths: String; override; function GetIncludePaths: String; override;
function GetLibraryPaths: String; override; function GetLibraryPaths: String; override;
function GetNamespaces: String; override;
function GetObjectPath: string; override; function GetObjectPath: string; override;
function GetSrcPath: string; override; function GetSrcPath: string; override;
function GetUnitOutputDir: string; override; function GetUnitOutputDir: string; override;
@ -454,6 +460,7 @@ type
procedure SetIncludePaths(const AValue: String); override; procedure SetIncludePaths(const AValue: String); override;
procedure SetLibraryPaths(const AValue: String); override; procedure SetLibraryPaths(const AValue: String); override;
procedure SetLinkerOptions(const AValue: String); override; procedure SetLinkerOptions(const AValue: String); override;
procedure SetNamespaces(const AValue: String); override;
procedure SetUnitPaths(const AValue: String); override; procedure SetUnitPaths(const AValue: String); override;
procedure SetUnitOutputDir(const AValue: string); override; procedure SetUnitOutputDir(const AValue: string); override;
procedure SetObjectPath(const AValue: string); override; procedure SetObjectPath(const AValue: string); override;
@ -514,6 +521,7 @@ type
function GetUnitPath(RelativeToBaseDir: boolean; function GetUnitPath(RelativeToBaseDir: boolean;
Parsed: TCompilerOptionsParseType = coptParsed; Parsed: TCompilerOptionsParseType = coptParsed;
WithBaseDir: boolean = true): string; override; WithBaseDir: boolean = true): string; override;
function GetNamespacesParsed(Parsed: TCompilerOptionsParseType = coptParsed): string; override;
function GetIncludePath(RelativeToBaseDir: boolean; function GetIncludePath(RelativeToBaseDir: boolean;
Parsed: TCompilerOptionsParseType = coptParsed; Parsed: TCompilerOptionsParseType = coptParsed;
WithBaseDir: boolean = true): string; override; WithBaseDir: boolean = true): string; override;
@ -557,6 +565,7 @@ type
ChangeConditionals: boolean); virtual; ChangeConditionals: boolean); virtual;
procedure MergeToIncludePaths(const AddSearchPath: string); procedure MergeToIncludePaths(const AddSearchPath: string);
procedure MergeToLibraryPaths(const AddSearchPath: string); procedure MergeToLibraryPaths(const AddSearchPath: string);
procedure MergeToNamespaces(const AddNamespaces: string);
procedure MergeToUnitPaths(const AddSearchPath: string); procedure MergeToUnitPaths(const AddSearchPath: string);
procedure MergeToObjectPath(const AddSearchPath: string); procedure MergeToObjectPath(const AddSearchPath: string);
procedure MergeToSrcPath(const AddSearchPath: string); procedure MergeToSrcPath(const AddSearchPath: string);
@ -600,6 +609,7 @@ type
function GetIncludePath: string; virtual; function GetIncludePath: string; virtual;
function GetLibraryPath: string; virtual; function GetLibraryPath: string; virtual;
function GetLinkerOptions: string; virtual; function GetLinkerOptions: string; virtual;
function GetNamespaces: string; virtual;
function GetObjectPath: string; virtual; function GetObjectPath: string; virtual;
function GetSrcPath: string; virtual; function GetSrcPath: string; virtual;
function GetUnitPath: string; virtual; function GetUnitPath: string; virtual;
@ -608,6 +618,7 @@ type
procedure SetIncludePath(const AValue: string); virtual; procedure SetIncludePath(const AValue: string); virtual;
procedure SetLibraryPath(const AValue: string); virtual; procedure SetLibraryPath(const AValue: string); virtual;
procedure SetLinkerOptions(const AValue: string); virtual; procedure SetLinkerOptions(const AValue: string); virtual;
procedure SetNamespaces(const AValue: string); virtual;
procedure SetObjectPath(const AValue: string); virtual; procedure SetObjectPath(const AValue: string); virtual;
procedure SetSrcPath(const AValue: string); virtual; procedure SetSrcPath(const AValue: string); virtual;
procedure SetUnitPath(const AValue: string); virtual; procedure SetUnitPath(const AValue: string); virtual;
@ -626,6 +637,7 @@ type
public public
property Owner: TObject read fOwner; property Owner: TObject read fOwner;
property UnitPath: string read GetUnitPath write SetUnitPath; property UnitPath: string read GetUnitPath write SetUnitPath;
property Namespaces: string read GetNamespaces write SetNamespaces;
property IncludePath: string read GetIncludePath write SetIncludePath; property IncludePath: string read GetIncludePath write SetIncludePath;
property SrcPath: string read GetSrcPath write SetSrcPath; property SrcPath: string read GetSrcPath write SetSrcPath;
property ObjectPath: string read GetObjectPath write SetObjectPath; property ObjectPath: string read GetObjectPath write SetObjectPath;
@ -753,6 +765,10 @@ begin
InheritedOptionStrings[icoUnitPath]:= InheritedOptionStrings[icoUnitPath]:=
MergeSearchPaths(InheritedOptionStrings[icoUnitPath], MergeSearchPaths(InheritedOptionStrings[icoUnitPath],
AddOptions.ParsedOpts.GetParsedValue(pcosUnitPath)); AddOptions.ParsedOpts.GetParsedValue(pcosUnitPath));
// namespaces
InheritedOptionStrings[icoNamespaces]:=
MergeSearchPaths(InheritedOptionStrings[icoNamespaces],
AddOptions.ParsedOpts.GetParsedValue(pcosNamespaces));
// include search path // include search path
InheritedOptionStrings[icoIncludePath]:= InheritedOptionStrings[icoIncludePath]:=
MergeSearchPaths(InheritedOptionStrings[icoIncludePath], MergeSearchPaths(InheritedOptionStrings[icoIncludePath],
@ -785,6 +801,10 @@ begin
InheritedOptionStrings[icoUnitPath]:= InheritedOptionStrings[icoUnitPath]:=
MergeSearchPaths(InheritedOptionStrings[icoUnitPath], MergeSearchPaths(InheritedOptionStrings[icoUnitPath],
AddOptions.ParsedOpts.GetParsedPIValue(pcosUnitPath)); AddOptions.ParsedOpts.GetParsedPIValue(pcosUnitPath));
// namespaces
InheritedOptionStrings[icoNamespaces]:=
MergeSearchPaths(InheritedOptionStrings[icoNamespaces],
AddOptions.ParsedOpts.GetParsedPIValue(pcosNamespaces));
// include search path // include search path
InheritedOptionStrings[icoIncludePath]:= InheritedOptionStrings[icoIncludePath]:=
MergeSearchPaths(InheritedOptionStrings[icoIncludePath], MergeSearchPaths(InheritedOptionStrings[icoIncludePath],
@ -820,18 +840,11 @@ begin
CurOptions:=InheritedOptionStrings[o]; CurOptions:=InheritedOptionStrings[o];
case o of case o of
icoNone: ; icoNone: ;
icoUnitPath,icoIncludePath,icoSrcPath,icoObjectPath,icoLibraryPath: icoUnitPath,icoNamespaces,icoIncludePath,icoSrcPath,icoObjectPath,
begin icoLibraryPath:
if CurOptions<>'' then CurOptions:=MergeWithDelimiter(CurOptions,UnparsedOption,';');
UnparsedOption:=';'+UnparsedOption;
CurOptions:=CurOptions+UnparsedOption;
end;
icoLinkerOptions,icoCustomOptions: icoLinkerOptions,icoCustomOptions:
begin CurOptions:=MergeWithDelimiter(CurOptions,UnparsedOption,' ');
if CurOptions<>'' then
UnparsedOption:=' '+UnparsedOption;
CurOptions:=CurOptions+UnparsedOption;
end;
else else
RaiseException('GatherInheritedOptions'); RaiseException('GatherInheritedOptions');
end; end;
@ -852,7 +865,7 @@ var
CurLibraryPath: String; CurLibraryPath: String;
CurObjectPath: String; CurObjectPath: String;
CurUnitPath: String; CurUnitPath: String;
CurCustomOptions: String; CurCustomOptions, CurNamespaces: String;
begin begin
Result:=''; Result:='';
@ -875,6 +888,11 @@ begin
Result := Result + ' ' + ConvertSearchPathToCmdLine('-Fl', CurLibraryPath); Result := Result + ' ' + ConvertSearchPathToCmdLine('-Fl', CurLibraryPath);
end; end;
// library path
CurNamespaces:=InheritedOptionStrings[icoNamespaces];
if CurNamespaces <> '' then
Result := Result + ' -NS'+CurNamespaces;
// object path // object path
CurObjectPath:=InheritedOptionStrings[icoObjectPath]; CurObjectPath:=InheritedOptionStrings[icoObjectPath];
if (CurObjectPath <> '') then if (CurObjectPath <> '') then
@ -1340,6 +1358,11 @@ begin
Result:=ParsedOpts.Values[pcosLibraryPath].UnparsedValue; Result:=ParsedOpts.Values[pcosLibraryPath].UnparsedValue;
end; end;
function TBaseCompilerOptions.GetNamespaces: String;
begin
Result:=ParsedOpts.Values[pcosNamespaces].UnparsedValue;
end;
function TBaseCompilerOptions.GetObjectPath: string; function TBaseCompilerOptions.GetObjectPath: string;
begin begin
Result:=ParsedOpts.Values[pcosObjectPath].UnparsedValue; Result:=ParsedOpts.Values[pcosObjectPath].UnparsedValue;
@ -1408,6 +1431,16 @@ begin
IncreaseChangeStamp; IncreaseChangeStamp;
end; end;
procedure TBaseCompilerOptions.SetNamespaces(const AValue: String);
begin
if Namespaces=AValue then exit;
ParsedOpts.SetUnparsedValue(pcosNamespaces,AValue);
{$IFDEF VerboseIDEModified}
debugln(['TBaseCompilerOptions.SetNamespaces ',AValue]);
{$ENDIF}
IncreaseChangeStamp;
end;
procedure TBaseCompilerOptions.SetUnitPaths(const AValue: String); procedure TBaseCompilerOptions.SetUnitPaths(const AValue: String);
var var
NewValue: String; NewValue: String;
@ -2190,6 +2223,30 @@ begin
Result:=GetPath(pcosUnitPath,icoUnitPath,RelativeToBaseDir,Parsed,WithBaseDir); Result:=GetPath(pcosUnitPath,icoUnitPath,RelativeToBaseDir,Parsed,WithBaseDir);
end; end;
function TBaseCompilerOptions.GetNamespacesParsed(Parsed: TCompilerOptionsParseType
): string;
var
CurNamespaces, InhNamespaces: String;
begin
// this namespaces
case Parsed of
coptParsed: CurNamespaces:=ParsedOpts.GetParsedValue(pcosNamespaces);
coptUnparsed: CurNamespaces:=ParsedOpts.Values[pcosNamespaces].UnparsedValue;
coptParsedPlatformIndependent:
CurNamespaces:=ParsedOpts.GetParsedPIValue(pcosNamespaces);
else
RaiseGDBException('');
end;
// inherited namespaces
InhNamespaces:=GetInheritedOption(icoNamespaces,false,Parsed);
// concatenate
Result:=MergeWithDelimiter(CurNamespaces,InhNamespaces,';');
// eliminate line breaks
Result:=SpecialCharsToSpaces(Result,true);
end;
function TBaseCompilerOptions.GetIncludePath(RelativeToBaseDir: boolean; function TBaseCompilerOptions.GetIncludePath(RelativeToBaseDir: boolean;
Parsed: TCompilerOptionsParseType; WithBaseDir: boolean): string; Parsed: TCompilerOptionsParseType; WithBaseDir: boolean): string;
begin begin
@ -2467,6 +2524,11 @@ begin
SetLibraryPaths(MergeSearchPaths(GetLibraryPaths,AddSearchPath)); SetLibraryPaths(MergeSearchPaths(GetLibraryPaths,AddSearchPath));
end; end;
procedure TBaseCompilerOptions.MergeToNamespaces(const AddNamespaces: string);
begin
SetNamespaces(MergeWithDelimiter(GetNamespacesParsed,AddNamespaces,';'));
end;
procedure TBaseCompilerOptions.MergeToUnitPaths(const AddSearchPath: string); procedure TBaseCompilerOptions.MergeToUnitPaths(const AddSearchPath: string);
begin begin
SetUnitPaths(MergeSearchPaths(GetUnitPaths,AddSearchPath)); SetUnitPaths(MergeSearchPaths(GetUnitPaths,AddSearchPath));
@ -2534,7 +2596,7 @@ var
DefaultTargetOS: string; DefaultTargetOS: string;
DefaultTargetCPU: string; DefaultTargetCPU: string;
FPCompilerFilename: String; FPCompilerFilename: String;
s: string; s, CurNamespaces: string;
CurFPCMsgFile: TFPCMsgFilePoolItem; CurFPCMsgFile: TFPCMsgFilePoolItem;
Quiet: Boolean; Quiet: Boolean;
@ -3089,6 +3151,11 @@ begin
switches := switches + ' ' + ConvertSearchPathToCmdLine('-Fl', CurLibraryPath); switches := switches + ' ' + ConvertSearchPathToCmdLine('-Fl', CurLibraryPath);
end; end;
// namespaces
CurNamespaces:=GetNamespacesParsed(coptParsed);
if CurNamespaces<>'' then
switches := switches +' -NS'+CurNamespaces;
// object path // object path
CurObjectPath:=GetObjectPath(not (ccloAbsolutePaths in Flags), CurObjectPath:=GetObjectPath(not (ccloAbsolutePaths in Flags),
coptParsed,false); coptParsed,false);
@ -3487,6 +3554,7 @@ begin
if Tool<>nil then Tool.Path:='Paths'; if Tool<>nil then Tool.Path:='Paths';
if Done(Tool.AddPathsDiff('IncludePaths',IncludePath,CompOpts.IncludePath)) then exit; if Done(Tool.AddPathsDiff('IncludePaths',IncludePath,CompOpts.IncludePath)) then exit;
if Done(Tool.AddPathsDiff('LibraryPaths',Libraries,CompOpts.Libraries)) then exit; if Done(Tool.AddPathsDiff('LibraryPaths',Libraries,CompOpts.Libraries)) then exit;
if Done(Tool.AddPathsDiff('Namespaces',Namespaces,CompOpts.Namespaces)) then exit;
if Done(Tool.AddPathsDiff('UnitPaths',OtherUnitFiles,CompOpts.OtherUnitFiles)) then exit; if Done(Tool.AddPathsDiff('UnitPaths',OtherUnitFiles,CompOpts.OtherUnitFiles)) then exit;
if Done(Tool.AddPathsDiff('UnitOutputDir',UnitOutputDirectory,CompOpts.UnitOutputDirectory)) then exit; if Done(Tool.AddPathsDiff('UnitOutputDir',UnitOutputDirectory,CompOpts.UnitOutputDirectory)) then exit;
if Done(Tool.AddPathsDiff('ObjectPath',ObjectPath,CompOpts.ObjectPath)) then exit; if Done(Tool.AddPathsDiff('ObjectPath',ObjectPath,CompOpts.ObjectPath)) then exit;
@ -3643,6 +3711,11 @@ begin
Result:=FParsedOpts.Values[pcosLinkerOptions].UnparsedValue; Result:=FParsedOpts.Values[pcosLinkerOptions].UnparsedValue;
end; end;
function TAdditionalCompilerOptions.GetNamespaces: string;
begin
Result:=FParsedOpts.Values[pcosNamespaces].UnparsedValue;
end;
function TAdditionalCompilerOptions.GetObjectPath: string; function TAdditionalCompilerOptions.GetObjectPath: string;
begin begin
Result:=FParsedOpts.Values[pcosObjectPath].UnparsedValue; Result:=FParsedOpts.Values[pcosObjectPath].UnparsedValue;
@ -3673,6 +3746,11 @@ begin
ParsedOpts.SetUnparsedValue(pcosLinkerOptions,AValue); ParsedOpts.SetUnparsedValue(pcosLinkerOptions,AValue);
end; end;
procedure TAdditionalCompilerOptions.SetNamespaces(const AValue: string);
begin
ParsedOpts.SetUnparsedValue(pcosNamespaces,AValue);
end;
procedure TAdditionalCompilerOptions.SetObjectPath(const AValue: string); procedure TAdditionalCompilerOptions.SetObjectPath(const AValue: string);
begin begin
ParsedOpts.SetUnparsedValue(pcosObjectPath,AValue); ParsedOpts.SetUnparsedValue(pcosObjectPath,AValue);
@ -3699,6 +3777,7 @@ end;
procedure TAdditionalCompilerOptions.Clear; procedure TAdditionalCompilerOptions.Clear;
begin begin
UnitPath:=''; UnitPath:='';
Namespaces:='';
SrcPath:=''; SrcPath:='';
IncludePath:=''; IncludePath:='';
CustomOptions:=''; CustomOptions:='';
@ -3715,6 +3794,7 @@ begin
raise Exception.Create('TAdditionalCompilerOptions.AssignOptions: Can not copy from '+DbgSName(Source)); raise Exception.Create('TAdditionalCompilerOptions.AssignOptions: Can not copy from '+DbgSName(Source));
Src:=TAdditionalCompilerOptions(Source); Src:=TAdditionalCompilerOptions(Source);
UnitPath:=Src.UnitPath; UnitPath:=Src.UnitPath;
Namespaces:=Src.Namespaces;
IncludePath:=Src.IncludePath; IncludePath:=Src.IncludePath;
SrcPath:=Src.SrcPath; SrcPath:=Src.SrcPath;
ObjectPath:=Src.ObjectPath; ObjectPath:=Src.ObjectPath;
@ -3738,6 +3818,7 @@ begin
IncludePath:=f(XMLConfig.GetValue(Path+'IncludePath/Value','')); IncludePath:=f(XMLConfig.GetValue(Path+'IncludePath/Value',''));
LibraryPath:=f(XMLConfig.GetValue(Path+'LibraryPath/Value','')); LibraryPath:=f(XMLConfig.GetValue(Path+'LibraryPath/Value',''));
LinkerOptions:=f(XMLConfig.GetValue(Path+'LinkerOptions/Value','')); LinkerOptions:=f(XMLConfig.GetValue(Path+'LinkerOptions/Value',''));
Namespaces:=f(XMLConfig.GetValue(Path+'Namespaces/Value',''));
ObjectPath:=f(XMLConfig.GetValue(Path+'ObjectPath/Value','')); ObjectPath:=f(XMLConfig.GetValue(Path+'ObjectPath/Value',''));
UnitPath:=f(XMLConfig.GetValue(Path+'UnitPath/Value','')); UnitPath:=f(XMLConfig.GetValue(Path+'UnitPath/Value',''));
SrcPath:=f(XMLConfig.GetValue(Path+'SrcPath/Value','')); SrcPath:=f(XMLConfig.GetValue(Path+'SrcPath/Value',''));
@ -3756,6 +3837,7 @@ begin
XMLConfig.SetDeleteValue(Path+'IncludePath/Value',f(IncludePath),''); XMLConfig.SetDeleteValue(Path+'IncludePath/Value',f(IncludePath),'');
XMLConfig.SetDeleteValue(Path+'LibraryPath/Value',f(LibraryPath),''); XMLConfig.SetDeleteValue(Path+'LibraryPath/Value',f(LibraryPath),'');
XMLConfig.SetDeleteValue(Path+'LinkerOptions/Value',f(LinkerOptions),''); XMLConfig.SetDeleteValue(Path+'LinkerOptions/Value',f(LinkerOptions),'');
XMLConfig.SetDeleteValue(Path+'Namespaces/Value',Namespaces,'');
XMLConfig.SetDeleteValue(Path+'ObjectPath/Value',f(ObjectPath),''); XMLConfig.SetDeleteValue(Path+'ObjectPath/Value',f(ObjectPath),'');
XMLConfig.SetDeleteValue(Path+'UnitPath/Value',f(UnitPath),''); XMLConfig.SetDeleteValue(Path+'UnitPath/Value',f(UnitPath),'');
XMLConfig.SetDeleteValue(Path+'SrcPath/Value',f(SrcPath),''); XMLConfig.SetDeleteValue(Path+'SrcPath/Value',f(SrcPath),'');
@ -3775,6 +3857,7 @@ begin
case AnOption of case AnOption of
icoNone: Result:=''; icoNone: Result:='';
icoUnitPath: Result:=UnitPath; icoUnitPath: Result:=UnitPath;
icoNamespaces: Result:=Namespaces;
icoIncludePath: Result:=IncludePath; icoIncludePath: Result:=IncludePath;
icoObjectPath: Result:=ObjectPath; icoObjectPath: Result:=ObjectPath;
icoLibraryPath: Result:=LibraryPath; icoLibraryPath: Result:=LibraryPath;
@ -3864,6 +3947,8 @@ begin
Result:=MergeSearchPaths(Result,GetForcedPathDelims(Vars[VarName])); Result:=MergeSearchPaths(Result,GetForcedPathDelims(Vars[VarName]));
pcosLinkerOptions: pcosLinkerOptions:
Result:=MergeLinkerOptions(Result,Vars[VarName]); Result:=MergeLinkerOptions(Result,Vars[VarName]);
pcosNamespaces:
Result:=MergeWithDelimiter(Result,Vars[VarName],';');
pcosCustomOptions: pcosCustomOptions:
begin begin
Result:=MergeCustomOptions(Result,Vars[VarName]); Result:=MergeCustomOptions(Result,Vars[VarName]);

View File

@ -234,6 +234,7 @@ resourcestring
lisLaunchingCmdLine = 'Launching target command line'; lisLaunchingCmdLine = 'Launching target command line';
lisPublishProjDir = 'Publish project directory'; lisPublishProjDir = 'Publish project directory';
lisProjectUnitPath = 'Project Unit Path'; lisProjectUnitPath = 'Project Unit Path';
lisProjectNamespaces = 'Project Namespaces';
lisProjectIncPath = 'Project Include Path'; lisProjectIncPath = 'Project Include Path';
lisProjectSrcPath = 'Project Src Path'; lisProjectSrcPath = 'Project Src Path';
lisProjectOutDir = 'Project Output directory (e.g. the ppu directory)'; lisProjectOutDir = 'Project Output directory (e.g. the ppu directory)';
@ -4393,6 +4394,7 @@ resourcestring
// package defs // package defs
lisPkgDefsOutputDirectory = 'Output directory'; lisPkgDefsOutputDirectory = 'Output directory';
lisPkgDefsCompiledSrcPathAddition = 'CompiledSrcPath addition'; lisPkgDefsCompiledSrcPathAddition = 'CompiledSrcPath addition';
lisPkgDefsNamespaces = 'Namespaces';
lisPkgDefsUnitPath = 'Unit Path'; lisPkgDefsUnitPath = 'Unit Path';
lisProjProjectSourceDirectoryMark = 'Project Source Directory Mark'; lisProjProjectSourceDirectoryMark = 'Project Source Directory Mark';
lisPkgDefsSrcDirMark = 'Package Source Directory Mark'; lisPkgDefsSrcDirMark = 'Package Source Directory Mark';

View File

@ -521,6 +521,7 @@ type
procedure SetIncludePaths(const AValue: string); override; procedure SetIncludePaths(const AValue: string); override;
procedure SetLibraryPaths(const AValue: string); override; procedure SetLibraryPaths(const AValue: string); override;
procedure SetLinkerOptions(const AValue: string); override; procedure SetLinkerOptions(const AValue: string); override;
procedure SetNamespaces(const AValue: string); override;
procedure SetObjectPath(const AValue: string); override; procedure SetObjectPath(const AValue: string); override;
procedure SetSrcPath(const AValue: string); override; procedure SetSrcPath(const AValue: string); override;
procedure SetUnitPaths(const AValue: string); override; procedure SetUnitPaths(const AValue: string); override;
@ -4411,6 +4412,7 @@ procedure TProject.GetVirtualDefines(DefTree: TDefineTree; DirDef: TDirectoryDef
begin begin
if (not IsVirtual) then exit; if (not IsVirtual) then exit;
ExtendPath(NamespacesMacroName,CompilerOptions.Namespaces);
ExtendPath(UnitPathMacroName,CompilerOptions.OtherUnitFiles); ExtendPath(UnitPathMacroName,CompilerOptions.OtherUnitFiles);
ExtendPath(IncludePathMacroName,CompilerOptions.IncludePath); ExtendPath(IncludePathMacroName,CompilerOptions.IncludePath);
ExtendPath(SrcPathMacroName,CompilerOptions.SrcPath); ExtendPath(SrcPathMacroName,CompilerOptions.SrcPath);
@ -6108,6 +6110,13 @@ begin
inherited SetLinkerOptions(AValue); inherited SetLinkerOptions(AValue);
end; end;
procedure TProjectCompilerOptions.SetNamespaces(const AValue: string);
begin
if Namespaces=AValue then exit;
InvalidateOptions;
inherited SetNamespaces(AValue);
end;
procedure TProjectCompilerOptions.SetObjectPath(const AValue: string); procedure TProjectCompilerOptions.SetObjectPath(const AValue: string);
begin begin
if ObjectPath=AValue then exit; if ObjectPath=AValue then exit;
@ -6327,6 +6336,7 @@ end;
procedure TProjectDefineTemplates.UpdateSrcDirIfDef; procedure TProjectDefineTemplates.UpdateSrcDirIfDef;
var var
Changed: Boolean; Changed: Boolean;
NamespacesDefTempl: TDefineTemplate;
UnitPathDefTempl: TDefineTemplate; UnitPathDefTempl: TDefineTemplate;
IncPathDefTempl: TDefineTemplate; IncPathDefTempl: TDefineTemplate;
SrcPathDefTempl: TDefineTemplate; SrcPathDefTempl: TDefineTemplate;
@ -6355,21 +6365,27 @@ begin
da_If); da_If);
FMain.AddChild(FSrcDirIf); FMain.AddChild(FSrcDirIf);
// create namespaces template for this directory
NamespacesDefTempl:=TDefineTemplate.Create('Namespaces', lisPkgDefsNamespaces,
NamespacesMacroName,NamespacesMacro+';$ProjectNamespaces('+Owner.IDAsString+')',
da_Define);
FSrcDirIf.AddChild(NamespacesDefTempl);
// create unit path template for this directory // create unit path template for this directory
UnitPathDefTempl:=TDefineTemplate.Create('UnitPath', lisPkgDefsUnitPath, UnitPathDefTempl:=TDefineTemplate.Create('UnitPath', lisPkgDefsUnitPath,
'#UnitPath','$(#UnitPath);$ProjectUnitPath('+Owner.IDAsString+')', UnitPathMacroName,UnitPathMacro+';$ProjectUnitPath('+Owner.IDAsString+')',
da_Define); da_Define);
FSrcDirIf.AddChild(UnitPathDefTempl); FSrcDirIf.AddChild(UnitPathDefTempl);
// create include path template for this directory // create include path template for this directory
IncPathDefTempl:=TDefineTemplate.Create('IncPath','Include Path', IncPathDefTempl:=TDefineTemplate.Create('IncPath','Include Path',
'#IncPath','$(#IncPath);$ProjectIncPath('+Owner.IDAsString+')', IncludePathMacroName,IncludePathMacro+';$ProjectIncPath('+Owner.IDAsString+')',
da_Define); da_Define);
FSrcDirIf.AddChild(IncPathDefTempl); FSrcDirIf.AddChild(IncPathDefTempl);
// create src path template for this directory // create src path template for this directory
SrcPathDefTempl:=TDefineTemplate.Create('SrcPath','Src Path', SrcPathDefTempl:=TDefineTemplate.Create('SrcPath','Src Path',
'#SrcPath','$(#SrcPath);$ProjectSrcPath('+Owner.IDAsString+')', SrcPathMacroName,SrcPathMacro+';$ProjectSrcPath('+Owner.IDAsString+')',
da_Define); da_Define);
FSrcDirIf.AddChild(SrcPathDefTempl); FSrcDirIf.AddChild(SrcPathDefTempl);