mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 04:18:48 +02:00
IDE: compute build macros in local package substitution
git-svn-id: trunk@27125 -
This commit is contained in:
parent
fc87d06bd0
commit
264e8abdc8
@ -3413,11 +3413,11 @@ var
|
||||
BaseDirectory: String;
|
||||
begin
|
||||
s:=OptionText;
|
||||
// parse locally
|
||||
// parse locally (macros depending on owner, like pkgdir and build macros)
|
||||
//DebugLn(['TParsedCompilerOptions.DoParseOption local "',s,'" ...']);
|
||||
if Assigned(OnLocalSubstitute) then
|
||||
s:=OnLocalSubstitute(s,PlatformIndependent);
|
||||
// parse globally
|
||||
// parse globally (general macros)
|
||||
//DebugLn(['TParsedCompilerOptions.DoParseOption global "',s,'" ...']);
|
||||
s:=ParseString(Self,s,PlatformIndependent);
|
||||
//DebugLn(['TParsedCompilerOptions.DoParseOption complete "',s,'" ...']);
|
||||
|
@ -221,9 +221,8 @@ begin
|
||||
);
|
||||
OpenPackageMenuItem.Visible:=true;
|
||||
ShownFilename:=PkgComponent.PkgFile.Filename;
|
||||
UnitFilename:=APackage.SubstitutePkgMacro(ShownFilename,true);
|
||||
IDEMacros.SubstituteMacros(UnitFilename);
|
||||
if not FileExistsUTF8(UnitFilename) then begin
|
||||
UnitFilename:=PkgComponent.PkgFile.GetFullFilename;
|
||||
if not FileExistsCached(UnitFilename) then begin
|
||||
UnitFilename:=LazarusIDE.FindSourceFile(ExtractFilename(UnitFilename),
|
||||
APackage.Directory,[]);
|
||||
if FileExistsUTF8(UnitFilename) then
|
||||
@ -231,7 +230,7 @@ begin
|
||||
end;
|
||||
OpenUnitMenuItem.Caption:=Format(lisCPOpenUnit, [ShownFilename]);
|
||||
OpenUnitMenuItem.Visible:=true;
|
||||
OpenUnitMenuItem.Enabled:=FileExistsUTF8(UnitFilename);
|
||||
OpenUnitMenuItem.Enabled:=FileExistsCached(UnitFilename);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -76,7 +76,7 @@ type
|
||||
function GetFullFilename: string; virtual; abstract;
|
||||
function GetShortFilename(UseUp: boolean): string; virtual; abstract;
|
||||
public
|
||||
property Filename: string read FFilename write SetFilename;
|
||||
property Filename: string read FFilename write SetFilename; // can contain macros if package was auto created
|
||||
property LazPackage: TIDEPackage read GetIDEPackage;
|
||||
property Removed: boolean read FRemoved write SetRemoved;
|
||||
end;
|
||||
|
@ -47,7 +47,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, LResources, Graphics, Forms, FileUtil,
|
||||
AvgLvlTree, AVL_Tree, LazConfigStorage,
|
||||
DefineTemplates, CodeToolManager, Laz_XMLCfg, CodeCache,
|
||||
CodeToolsCfgScript, DefineTemplates, CodeToolManager, Laz_XMLCfg, CodeCache,
|
||||
PropEdits, LazIDEIntf, MacroIntf, PackageIntf,
|
||||
EditDefineTree, CompilerOptions, CompOptsModes, IDEOptionDefs,
|
||||
LazarusIDEStrConsts, IDEProcs, ComponentReg,
|
||||
@ -665,8 +665,8 @@ type
|
||||
function GetUnitPath(RelativeToBaseDir: boolean): string;
|
||||
function GetIncludePath(RelativeToBaseDir: boolean): string;
|
||||
function NeedsDefineTemplates: boolean;
|
||||
function SubstitutePkgMacro(const s: string;
|
||||
PlatformIndependent: boolean): string;
|
||||
function SubstitutePkgMacros(const s: string;
|
||||
PlatformIndependent: boolean): string;
|
||||
procedure WriteInheritedUnparsedOptions;
|
||||
// files
|
||||
function IndexOfPkgFile(PkgFile: TPkgFile): integer;
|
||||
@ -1532,7 +1532,7 @@ begin
|
||||
fFullFilenameStamp:=CompilerParseStamp;
|
||||
if LazPackage<>nil then begin
|
||||
// substitute locally
|
||||
LazPackage.SubstitutePkgMacro(fFullFilename,false);
|
||||
LazPackage.SubstitutePkgMacros(fFullFilename,false);
|
||||
end;
|
||||
// substitute globally
|
||||
IDEMacros.SubstituteMacros(fFullFilename);
|
||||
@ -1633,7 +1633,7 @@ end;
|
||||
|
||||
function TPkgFile.GetShortFilename(UseUp: boolean): string;
|
||||
begin
|
||||
Result:=Filename;
|
||||
Result:=GetFullFilename;
|
||||
LazPackage.ShortenFilename(Result,UseUp);
|
||||
end;
|
||||
|
||||
@ -2028,7 +2028,31 @@ end;
|
||||
procedure TLazPackage.OnMacroListSubstitution(TheMacro: TTransferMacro;
|
||||
const MacroName: string; var s: string; const Data: PtrInt;
|
||||
var Handled, Abort: boolean; Depth: integer);
|
||||
{$IFDEF EnableBuildModes}
|
||||
var
|
||||
Values: TCTCfgScriptVariables;
|
||||
Macro: PCTCfgScriptVariable;
|
||||
{$ENDIF}
|
||||
begin
|
||||
{$IFDEF EnableBuildModes}
|
||||
// check build macros
|
||||
if (MacroName<>'') and IsValidIdent(MacroName) then
|
||||
begin
|
||||
Values:=GetBuildMacroValues(CompilerOptions,true);
|
||||
if Values<>nil then begin
|
||||
Macro:=Values.GetVariable(PChar(MacroName));
|
||||
if Macro<>nil then
|
||||
begin
|
||||
s:=GetCTCSVariableAsString(Macro);
|
||||
debugln(['TLazPackage.OnMacroListSubstitution Pkg=',Name,' Macro=',MacroName,' Value="',s,'"']);
|
||||
Handled:=true;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
// check local macros
|
||||
if CompareText(s,'PkgOutDir')=0 then begin
|
||||
Handled:=true;
|
||||
if Data=CompilerOptionMacroNormal then
|
||||
@ -2048,7 +2072,7 @@ begin
|
||||
FUserReadOnly:=AValue;
|
||||
end;
|
||||
|
||||
function TLazPackage.SubstitutePkgMacro(const s: string;
|
||||
function TLazPackage.SubstitutePkgMacros(const s: string;
|
||||
PlatformIndependent: boolean): string;
|
||||
begin
|
||||
Result:=s;
|
||||
@ -2379,10 +2403,10 @@ begin
|
||||
FMacros.OnSubstitution:=@OnMacroListSubstitution;
|
||||
FCompilerOptions:=TPkgCompilerOptions.Create(Self);
|
||||
FCompilerOptions.ParsedOpts.InvalidateParseOnChange:=true;
|
||||
FCompilerOptions.ParsedOpts.OnLocalSubstitute:=@SubstitutePkgMacro;
|
||||
FCompilerOptions.ParsedOpts.OnLocalSubstitute:=@SubstitutePkgMacros;
|
||||
FCompilerOptions.DefaultMakeOptionsFlags:=[ccloNoLinkerOpts];
|
||||
FUsageOptions:=TPkgAdditionalCompilerOptions.Create(Self);
|
||||
FUsageOptions.ParsedOpts.OnLocalSubstitute:=@SubstitutePkgMacro;
|
||||
FUsageOptions.ParsedOpts.OnLocalSubstitute:=@SubstitutePkgMacros;
|
||||
FDefineTemplates:=TLazPackageDefineTemplates.Create(Self);
|
||||
fPublishOptions:=TPublishPackageOptions.Create(Self);
|
||||
FProvides:=TStringList.Create;
|
||||
@ -3366,7 +3390,7 @@ end;
|
||||
|
||||
function TLazPackage.GetPOOutDirectory: string;
|
||||
begin
|
||||
Result:=TrimFilename(SubstitutePkgMacro(fPOOutputDirectory,false));
|
||||
Result:=TrimFilename(SubstitutePkgMacros(fPOOutputDirectory,false));
|
||||
LongenFilename(Result);
|
||||
IDEMacros.SubstituteMacros(Result);
|
||||
Result:=TrimFilename(Result);
|
||||
|
@ -811,12 +811,6 @@ begin
|
||||
ParseOpts:=Options.ParsedOpts;
|
||||
if ParseOpts=nil then exit;
|
||||
|
||||
if ParseOpts.MacroValuesParsing then begin
|
||||
// circle
|
||||
debugln(['TPkgManager.OnGetBuildMacroValues circle computing macros of ',dbgsname(Options.Owner)]);
|
||||
exit;
|
||||
end;
|
||||
|
||||
if IncludeSelf then begin
|
||||
Result:=ParseOpts.MacroValues.Variables;
|
||||
|
||||
@ -824,7 +818,7 @@ begin
|
||||
// compute macro values
|
||||
|
||||
if ParseOpts.MacroValuesParsing then begin
|
||||
debugln(['TPkgManager.OnGetBuildMacroValues circle computing inherited macros of ',dbgsname(Options.Owner)]);
|
||||
debugln(['TPkgManager.OnGetBuildMacroValues circle computing macros of ',dbgsname(Options.Owner)]);
|
||||
exit;
|
||||
end;
|
||||
|
||||
@ -853,6 +847,10 @@ begin
|
||||
|
||||
if ParseOpts.InheritedMacroValuesStamp<>BuildMacroChangeStamp then begin
|
||||
// compute inherited values
|
||||
if ParseOpts.InheritedMacroValuesParsing then begin
|
||||
debugln(['TPkgManager.OnGetBuildMacroValues circle computing inherited macros of ',dbgsname(Options.Owner)]);
|
||||
exit;
|
||||
end;
|
||||
ParseOpts.InheritedMacroValuesParsing:=true;
|
||||
try
|
||||
Result.Clear;
|
||||
|
Loading…
Reference in New Issue
Block a user