mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-04 18:40:29 +02:00
IDE: environment option FPCSourceDirectory can now contain macros
git-svn-id: trunk@16122 -
This commit is contained in:
parent
e61e9ba99e
commit
1752c2e410
@ -160,6 +160,11 @@ type
|
|||||||
end;
|
end;
|
||||||
PUnitFile = ^TUnitFile;
|
PUnitFile = ^TUnitFile;
|
||||||
|
|
||||||
|
procedure BMLazConfMacroFunction(var s: string);
|
||||||
|
begin
|
||||||
|
GlobalMacroList.SubstituteStr(s);
|
||||||
|
end;
|
||||||
|
|
||||||
function CompareUnitFiles(UnitFile1, UnitFile2: PUnitFile): integer;
|
function CompareUnitFiles(UnitFile1, UnitFile2: PUnitFile): integer;
|
||||||
begin
|
begin
|
||||||
Result:=CompareIdentifierPtrs(Pointer(UnitFile1^.UnitName),
|
Result:=CompareIdentifierPtrs(Pointer(UnitFile1^.UnitName),
|
||||||
@ -197,15 +202,17 @@ end;
|
|||||||
|
|
||||||
destructor TBuildManager.Destroy;
|
destructor TBuildManager.Destroy;
|
||||||
begin
|
begin
|
||||||
|
LazConfMacroFunc:=nil;
|
||||||
OnBackupFileInteractive:=nil;
|
OnBackupFileInteractive:=nil;
|
||||||
FreeAndNil(InputHistories);
|
FreeAndNil(InputHistories);
|
||||||
|
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
MainBuildBoss:=nil;
|
MainBuildBoss:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBuildManager.SetupTransferMacros;
|
procedure TBuildManager.SetupTransferMacros;
|
||||||
begin
|
begin
|
||||||
|
LazConfMacroFunc:=@BMLazConfMacroFunction;
|
||||||
GlobalMacroList:=TTransferMacroList.Create;
|
GlobalMacroList:=TTransferMacroList.Create;
|
||||||
IDEMacros:=TLazIDEMacros.Create;
|
IDEMacros:=TLazIDEMacros.Create;
|
||||||
CompilerOptions.OnParseString:=@OnSubstituteCompilerOption;
|
CompilerOptions.OnParseString:=@OnSubstituteCompilerOption;
|
||||||
@ -517,7 +524,7 @@ begin
|
|||||||
UnitLinksValid:=false;
|
UnitLinksValid:=false;
|
||||||
end
|
end
|
||||||
else if CompareFilenames(InputHistories.FPCConfigCache.Items[i].FPCSrcDir,
|
else if CompareFilenames(InputHistories.FPCConfigCache.Items[i].FPCSrcDir,
|
||||||
EnvironmentOptions.FPCSourceDirectory)<>0
|
EnvironmentOptions.GetFPCSourceDirectory)<>0
|
||||||
then
|
then
|
||||||
UnitLinksValid:=false;
|
UnitLinksValid:=false;
|
||||||
end;
|
end;
|
||||||
@ -557,7 +564,7 @@ begin
|
|||||||
// save unitlinks
|
// save unitlinks
|
||||||
InputHistories.SetLastFPCUnitLinks(EnvironmentOptions.CompilerFilename,
|
InputHistories.SetLastFPCUnitLinks(EnvironmentOptions.CompilerFilename,
|
||||||
CurOptions,CompilerUnitSearchPath,
|
CurOptions,CompilerUnitSearchPath,
|
||||||
EnvironmentOptions.FPCSourceDirectory,
|
EnvironmentOptions.GetFPCSourceDirectory,
|
||||||
CompilerUnitLinks);
|
CompilerUnitLinks);
|
||||||
InputHistories.Save;
|
InputHistories.Save;
|
||||||
end else begin
|
end else begin
|
||||||
|
@ -47,7 +47,7 @@ uses
|
|||||||
MacroIntf, PackageIntf, LazHelpIntf, ProjectIntf, IDEDialogs, LazIDEIntf,
|
MacroIntf, PackageIntf, LazHelpIntf, ProjectIntf, IDEDialogs, LazIDEIntf,
|
||||||
// IDE
|
// IDE
|
||||||
LazarusIDEStrConsts, CompilerOptions, IDEProcs, PackageDefs, EnvironmentOpts,
|
LazarusIDEStrConsts, CompilerOptions, IDEProcs, PackageDefs, EnvironmentOpts,
|
||||||
PackageSystem, DialogProcs;
|
TransferMacros, PackageSystem, DialogProcs;
|
||||||
|
|
||||||
type
|
type
|
||||||
TFPDocItem = (
|
TFPDocItem = (
|
||||||
|
@ -472,18 +472,12 @@ const LCLWidgetLinkerAddition: array[TLCLPlatform] of string = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
type
|
type
|
||||||
TCompilerParseStampIncreasedEvent = procedure of object;
|
|
||||||
TRunCompilerWithOptions = function(ExtTool: TIDEExternalToolOptions;
|
TRunCompilerWithOptions = function(ExtTool: TIDEExternalToolOptions;
|
||||||
ACompilerOptions: TBaseCompilerOptions): TModalResult of object;
|
ACompilerOptions: TBaseCompilerOptions): TModalResult of object;
|
||||||
|
|
||||||
var
|
var
|
||||||
CompilerParseStamp: integer; // TimeStamp of base value for macros
|
|
||||||
OnParseString: TParseStringEvent = nil;
|
OnParseString: TParseStringEvent = nil;
|
||||||
CompilerParseStampIncreased: TCompilerParseStampIncreasedEvent = nil;
|
|
||||||
|
|
||||||
RunCompilerWithOptions: TRunCompilerWithOptions = nil;
|
RunCompilerWithOptions: TRunCompilerWithOptions = nil;
|
||||||
|
|
||||||
procedure IncreaseCompilerParseStamp;
|
|
||||||
function ParseString(Options: TParsedCompilerOptions;
|
function ParseString(Options: TParsedCompilerOptions;
|
||||||
const UnparsedValue: string;
|
const UnparsedValue: string;
|
||||||
PlatformIndependent: boolean): string;
|
PlatformIndependent: boolean): string;
|
||||||
@ -512,19 +506,6 @@ implementation
|
|||||||
const
|
const
|
||||||
CompilerOptionsVersion = 5;
|
CompilerOptionsVersion = 5;
|
||||||
Config_Filename = 'compileroptions.xml';
|
Config_Filename = 'compileroptions.xml';
|
||||||
MaxParseStamp = $7fffffff;
|
|
||||||
MinParseStamp = -$7fffffff;
|
|
||||||
InvalidParseStamp = MinParseStamp-1;
|
|
||||||
|
|
||||||
procedure IncreaseCompilerParseStamp;
|
|
||||||
begin
|
|
||||||
if CompilerParseStamp<MaxParseStamp then
|
|
||||||
inc(CompilerParseStamp)
|
|
||||||
else
|
|
||||||
CompilerParseStamp:=MinParseStamp;
|
|
||||||
if Assigned(CompilerParseStampIncreased) then
|
|
||||||
CompilerParseStampIncreased();
|
|
||||||
end;
|
|
||||||
|
|
||||||
function ParseString(Options: TParsedCompilerOptions;
|
function ParseString(Options: TParsedCompilerOptions;
|
||||||
const UnparsedValue: string; PlatformIndependent: boolean): string;
|
const UnparsedValue: string; PlatformIndependent: boolean): string;
|
||||||
|
@ -41,9 +41,9 @@ uses
|
|||||||
ComCtrls, Buttons, StdCtrls, ExtCtrls,
|
ComCtrls, Buttons, StdCtrls, ExtCtrls,
|
||||||
Graphics, LResources, FileUtil, Dialogs, Controls, GraphType,
|
Graphics, LResources, FileUtil, Dialogs, Controls, GraphType,
|
||||||
MacroIntf, ProjectIntf, IDEWindowIntf, IDEContextHelpEdit,
|
MacroIntf, ProjectIntf, IDEWindowIntf, IDEContextHelpEdit,
|
||||||
PathEditorDlg, LazarusIDEStrConsts, IDEOptionDefs, LazConf, IDEProcs,
|
TransferMacros, PathEditorDlg, LazarusIDEStrConsts, IDEOptionDefs, LazConf,
|
||||||
IDEImagesIntf, ShowCompilerOpts, Project, PackageDefs, CompilerOptions,
|
IDEProcs, IDEImagesIntf, ShowCompilerOpts, Project, PackageDefs,
|
||||||
CheckCompilerOpts;
|
CompilerOptions, CheckCompilerOpts;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ Compiler options form }
|
{ Compiler options form }
|
||||||
|
@ -192,6 +192,9 @@ type
|
|||||||
FCompilerFilename: string;
|
FCompilerFilename: string;
|
||||||
FCompilerFileHistory: TStringList;
|
FCompilerFileHistory: TStringList;
|
||||||
FFPCSourceDirectory: string;
|
FFPCSourceDirectory: string;
|
||||||
|
FFPCSrcDirParsed: string;
|
||||||
|
FFPCSrcDirParsedValid: boolean;
|
||||||
|
FFPCSrcDirParsedStamp: integer;
|
||||||
FFPCSourceDirHistory: TStringList;
|
FFPCSourceDirHistory: TStringList;
|
||||||
FMakeFileName: string;
|
FMakeFileName: string;
|
||||||
FMakeFileHistory: TStringList;
|
FMakeFileHistory: TStringList;
|
||||||
@ -257,6 +260,7 @@ type
|
|||||||
procedure CreateWindowLayout(const TheFormID: string);
|
procedure CreateWindowLayout(const TheFormID: string);
|
||||||
function IsDebuggerClassDefined: boolean;
|
function IsDebuggerClassDefined: boolean;
|
||||||
function GetTestBuildDirectory: string;
|
function GetTestBuildDirectory: string;
|
||||||
|
function GetFPCSourceDirectory: string;
|
||||||
|
|
||||||
// macro functions
|
// macro functions
|
||||||
procedure InitMacros(AMacroList: TTransferMacroList);
|
procedure InitMacros(AMacroList: TTransferMacroList);
|
||||||
@ -1522,6 +1526,18 @@ begin
|
|||||||
Result:=AppendPathDelim(TestBuildDirectory);
|
Result:=AppendPathDelim(TestBuildDirectory);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TEnvironmentOptions.GetFPCSourceDirectory: string;
|
||||||
|
begin
|
||||||
|
if (not FFPCSrcDirParsedValid) or (FFPCSrcDirParsedStamp<>CompilerParseStamp)
|
||||||
|
then begin
|
||||||
|
FFPCSrcDirParsed:=FFPCSourceDirectory;
|
||||||
|
GlobalMacroList.SubstituteStr(FFPCSrcDirParsed);
|
||||||
|
FFPCSrcDirParsedStamp:=CompilerParseStamp;
|
||||||
|
FFPCSrcDirParsedValid:=true;
|
||||||
|
end;
|
||||||
|
Result:=FFPCSrcDirParsed;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TEnvironmentOptions.InitMacros(AMacroList: TTransferMacroList);
|
procedure TEnvironmentOptions.InitMacros(AMacroList: TTransferMacroList);
|
||||||
begin
|
begin
|
||||||
AMacroList.Add(TTransferMacro.Create('CompPath','',
|
AMacroList.Add(TTransferMacro.Create('CompPath','',
|
||||||
|
@ -24,7 +24,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const
|
const
|
||||||
DefaultFPCSrcDirs: array[1..14] of string = (
|
DefaultFPCSrcDirs: array[1..15] of string = (
|
||||||
|
// search first for sources with right version
|
||||||
|
'/usr/share/fpcsrc/$(FPCVer)',
|
||||||
|
// then search for global paths
|
||||||
'/usr/share/fpcsrc',
|
'/usr/share/fpcsrc',
|
||||||
'/usr/local/share/fpcsrc',
|
'/usr/local/share/fpcsrc',
|
||||||
'/usr/fpcsrc',
|
'/usr/fpcsrc',
|
||||||
@ -175,6 +178,12 @@ begin
|
|||||||
if Find('iexplore.exe',Browser) then exit;
|
if Find('iexplore.exe',Browser) then exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure LazConfSubstituteMacros(var s: string);
|
||||||
|
begin
|
||||||
|
if Assigned(LazConfMacroFunc) then
|
||||||
|
LazConfMacroFunc(s);
|
||||||
|
end;
|
||||||
|
|
||||||
{---------------------------------------------------------------------------
|
{---------------------------------------------------------------------------
|
||||||
procedure InternalInit;
|
procedure InternalInit;
|
||||||
---------------------------------------------------------------------------}
|
---------------------------------------------------------------------------}
|
||||||
|
@ -87,7 +87,7 @@ const
|
|||||||
function FindDefaultMakePath: string;
|
function FindDefaultMakePath: string;
|
||||||
function FindDefaultFPCSrcDirectory: string;
|
function FindDefaultFPCSrcDirectory: string;
|
||||||
function FindDefaultLazarusSrcDirectory: string;
|
function FindDefaultLazarusSrcDirectory: string;
|
||||||
function CheckFPCSourceDir(const ADirectory: string): boolean;
|
function CheckFPCSourceDir(ADirectory: string): boolean;
|
||||||
function CheckLazarusDirectory(const ADirectory: string): boolean;
|
function CheckLazarusDirectory(const ADirectory: string): boolean;
|
||||||
|
|
||||||
// create a pascal file, which can be used to test the compiler
|
// create a pascal file, which can be used to test the compiler
|
||||||
@ -119,6 +119,12 @@ const
|
|||||||
// returrns the default browser
|
// returrns the default browser
|
||||||
procedure GetDefaultBrowser(var Browser, Params: string);
|
procedure GetDefaultBrowser(var Browser, Params: string);
|
||||||
|
|
||||||
|
type
|
||||||
|
TLazConfMacroFunc = procedure(var s: string);
|
||||||
|
var
|
||||||
|
LazConfMacroFunc: TLazConfMacroFunc = nil;
|
||||||
|
procedure LazConfSubstituteMacros(var s: string);
|
||||||
|
|
||||||
const
|
const
|
||||||
EmptyLine = LineEnding + LineEnding;
|
EmptyLine = LineEnding + LineEnding;
|
||||||
EndOfLine: shortstring = LineEnding;
|
EndOfLine: shortstring = LineEnding;
|
||||||
@ -284,11 +290,12 @@ begin
|
|||||||
Result:=DefineTemplates.GetDefaultCompilerFilename;
|
Result:=DefineTemplates.GetDefaultCompilerFilename;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CheckFPCSourceDir(const ADirectory: string): boolean;
|
function CheckFPCSourceDir(ADirectory: string): boolean;
|
||||||
var
|
var
|
||||||
Dir: String;
|
Dir: String;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
|
LazConfSubstituteMacros(ADirectory);
|
||||||
if DirPathExists(ADirectory) then begin
|
if DirPathExists(ADirectory) then begin
|
||||||
Dir:=AppendPathDelim(ADirectory);
|
Dir:=AppendPathDelim(ADirectory);
|
||||||
// test on rtl/inc, to prevent a false positive on a fpc compiled units dir
|
// test on rtl/inc, to prevent a false positive on a fpc compiled units dir
|
||||||
|
10
ide/main.pp
10
ide/main.pp
@ -11729,7 +11729,7 @@ begin
|
|||||||
'NOTE: Lazarus Source Directory not set! (see Environment Options)');
|
'NOTE: Lazarus Source Directory not set! (see Environment Options)');
|
||||||
end;
|
end;
|
||||||
if (EnvironmentOptions.FPCSourceDirectory='')
|
if (EnvironmentOptions.FPCSourceDirectory='')
|
||||||
or not DirPathExists(EnvironmentOptions.FPCSourceDirectory) then begin
|
or not DirPathExists(EnvironmentOptions.GetFPCSourceDirectory) then begin
|
||||||
DebugLn('');
|
DebugLn('');
|
||||||
DebugLn('NOTE: FPC Source Directory not set! (see Environment Options)');
|
DebugLn('NOTE: FPC Source Directory not set! (see Environment Options)');
|
||||||
end;
|
end;
|
||||||
@ -11738,11 +11738,11 @@ begin
|
|||||||
with CodeToolBoss.GlobalValues do begin
|
with CodeToolBoss.GlobalValues do begin
|
||||||
Variables[ExternalMacroStart+'LazarusDir']:=
|
Variables[ExternalMacroStart+'LazarusDir']:=
|
||||||
EnvironmentOptions.LazarusDirectory;
|
EnvironmentOptions.LazarusDirectory;
|
||||||
Variables[ExternalMacroStart+'FPCSrcDir']:=
|
|
||||||
EnvironmentOptions.FPCSourceDirectory;
|
|
||||||
Variables[ExternalMacroStart+'ProjPath']:=VirtualDirectory;
|
Variables[ExternalMacroStart+'ProjPath']:=VirtualDirectory;
|
||||||
Variables[ExternalMacroStart+'LCLWidgetType']:=
|
Variables[ExternalMacroStart+'LCLWidgetType']:=
|
||||||
LCLPlatformDirNames[GetDefaultLCLWidgetType];
|
LCLPlatformDirNames[GetDefaultLCLWidgetType];
|
||||||
|
Variables[ExternalMacroStart+'FPCSrcDir']:=
|
||||||
|
EnvironmentOptions.GetFPCSourceDirectory;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// build DefinePool and Define Tree
|
// build DefinePool and Define Tree
|
||||||
@ -11768,7 +11768,7 @@ begin
|
|||||||
EnvironmentOptions.CompilerFilename;
|
EnvironmentOptions.CompilerFilename;
|
||||||
CompilerUnitLinks:=InputHistories.FPCConfigCache.GetUnitLinks('');
|
CompilerUnitLinks:=InputHistories.FPCConfigCache.GetUnitLinks('');
|
||||||
UnitLinksChanged:=InputHistories.LastFPCUnitLinksNeedsUpdate('',
|
UnitLinksChanged:=InputHistories.LastFPCUnitLinksNeedsUpdate('',
|
||||||
CompilerUnitSearchPath,EnvironmentOptions.FPCSourceDirectory);
|
CompilerUnitSearchPath,EnvironmentOptions.GetFPCSourceDirectory);
|
||||||
ADefTempl:=CreateFPCSrcTemplate(
|
ADefTempl:=CreateFPCSrcTemplate(
|
||||||
CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'FPCSrcDir'],
|
CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'FPCSrcDir'],
|
||||||
CompilerUnitSearchPath,
|
CompilerUnitSearchPath,
|
||||||
@ -11784,7 +11784,7 @@ begin
|
|||||||
InputHistories.SetLastFPCUnitLinks(EnvironmentOptions.CompilerFilename,
|
InputHistories.SetLastFPCUnitLinks(EnvironmentOptions.CompilerFilename,
|
||||||
'', // default options ''
|
'', // default options ''
|
||||||
CompilerUnitSearchPath,
|
CompilerUnitSearchPath,
|
||||||
EnvironmentOptions.FPCSourceDirectory,
|
EnvironmentOptions.GetFPCSourceDirectory,
|
||||||
CompilerUnitLinks);
|
CompilerUnitLinks);
|
||||||
InputHistories.Save;
|
InputHistories.Save;
|
||||||
end;
|
end;
|
||||||
|
@ -56,7 +56,7 @@ uses
|
|||||||
W32VersionInfo, W32Manifest,
|
W32VersionInfo, W32Manifest,
|
||||||
// IDE
|
// IDE
|
||||||
LazarusIDEStrConsts, CompilerOptions, CodeToolManager, CodeCache,
|
LazarusIDEStrConsts, CompilerOptions, CodeToolManager, CodeCache,
|
||||||
EditorOptions, IDEProcs, RunParamsOpts, ProjectDefs,
|
TransferMacros, EditorOptions, IDEProcs, RunParamsOpts, ProjectDefs,
|
||||||
FileReferenceList, EditDefineTree, DefineTemplates, PackageDefs
|
FileReferenceList, EditDefineTree, DefineTemplates, PackageDefs
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -120,11 +120,33 @@ type
|
|||||||
var
|
var
|
||||||
GlobalMacroList: TTransferMacroList = nil;
|
GlobalMacroList: TTransferMacroList = nil;
|
||||||
|
|
||||||
|
const
|
||||||
|
MaxParseStamp = $7fffffff;
|
||||||
|
MinParseStamp = -$7fffffff;
|
||||||
|
InvalidParseStamp = MinParseStamp-1;
|
||||||
|
type
|
||||||
|
TCompilerParseStampIncreasedEvent = procedure of object;
|
||||||
|
var
|
||||||
|
CompilerParseStamp: integer; // TimeStamp of base value for macros
|
||||||
|
CompilerParseStampIncreased: TCompilerParseStampIncreasedEvent = nil;
|
||||||
|
|
||||||
|
procedure IncreaseCompilerParseStamp;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
var
|
var
|
||||||
IsIdentChar: array[char] of boolean;
|
IsIdentChar: array[char] of boolean;
|
||||||
|
|
||||||
|
procedure IncreaseCompilerParseStamp;
|
||||||
|
begin
|
||||||
|
if CompilerParseStamp<MaxParseStamp then
|
||||||
|
inc(CompilerParseStamp)
|
||||||
|
else
|
||||||
|
CompilerParseStamp:=MinParseStamp;
|
||||||
|
if Assigned(CompilerParseStampIncreased) then
|
||||||
|
CompilerParseStampIncreased();
|
||||||
|
end;
|
||||||
|
|
||||||
{ TTransferMacro }
|
{ TTransferMacro }
|
||||||
|
|
||||||
constructor TTransferMacro.Create(AName, AValue, ADescription:string;
|
constructor TTransferMacro.Create(AName, AValue, ADescription:string;
|
||||||
|
@ -1427,7 +1427,7 @@ begin
|
|||||||
EnvironmentOptions.CompilerFilename);
|
EnvironmentOptions.CompilerFilename);
|
||||||
FPCMakeTool.CmdLineParams:='-q -TAll';
|
FPCMakeTool.CmdLineParams:='-q -TAll';
|
||||||
FPCMakeTool.EnvironmentOverrides.Add(
|
FPCMakeTool.EnvironmentOverrides.Add(
|
||||||
'FPCDIR='+EnvironmentOptions.FPCSourceDirectory);
|
'FPCDIR='+EnvironmentOptions.GetFPCSourceDirectory);
|
||||||
|
|
||||||
// clear old errors
|
// clear old errors
|
||||||
SourceNotebook.ClearErrorLines;
|
SourceNotebook.ClearErrorLines;
|
||||||
|
Loading…
Reference in New Issue
Block a user