IDEIntf: removed TLazCompilerOptions.LCLWidgetType, fixed computing default LCLWidgetType on cross target OS

git-svn-id: trunk@37086 -
This commit is contained in:
mattias 2012-04-29 17:43:58 +00:00
parent 62218fe07e
commit 37eb8f6bd9
4 changed files with 60 additions and 96 deletions

View File

@ -2136,7 +2136,7 @@ begin
end else
exit;
// set overrides
// set overrides (e.g. command line parameters)
Overrides:=GetBuildMacroOverrides;
try
for i:=0 to Overrides.Count-1 do
@ -2150,6 +2150,7 @@ begin
// add the defaults
// Note: see also ide/frames/compiler_buildmacro_options.pas procedure TCompOptBuildMacrosFrame.BuildMacrosTreeViewEdited
// TargetOS
if not Result.IsDefined('TargetOS') then begin
s:='';
if Project1<>nil then
@ -2158,14 +2159,17 @@ begin
s:=GetDefaultTargetOS;
Result.Values['TargetOS']:=s;
end;
// SrcOS
if not Result.IsDefined('SrcOS') then begin
s:=GetDefaultSrcOSForTargetOS(Result.Values['TargetOS']);
Result.Values['SrcOS']:=s;
end;
// SrcOS2
if not Result.IsDefined('SrcOS2') then begin
s:=GetDefaultSrcOS2ForTargetOS(Result.Values['TargetOS']);
Result.Values['SrcOS2']:=s;
end;
// TargetCPU
if not Result.IsDefined('TargetCPU') then begin
s:='';
if Project1<>nil then
@ -2174,14 +2178,6 @@ begin
s:=GetDefaultTargetCPU;
Result.Values['TargetCPU']:=s;
end;
if Result.Values['LCLWidgetType']='' then begin
s:='';
if Project1<>nil then
s:=Project1.CompilerOptions.GetEffectiveLCLWidgetType;
if s='' then
s:=LCLPlatformDirNames[GetDefaultLCLWidgetType];
Result.Values['LCLWidgetType']:=s;
end;
{$IFDEF VerboseBuildMacros}
Result.WriteDebugReport('OnGetBuildMacroValues project values');
@ -2267,6 +2263,21 @@ end;
procedure TBuildManager.SetBuildTarget(const TargetOS, TargetCPU,
LCLWidgetType: string; ScanFPCSrc: TScanModeFPCSources; Quiet: boolean);
function GetEffectiveLCLWidgetType: string;
begin
if OverrideLCLWidgetType<>'' then
Result:=OverrideLCLWidgetType
else if Project1<>nil then begin
Result:=Project1.CompilerOptions.GetEffectiveLCLWidgetType
end
else
Result:='';
if (Result='') or (SysUtils.CompareText(Result,'default')=0) then
Result:=LCLPlatformDirNames[GetDefaultLCLWidgetType];
Result:=lowercase(Result);
end;
var
OldTargetOS: String;
OldTargetCPU: String;
@ -2274,7 +2285,7 @@ var
FPCTargetChanged: Boolean;
LCLTargetChanged: Boolean;
begin
debugln(['TBuildManager.SetBuildTarget TargetOS="',TargetOS,'" TargetCPU="',TargetCPU,'" LCLWidgetType="',LCLWidgetType,'"']);
//debugln(['TBuildManager.SetBuildTarget TargetOS="',TargetOS,'" TargetCPU="',TargetCPU,'" LCLWidgetType="',LCLWidgetType,'"']);
OldTargetOS:=fTargetOS;
OldTargetCPU:=fTargetCPU;
OldLCLWidgetType:=fLCLWidgetType;
@ -2304,27 +2315,19 @@ begin
fTargetCPU:=GetDefaultTargetCPU;
fTargetCPU:=GetFPCTargetCPU(fTargetCPU);
// compute new LCLWidgetType
if OverrideLCLWidgetType<>'' then
fLCLWidgetType:=OverrideLCLWidgetType
else if Project1<>nil then
fLCLWidgetType:=Project1.CompilerOptions.GetEffectiveLCLWidgetType
else
fLCLWidgetType:='';
if (fLCLWidgetType='') or (SysUtils.CompareText(fLCLWidgetType,'default')=0) then
fLCLWidgetType:=LCLPlatformDirNames[GetDefaultLCLWidgetType];
fLCLWidgetType:=lowercase(fLCLWidgetType);
FPCTargetChanged:=(OldTargetOS<>fTargetOS)
or (OldTargetCPU<>fTargetCPU)
or (CodeToolBoss.DefineTree.FindDefineTemplateByName(
StdDefTemplLazarusSrcDir,true)=nil);
if FPCTargetChanged then
IncreaseBuildMacroChangeStamp;
// compute new LCLWidgetType
fLCLWidgetType:=GetEffectiveLCLWidgetType;
LCLTargetChanged:=(OldLCLWidgetType<>fLCLWidgetType);
if FPCTargetChanged or LCLTargetChanged then begin
//DebugLn('TMainIDE.SetBuildTarget Old=',OldTargetCPU,'-',OldTargetOS,'-',OldLCLWidgetType,
// ' New=',fTargetCPU,'-',fTargetOS,'-',fLCLWidgetType,' FPC=',dbgs(FPCTargetChanged),' LCL=',dbgs(LCLTargetChanged));
IncreaseBuildMacroChangeStamp;
//DebugLn(['TMainIDE.SetBuildTarget Old=',OldTargetCPU,'-',OldTargetOS,'-',OldLCLWidgetType,' New=',fTargetCPU,'-',fTargetOS,'-',fLCLWidgetType,' FPC=',FPCTargetChanged,' LCL=',LCLTargetChanged]);
end;
if LCLTargetChanged then
CodeToolBoss.SetGlobalValue(ExternalMacroStart+'LCLWidgetType',fLCLWidgetType);

View File

@ -473,7 +473,6 @@ type
procedure SetTargetProc(const AValue: string); override;
procedure SetTargetOS(const AValue: string); override;
procedure SetTargetFilename(const AValue: String); override;
procedure SetLCLWidgetType(const AValue: string); override;
procedure SetUseMsgFile(AValue: Boolean);
procedure SetMsgFileName(AValue: String);
procedure SetModified(const AValue: boolean); override;
@ -522,6 +521,7 @@ type
function NeedsLinkerOpts: boolean;
function GetEffectiveTargetOS: string; override;
function GetEffectiveTargetCPU: string; override;
function GetEffectiveLCLWidgetType: string; override;
function GetUnitPath(RelativeToBaseDir: boolean;
Parsed: TCompilerOptionsParseType = coptParsed;
WithBaseDir: boolean = true): string; override;
@ -563,7 +563,6 @@ type
function GetCustomOptions(Parsed: TCompilerOptionsParseType): string;
function TrimCustomOptions(o: string): string; override;
function GetOptionsForCTDefines: string;
function GetEffectiveLCLWidgetType: string; virtual;
function GetParsedMsgFilename: string;
procedure RenameMacro(const OldName, NewName: string;
@ -1151,14 +1150,6 @@ begin
IncreaseChangeStamp;
end;
procedure TBaseCompilerOptions.SetLCLWidgetType(const AValue: string);
begin
if LCLWidgetType=AValue then exit;
inherited SetLCLWidgetType(AValue);
if ParsedOpts.InvalidateParseOnChange then
IncreaseBuildMacroChangeStamp;
end;
procedure TBaseCompilerOptions.SetUseMsgFile(AValue: Boolean);
begin
if fUseMsgFile=AValue then Exit;
@ -1309,7 +1300,6 @@ var
b, PathDelimChange: boolean;
FileVersion: Integer;
i: LongInt;
s: String;
dit: TCompilerDbgSymbolType;
function f(const Filename: string): string;
@ -1375,13 +1365,6 @@ begin
FConditionals:=aXMLConfig.GetValue(Path+'Conditionals/Value','');
TIDEBuildMacros(fBuildMacros).LoadFromXMLConfig(aXMLConfig,
Path+'BuildMacros/',PathDelimChange);
if FileVersion<10 then
begin
// LCLWidgetType was not a macro but a property of its own
s := aXMLConfig.GetValue(p+'LCLWidgetType/Value', '');
if s<>'' then
LCLWidgetType:=s;
end;
{ Parsing }
p:=Path+'Parsing/';
@ -1620,8 +1603,6 @@ begin
aXMLConfig.SetDeleteValue(Path+'Conditionals/Value',Conditionals,'');
TIDEBuildMacros(fBuildMacros).SaveToXMLConfig(aXMLConfig,
Path+'BuildMacros/',UsePathDelim);
// write the LCLWidgetType value to let older IDEs read the value
aXMLConfig.SetDeleteValue(p+'LCLWidgetType/Value', LCLWidgetType,'');
{ Parsing }
p:=Path+'Parsing/';
@ -1996,6 +1977,16 @@ begin
Result:=GetCompiledTargetCPU;
end;
function TBaseCompilerOptions.GetEffectiveLCLWidgetType: string;
var
Vars: TCTCfgScriptVariables;
begin
Result:='';
Vars:=GetBuildMacroValues(Self,true);
if Vars<>nil then
Result:=Vars.Values['LCLWidgetType'];
end;
function TBaseCompilerOptions.GetUnitPath(RelativeToBaseDir: boolean;
Parsed: TCompilerOptionsParseType; WithBaseDir: boolean): string;
begin
@ -2257,13 +2248,6 @@ begin
Add(GetSyntaxOptionsString);
end;
function TBaseCompilerOptions.GetEffectiveLCLWidgetType: string;
begin
Result:=LCLWidgetType;
if (Result='') or (Result='default') then
Result:= LCLPlatformDirNames[GetDefaultLCLWidgetType];
end;
function TBaseCompilerOptions.GetParsedMsgFilename: string;
begin
Result:=ParsedOpts.GetParsedValue(pcosMsgFile);
@ -3097,8 +3081,7 @@ begin
ObjectPath:='';
SrcPath:='';
DebugPath:='';
fLCLWidgetType := '';
// parsing
FSyntaxMode:='ObjFPC';
fAssemblerStyle := 0;
@ -3212,7 +3195,6 @@ begin
// conditionals
Conditionals:=CompOpts.Conditionals;
TIDEBuildMacros(BuildMacros).Assign(CompOpts.BuildMacros);
fLCLWidgetType := CompOpts.fLCLWidgetType;
// Parsing
FSyntaxMode := CompOpts.FSyntaxMode;
@ -3359,7 +3341,6 @@ begin
if Done(Tool.AddPathsDiff('Conditionals',FConditionals,CompOpts.FConditionals)) then exit;
if Tool<>nil then Tool.Path:='BuildModes';
if Done(TIDEBuildMacros(fBuildMacros).CreateDiff(CompOpts.BuildMacros,Tool)) then exit;
if Done(Tool.AddDiff('LCLWidgetType',fLCLWidgetType,CompOpts.fLCLWidgetType)) then exit;
// parsing
if Tool<>nil then Tool.Path:='Parsing';

View File

@ -512,7 +512,6 @@ type
procedure SetUnitPaths(const AValue: string); override;
procedure SetUnitOutputDir(const AValue: string); override;
procedure SetConditionals(const AValue: string); override;
procedure SetLCLWidgetType(const AValue: string); override;
function SubstituteProjectMacros(const s: string;
PlatformIndependent: boolean): string;
public
@ -533,7 +532,6 @@ type
function CreateDiff(CompOpts: TBaseCompilerOptions;
Tool: TCompilerDiffTool = nil): boolean; override; // true if differ
procedure InvalidateOptions;
function GetEffectiveLCLWidgetType: string; override;
procedure SetAlternativeCompile(const Command: string; ScanFPCMsgs: boolean
); override;
public
@ -5851,9 +5849,24 @@ end;
procedure TProjectCompilerOptions.LoadFromXMLConfig(AXMLConfig: TXMLConfig;
const Path: string);
var
FileVersion: Integer;
s: String;
begin
inherited LoadFromXMLConfig(AXMLConfig,Path);
FileVersion:=aXMLConfig.GetValue(Path+'Version/Value', 0);
if FileVersion<10 then
begin
if LazProject.ActiveBuildMode<>nil then begin
// LCLWidgetType was not a macro but a property of its own
s := aXMLConfig.GetValue(Path+'LCLWidgetType/Value', '');
if (s<>'') and (SysUtils.CompareText(s,'default')<>0) then
LazProject.ActiveBuildMode.MacroValues.Values['LCLWidgetType']:=s;
end;
end;
// old compatability
if AXMLConfig.GetValue(Path+'SkipCompiler/Value',false)
then FCompileReasons := []
@ -5870,6 +5883,11 @@ begin
SaveXMLCompileReasons(AXMLConfig, Path+'CompileReasons/', FCompileReasons,
crAll);
// write the LCLWidgetType value to let older IDEs read the value
if LazProject.ActiveBuildMode<>nil then
aXMLConfig.SetDeleteValue(Path+'LCLWidgetType/Value',
LazProject.ActiveBuildMode.MacroValues.Values['LCLWidgetType'],'');
//debugln(['TProjectCompilerOptions.SaveToXMLConfig ',Path+'CompileReasons/ ',crCompile in FCompileReasons]);
end;
@ -5953,22 +5971,6 @@ begin
inherited SetConditionals(NewValue);
end;
procedure TProjectCompilerOptions.SetLCLWidgetType(const AValue: string);
var
NewValue: String;
begin
NewValue:=AValue;
if NewValue='default' then NewValue:='';
//debugln(['TProjectCompilerOptions.SetLCLWidgetType OldMacro=',LazProject.ActiveBuildMode.MacroValues.Values['LCLWidgetType'],' Prop=',LCLWidgetType,' New=',NewValue]);
if LazProject.ActiveBuildMode<>nil then begin
LazProject.ActiveBuildMode.MacroValues.Values['LCLWidgetType']:=NewValue;
inherited SetLCLWidgetType('');
end
else
inherited SetLCLWidgetType(AValue);
//debugln(['TProjectCompilerOptions.SetLCLWidgetType END Macro=',LazProject.ActiveBuildMode.MacroValues.Values['LCLWidgetType'],' Prop=',LCLWidgetType]);
end;
function TProjectCompilerOptions.SubstituteProjectMacros(const s: string;
PlatformIndependent: boolean): string;
begin
@ -6022,18 +6024,6 @@ begin
if (LazProject=nil) then exit;
end;
function TProjectCompilerOptions.GetEffectiveLCLWidgetType: string;
begin
if (LazProject.ActiveBuildMode<>nil) then
Result:=LazProject.ActiveBuildMode.MacroValues.Values['LCLWidgetType']
else if LazProject.Requires(PackageGraph.LCLPackage,true) then
Result:=inherited GetEffectiveLCLWidgetType
else
Result:=LCLPlatformDirNames[lpNoGUI];
if (Result='') or (SysUtils.CompareText(Result,'default')=0) then
Result:= LCLPlatformDirNames[GetDefaultLCLWidgetType];
end;
procedure TProjectCompilerOptions.SetAlternativeCompile(const Command: string;
ScanFPCMsgs: boolean);
begin

View File

@ -181,7 +181,6 @@ type
// conditionals / build modes
FConditionals: string;
fBuildMacros: TLazBuildMacros;
fLCLWidgetType: string;
// Parsing:
// assembler style
@ -287,7 +286,6 @@ type
procedure SetTargetProc(const AValue: string); virtual; abstract;
procedure SetUnitOutputDir(const AValue: string); virtual; abstract;
procedure SetUnitPaths(const AValue: String); virtual; abstract;
procedure SetLCLWidgetType(const AValue: string); virtual;
public
constructor Create(const TheOwner: TObject); virtual;
destructor Destroy; override;
@ -307,6 +305,7 @@ type
public
function GetEffectiveTargetOS: string; virtual; abstract;
function GetEffectiveTargetCPU: string; virtual; abstract;
function GetEffectiveLCLWidgetType: string; virtual; abstract;
function GetUnitPath(RelativeToBaseDir: boolean;
Parsed: TCompilerOptionsParseType = coptParsed;
WithBaseDir: boolean = true): string; virtual; abstract;
@ -338,8 +337,6 @@ type
// conditional / build modes
property Conditionals: string read FConditionals write SetConditionals;
property BuildMacros: TLazBuildMacros read fBuildMacros;
// Beware: eventually LCLWidgetType will be replaced by a more generic solution
property LCLWidgetType: string read fLCLWidgetType write SetLCLWidgetType;
// target:
property TargetFilename: String read fTargetFilename write SetTargetFilename;
@ -447,13 +444,6 @@ end;
{ TLazCompilerOptions }
procedure TLazCompilerOptions.SetLCLWidgetType(const AValue: string);
begin
if AValue=LCLWidgetType then exit;
fLCLWidgetType:=AValue;
IncreaseChangeStamp;
end;
procedure TLazCompilerOptions.SetLinkSmart(const AValue: Boolean);
begin
if fLinkSmart=AValue then exit;