mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-24 15:30:02 +01:00
fixed loading old project compiler options
git-svn-id: trunk@4632 -
This commit is contained in:
parent
55955882c7
commit
d5f2315cf8
@ -83,7 +83,9 @@ function DoImportComilerOptions(CompOptsDialog: TfrmCompilerOptions;
|
|||||||
CompilerOpts: TBaseCompilerOptions; const Filename: string): TModalResult;
|
CompilerOpts: TBaseCompilerOptions; const Filename: string): TModalResult;
|
||||||
function DoExportComilerOptions(CompOptsDialog: TfrmCompilerOptions;
|
function DoExportComilerOptions(CompOptsDialog: TfrmCompilerOptions;
|
||||||
CompilerOpts: TBaseCompilerOptions; const Filename: string): TModalResult;
|
CompilerOpts: TBaseCompilerOptions; const Filename: string): TModalResult;
|
||||||
function GetXMLPathForCompilerOptionsInFile(const Filename: string): string;
|
function GetXMLPathForCompilerOptions(XMLConfig: TXMLConfig): string;
|
||||||
|
function ReadIntFromXMLConfig(const Filename, Path: string;
|
||||||
|
DefaultValue, ValueForReadError: integer): integer;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -125,8 +127,8 @@ begin
|
|||||||
CompilerOpts:=TBaseCompilerOptions.Create(nil);
|
CompilerOpts:=TBaseCompilerOptions.Create(nil);
|
||||||
FreeCompilerOpts:=true;
|
FreeCompilerOpts:=true;
|
||||||
end;
|
end;
|
||||||
Path:=GetXMLPathForCompilerOptionsInFile(Filename);
|
Path:=GetXMLPathForCompilerOptions(XMLConfig);
|
||||||
CompilerOpts.LoadFromXMLConfig(XMLConfig,Path+'CompilerOptions/');
|
CompilerOpts.LoadFromXMLConfig(XMLConfig,Path);
|
||||||
if CompOptsDialog<>nil then
|
if CompOptsDialog<>nil then
|
||||||
CompOptsDialog.GetCompilerOptions(CompilerOpts);
|
CompOptsDialog.GetCompilerOptions(CompilerOpts);
|
||||||
finally
|
finally
|
||||||
@ -154,8 +156,8 @@ begin
|
|||||||
try
|
try
|
||||||
XMLConfig:=TXMLConfig.Create(Filename);
|
XMLConfig:=TXMLConfig.Create(Filename);
|
||||||
try
|
try
|
||||||
Path:=GetXMLPathForCompilerOptionsInFile(Filename);
|
Path:=GetXMLPathForCompilerOptions(XMLConfig);
|
||||||
CompilerOpts.SaveToXMLConfig(XMLConfig,Path+'CompilerOptions/');
|
CompilerOpts.SaveToXMLConfig(XMLConfig,Path);
|
||||||
XMLConfig.Flush;
|
XMLConfig.Flush;
|
||||||
finally
|
finally
|
||||||
XMLConfig.Free;
|
XMLConfig.Free;
|
||||||
@ -188,15 +190,28 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetXMLPathForCompilerOptionsInFile(const Filename: string): string;
|
function GetXMLPathForCompilerOptions(XMLConfig: TXMLConfig): string;
|
||||||
var
|
var
|
||||||
FileVersion: Integer;
|
FileVersion: Integer;
|
||||||
begin
|
begin
|
||||||
Result:='';
|
if XMLConfig.GetValue('SearchPaths/CompilerPath/Value','')<>'' then
|
||||||
if CompareFileExt(Filename,'.lpk',false)=0 then begin
|
Result:=''
|
||||||
FileVersion:=ReadIntFromXMLConfig(Filename,'Package/Version',0,2);
|
else if XMLConfig.GetValue(
|
||||||
if FileVersion>=2 then
|
'CompilerOptions/SearchPaths/CompilerPath/Value','')<>''
|
||||||
Result:='Package/';
|
then
|
||||||
|
Result:='CompilerOptions/'
|
||||||
|
else if XMLConfig.GetValue(
|
||||||
|
'Package/CompilerOptions/SearchPaths/CompilerPath/Value','')<>''
|
||||||
|
then
|
||||||
|
Result:='Package/CompilerOptions/'
|
||||||
|
else begin
|
||||||
|
// default: depending on file type
|
||||||
|
Result:='CompilerOptions/';
|
||||||
|
if CompareFileExt(XMLConfig.Filename,'.lpk',false)=0 then begin
|
||||||
|
FileVersion:=ReadIntFromXMLConfig(XMLConfig.Filename,'Package/Version',0,2);
|
||||||
|
if FileVersion>=2 then
|
||||||
|
Result:='Package/CompilerOptions/';
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
110
ide/project.pp
110
ide/project.pp
@ -529,7 +529,7 @@ function ProjectFlagsToStr(Flags: TProjectFlags): string;
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
const
|
const
|
||||||
ProjectInfoFileVersion = 2;
|
ProjectInfoFileVersion = 3;
|
||||||
|
|
||||||
function ProjectFlagsToStr(Flags: TProjectFlags): string;
|
function ProjectFlagsToStr(Flags: TProjectFlags): string;
|
||||||
var f: TProjectFlag;
|
var f: TProjectFlag;
|
||||||
@ -1298,12 +1298,13 @@ function TProject.WriteProject(ProjectWriteFlags: TProjectWriteFlags;
|
|||||||
const OverrideProjectInfoFile: string): TModalResult;
|
const OverrideProjectInfoFile: string): TModalResult;
|
||||||
var
|
var
|
||||||
confPath: String;
|
confPath: String;
|
||||||
|
Path: String;
|
||||||
|
|
||||||
procedure SaveFlags;
|
procedure SaveFlags;
|
||||||
var f: TProjectFlag;
|
var f: TProjectFlag;
|
||||||
begin
|
begin
|
||||||
for f:=Low(TProjectFlag) to High(TProjectFlag) do begin
|
for f:=Low(TProjectFlag) to High(TProjectFlag) do begin
|
||||||
xmlconfig.SetDeleteValue('ProjectOptions/General/Flags/'
|
xmlconfig.SetDeleteValue(Path+'General/Flags/'
|
||||||
+ProjectFlagNames[f]+'/Value', f in Flags,f in DefaultProjectFlags);
|
+ProjectFlagNames[f]+'/Value', f in Flags,f in DefaultProjectFlags);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1354,11 +1355,11 @@ var
|
|||||||
for i:=0 to UnitCount-1 do begin
|
for i:=0 to UnitCount-1 do begin
|
||||||
if UnitMustBeSaved(i) then begin
|
if UnitMustBeSaved(i) then begin
|
||||||
Units[i].SaveToXMLConfig(
|
Units[i].SaveToXMLConfig(
|
||||||
xmlconfig,'ProjectOptions/Units/Unit'+IntToStr(SaveUnitCount)+'/');
|
xmlconfig,Path+'Units/Unit'+IntToStr(SaveUnitCount)+'/');
|
||||||
inc(SaveUnitCount);
|
inc(SaveUnitCount);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
xmlconfig.SetDeleteValue('ProjectOptions/Units/Count',SaveUnitCount,0);
|
xmlconfig.SetDeleteValue(Path+'Units/Count',SaveUnitCount,0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1394,39 +1395,39 @@ begin
|
|||||||
|
|
||||||
repeat
|
repeat
|
||||||
try
|
try
|
||||||
xmlconfig.SetValue('ProjectOptions/Version/Value',ProjectInfoFileVersion);
|
Path:='ProjectOptions/';
|
||||||
xmlconfig.SetDeleteValue('ProjectOptions/General/ProjectType/Value',
|
xmlconfig.SetValue(Path+'Version/Value',ProjectInfoFileVersion);
|
||||||
|
xmlconfig.SetDeleteValue(Path+'General/ProjectType/Value',
|
||||||
ProjectTypeNames[ProjectType],'');
|
ProjectTypeNames[ProjectType],'');
|
||||||
SaveFlags;
|
SaveFlags;
|
||||||
xmlconfig.SetDeleteValue('ProjectOptions/General/MainUnit/Value', MainUnitID,-1);
|
xmlconfig.SetDeleteValue(Path+'General/MainUnit/Value', MainUnitID,-1);
|
||||||
xmlconfig.SetDeleteValue('ProjectOptions/General/ActiveEditorIndexAtStart/Value'
|
xmlconfig.SetDeleteValue(Path+'General/ActiveEditorIndexAtStart/Value'
|
||||||
,ActiveEditorIndexAtStart,-1);
|
,ActiveEditorIndexAtStart,-1);
|
||||||
xmlconfig.SetDeleteValue('ProjectOptions/General/AutoCreateForms/Value'
|
xmlconfig.SetDeleteValue(Path+'General/AutoCreateForms/Value'
|
||||||
,AutoCreateForms,true);
|
,AutoCreateForms,true);
|
||||||
xmlconfig.SetDeleteValue('ProjectOptions/General/IconPath/Value',
|
xmlconfig.SetDeleteValue(Path+'General/IconPath/Value',
|
||||||
IconPath,'');
|
IconPath,'');
|
||||||
xmlconfig.SetValue('ProjectOptions/General/TargetFileExt/Value'
|
xmlconfig.SetValue(Path+'General/TargetFileExt/Value'
|
||||||
,TargetFileExt);
|
,TargetFileExt);
|
||||||
xmlconfig.SetDeleteValue('ProjectOptions/General/Title/Value', Title,'');
|
xmlconfig.SetDeleteValue(Path+'General/Title/Value', Title,'');
|
||||||
if not (pfSaveOnlyProjectUnits in Flags) then begin
|
if not (pfSaveOnlyProjectUnits in Flags) then begin
|
||||||
fJumpHistory.DeleteInvalidPositions;
|
fJumpHistory.DeleteInvalidPositions;
|
||||||
fJumpHistory.SaveToXMLConfig(xmlconfig,'ProjectOptions/');
|
fJumpHistory.SaveToXMLConfig(xmlconfig,Path);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
SaveUnits;
|
SaveUnits;
|
||||||
|
|
||||||
// Save the compiler options
|
// Save the compiler options
|
||||||
CompilerOptions.SaveToXMLConfig(XMLConfig,'');
|
CompilerOptions.SaveToXMLConfig(XMLConfig,'CompilerOptions/');
|
||||||
|
|
||||||
// save the Publish Options
|
// save the Publish Options
|
||||||
PublishOptions.SaveToXMLConfig(xmlconfig,
|
PublishOptions.SaveToXMLConfig(xmlconfig,Path+'PublishOptions/');
|
||||||
'ProjectOptions/PublishOptions/');
|
|
||||||
|
|
||||||
// save the Run Parameter Options
|
// save the Run Parameter Options
|
||||||
RunParameterOptions.Save(xmlconfig,'ProjectOptions/');
|
RunParameterOptions.Save(xmlconfig,Path);
|
||||||
|
|
||||||
// save dependencies
|
// save dependencies
|
||||||
SavePkgDependencyList(XMLConfig,'ProjectOptions/RequiredPackages/',
|
SavePkgDependencyList(XMLConfig,Path+'RequiredPackages/',
|
||||||
FFirstRequiredDependency,pdlRequires);
|
FFirstRequiredDependency,pdlRequires);
|
||||||
|
|
||||||
if Assigned(OnSaveProjectInfo) then OnSaveProjectInfo(Self,XMLConfig);
|
if Assigned(OnSaveProjectInfo) then OnSaveProjectInfo(Self,XMLConfig);
|
||||||
@ -1451,12 +1452,37 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TProject.ReadProject(const LPIFilename: string): TModalResult;
|
function TProject.ReadProject(const LPIFilename: string): TModalResult;
|
||||||
|
|
||||||
|
var
|
||||||
|
NewUnitInfo: TUnitInfo;
|
||||||
|
NewUnitCount,i: integer;
|
||||||
|
FileVersion: Integer;
|
||||||
|
OldSrcPath: String;
|
||||||
|
Path: String;
|
||||||
|
|
||||||
|
procedure LoadCompilerOptions;
|
||||||
|
var
|
||||||
|
CompOptsPath: String;
|
||||||
|
begin
|
||||||
|
CompOptsPath:='CompilerOptions/';
|
||||||
|
if FileVersion<3 then begin
|
||||||
|
// due to an old bug, the XML path can be 'CompilerOptions/' or ''
|
||||||
|
if XMLConfig.GetValue('SearchPaths/CompilerPath/Value','')<>'' then
|
||||||
|
CompOptsPath:=''
|
||||||
|
else if XMLConfig.GetValue(
|
||||||
|
'CompilerOptions/SearchPaths/CompilerPath/Value','')<>''
|
||||||
|
then
|
||||||
|
CompOptsPath:='CompilerOptions/';
|
||||||
|
end;
|
||||||
|
CompilerOptions.LoadFromXMLConfig(xmlconfig,CompOptsPath);
|
||||||
|
if FileVersion<2 then CompilerOptions.SrcPath:=OldSrcPath;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure LoadFlags;
|
procedure LoadFlags;
|
||||||
var f: TProjectFlag;
|
var f: TProjectFlag;
|
||||||
begin
|
begin
|
||||||
FFlags:=[];
|
FFlags:=[];
|
||||||
for f:=Low(TProjectFlag) to High(TProjectFlag) do begin
|
for f:=Low(TProjectFlag) to High(TProjectFlag) do begin
|
||||||
if xmlconfig.GetValue('ProjectOptions/General/Flags/'
|
if xmlconfig.GetValue(Path+'General/Flags/'
|
||||||
+ProjectFlagNames[f]+'/Value', f in DefaultProjectFlags)
|
+ProjectFlagNames[f]+'/Value', f in DefaultProjectFlags)
|
||||||
then
|
then
|
||||||
Include(FFlags,f)
|
Include(FFlags,f)
|
||||||
@ -1465,11 +1491,6 @@ function TProject.ReadProject(const LPIFilename: string): TModalResult;
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
|
||||||
NewUnitInfo: TUnitInfo;
|
|
||||||
NewUnitCount,i: integer;
|
|
||||||
FileVersion: Integer;
|
|
||||||
OldSrcPath: String;
|
|
||||||
begin
|
begin
|
||||||
Result := mrCancel;
|
Result := mrCancel;
|
||||||
BeginUpdate(true);
|
BeginUpdate(true);
|
||||||
@ -1491,47 +1512,47 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
Path:='ProjectOptions/';
|
||||||
fPathDelimChanged:=
|
fPathDelimChanged:=
|
||||||
XMLConfig.GetValue('ProjectOptions/PathDelim/Value', '/')<>PathDelim;
|
XMLConfig.GetValue(Path+'PathDelim/Value', '/')<>PathDelim;
|
||||||
|
|
||||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject C reading values');{$ENDIF}
|
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject C reading values');{$ENDIF}
|
||||||
FileVersion:= XMLConfig.GetValue('ProjectOptions/Version/Value',0);
|
FileVersion:= XMLConfig.GetValue(Path+'Version/Value',0);
|
||||||
ProjectType := ProjectTypeNameToType(xmlconfig.GetValue(
|
ProjectType := ProjectTypeNameToType(xmlconfig.GetValue(
|
||||||
'ProjectOptions/General/ProjectType/Value', ''));
|
Path+'General/ProjectType/Value', ''));
|
||||||
LoadFlags;
|
LoadFlags;
|
||||||
MainUnitID := xmlconfig.GetValue('ProjectOptions/General/MainUnit/Value', -1);
|
MainUnitID := xmlconfig.GetValue(Path+'General/MainUnit/Value', -1);
|
||||||
ActiveEditorIndexAtStart := xmlconfig.GetValue(
|
ActiveEditorIndexAtStart := xmlconfig.GetValue(
|
||||||
'ProjectOptions/General/ActiveEditorIndexAtStart/Value', -1);
|
Path+'General/ActiveEditorIndexAtStart/Value', -1);
|
||||||
AutoCreateForms := xmlconfig.GetValue(
|
AutoCreateForms := xmlconfig.GetValue(
|
||||||
'ProjectOptions/General/AutoCreateForms/Value', true);
|
Path+'General/AutoCreateForms/Value', true);
|
||||||
IconPath := xmlconfig.GetValue('ProjectOptions/General/IconPath/Value', './');
|
IconPath := xmlconfig.GetValue(Path+'General/IconPath/Value', './');
|
||||||
TargetFileExt := xmlconfig.GetValue(
|
TargetFileExt := xmlconfig.GetValue(
|
||||||
'ProjectOptions/General/TargetFileExt/Value', GetDefaultExecutableExt);
|
Path+'General/TargetFileExt/Value', GetDefaultExecutableExt);
|
||||||
Title := xmlconfig.GetValue('ProjectOptions/General/Title/Value', '');
|
Title := xmlconfig.GetValue(Path+'General/Title/Value', '');
|
||||||
fJumpHistory.LoadFromXMLConfig(xmlconfig,'ProjectOptions/');
|
fJumpHistory.LoadFromXMLConfig(xmlconfig,Path+'');
|
||||||
if FileVersion<2 then
|
if FileVersion<2 then
|
||||||
OldSrcPath := xmlconfig.GetValue('ProjectOptions/General/SrcPath/Value','');
|
OldSrcPath := xmlconfig.GetValue(Path+'General/SrcPath/Value','');
|
||||||
|
|
||||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject D reading units');{$ENDIF}
|
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject D reading units');{$ENDIF}
|
||||||
NewUnitCount:=xmlconfig.GetValue('ProjectOptions/Units/Count',0);
|
NewUnitCount:=xmlconfig.GetValue(Path+'Units/Count',0);
|
||||||
for i := 0 to NewUnitCount - 1 do begin
|
for i := 0 to NewUnitCount - 1 do begin
|
||||||
NewUnitInfo:=TUnitInfo.Create(nil);
|
NewUnitInfo:=TUnitInfo.Create(nil);
|
||||||
AddUnit(NewUnitInfo,false);
|
AddUnit(NewUnitInfo,false);
|
||||||
NewUnitInfo.LoadFromXMLConfig(
|
NewUnitInfo.LoadFromXMLConfig(
|
||||||
xmlconfig,'ProjectOptions/Units/Unit'+IntToStr(i)+'/');
|
xmlconfig,Path+'Units/Unit'+IntToStr(i)+'/');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject E reading comp sets');{$ENDIF}
|
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject E reading comp sets');{$ENDIF}
|
||||||
// Load the compiler options
|
// Load the compiler options
|
||||||
CompilerOptions.LoadFromXMLConfig(xmlconfig,'');
|
LoadCompilerOptions;
|
||||||
if FileVersion<2 then CompilerOptions.SrcPath:=OldSrcPath;
|
|
||||||
|
|
||||||
// load the Publish Options
|
// load the Publish Options
|
||||||
PublishOptions.LoadFromXMLConfig(xmlconfig,
|
PublishOptions.LoadFromXMLConfig(xmlconfig,
|
||||||
'ProjectOptions/PublishOptions/',fPathDelimChanged);
|
Path+'PublishOptions/',fPathDelimChanged);
|
||||||
|
|
||||||
// load the Run Parameter Options
|
// load the Run Parameter Options
|
||||||
RunParameterOptions.Load(xmlconfig,'ProjectOptions/',fPathDelimChanged);
|
RunParameterOptions.Load(xmlconfig,Path,fPathDelimChanged);
|
||||||
|
|
||||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject update ct boss');{$ENDIF}
|
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject update ct boss');{$ENDIF}
|
||||||
CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'ProjPath']:=
|
CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'ProjPath']:=
|
||||||
@ -1539,7 +1560,7 @@ begin
|
|||||||
CodeToolBoss.DefineTree.ClearCache;
|
CodeToolBoss.DefineTree.ClearCache;
|
||||||
|
|
||||||
// load the dependencies
|
// load the dependencies
|
||||||
LoadPkgDependencyList(XMLConfig,'ProjectOptions/RequiredPackages/',
|
LoadPkgDependencyList(XMLConfig,Path+'RequiredPackages/',
|
||||||
FFirstRequiredDependency,pdlRequires,Self,true);
|
FFirstRequiredDependency,pdlRequires,Self,true);
|
||||||
|
|
||||||
if Assigned(OnLoadProjectInfo) then OnLoadProjectInfo(Self,XMLConfig);
|
if Assigned(OnLoadProjectInfo) then OnLoadProjectInfo(Self,XMLConfig);
|
||||||
@ -2689,10 +2710,11 @@ end;
|
|||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.136 2003/09/17 08:43:17 mattias
|
||||||
|
fixed loading old project compiler options
|
||||||
|
|
||||||
Revision 1.135 2003/09/10 12:13:48 mattias
|
Revision 1.135 2003/09/10 12:13:48 mattias
|
||||||
implemented Import and Export of compiler options
|
implemented Import and Export of compiler options
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user