IDE: Import / export compiler options, use const strings.

git-svn-id: trunk@45606 -
This commit is contained in:
juha 2014-06-22 09:54:01 +00:00
parent 732fcf9725
commit eef99cf9b7
2 changed files with 16 additions and 11 deletions

View File

@ -8,7 +8,7 @@ object ImExportCompOptsDlg: TImExportCompOptsDlg
ClientWidth = 554
OnClose = ImExportCompOptsDlgCLOSE
OnCreate = ImExportCompOptsDlgCREATE
LCLVersion = '0.9.27'
LCLVersion = '1.3'
object OpenRecentGroupbox: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner

View File

@ -81,6 +81,9 @@ implementation
{$R *.lfm}
const
DefaultCompilerOptPath = 'CompilerOptions/';
function ReadIntFromXMLConfig(const Filename, Path: string;
DefaultValue, ValueForReadError: integer): integer;
var
@ -98,26 +101,28 @@ end;
function GetXMLPathForCompilerOptions(XMLConfig: TXMLConfig): string;
const
PathSuffix = 'SearchPaths/CompilerPath/Value';
OptPathSuffix = 'SearchPaths/CompilerPath/Value';
PkgCompilerOptPath = 'Package/CompilerOptions/';
PkgVersionPath = 'Package/Version';
var
FileVersion: Integer;
begin
if XMLConfig.GetValue(PathSuffix,'')<>'' then
if XMLConfig.GetValue(OptPathSuffix,'')<>'' then
// old lpi file
Result:=''
else if XMLConfig.GetValue('CompilerOptions/'+PathSuffix,'')<>'' then
else if XMLConfig.GetValue(DefaultCompilerOptPath+OptPathSuffix,'')<>'' then
// current lpi file
Result:='CompilerOptions/'
else if XMLConfig.GetValue('Package/CompilerOptions/'+PathSuffix,'')<>'' then
Result:=DefaultCompilerOptPath
else if XMLConfig.GetValue(PkgCompilerOptPath+OptPathSuffix,'')<>'' then
// current lpk file
Result:='Package/CompilerOptions/'
Result:=PkgCompilerOptPath
else begin
// default: depending on file type
Result:='CompilerOptions/';
Result:=DefaultCompilerOptPath;
if CompareFileExt(XMLConfig.Filename,'.lpk',false)=0 then begin
FileVersion:=ReadIntFromXMLConfig(XMLConfig.Filename,'Package/Version',0,2);
FileVersion:=ReadIntFromXMLConfig(XMLConfig.Filename,PkgVersionPath,0,2);
if FileVersion>=2 then
Result:='Package/CompilerOptions/';
Result:=PkgCompilerOptPath; // current lpk file
end;
end;
end;
@ -171,7 +176,7 @@ begin
InvalidateFileStateCache;
XMLConfig:=TXMLConfig.Create(Filename);
try
Path:=GetXMLPathForCompilerOptions(XMLConfig);
Path:=DefaultCompilerOptPath; // GetXMLPathForCompilerOptions(XMLConfig);
CompilerOpts.SaveToXMLConfig(XMLConfig,Path);
XMLConfig.Flush;
finally