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