IDE: default project options: save whole lpi, load all build modes, formerly: only active build mode

git-svn-id: trunk@34554 -
This commit is contained in:
mattias 2012-01-03 15:10:08 +00:00
parent 5faf994f71
commit d68222bb17
5 changed files with 178 additions and 110 deletions

View File

@ -1847,7 +1847,7 @@ end;
procedure TDebugManager.SaveProjectSpecificInfo(XMLConfig: TXMLConfig; procedure TDebugManager.SaveProjectSpecificInfo(XMLConfig: TXMLConfig;
Flags: TProjectWriteFlags); Flags: TProjectWriteFlags);
begin begin
if not (pwfDoNotSaveSessionInfo in Flags) then if not (pwfSkipSeparateSessionInfo in Flags) then
begin begin
FBreakPointGroups.SaveToXMLConfig(XMLConfig, FBreakPointGroups.SaveToXMLConfig(XMLConfig,
'Debugging/'+XMLBreakPointGroupsNode+'/'); 'Debugging/'+XMLBreakPointGroupsNode+'/');
@ -1855,7 +1855,7 @@ begin
@Project1.ConvertToLPIFilename); @Project1.ConvertToLPIFilename);
FWatches.SaveToXMLConfig(XMLConfig,'Debugging/'+XMLWatchesNode+'/'); FWatches.SaveToXMLConfig(XMLConfig,'Debugging/'+XMLWatchesNode+'/');
end; end;
if not (pwfDoNotSaveProjectInfo in Flags) then if not (pwfSkipProjectInfo in Flags) then
begin begin
// exceptions are not part of the project info (#0015256) // exceptions are not part of the project info (#0015256)
FExceptions.SaveToXMLConfig(XMLConfig,'Debugging/'+XMLExceptionsNode+'/'); FExceptions.SaveToXMLConfig(XMLConfig,'Debugging/'+XMLExceptionsNode+'/');

View File

@ -672,6 +672,7 @@ resourcestring
lisUnableToReadFile2 = 'Unable to read file %s%s%s!'; lisUnableToReadFile2 = 'Unable to read file %s%s%s!';
lisUnableToReadTheProjectInfoFile = 'Unable to read the project info file%s%' lisUnableToReadTheProjectInfoFile = 'Unable to read the project info file%s%'
+'s%s%s.'; +'s%s%s.';
lisUnableToReadLpi = 'Unable to read lpi';
lisStrangeLpiFile = 'Strange lpi file'; lisStrangeLpiFile = 'Strange lpi file';
lisTheFileDoesNotLookLikeALpiFile = 'The file %s does not look like a lpi file.'; lisTheFileDoesNotLookLikeALpiFile = 'The file %s does not look like a lpi file.';
lisUnableToReadTheProjectInfoFile2 = 'Unable to read the project info file%s%s%s%s.'; lisUnableToReadTheProjectInfoFile2 = 'Unable to read the project info file%s%s%s%s.';

View File

@ -882,7 +882,7 @@ type
ACaretPoint: TPoint; WantedTopLine: integer = -1): TUnitEditorInfo; ACaretPoint: TPoint; WantedTopLine: integer = -1): TUnitEditorInfo;
// project(s) // project(s)
procedure DoLoadDefaultCompilerOptions(AProject: TProject); procedure DoMergeDefaultProjectOptions(AProject: TProject);
function DoNewProject(ProjectDesc: TProjectDescriptor): TModalResult; override; function DoNewProject(ProjectDesc: TProjectDescriptor): TModalResult; override;
function DoSaveProject(Flags: TSaveFlags): TModalResult; override; function DoSaveProject(Flags: TSaveFlags): TModalResult; override;
function DoCloseProject: TModalResult; override; function DoCloseProject: TModalResult; override;
@ -5130,8 +5130,8 @@ begin
MainBuildBoss.SetBuildTargetProject1(false); MainBuildBoss.SetBuildTargetProject1(false);
if (not Restore) and AProject.UseAsDefault then if (not Restore) and AProject.UseAsDefault then
begin begin
aFilename:=AppendPathDelim(GetPrimaryConfigPath)+DefaultProjectCompilerOptionsFilename; aFilename:=AppendPathDelim(GetPrimaryConfigPath)+DefaultProjectOptionsFilename;
AProject.CompilerOptions.SaveToFile(aFilename); AProject.WriteProject([pwfSkipSeparateSessionInfo,pwfIgnoreModified],aFilename);
end; end;
if Restore then if Restore then
AProject.RestoreSession; AProject.RestoreSession;
@ -10503,17 +10503,27 @@ begin
end; end;
end; end;
procedure TMainIDE.DoLoadDefaultCompilerOptions(AProject: TProject); procedure TMainIDE.DoMergeDefaultProjectOptions(AProject: TProject);
var var
AFilename: String; AFilename: String;
begin begin
// load default compiler options if exists // load default project options if exists
AFilename:=AppendPathDelim(GetPrimaryConfigPath)+DefaultProjectCompilerOptionsFilename; AFilename:=AppendPathDelim(GetPrimaryConfigPath)+DefaultProjectOptionsFilename;
if not FileExistsUTF8(AFilename) then if not FileExistsUTF8(AFilename) then
CopySecondaryConfigFile(DefaultProjectCompilerOptionsFilename); CopySecondaryConfigFile(DefaultProjectOptionsFilename);
if not FileExistsUTF8(AFilename) then exit; if FileExistsUTF8(AFilename) then begin
if AProject.CompilerOptions.LoadFromFile(AFilename)<>mrOk then if AProject.ReadProject(AFilename,[prfMerge,prfMergeBuildModes])<>mrOk then
DebugLn(['TMainIDE.DoLoadDefaultCompilerOptions failed']); DebugLn(['TMainIDE.DoLoadDefaultCompilerOptions failed']);
end else begin
// old way (<0.9.31)
// load default compiler options if exists
AFilename:=AppendPathDelim(GetPrimaryConfigPath)+DefaultProjectCompilerOptionsFilename;
if not FileExistsUTF8(AFilename) then
CopySecondaryConfigFile(DefaultProjectCompilerOptionsFilename);
if not FileExistsUTF8(AFilename) then exit;
if AProject.CompilerOptions.LoadFromFile(AFilename)<>mrOk then
DebugLn(['TMainIDE.DoLoadDefaultCompilerOptions failed']);
end;
end; end;
function TMainIDE.DoNewProject(ProjectDesc: TProjectDescriptor):TModalResult; function TMainIDE.DoNewProject(ProjectDesc: TProjectDescriptor):TModalResult;
@ -10567,7 +10577,7 @@ begin
try try
Project1.CompilerOptions.CompilerPath:='$(CompPath)'; Project1.CompilerOptions.CompilerPath:='$(CompPath)';
if pfUseDefaultCompilerOptions in Project1.Flags then begin if pfUseDefaultCompilerOptions in Project1.Flags then begin
DoLoadDefaultCompilerOptions(Project1); DoMergeDefaultProjectOptions(Project1);
Project1.Flags:=Project1.Flags-[pfUseDefaultCompilerOptions]; Project1.Flags:=Project1.Flags-[pfUseDefaultCompilerOptions];
end; end;
Project1.AutoAddOutputDirToIncPath; Project1.AutoAddOutputDirToIncPath;
@ -11121,7 +11131,7 @@ begin
MainUnitInfo:=Project1.MainUnitInfo; MainUnitInfo:=Project1.MainUnitInfo;
MainUnitInfo.Source:=ProgramBuf; MainUnitInfo.Source:=ProgramBuf;
Project1.ProjectInfoFile:=ChangeFileExt(ProgramBuf.Filename,'.lpi'); Project1.ProjectInfoFile:=ChangeFileExt(ProgramBuf.Filename,'.lpi');
DoLoadDefaultCompilerOptions(Project1); DoMergeDefaultProjectOptions(Project1);
UpdateCaption; UpdateCaption;
IncreaseCompilerParseStamp; IncreaseCompilerParseStamp;
@ -13290,8 +13300,7 @@ begin
NewProjectFilename:=DestDir+ExtractFilename(CurProject.ProjectInfoFile); NewProjectFilename:=DestDir+ExtractFilename(CurProject.ProjectInfoFile);
DeleteFileUTF8(NewProjectFilename); DeleteFileUTF8(NewProjectFilename);
Result:=CurProject.WriteProject(CurProject.PublishOptions.WriteFlags Result:=CurProject.WriteProject(CurProject.PublishOptions.WriteFlags
+[pwfSkipDebuggerSettings,pwfSkipJumpPoints,pwfDoNotSaveSessionInfo, +pwfSkipSessionInfo+[pwfIgnoreModified],
pwfIgnoreModified],
NewProjectFilename); NewProjectFilename);
if Result<>mrOk then begin if Result<>mrOk then begin
debugln('TMainIDE.DoPublishModule CurProject.WriteProject failed'); debugln('TMainIDE.DoPublishModule CurProject.WriteProject failed');

View File

@ -369,7 +369,7 @@ type
SaveData, SaveSession: boolean; SaveData, SaveSession: boolean;
UsePathDelim: TPathDelimSwitch); UsePathDelim: TPathDelimSwitch);
procedure UpdateUsageCount(Min, IfBelowThis, IncIfBelow: extended); procedure UpdateUsageCount(Min, IfBelowThis, IncIfBelow: extended);
procedure UpdateUsageCount(TheUsage: TUnitUsage; const Factor: extended); procedure UpdateUsageCount(TheUsage: TUnitUsage; const Factor: TDateTime);
procedure UpdateSourceDirectoryReference; procedure UpdateSourceDirectoryReference;
procedure SetSourceText(const SourceText: string); override; procedure SetSourceText(const SourceText: string); override;
@ -800,6 +800,7 @@ type
FUnitList: TFPList; // list of _all_ units (TUnitInfo) FUnitList: TFPList; // list of _all_ units (TUnitInfo)
FUpdateLock: integer; FUpdateLock: integer;
FUseAsDefault: Boolean; FUseAsDefault: Boolean;
procedure ClearBuildModes;
function GetAllEditorsInfo(Index: Integer): TUnitEditorInfo; function GetAllEditorsInfo(Index: Integer): TUnitEditorInfo;
function GetFirstAutoRevertLockedUnit: TUnitInfo; function GetFirstAutoRevertLockedUnit: TUnitInfo;
function GetFirstLoadedUnit: TUnitInfo; function GetFirstLoadedUnit: TUnitInfo;
@ -887,7 +888,8 @@ type
procedure GetUnitsChangedOnDisk(var AnUnitList: TFPList); procedure GetUnitsChangedOnDisk(var AnUnitList: TFPList);
function HasProjectInfoFileChangedOnDisk: boolean; function HasProjectInfoFileChangedOnDisk: boolean;
procedure IgnoreProjectInfoFileOnDisk; procedure IgnoreProjectInfoFileOnDisk;
function ReadProject(const NewProjectInfoFile: string): TModalResult; function ReadProject(const NewProjectInfoFile: string;
ReadFlags: TProjectReadFlags = []): TModalResult;
function WriteProject(ProjectWriteFlags: TProjectWriteFlags; function WriteProject(ProjectWriteFlags: TProjectWriteFlags;
const OverrideProjectInfoFile: string): TModalResult; const OverrideProjectInfoFile: string): TModalResult;
procedure UpdateExecutableType; override; procedure UpdateExecutableType; override;
@ -1112,7 +1114,8 @@ type
const const
ResourceFileExt = '.lrs'; ResourceFileExt = '.lrs';
DefaultProjectCompilerOptionsFilename = 'compileroptions.xml'; DefaultProjectOptionsFilename = 'projectoptions.xml';
DefaultProjectCompilerOptionsFilename = 'compileroptions.xml'; // old way < 0.9.31
var var
Project1: TProject = nil;// the main project Project1: TProject = nil;// the main project
@ -2074,7 +2077,7 @@ begin
end; end;
procedure TUnitInfo.UpdateUsageCount(TheUsage: TUnitUsage; procedure TUnitInfo.UpdateUsageCount(TheUsage: TUnitUsage;
const Factor: extended); const Factor: TDateTime);
begin begin
case TheUsage of case TheUsage of
uuIsPartOfProject: UpdateUsageCount(20,200,2*Factor); uuIsPartOfProject: UpdateUsageCount(20,200,2*Factor);
@ -2620,16 +2623,15 @@ function TProject.WriteProject(ProjectWriteFlags: TProjectWriteFlags;
procedure UpdateUsageCounts(const ConfigFilename: string); procedure UpdateUsageCounts(const ConfigFilename: string);
var var
UnitUsageCount: extended; UnitUsageCount: TDateTime;
DiffTime: TDateTime; DiffTime: TDateTime;
i: Integer; i: Integer;
begin begin
UnitUsageCount:=0; UnitUsageCount:=0;
if CompareFileNames(ConfigFilename,fLastReadLPIFilename)=0 then begin if CompareFileNames(ConfigFilename,fLastReadLPIFilename)=0 then begin
DiffTime:=Now-fLastReadLPIFileDate; DiffTime:=Now-fLastReadLPIFileDate;
if DiffTime>0 then begin if DiffTime>0 then
UnitUsageCount:= DiffTime*24; // one step every hour UnitUsageCount:= DiffTime*24; // one step every hour
end;
fLastReadLPIFileDate:=Now; fLastReadLPIFileDate:=Now;
end; end;
for i:=0 to UnitCount-1 do begin for i:=0 to UnitCount-1 do begin
@ -2651,7 +2653,7 @@ function TProject.WriteProject(ProjectWriteFlags: TProjectWriteFlags;
if (pwfSaveOnlyProjectUnits in ProjectWriteFlags) then exit; if (pwfSaveOnlyProjectUnits in ProjectWriteFlags) then exit;
if (not Units[i].Loaded) then begin if (not Units[i].Loaded) then begin
if (not (pfSaveClosedUnits in Flags)) then exit; if (not (pfSaveClosedUnits in Flags)) then exit;
if (pwfDontSaveClosedUnits in ProjectWriteFlags) then exit; if (pwfSkipClosedUnits in ProjectWriteFlags) then exit;
if Units[i].fUsageCount<=0 then exit; if Units[i].fUsageCount<=0 then exit;
end; end;
end; end;
@ -2762,7 +2764,7 @@ begin
CfgFilename:=SetDirSeparators(CfgFilename); CfgFilename:=SetDirSeparators(CfgFilename);
CurSessionFilename := ''; CurSessionFilename := '';
if (not (pwfDoNotSaveSessionInfo in ProjectWriteFlags)) if (not (pwfSkipSeparateSessionInfo in ProjectWriteFlags))
and (SessionStorage in [pssInProjectDir,pssInIDEConfig]) then begin and (SessionStorage in [pssInProjectDir,pssInIDEConfig]) then begin
// save session in separate file .lps // save session in separate file .lps
@ -2775,11 +2777,12 @@ begin
end; end;
// first save the .lpi file // first save the .lpi file
SaveSessionInfoInLPI:=(CurSessionFilename='') if (pwfSkipSeparateSessionInfo in ProjectWriteFlags)
or (CompareFilenames(CurSessionFilename,CfgFilename)=0);
if (pwfDoNotSaveSessionInfo in ProjectWriteFlags)
or (SessionStorage=pssNone) then or (SessionStorage=pssNone) then
SaveSessionInfoInLPI:=false; SaveSessionInfoInLPI:=false
else
SaveSessionInfoInLPI:=(CurSessionFilename='')
or (CompareFilenames(CurSessionFilename,CfgFilename)=0);
// check if modified // check if modified
if not (pwfIgnoreModified in ProjectWriteFlags) then if not (pwfIgnoreModified in ProjectWriteFlags) then
@ -2889,13 +2892,15 @@ begin
SaveSessionInfo(XMLConfig,Path); SaveSessionInfo(XMLConfig,Path);
end; end;
// notifiy hooks
if Assigned(OnSaveProjectInfo) then begin if Assigned(OnSaveProjectInfo) then begin
CurFlags:=ProjectWriteFlags; CurFlags:=ProjectWriteFlags;
if not SaveSessionInfoInLPI then if not SaveSessionInfoInLPI then
CurFlags:=CurFlags+[pwfDoNotSaveSessionInfo]; CurFlags:=CurFlags+[pwfSkipSeparateSessionInfo];
OnSaveProjectInfo(Self,XMLConfig,CurFlags); OnSaveProjectInfo(Self,XMLConfig,CurFlags);
end; end;
// save lpi to disk
InvalidateFileStateCache; InvalidateFileStateCache;
xmlconfig.Flush; xmlconfig.Flush;
Modified:=false; Modified:=false;
@ -2911,6 +2916,7 @@ begin
end; end;
end; end;
if CompareFilenames(ProjectInfoFile,xmlconfig.Filename)=0 then begin if CompareFilenames(ProjectInfoFile,xmlconfig.Filename)=0 then begin
// update file buffer
fProjectInfoFileBuffer:=CodeToolBoss.LoadFile(ProjectInfoFile,true,true); fProjectInfoFileBuffer:=CodeToolBoss.LoadFile(ProjectInfoFile,true,true);
fProjectInfoFileDate:=FileAgeCached(ProjectInfoFile); fProjectInfoFileDate:=FileAgeCached(ProjectInfoFile);
if fProjectInfoFileBuffer<>nil then if fProjectInfoFileBuffer<>nil then
@ -2968,8 +2974,9 @@ begin
// save session // save session
SaveSessionInfo(XMLConfig,Path); SaveSessionInfo(XMLConfig,Path);
// notifiy hooks
if Assigned(OnSaveProjectInfo) then begin if Assigned(OnSaveProjectInfo) then begin
CurFlags:=ProjectWriteFlags+[pwfDoNotSaveProjectInfo]; CurFlags:=ProjectWriteFlags+[pwfSkipProjectInfo];
OnSaveProjectInfo(Self,XMLConfig,CurFlags); OnSaveProjectInfo(Self,XMLConfig,CurFlags);
end; end;
@ -3078,7 +3085,8 @@ end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
TProject ReadProject TProject ReadProject
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TProject.ReadProject(const NewProjectInfoFile: string): TModalResult; function TProject.ReadProject(const NewProjectInfoFile: string;
ReadFlags: TProjectReadFlags): TModalResult;
type type
TOldProjectType = (ptApplication, ptProgram, ptCustomProgram); TOldProjectType = (ptApplication, ptProgram, ptCustomProgram);
const const
@ -3086,6 +3094,7 @@ const
'Application', 'Program', 'Custom program' 'Application', 'Program', 'Custom program'
); );
var var
Merge: boolean;
FileVersion: Integer; FileVersion: Integer;
NewMainUnitID: LongInt; NewMainUnitID: LongInt;
@ -3101,6 +3110,11 @@ var
MacroValsPath: String; MacroValsPath: String;
ActiveIdentifier: String; ActiveIdentifier: String;
begin begin
if Merge then begin
if not (prfMergeBuildModes in ReadFlags) then exit;
ClearBuildModes;
end;
Cnt:=XMLConfig.GetValue(Path+'BuildModes/Count',0); Cnt:=XMLConfig.GetValue(Path+'BuildModes/Count',0);
//debugln(['LoadBuildModes Cnt=',Cnt,' LoadData=',LoadData]); //debugln(['LoadBuildModes Cnt=',Cnt,' LoadData=',LoadData]);
if Cnt>0 then begin if Cnt>0 then begin
@ -3320,39 +3334,56 @@ var
xmlconfig: TXMLConfig; xmlconfig: TXMLConfig;
begin begin
Result := mrCancel; Result := mrCancel;
Merge:=prfMerge in ReadFlags;
BeginUpdate(true); BeginUpdate(true);
try try
Clear; if Merge then begin
// read only parts of the lpi, keep other values
try
xmlconfig := TCodeBufXMLConfig.CreateWithCache(NewProjectInfoFile,true)
except
on E: Exception do begin
MessageDlg(lisUnableToReadLpi,
Format(lisUnableToReadTheProjectInfoFile, [#13, '"',NewProjectInfoFile, '"'])+#13
+E.Message
,mtError,[mbOk],0);
Result:=mrCancel;
exit;
end;
end;
end else begin
// read the whole lpi, clear any old values
Clear;
ProjectInfoFile:=NewProjectInfoFile;
fProjectInfoFileBuffer:=CodeToolBoss.LoadFile(ProjectInfoFile,true,true);
fProjectInfoFileBufChangeStamp:=CTInvalidChangeStamp;
try
fProjectInfoFileDate:=FileAgeCached(ProjectInfoFile);
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject A reading lpi');{$ENDIF}
if fProjectInfoFileBuffer=nil then
xmlconfig := TCodeBufXMLConfig.CreateWithCache(ProjectInfoFile,false)
else begin
xmlconfig := TCodeBufXMLConfig.CreateWithCache(ProjectInfoFile,false,true,
fProjectInfoFileBuffer.Source);
fProjectInfoFileBufChangeStamp:=fProjectInfoFileBuffer.ChangeStep;
end;
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject B done lpi');{$ENDIF}
except
on E: Exception do begin
MessageDlg(lisUnableToReadLpi,
Format(lisUnableToReadTheProjectInfoFile, [#13, '"',ProjectInfoFile, '"'])+#13
+E.Message
,mtError,[mbOk],0);
Result:=mrCancel;
exit;
end;
end;
ProjectInfoFile:=NewProjectInfoFile; fLastReadLPIFilename:=ProjectInfoFile;
fProjectInfoFileBuffer:=CodeToolBoss.LoadFile(ProjectInfoFile,true,true); fLastReadLPIFileDate:=Now;
fProjectInfoFileBufChangeStamp:=CTInvalidChangeStamp; NewMainUnitID:=-1;
try
fProjectInfoFileDate:=FileAgeCached(ProjectInfoFile);
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject A reading lpi');{$ENDIF}
if fProjectInfoFileBuffer=nil then
xmlconfig := TCodeBufXMLConfig.CreateWithCache(ProjectInfoFile,false)
else begin
xmlconfig := TCodeBufXMLConfig.CreateWithCache(ProjectInfoFile,false,true,
fProjectInfoFileBuffer.Source);
fProjectInfoFileBufChangeStamp:=fProjectInfoFileBuffer.ChangeStep;
end;
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject B done lpi');{$ENDIF}
except
on E: Exception do begin
MessageDlg('Unable to read project',
Format(lisUnableToReadTheProjectInfoFile, [#13, '"',ProjectInfoFile, '"'])+#13
+E.Message
,mtError,[mbOk],0);
Result:=mrCancel;
exit;
end;
end; end;
fLastReadLPIFilename:=ProjectInfoFile;
fLastReadLPIFileDate:=Now;
NewMainUnitID:=-1;
try try
Path:='ProjectOptions/'; Path:='ProjectOptions/';
// get format // get format
@ -3362,19 +3393,21 @@ begin
{$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(Path+'Version/Value',0); FileVersion:= XMLConfig.GetValue(Path+'Version/Value',0);
if (Fileversion=0) and (xmlconfig.GetValue(Path+'Units/Count',0)=0) then if (Fileversion=0) and (not Merge)
and (xmlconfig.GetValue(Path+'Units/Count',0)=0) then
begin begin
if MessageDlg(lisStrangeLpiFile, if MessageDlg(lisStrangeLpiFile,
Format(lisTheFileDoesNotLookLikeALpiFile, [ProjectInfoFile]), Format(lisTheFileDoesNotLookLikeALpiFile, [ProjectInfoFile]),
mtConfirmation,[mbIgnore,mbAbort],0)<>mrIgnore then exit; mtConfirmation,[mbIgnore,mbAbort],0)<>mrIgnore then exit;
end; end;
LoadFlags(XMLConfig,Path); if not Merge then begin
LoadFlags(XMLConfig,Path);
SessionStorage:=StrToProjectSessionStorage( SessionStorage:=StrToProjectSessionStorage(
XMLConfig.GetValue(Path+'General/SessionStorage/Value', XMLConfig.GetValue(Path+'General/SessionStorage/Value',
ProjectSessionStorageNames[DefaultProjectSessionStorage])); ProjectSessionStorageNames[DefaultProjectSessionStorage]));
//DebugLn('TProject.ReadProject SessionStorage=',dbgs(ord(SessionStorage)),' ProjectSessionFile=',ProjectSessionFile); //DebugLn('TProject.ReadProject SessionStorage=',dbgs(ord(SessionStorage)),' ProjectSessionFile=',ProjectSessionFile);
end;
// load properties // load properties
// Note: in FileVersion<9 the default value was -1 // Note: in FileVersion<9 the default value was -1
@ -3382,59 +3415,73 @@ begin
// added to the lpi. // added to the lpi.
// Changing the default value to 0 avoids the redundancy and // Changing the default value to 0 avoids the redundancy and
// automatically fixes broken lpi files. // automatically fixes broken lpi files.
NewMainUnitID := xmlconfig.GetValue(Path+'General/MainUnit/Value', 0); if not Merge then begin
AutoCreateForms := xmlconfig.GetValue( NewMainUnitID := xmlconfig.GetValue(Path+'General/MainUnit/Value', 0);
Path+'General/AutoCreateForms/Value', true); Title := xmlconfig.GetValue(Path+'General/Title/Value', '');
Title := xmlconfig.GetValue(Path+'General/Title/Value', ''); UseAppBundle := xmlconfig.GetValue(Path+'General/UseAppBundle/Value', True);
UseAppBundle := xmlconfig.GetValue(Path+'General/UseAppBundle/Value', True); AutoCreateForms := xmlconfig.GetValue(
Path+'General/AutoCreateForms/Value', true);
// Lazdoc end;
LazDocPaths := SwitchPathDelims(xmlconfig.GetValue(Path+'LazDoc/Paths', ''),
fPathDelimChanged); // Lazdoc
if not Merge then begin
// i18n LazDocPaths := SwitchPathDelims(xmlconfig.GetValue(Path+'LazDoc/Paths', ''),
if FileVersion<6 then begin fPathDelimChanged);
POOutputDirectory := SwitchPathDelims( end;
xmlconfig.GetValue(Path+'RST/OutDir', ''),fPathDelimChanged);
EnableI18N := POOutputDirectory <> ''; // i18n
end else begin if not Merge then begin
EnableI18N := xmlconfig.GetValue(Path+'i18n/EnableI18N/Value', False); if FileVersion<6 then begin
EnableI18NForLFM := xmlconfig.GetValue(Path+'i18n/EnableI18N/LFM', True); POOutputDirectory := SwitchPathDelims(
POOutputDirectory := SwitchPathDelims( xmlconfig.GetValue(Path+'RST/OutDir', ''),fPathDelimChanged);
xmlconfig.GetValue(Path+'i18n/OutDir/Value', ''),fPathDelimChanged); EnableI18N := POOutputDirectory <> '';
end else begin
EnableI18N := xmlconfig.GetValue(Path+'i18n/EnableI18N/Value', False);
EnableI18NForLFM := xmlconfig.GetValue(Path+'i18n/EnableI18N/LFM', True);
POOutputDirectory := SwitchPathDelims(
xmlconfig.GetValue(Path+'i18n/OutDir/Value', ''),fPathDelimChanged);
end;
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject E reading comp sets');{$ENDIF}
end; end;
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject E reading comp sets');{$ENDIF}
// load MacroValues and compiler options // load MacroValues and compiler options
LoadBuildModes(XMLConfig,Path,true); LoadBuildModes(XMLConfig,Path,true);
// Resources // Resources
ProjResources.ReadFromProjectFile(xmlconfig, Path); if not Merge then
ProjResources.ReadFromProjectFile(xmlconfig, Path);
// load custom data // load custom data
LoadStringToStringTree(xmlconfig,CustomData,Path+'CustomData/'); if not Merge then
LoadStringToStringTree(xmlconfig,CustomData,Path+'CustomData/');
{$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']:= if not Merge then begin
ProjectDirectory; CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'ProjPath']:=
CodeToolBoss.DefineTree.ClearCache; ProjectDirectory;
CodeToolBoss.DefineTree.ClearCache;
end;
// load the dependencies // load the dependencies
LoadPkgDependencyList(XMLConfig,Path+'RequiredPackages/', if not Merge then
LoadPkgDependencyList(XMLConfig,Path+'RequiredPackages/',
FFirstRequiredDependency,pdlRequires,Self,true,false); FFirstRequiredDependency,pdlRequires,Self,true,false);
// load the Run and Build parameter Options // load the Run and Build parameter Options
RunParameterOptions.Load(xmlconfig,Path,fPathDelimChanged); if not Merge then
RunParameterOptions.Load(xmlconfig,Path,fPathDelimChanged);
// load the Publish Options // load the Publish Options
PublishOptions.LoadFromXMLConfig(xmlconfig, if not Merge then
PublishOptions.LoadFromXMLConfig(xmlconfig,
Path+'PublishOptions/',fPathDelimChanged); Path+'PublishOptions/',fPathDelimChanged);
// load session info // load session info
LoadSessionInfo(XMLConfig,Path,false); if not Merge then
LoadSessionInfo(XMLConfig,Path,false);
// call hooks to read their info (e.g. DebugBoss) // call hooks to read their info (e.g. DebugBoss)
if Assigned(OnLoadProjectInfo) then begin if (not Merge) and Assigned(OnLoadProjectInfo) then begin
OnLoadProjectInfo(Self,XMLConfig,false); OnLoadProjectInfo(Self,XMLConfig,false);
end; end;
finally finally
@ -3449,7 +3496,8 @@ begin
end; end;
// load session file (if available) // load session file (if available)
if (SessionStorage in [pssInProjectDir,pssInIDEConfig]) if (not Merge)
and (SessionStorage in [pssInProjectDir,pssInIDEConfig])
and (CompareFilenames(ProjectInfoFile,ProjectSessionFile)<>0) then begin and (CompareFilenames(ProjectInfoFile,ProjectSessionFile)<>0) then begin
if FileExistsUTF8(ProjectSessionFile) then begin if FileExistsUTF8(ProjectSessionFile) then begin
//DebugLn('TProject.ReadProject loading Session ProjectSessionFile=',ProjectSessionFile); //DebugLn('TProject.ReadProject loading Session ProjectSessionFile=',ProjectSessionFile);
@ -3694,10 +3742,7 @@ begin
FEnableI18N:=false; FEnableI18N:=false;
FEnableI18NForLFM:=true; FEnableI18NForLFM:=true;
FBookmarks.Clear; FBookmarks.Clear;
ActiveBuildMode:=nil; ClearBuildModes;
FBuildModes.Clear;
if not fDestroying then
ActiveBuildMode:=FBuildModes.Add('default');
FDefineTemplates.Clear; FDefineTemplates.Clear;
FJumpHistory.Clear; FJumpHistory.Clear;
fMainUnitID := -1; fMainUnitID := -1;
@ -4255,6 +4300,14 @@ begin
Result := FAllEditorsInfoList[Index]; Result := FAllEditorsInfoList[Index];
end; end;
procedure TProject.ClearBuildModes;
begin
ActiveBuildMode:=nil;
FBuildModes.Clear;
if not fDestroying then
ActiveBuildMode:=FBuildModes.Add('default');
end;
function TProject.GetFirstUnitWithComponent: TUnitInfo; function TProject.GetFirstUnitWithComponent: TUnitInfo;
begin begin
Result:=fFirst[uilWithComponent]; Result:=fFirst[uilWithComponent];

View File

@ -46,21 +46,26 @@ uses
type type
TOnLoadSaveFilename = procedure(var Filename:string; Load:boolean) of object; TOnLoadSaveFilename = procedure(var Filename:string; Load:boolean) of object;
TProjectReadFlag = (
prfMerge,
prfMergeBuildModes
);
TProjectReadFlags = set of TProjectReadFlag;
TProjectWriteFlag = ( TProjectWriteFlag = (
pwfDontSaveClosedUnits, pwfSkipClosedUnits, // skip history data
pwfSaveOnlyProjectUnits, pwfSaveOnlyProjectUnits,
pwfSkipDebuggerSettings, pwfSkipDebuggerSettings,
pwfSkipJumpPoints, pwfSkipJumpPoints,
pwfDoNotSaveProjectInfo, pwfSkipProjectInfo, // do not write lpi file
pwfDoNotSaveSessionInfo, pwfSkipSeparateSessionInfo, // do not write lps file
pwfIgnoreModified // write always even if nothing modified (e.g. to upgrade to a newer lpi version) pwfIgnoreModified // write always even if nothing modified (e.g. to upgrade to a newer lpi version)
); );
TProjectWriteFlags = set of TProjectWriteFlag; TProjectWriteFlags = set of TProjectWriteFlag;
const const
pwfSkipSessionInfo = [pwfSaveOnlyProjectUnits,pwfSkipDebuggerSettings, pwfSkipSessionInfo = [pwfSkipSeparateSessionInfo,pwfSaveOnlyProjectUnits,
pwfSkipJumpPoints]; pwfSkipDebuggerSettings,pwfSkipJumpPoints];
type type
TNewUnitType = ( TNewUnitType = (
nuEmpty, // no code nuEmpty, // no code
@ -881,7 +886,7 @@ begin
if not SaveEditorInfoOfNonProjectFiles then if not SaveEditorInfoOfNonProjectFiles then
Include(Result,pwfSaveOnlyProjectUnits); Include(Result,pwfSaveOnlyProjectUnits);
if not SaveClosedEditorFilesInfo then if not SaveClosedEditorFilesInfo then
Include(Result,pwfDontSaveClosedUnits); Include(Result,pwfSkipClosedUnits);
end; end;