implemented inherited project compiler options

git-svn-id: trunk@4087 -
This commit is contained in:
mattias 2003-04-20 23:10:03 +00:00
parent 59957529dc
commit 70019f98d4
9 changed files with 181 additions and 81 deletions

View File

@ -52,13 +52,15 @@ type
icoIncludePath, icoIncludePath,
icoObjectPath, icoObjectPath,
icoLibraryPath, icoLibraryPath,
icoSrcPath,
icoLinkerOptions, icoLinkerOptions,
icoCustomOptions icoCustomOptions
); );
TInheritedCompilerOptions = set of TInheritedCompilerOption; TInheritedCompilerOptions = set of TInheritedCompilerOption;
const const
icoAllSearchPaths = [icoUnitPath,icoIncludePath,icoObjectPath,icoLibraryPath]; icoAllSearchPaths = [icoUnitPath,icoIncludePath,icoObjectPath,icoLibraryPath,
icoSrcPath];
type type
@ -70,6 +72,7 @@ type
pcosIncludePath, // search path for pascal include files pcosIncludePath, // search path for pascal include files
pcosObjectPath, // search path for .o files pcosObjectPath, // search path for .o files
pcosLibraryPath, // search path for libraries pcosLibraryPath, // search path for libraries
pcosSrcPath, // additional search path for pascal source files
pcosLinkerOptions,// additional linker options pcosLinkerOptions,// additional linker options
pcosCustomOptions,// additional options pcosCustomOptions,// additional options
pcosOutputDir, // the output directory pcosOutputDir, // the output directory
@ -78,8 +81,8 @@ type
TParsedCompilerOptStrings = set of TParsedCompilerOptString; TParsedCompilerOptStrings = set of TParsedCompilerOptString;
const const
ParsedCompilerSearchPaths = [pcosUnitPath,pcosIncludePath, ParsedCompilerSearchPaths = [pcosUnitPath,pcosIncludePath,pcosObjectPath,
pcosObjectPath,pcosLibraryPath]; pcosLibraryPath,pcosSrcPath];
ParsedCompilerFilenames = [pcosCompilerPath]; ParsedCompilerFilenames = [pcosCompilerPath];
ParsedCompilerDirectories = [pcosOutputDir]; ParsedCompilerDirectories = [pcosOutputDir];
ParsedCompilerFiles = ParsedCompilerFiles =
@ -143,10 +146,11 @@ type
fIncludeFiles: String; fIncludeFiles: String;
fLibraries: String; fLibraries: String;
fOtherUnitFiles: String; fOtherUnitFiles: String;
FObjectPath: string;
FSrcPath: string;
fCompilerPath: String; fCompilerPath: String;
fUnitOutputDir: string; fUnitOutputDir: string;
fLCLWidgetType: string; fLCLWidgetType: string;
FObjectPath: string;
// Parsing: // Parsing:
// style // style
@ -217,7 +221,6 @@ type
fAdditionalConfigFile: Boolean; fAdditionalConfigFile: Boolean;
fConfigFilePath: String; fConfigFilePath: String;
fCustomOptions: string; fCustomOptions: string;
procedure SetDefaultMakeOptionsFlags(const AValue: TCompilerCmdLineOptions);
protected protected
procedure SetBaseDirectory(const AValue: string); virtual; procedure SetBaseDirectory(const AValue: string); virtual;
procedure SetCompilerPath(const AValue: String); virtual; procedure SetCompilerPath(const AValue: String); virtual;
@ -228,11 +231,13 @@ type
procedure SetOtherUnitFiles(const AValue: String); virtual; procedure SetOtherUnitFiles(const AValue: String); virtual;
procedure SetUnitOutputDir(const AValue: string); virtual; procedure SetUnitOutputDir(const AValue: string); virtual;
procedure SetObjectPath(const AValue: string); virtual; procedure SetObjectPath(const AValue: string); virtual;
procedure SetSrcPath(const AValue: string); virtual;
protected protected
procedure LoadTheCompilerOptions(const Path: string); virtual; procedure LoadTheCompilerOptions(const Path: string); virtual;
procedure SaveTheCompilerOptions(const Path: string); virtual; procedure SaveTheCompilerOptions(const Path: string); virtual;
procedure SetModified(const AValue: boolean); virtual; procedure SetModified(const AValue: boolean); virtual;
procedure ClearInheritedOptions; procedure ClearInheritedOptions;
procedure SetDefaultMakeOptionsFlags(const AValue: TCompilerCmdLineOptions);
public public
constructor Create(TheOwner: TObject); constructor Create(TheOwner: TObject);
destructor Destroy; override; destructor Destroy; override;
@ -282,10 +287,11 @@ type
property IncludeFiles: String read fIncludeFiles write SetIncludeFiles; property IncludeFiles: String read fIncludeFiles write SetIncludeFiles;
property Libraries: String read fLibraries write SetLibraries; property Libraries: String read fLibraries write SetLibraries;
property OtherUnitFiles: String read fOtherUnitFiles write SetOtherUnitFiles; property OtherUnitFiles: String read fOtherUnitFiles write SetOtherUnitFiles;
property ObjectPath: string read FObjectPath write SetObjectPath;
property SrcPath: string read FSrcPath write SetSrcPath;
property CompilerPath: String read fCompilerPath write SetCompilerPath; property CompilerPath: String read fCompilerPath write SetCompilerPath;
property UnitOutputDirectory: string read fUnitOutputDir write SetUnitOutputDir; property UnitOutputDirectory: string read fUnitOutputDir write SetUnitOutputDir;
property LCLWidgetType: string read fLCLWidgetType write fLCLWidgetType; property LCLWidgetType: string read fLCLWidgetType write fLCLWidgetType;
property ObjectPath: string read FObjectPath write SetObjectPath;
// parsing: // parsing:
property Style: Integer read fStyle write fStyle; property Style: Integer read fStyle write fStyle;
@ -590,8 +596,6 @@ type
ImageIndexRequired: integer; ImageIndexRequired: integer;
ImageIndexInherited: integer; ImageIndexInherited: integer;
InheritedChildDatas: TList; // list of PInheritedNodeData InheritedChildDatas: TList; // list of PInheritedNodeData
function GetOtherSourcePath: string;
procedure SetOtherSourcePath(const AValue: string);
procedure SetReadOnly(const AValue: boolean); procedure SetReadOnly(const AValue: boolean);
procedure UpdateInheritedTab; procedure UpdateInheritedTab;
procedure ClearInheritedTree; procedure ClearInheritedTree;
@ -604,8 +608,6 @@ type
procedure GetCompilerOptions; procedure GetCompilerOptions;
procedure PutCompilerOptions; procedure PutCompilerOptions;
public public
property OtherSourcePath: string
read GetOtherSourcePath write SetOtherSourcePath;
property ReadOnly: boolean read FReadOnly write SetReadOnly; property ReadOnly: boolean read FReadOnly write SetReadOnly;
end; end;
@ -752,6 +754,13 @@ begin
FDefaultMakeOptionsFlags:=AValue; FDefaultMakeOptionsFlags:=AValue;
end; end;
procedure TBaseCompilerOptions.SetSrcPath(const AValue: string);
begin
if FSrcPath=AValue then exit;
FSrcPath:=AValue;
ParsedOpts.SetUnparsedValue(pcosSrcPath,FSrcPath);
end;
procedure TBaseCompilerOptions.SetBaseDirectory(const AValue: string); procedure TBaseCompilerOptions.SetBaseDirectory(const AValue: string);
begin begin
if FBaseDirectory=AValue then exit; if FBaseDirectory=AValue then exit;
@ -826,6 +835,7 @@ begin
UnitOutputDirectory := XMLConfigFile.GetValue(p+'UnitOutputDirectory/Value', ''); UnitOutputDirectory := XMLConfigFile.GetValue(p+'UnitOutputDirectory/Value', '');
LCLWidgetType := XMLConfigFile.GetValue(p+'LCLWidgetType/Value', 'gtk'); LCLWidgetType := XMLConfigFile.GetValue(p+'LCLWidgetType/Value', 'gtk');
ObjectPath := XMLConfigFile.GetValue(p+'ObjectPath/Value', ''); ObjectPath := XMLConfigFile.GetValue(p+'ObjectPath/Value', '');
SrcPath := XMLConfigFile.GetValue(p+'SrcPath/Value', '');
{ Parsing } { Parsing }
p:='CompilerOptions/Parsing/'; p:='CompilerOptions/Parsing/';
@ -954,6 +964,7 @@ begin
XMLConfigFile.SetDeleteValue(p+'UnitOutputDirectory/Value', UnitOutputDirectory,''); XMLConfigFile.SetDeleteValue(p+'UnitOutputDirectory/Value', UnitOutputDirectory,'');
XMLConfigFile.SetDeleteValue(p+'LCLWidgetType/Value', LCLWidgetType,''); XMLConfigFile.SetDeleteValue(p+'LCLWidgetType/Value', LCLWidgetType,'');
XMLConfigFile.SetDeleteValue(p+'ObjectPath/Value', ObjectPath,''); XMLConfigFile.SetDeleteValue(p+'ObjectPath/Value', ObjectPath,'');
XMLConfigFile.SetDeleteValue(p+'SrcPath/Value', SrcPath,'');
{ Parsing } { Parsing }
p:='CompilerOptions/Parsing/'; p:='CompilerOptions/Parsing/';
@ -1131,6 +1142,7 @@ begin
MergeCustomOptions(fInheritedOptions[icoCustomOptions], MergeCustomOptions(fInheritedOptions[icoCustomOptions],
AddOptions.ParsedOpts.GetParsedValue(pcosCustomOptions)); AddOptions.ParsedOpts.GetParsedValue(pcosCustomOptions));
end; end;
OptionsList.Free;
end; end;
fInheritedOptParseStamps:=CompilerParseStamp; fInheritedOptParseStamps:=CompilerParseStamp;
fInheritedOptGraphStamps:=CompilerGraphStamp; fInheritedOptGraphStamps:=CompilerGraphStamp;
@ -1892,6 +1904,7 @@ begin
CompilerPath := '$(CompPath)'; CompilerPath := '$(CompPath)';
UnitOutputDirectory := ''; UnitOutputDirectory := '';
ObjectPath:=''; ObjectPath:='';
SrcPath:='';
fLCLWidgetType := 'gtk'; fLCLWidgetType := 'gtk';
// parsing // parsing
@ -1977,6 +1990,7 @@ begin
UnitOutputDirectory := CompOpts.fUnitOutputDir; UnitOutputDirectory := CompOpts.fUnitOutputDir;
fLCLWidgetType := CompOpts.fLCLWidgetType; fLCLWidgetType := CompOpts.fLCLWidgetType;
ObjectPath := CompOpts.FObjectPath; ObjectPath := CompOpts.FObjectPath;
SrcPath := CompOpts.SrcPath;
// Parsing // Parsing
fStyle := CompOpts.fStyle; fStyle := CompOpts.fStyle;
@ -2057,6 +2071,7 @@ begin
and (fCompilerPath = CompOpts.fCompilerPath) and (fCompilerPath = CompOpts.fCompilerPath)
and (fUnitOutputDir = CompOpts.fUnitOutputDir) and (fUnitOutputDir = CompOpts.fUnitOutputDir)
and (FObjectPath = CompOpts.FObjectPath) and (FObjectPath = CompOpts.FObjectPath)
and (FSrcPath = CompOpts.FSrcPath)
and (fLCLWidgetType = CompOpts.fLCLWidgetType) and (fLCLWidgetType = CompOpts.fLCLWidgetType)
@ -2442,6 +2457,7 @@ begin
edtIncludeFiles.Text := CompilerOpts.IncludeFiles; edtIncludeFiles.Text := CompilerOpts.IncludeFiles;
edtLibraries.Text := CompilerOpts.Libraries; edtLibraries.Text := CompilerOpts.Libraries;
grpLibraries.Enabled:=EnabledLinkerOpts; grpLibraries.Enabled:=EnabledLinkerOpts;
edtOtherSources.Text := CompilerOpts.SrcPath;
edtCompiler.Text := CompilerOpts.CompilerPath; edtCompiler.Text := CompilerOpts.CompilerPath;
edtUnitOutputDir.Text := CompilerOpts.UnitOutputDirectory; edtUnitOutputDir.Text := CompilerOpts.UnitOutputDirectory;
@ -2584,6 +2600,7 @@ begin
CompilerOpts.IncludeFiles := edtIncludeFiles.Text; CompilerOpts.IncludeFiles := edtIncludeFiles.Text;
CompilerOpts.Libraries := edtLibraries.Text; CompilerOpts.Libraries := edtLibraries.Text;
CompilerOpts.OtherUnitFiles := edtOtherUnits.Text; CompilerOpts.OtherUnitFiles := edtOtherUnits.Text;
CompilerOpts.SrcPath := edtOtherSources.Text;
CompilerOpts.CompilerPath := edtCompiler.Text; CompilerOpts.CompilerPath := edtCompiler.Text;
CompilerOpts.UnitOutputDirectory := edtUnitOutputDir.Text; CompilerOpts.UnitOutputDirectory := edtUnitOutputDir.Text;
@ -2632,6 +2649,7 @@ var
end; end;
begin begin
OptionsList:=nil;
CompilerOpts.GetInheritedCompilerOptions(OptionsList); CompilerOpts.GetInheritedCompilerOptions(OptionsList);
InhTreeView.BeginUpdate; InhTreeView.BeginUpdate;
ClearInheritedTree; ClearInheritedTree;
@ -2682,6 +2700,7 @@ begin
end; end;
AncestorNode.Expanded:=true; AncestorNode.Expanded:=true;
end; end;
OptionsList.Free;
end else begin end else begin
InhTreeView.Items.Add(nil,'No compiler options inherited.'); InhTreeView.Items.Add(nil,'No compiler options inherited.');
end; end;
@ -4070,16 +4089,6 @@ begin
SetBounds(x-120,y,120,Height); SetBounds(x-120,y,120,Height);
end; end;
function TfrmCompilerOptions.GetOtherSourcePath: string;
begin
Result:=edtOtherSources.Text;
end;
procedure TfrmCompilerOptions.SetOtherSourcePath(const AValue: string);
begin
edtOtherSources.Text:=AValue;
end;
procedure TfrmCompilerOptions.SetReadOnly(const AValue: boolean); procedure TfrmCompilerOptions.SetReadOnly(const AValue: boolean);
begin begin
if FReadOnly=AValue then exit; if FReadOnly=AValue then exit;

View File

@ -38,8 +38,7 @@ uses
Classes, SysUtils, IDEProcs, CodeToolManager, DefineTemplates, Classes, SysUtils, IDEProcs, CodeToolManager, DefineTemplates,
CompilerOptions, TransferMacros, LinkScanner, FileProcs; CompilerOptions, TransferMacros, LinkScanner, FileProcs;
procedure CreateProjectDefineTemplate(CompOpts: TCompilerOptions; procedure CreateProjectDefineTemplate(CompOpts: TCompilerOptions);
const SrcPath: string);
procedure SetAdditionalGlobalSrcPathToCodeToolBoss(const SrcPath: string); procedure SetAdditionalGlobalSrcPathToCodeToolBoss(const SrcPath: string);
function FindCurrentProjectDirTemplate: TDefineTemplate; function FindCurrentProjectDirTemplate: TDefineTemplate;
function FindCurrentProjectDirSrcPathTemplate: TDefineTemplate; function FindCurrentProjectDirSrcPathTemplate: TDefineTemplate;
@ -143,8 +142,7 @@ begin
end; end;
end; end;
procedure CreateProjectDefineTemplate(CompOpts: TCompilerOptions; procedure CreateProjectDefineTemplate(CompOpts: TCompilerOptions);
const SrcPath: string);
var ProjectDir, s: string; var ProjectDir, s: string;
ProjTempl: TDefineTemplate; ProjTempl: TDefineTemplate;
begin begin
@ -234,11 +232,11 @@ begin
da_DefineRecurse)); da_DefineRecurse));
end; end;
// source path (unitpath + sources for the CodeTools, hidden to the compiler) // source path (unitpath + sources for the CodeTools, hidden to the compiler)
if (SrcPath<>'') or (s<>'') then begin if (CompOpts.SrcPath<>'') or (s<>'') then begin
// add compiled unit path // add compiled unit path
ProjTempl.AddChild(TDefineTemplate.Create('SrcPath', ProjTempl.AddChild(TDefineTemplate.Create('SrcPath',
'source path addition',ExternalMacroStart+'SrcPath', 'source path addition',ExternalMacroStart+'SrcPath',
ConvertTransferMacrosToExternalMacros(s+';'+SrcPath)+';' ConvertTransferMacrosToExternalMacros(s+';'+CompOpts.SrcPath)+';'
+'$('+ExternalMacroStart+'SrcPath)', +'$('+ExternalMacroStart+'SrcPath)',
da_DefineRecurse)); da_DefineRecurse));
end; end;

View File

@ -103,7 +103,8 @@ type
ofAddToRecent, // add file to recent files ofAddToRecent, // add file to recent files
ofRegularFile, // open as regular file (e.g. do not open projects) ofRegularFile, // open as regular file (e.g. do not open projects)
ofVirtualFile, // open the virtual file ofVirtualFile, // open the virtual file
ofConvertMacros // replace macros in filename ofConvertMacros, // replace macros in filename
ofUseCache // do not update file from file
); );
TOpenFlags = set of TOpenFlag; TOpenFlags = set of TOpenFlag;
@ -395,7 +396,8 @@ const
'ofAddToRecent', 'ofAddToRecent',
'ofRegularFile', 'ofRegularFile',
'ofVirtualFile', 'ofVirtualFile',
'ofConvertMacros' 'ofConvertMacros',
'ofUseCache'
); );
SaveFlagNames: array[TSaveFlag] of string = ( SaveFlagNames: array[TSaveFlag] of string = (

View File

@ -210,6 +210,7 @@ type
constructor Create(TheProject: TProject); constructor Create(TheProject: TProject);
function GetOwnerName: string; override; function GetOwnerName: string; override;
function GetDefaultMainSourceFileName: string; override; function GetDefaultMainSourceFileName: string; override;
procedure GetInheritedCompilerOptions(var OptionsList: TList); override;
public public
property OwnerProject: TProject read FOwnerProject; property OwnerProject: TProject read FOwnerProject;
end; end;
@ -255,17 +256,14 @@ type
FOnBeginUpdate: TNotifyEvent; FOnBeginUpdate: TNotifyEvent;
FOnEndUpdate: TEndUpdateProjectEvent; FOnEndUpdate: TEndUpdateProjectEvent;
fOnFileBackup: TOnFileBackup; fOnFileBackup: TOnFileBackup;
fOutputDirectory: String;
fProjectDirectory: string; fProjectDirectory: string;
fProjectInfoFile: String; // the lpi filename fProjectInfoFile: String; // the lpi filename
fProjectType: TProjectType; fProjectType: TProjectType;
fPublishOptions: TPublishProjectOptions; fPublishOptions: TPublishProjectOptions;
fRunParameterOptions: TRunParamsOptions; fRunParameterOptions: TRunParamsOptions;
fSrcPath: string; // source path addition for units in ProjectDir
fTargetFileExt: String; fTargetFileExt: String;
fTitle: String; fTitle: String;
fUnitList: TList; // list of _all_ units (TUnitInfo) fUnitList: TList; // list of _all_ units (TUnitInfo)
fUnitOutputDirectory: String;
FUpdateLock: integer; FUpdateLock: integer;
xmlconfig: TXMLConfig; xmlconfig: TXMLConfig;
function GetMainFilename: String; function GetMainFilename: String;
@ -284,7 +282,6 @@ type
procedure SetFlags(const AValue: TProjectFlags); procedure SetFlags(const AValue: TProjectFlags);
procedure SetMainUnitID(const AValue: Integer); procedure SetMainUnitID(const AValue: Integer);
procedure SetProjectInfoFile(const NewFilename: string); procedure SetProjectInfoFile(const NewFilename: string);
procedure SetSrcPath(const NewSrcPath: string);
procedure SetTargetFilename(const NewTargetFilename: string); procedure SetTargetFilename(const NewTargetFilename: string);
procedure SetUnits(Index:integer; AUnitInfo: TUnitInfo); procedure SetUnits(Index:integer; AUnitInfo: TUnitInfo);
procedure UpdateProjectDirectory; procedure UpdateProjectDirectory;
@ -417,7 +414,6 @@ type
property OnBeginUpdate: TNotifyEvent read FOnBeginUpdate write FOnBeginUpdate; property OnBeginUpdate: TNotifyEvent read FOnBeginUpdate write FOnBeginUpdate;
property OnEndUpdate: TEndUpdateProjectEvent read FOnEndUpdate write FOnEndUpdate; property OnEndUpdate: TEndUpdateProjectEvent read FOnEndUpdate write FOnEndUpdate;
property OnFileBackup: TOnFileBackup read fOnFileBackup write fOnFileBackup; property OnFileBackup: TOnFileBackup read fOnFileBackup write fOnFileBackup;
property OutputDirectory: String read fOutputDirectory write fOutputDirectory;
property ProjectDirectory: string read fProjectDirectory; property ProjectDirectory: string read fProjectDirectory;
property ProjectInfoFile: string property ProjectInfoFile: string
read GetProjectInfoFile write SetProjectInfoFile; read GetProjectInfoFile write SetProjectInfoFile;
@ -425,13 +421,10 @@ type
property PublishOptions: TPublishProjectOptions property PublishOptions: TPublishProjectOptions
read fPublishOptions write fPublishOptions; read fPublishOptions write fPublishOptions;
property RunParameterOptions: TRunParamsOptions read fRunParameterOptions; property RunParameterOptions: TRunParamsOptions read fRunParameterOptions;
property SrcPath: string read fSrcPath write fSrcPath;
property TargetFileExt: String read fTargetFileExt write fTargetFileExt; property TargetFileExt: String read fTargetFileExt write fTargetFileExt;
property TargetFilename: string property TargetFilename: string
read GetTargetFilename write SetTargetFilename; read GetTargetFilename write SetTargetFilename;
property Title: String read fTitle write fTitle; property Title: String read fTitle write fTitle;
property UnitOutputDirectory: String
read fUnitOutputDirectory write fUnitOutputDirectory;
property Units[Index: integer]:TUnitInfo read GetUnits write SetUnits; property Units[Index: integer]:TUnitInfo read GetUnits write SetUnits;
property UpdateLock: integer read FUpdateLock; property UpdateLock: integer read FUpdateLock;
end; end;
@ -480,6 +473,8 @@ function ProjectFlagsToStr(Flags: TProjectFlags): string;
implementation implementation
const
ProjectInfoFileVersion = 2;
function ProjectFlagsToStr(Flags: TProjectFlags): string; function ProjectFlagsToStr(Flags: TProjectFlags): string;
var f: TProjectFlag; var f: TProjectFlag;
@ -1032,9 +1027,11 @@ end;
procedure TUnitInfo.SetIsPartOfProject(const AValue: boolean); procedure TUnitInfo.SetIsPartOfProject(const AValue: boolean);
begin begin
if fIsPartOfProject=AValue then exit; if fIsPartOfProject=AValue then exit;
if Project<>nil then Project.BeginUpdate(true);
fIsPartOfProject:=AValue; fIsPartOfProject:=AValue;
UpdatePartOfProjectList; UpdatePartOfProjectList;
if fIsPartOfProject then UpdateUsageCount(uuIsPartOfProject,0); if fIsPartOfProject then UpdateUsageCount(uuIsPartOfProject,0);
if Project<>nil then Project.EndUpdate;
end; end;
{------------------------------------------------------------------------------- {-------------------------------------------------------------------------------
@ -1105,16 +1102,13 @@ begin
fJumpHistory.OnLoadSaveFilename:=@OnLoadSaveFilename; fJumpHistory.OnLoadSaveFilename:=@OnLoadSaveFilename;
fMainUnitID := -1; fMainUnitID := -1;
fModified := false; fModified := false;
fOutputDirectory := '.';
fProjectInfoFile := ''; fProjectInfoFile := '';
UpdateProjectDirectory; UpdateProjectDirectory;
fPublishOptions:=TPublishProjectOptions.Create; fPublishOptions:=TPublishProjectOptions.Create;
fRunParameterOptions:=TRunParamsOptions.Create; fRunParameterOptions:=TRunParamsOptions.Create;
fSrcPath := '';
fTargetFileExt := DefaultTargetFileExt; fTargetFileExt := DefaultTargetFileExt;
fTitle := ''; fTitle := '';
fUnitList := TList.Create; // list of TUnitInfo fUnitList := TList.Create; // list of TUnitInfo
fUnitOutputDirectory := '.';
// create program source // create program source
NewSource:=TStringList.Create; NewSource:=TStringList.Create;
@ -1285,6 +1279,7 @@ begin
repeat repeat
try try
xmlconfig.SetValue('ProjectOptions/Version/Value',ProjectInfoFileVersion);
xmlconfig.SetDeleteValue('ProjectOptions/General/ProjectType/Value', xmlconfig.SetDeleteValue('ProjectOptions/General/ProjectType/Value',
ProjectTypeNames[ProjectType],''); ProjectTypeNames[ProjectType],'');
SaveFlags; SaveFlags;
@ -1298,14 +1293,8 @@ begin
xmlconfig.SetValue('ProjectOptions/General/TargetFileExt/Value' xmlconfig.SetValue('ProjectOptions/General/TargetFileExt/Value'
,TargetFileExt); ,TargetFileExt);
xmlconfig.SetDeleteValue('ProjectOptions/General/Title/Value', Title,''); xmlconfig.SetDeleteValue('ProjectOptions/General/Title/Value', Title,'');
xmlconfig.SetDeleteValue('ProjectOptions/General/OutputDirectory/Value'
,OutputDirectory,'');
xmlconfig.SetDeleteValue('ProjectOptions/General/UnitOutputDirectory/Value'
,UnitOutputDirectory,'');
fJumpHistory.DeleteInvalidPositions; fJumpHistory.DeleteInvalidPositions;
fJumpHistory.SaveToXMLConfig(xmlconfig,'ProjectOptions/'); fJumpHistory.SaveToXMLConfig(xmlconfig,'ProjectOptions/');
xmlconfig.SetDeleteValue('ProjectOptions/General/SrcPath/Value',
fSrcPath,'');
SaveUnits; SaveUnits;
@ -1361,6 +1350,8 @@ function TProject.ReadProject(const LPIFilename: string): TModalResult;
var var
NewUnitInfo: TUnitInfo; NewUnitInfo: TUnitInfo;
NewUnitCount,i: integer; NewUnitCount,i: integer;
FileVersion: Integer;
OldSrcPath: String;
begin begin
Result := mrCancel; Result := mrCancel;
BeginUpdate(true); BeginUpdate(true);
@ -1383,6 +1374,7 @@ begin
try try
{$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);
ProjectType := ProjectTypeNameToType(xmlconfig.GetValue( ProjectType := ProjectTypeNameToType(xmlconfig.GetValue(
'ProjectOptions/General/ProjectType/Value', '')); 'ProjectOptions/General/ProjectType/Value', ''));
LoadFlags; LoadFlags;
@ -1395,12 +1387,9 @@ begin
TargetFileExt := xmlconfig.GetValue( TargetFileExt := xmlconfig.GetValue(
'ProjectOptions/General/TargetFileExt/Value', DefaultTargetFileExt); 'ProjectOptions/General/TargetFileExt/Value', DefaultTargetFileExt);
Title := xmlconfig.GetValue('ProjectOptions/General/Title/Value', ''); Title := xmlconfig.GetValue('ProjectOptions/General/Title/Value', '');
OutputDirectory := xmlconfig.GetValue(
'ProjectOptions/General/OutputDirectory/Value', '.');
UnitOutputDirectory := xmlconfig.GetValue(
'ProjectOptions/General/UnitOutputDirectory/Value', '.');
fJumpHistory.LoadFromXMLConfig(xmlconfig,'ProjectOptions/'); fJumpHistory.LoadFromXMLConfig(xmlconfig,'ProjectOptions/');
FSrcPath := xmlconfig.GetValue('ProjectOptions/General/SrcPath/Value',''); if FileVersion<2 then
OldSrcPath := xmlconfig.GetValue('ProjectOptions/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('ProjectOptions/Units/Count',0);
@ -1415,7 +1404,8 @@ begin
// Load the compiler options // Load the compiler options
CompilerOptions.XMLConfigFile := xmlconfig; CompilerOptions.XMLConfigFile := xmlconfig;
CompilerOptions.LoadCompilerOptions(true); CompilerOptions.LoadCompilerOptions(true);
CreateProjectDefineTemplate(CompilerOptions,FSrcPath); if FileVersion<2 then CompilerOptions.SrcPath:=OldSrcPath;
CreateProjectDefineTemplate(CompilerOptions);
// load the Publish Options // load the Publish Options
PublishOptions.LoadFromXMLConfig(xmlconfig,'ProjectOptions/PublishOptions/'); PublishOptions.LoadFromXMLConfig(xmlconfig,'ProjectOptions/PublishOptions/');
@ -1550,14 +1540,11 @@ begin
fJumpHistory.Clear; fJumpHistory.Clear;
fMainUnitID := -1; fMainUnitID := -1;
fModified := false; fModified := false;
fOutputDirectory := '.';
fProjectInfoFile := ''; fProjectInfoFile := '';
UpdateProjectDirectory; UpdateProjectDirectory;
fPublishOptions.Clear; fPublishOptions.Clear;
fSrcPath := '';
fTargetFileExt := DefaultTargetFileExt; fTargetFileExt := DefaultTargetFileExt;
fTitle := ''; fTitle := '';
fUnitOutputDirectory := '.';
EndUpdate; EndUpdate;
end; end;
@ -2095,7 +2082,7 @@ begin
if (not IsVirtual) then exit; if (not IsVirtual) then exit;
ExtendPath(UnitPathMacroName,CompilerOptions.OtherUnitFiles); ExtendPath(UnitPathMacroName,CompilerOptions.OtherUnitFiles);
ExtendPath(IncludePathMacroName,CompilerOptions.IncludeFiles); ExtendPath(IncludePathMacroName,CompilerOptions.IncludeFiles);
ExtendPath(SrcPathMacroName,SrcPath); ExtendPath(SrcPathMacroName,CompilerOptions.SrcPath);
end; end;
procedure TProject.GetUnitsChangedOnDisk(var AnUnitList: TList); procedure TProject.GetUnitsChangedOnDisk(var AnUnitList: TList);
@ -2366,12 +2353,6 @@ begin
end; end;
end; end;
procedure TProject.SetSrcPath(const NewSrcPath: string);
begin
if FSrcPath=NewSrcPath then exit;
fSrcPath:=NewSrcPath;
end;
procedure TProject.UpdateProjectDirectory; procedure TProject.UpdateProjectDirectory;
begin begin
fProjectDirectory:=ExtractFilePath(fProjectInfoFile); fProjectDirectory:=ExtractFilePath(fProjectInfoFile);
@ -2549,12 +2530,26 @@ begin
Result:=inherited GetDefaultMainSourceFileName; Result:=inherited GetDefaultMainSourceFileName;
end; end;
procedure TProjectCompilerOptions.GetInheritedCompilerOptions(
var OptionsList: TList);
var
PkgList: TList;
begin
PkgList:=nil;
OwnerProject.GetAllRequiredPackages(PkgList);
OptionsList:=GetUsageOptionsList(PkgList);
PkgList.Free;
end;
end. end.
{ {
$Log$ $Log$
Revision 1.112 2003/04/20 23:10:03 mattias
implemented inherited project compiler options
Revision 1.111 2003/04/20 20:32:40 mattias Revision 1.111 2003/04/20 20:32:40 mattias
implemented removing, re-adding, updating project dependencies implemented removing, re-adding, updating project dependencies

View File

@ -46,6 +46,8 @@ uses
type type
TOnAddUnitToProject = TOnAddUnitToProject =
function(Sender: TObject; AnUnitInfo: TUnitInfo): TModalresult of object; function(Sender: TObject; AnUnitInfo: TUnitInfo): TModalresult of object;
TRemoveProjInspFileEvent =
function(Sender: TObject; AnUnitInfo: TUnitInfo): TModalResult of object;
TProjectInspectorFlag = ( TProjectInspectorFlag = (
pifItemsChanged, pifItemsChanged,
@ -77,6 +79,7 @@ type
private private
FOnAddUnitToProject: TOnAddUnitToProject; FOnAddUnitToProject: TOnAddUnitToProject;
FOnOpen: TNotifyEvent; FOnOpen: TNotifyEvent;
FOnRemoveFile: TRemoveProjInspFileEvent;
FOnShowOptions: TNotifyEvent; FOnShowOptions: TNotifyEvent;
FUpdateLock: integer; FUpdateLock: integer;
FLazProject: TProject; FLazProject: TProject;
@ -119,6 +122,8 @@ type
property OnShowOptions: TNotifyEvent read FOnShowOptions write FOnShowOptions; property OnShowOptions: TNotifyEvent read FOnShowOptions write FOnShowOptions;
property OnAddUnitToProject: TOnAddUnitToProject read FOnAddUnitToProject property OnAddUnitToProject: TOnAddUnitToProject read FOnAddUnitToProject
write FOnAddUnitToProject; write FOnAddUnitToProject;
property OnRemoveFile: TRemoveProjInspFileEvent read FOnRemoveFile
write FOnRemoveFile;
end; end;
var var
@ -314,6 +319,7 @@ end;
procedure TProjectInspectorForm.RemoveBitBtnClick(Sender: TObject); procedure TProjectInspectorForm.RemoveBitBtnClick(Sender: TObject);
var var
CurDependency: TPkgDependency; CurDependency: TPkgDependency;
CurFile: TUnitInfo;
begin begin
CurDependency:=GetSelectedDependency; CurDependency:=GetSelectedDependency;
if (CurDependency<>nil) and (not CurDependency.Removed) then begin if (CurDependency<>nil) and (not CurDependency.Removed) then begin
@ -322,6 +328,18 @@ begin
mtConfirmation,[mbYes,mbNo],0)<>mrYes mtConfirmation,[mbYes,mbNo],0)<>mrYes
then exit; then exit;
LazProject.RemoveRequiredDependency(CurDependency); LazProject.RemoveRequiredDependency(CurDependency);
exit;
end;
CurFile:=GetSelectedFile;
if CurFile<>nil then begin
if (not CurFile.IsPartOfProject) or (CurFile=LazProject.MainUnitInfo)
then exit;
if MessageDlg('Confirm removing file',
'Remove file '+CurFile.Filename+' from project?',
mtConfirmation,[mbYes,mbNo],0)<>mrYes
then exit;
if Assigned(OnRemoveFile) then OnRemoveFile(Self,CurFile);
end; end;
end; end;

View File

@ -332,7 +332,7 @@ begin
if not PackageGraph.DependencyExists(NewDependency,fpfSearchPackageEverywhere) if not PackageGraph.DependencyExists(NewDependency,fpfSearchPackageEverywhere)
then begin then begin
MessageDlg('Package not found', MessageDlg('Package not found',
'The dependency "'+NewDependency.AsString+'" was not found.'#13 'No package found for dependency "'+NewDependency.AsString+'".'#13
+'Please choose an existing package.', +'Please choose an existing package.',
mtError,[mbCancel],0); mtError,[mbCancel],0);
exit; exit;

View File

@ -268,6 +268,7 @@ type
procedure SetLibraries(const AValue: string); override; procedure SetLibraries(const AValue: string); override;
procedure SetLinkerOptions(const AValue: string); override; procedure SetLinkerOptions(const AValue: string); override;
procedure SetObjectPath(const AValue: string); override; procedure SetObjectPath(const AValue: string); override;
procedure SetSrcPath(const AValue: string); override;
procedure SetOtherUnitFiles(const AValue: string); override; procedure SetOtherUnitFiles(const AValue: string); override;
procedure SetUnitOutputDir(const AValue: string); override; procedure SetUnitOutputDir(const AValue: string); override;
public public
@ -624,6 +625,14 @@ var
OnGetAllRequiredPackages: TGetAllRequiredPackagesEvent; OnGetAllRequiredPackages: TGetAllRequiredPackagesEvent;
function CompareLazPackageID(Data1, Data2: Pointer): integer;
function CompareNameWithPackageID(Key, Data: Pointer): integer;
function CompareLazPackageIDNames(Data1, Data2: Pointer): integer;
function CompareNameWithPkgDependency(Key, Data: Pointer): integer;
function ComparePkgDependencyNames(Data1, Data2: Pointer): integer;
function GetUsageOptionsList(PackageList: TList): TList;
function PkgFileTypeIdentToType(const s: string): TPkgFileType; function PkgFileTypeIdentToType(const s: string): TPkgFileType;
function LazPackageTypeIdentToType(const s: string): TLazPackageType; function LazPackageTypeIdentToType(const s: string): TLazPackageType;
@ -634,12 +643,6 @@ procedure LoadPkgDependencyList(XMLConfig: TXMLConfig; const ThePath: string;
procedure SavePkgDependencyList(XMLConfig: TXMLConfig; const ThePath: string; procedure SavePkgDependencyList(XMLConfig: TXMLConfig; const ThePath: string;
First: TPkgDependency; ListType: TPkgDependencyList); First: TPkgDependency; ListType: TPkgDependencyList);
function CompareLazPackageID(Data1, Data2: Pointer): integer;
function CompareNameWithPackageID(Key, Data: Pointer): integer;
function CompareLazPackageIDNames(Data1, Data2: Pointer): integer;
function CompareNameWithPkgDependency(Key, Data: Pointer): integer;
function ComparePkgDependencyNames(Data1, Data2: Pointer): integer;
function FindDependencyByNameInList(First: TPkgDependency; function FindDependencyByNameInList(First: TPkgDependency;
ListType: TPkgDependencyList; const Name: string): TPkgDependency; ListType: TPkgDependencyList; const Name: string): TPkgDependency;
function FindCompatibleDependencyInList(First: TPkgDependency; function FindCompatibleDependencyInList(First: TPkgDependency;
@ -805,6 +808,22 @@ begin
Result:=AnsiCompareText(Dependency1.PackageName,Dependency2.PackageName); Result:=AnsiCompareText(Dependency1.PackageName,Dependency2.PackageName);
end; end;
function GetUsageOptionsList(PackageList: TList): TList;
var
Cnt: Integer;
i: Integer;
begin
if PackageList<>nil then begin
Result:=TList.Create;
Cnt:=PackageList.Count;
for i:=0 to Cnt-1 do begin
Result.Add(TLazPackage(PackageList[i]).UsageOptions);
end;
end else begin
Result:=nil;
end;
end;
function FindDependencyByNameInList(First: TPkgDependency; function FindDependencyByNameInList(First: TPkgDependency;
ListType: TPkgDependencyList; const Name: string): TPkgDependency; ListType: TPkgDependencyList; const Name: string): TPkgDependency;
begin begin
@ -2223,20 +2242,11 @@ end;
procedure TLazPackage.GetInheritedCompilerOptions(var OptionsList: TList); procedure TLazPackage.GetInheritedCompilerOptions(var OptionsList: TList);
var var
PkgList: TList; // list of TLazPackage PkgList: TList; // list of TLazPackage
Cnt: Integer;
i: Integer;
begin begin
PkgList:=nil; PkgList:=nil;
GetAllRequiredPackages(PkgList); GetAllRequiredPackages(PkgList);
if PkgList<>nil then begin OptionsList:=GetUsageOptionsList(PkgList);
OptionsList:=TList.Create; PkgList.Free;
Cnt:=PkgList.Count;
for i:=0 to Cnt-1 do begin
OptionsList.Add(TLazPackage(PkgList[i]).UsageOptions);
end;
end else begin
OptionsList:=nil;
end;
end; end;
function TLazPackage.GetCompileSourceFilename: string; function TLazPackage.GetCompileSourceFilename: string;
@ -2475,6 +2485,13 @@ begin
inherited SetObjectPath(AValue); inherited SetObjectPath(AValue);
end; end;
procedure TPkgCompilerOptions.SetSrcPath(const AValue: string);
begin
if SrcPath=AValue then exit;
InvalidateOptions;
inherited SetSrcPath(AValue);
end;
procedure TPkgCompilerOptions.SetOtherUnitFiles(const AValue: string); procedure TPkgCompilerOptions.SetOtherUnitFiles(const AValue: string);
begin begin
if OtherUnitFiles=AValue then exit; if OtherUnitFiles=AValue then exit;

View File

@ -120,6 +120,7 @@ type
IgnorePackage: TLazPackage): TLazPackage; IgnorePackage: TLazPackage): TLazPackage;
function FindBrokenDependencyPath(APackage: TLazPackage): TList; function FindBrokenDependencyPath(APackage: TLazPackage): TList;
function FindCircleDependencyPath(APackage: TLazPackage): TList; function FindCircleDependencyPath(APackage: TLazPackage): TList;
function FindUnsavedDependencyPath(APackage: TLazPackage): TList;
function FindFileInAllPackages(const TheFilename: string; function FindFileInAllPackages(const TheFilename: string;
ResolveLinks, IgnoreDeleted: boolean): TPkgFile; ResolveLinks, IgnoreDeleted: boolean): TPkgFile;
function FindLowestPkgNodeByName(const PkgName: string): TAVLTreeNode; function FindLowestPkgNodeByName(const PkgName: string): TAVLTreeNode;
@ -1038,6 +1039,56 @@ begin
FindCircle(APackage,Result); FindCircle(APackage,Result);
end; end;
function TLazPackageGraph.FindUnsavedDependencyPath(APackage: TLazPackage
): TList;
procedure FindUnsaved(CurPackage: TLazPackage; var PathList: TList);
var
Dependency: TPkgDependency;
RequiredPackage: TLazPackage;
begin
CurPackage.Flags:=CurPackage.Flags+[lpfVisited];
Dependency:=CurPackage.FirstRequiredDependency;
while Dependency<>nil do begin
if Dependency.LoadPackageResult=lprSuccess then begin
// dependency ok
RequiredPackage:=Dependency.RequiredPackage;
if RequiredPackage.Modified then begin
// unsaved package detected
PathList:=TList.Create;
PathList.Add(CurPackage);
PathList.Add(RequiredPackage);
exit;
end;
if not (lpfVisited in RequiredPackage.Flags) then begin
FindUnsaved(RequiredPackage,PathList);
if PathList<>nil then begin
// unsaved package detected
// -> add current package to list
PathList.Insert(0,CurPackage);
exit;
end;
end;
end;
Dependency:=Dependency.NextRequiresDependency;
end;
CurPackage.Flags:=CurPackage.Flags-[lpfCircle];
end;
var
i: Integer;
Pkg: TLazPackage;
begin
Result:=nil;
if (Count=0) or (APackage=nil) then exit;
// mark all packages as not visited
for i:=FItems.Count-1 downto 0 do begin
Pkg:=TLazPackage(FItems[i]);
Pkg.Flags:=Pkg.Flags-[lpfVisited];
end;
FindUnsaved(APackage,Result);
end;
function TLazPackageGraph.GetAutoCompilationOrder(APackage: TLazPackage function TLazPackageGraph.GetAutoCompilationOrder(APackage: TLazPackage
): TList; ): TList;

View File

@ -600,7 +600,17 @@ begin
mtError,[mbCancel,mbAbort],0); mtError,[mbCancel,mbAbort],0);
exit; exit;
end; end;
// check for unsaved packages
PathList:=PackageGraph.FindUnsavedDependencyPath(APackage);
if PathList<>nil then begin
DoShowPackageGraphPathList(PathList);
Result:=MessageDlg('Unsaved package',
'There is an unsaved package in the required packages. See package graph.',
mtError,[mbCancel,mbAbort],0);
exit;
end;
Result:=mrOk; Result:=mrOk;
end; end;
@ -1012,7 +1022,7 @@ begin
begin begin
// add lcl pp/pas dirs to source search path // add lcl pp/pas dirs to source search path
ds:=PathDelim; ds:=PathDelim;
AProject.SrcPath:= AProject.CompilerOptions.SrcPath:=
'$(LazarusDir)'+ds+'lcl' '$(LazarusDir)'+ds+'lcl'
+';'+ +';'+
'$(LazarusDir)'+ds+'lcl'+ds+'interfaces'+ds+'$(LCLWidgetType)'; '$(LazarusDir)'+ds+'lcl'+ds+'interfaces'+ds+'$(LCLWidgetType)';