mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-08 15:36:03 +02:00
IDE: add to project: add relative include path, bug #17021
git-svn-id: trunk@26812 -
This commit is contained in:
parent
0bfff4fa03
commit
62bc8849e3
@ -4788,6 +4788,9 @@ resourcestring
|
||||
lisAddPackageToProject2 = 'Add package to project';
|
||||
lisAddUnitNotRecommended = 'Add unit (not recommended)';
|
||||
lisAddPackageToProject = 'Add package %s to project?';
|
||||
lisAddToIncludeSearchPath = 'Add to include search path?';
|
||||
lisTheNewIncludeFileIsNotYetInTheIncludeSearchPathAdd = 'The new include '
|
||||
+'file is not yet in the include search path.%sAdd directory %s?';
|
||||
lisOnBreakLineIEReturnOrEnterKey = 'On break line (i.e. return or enter key)';
|
||||
lisSetupDefaultIndentation = '(Setup default indentation)';
|
||||
lisIndentationForPascalSources = 'Indentation for pascal sources';
|
||||
|
70
ide/main.pp
70
ide/main.pp
@ -505,7 +505,9 @@ type
|
||||
// Checks if the UnitDirectory is part of the Unit Search Paths,
|
||||
// if not, then ask the user if he wants to extend dependencies
|
||||
// or the Unit Search Paths.
|
||||
procedure CheckUnitDirIsInSearchPath(UnitInfo: TUnitInfo;
|
||||
procedure CheckDirIsInUnitSearchPath(UnitInfo: TUnitInfo;
|
||||
AllowAddingDependencies: boolean; out DependencyAdded: boolean);
|
||||
procedure CheckDirIsInIncludeSearchPath(UnitInfo: TUnitInfo;
|
||||
AllowAddingDependencies: boolean; out DependencyAdded: boolean);
|
||||
|
||||
// compiler options dialog events
|
||||
@ -10278,7 +10280,11 @@ begin
|
||||
if MessageDlg(Format(lisAddToProject, [s]), mtConfirmation, [mbYes,
|
||||
mbCancel], 0) in [mrOk,mrYes]
|
||||
then begin
|
||||
CheckUnitDirIsInSearchPath(ActiveUnitInfo,false,DependencyAdded);
|
||||
DependencyAdded:=false;
|
||||
if FilenameIsPascalUnit(ActiveUnitInfo.Filename) then
|
||||
CheckDirIsInUnitSearchPath(ActiveUnitInfo,false,DependencyAdded)
|
||||
else if CompareFileExt(ActiveUnitInfo.Filename,'inc',false)=0 then
|
||||
CheckDirIsInIncludeSearchPath(ActiveUnitInfo,false,DependencyAdded);
|
||||
if not DependencyAdded then begin
|
||||
ActiveUnitInfo.IsPartOfProject:=true;
|
||||
Project1.Modified:=true;
|
||||
@ -15953,7 +15959,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.CheckUnitDirIsInSearchPath(UnitInfo: TUnitInfo;
|
||||
procedure TMainIDE.CheckDirIsInUnitSearchPath(UnitInfo: TUnitInfo;
|
||||
AllowAddingDependencies: boolean; out DependencyAdded: boolean);
|
||||
var
|
||||
CurDirectory: String;
|
||||
@ -16006,6 +16012,59 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.CheckDirIsInIncludeSearchPath(UnitInfo: TUnitInfo;
|
||||
AllowAddingDependencies: boolean; out DependencyAdded: boolean);
|
||||
var
|
||||
CurDirectory: String;
|
||||
CurIncPath: String;
|
||||
Owners: TFPList;
|
||||
i: Integer;
|
||||
APackage: TLazPackage;
|
||||
ShortDir: String;
|
||||
begin
|
||||
DependencyAdded:=false;
|
||||
if UnitInfo.IsVirtual then exit;
|
||||
CurIncPath:=Project1.CompilerOptions.GetIncludePath(false);
|
||||
CurDirectory:=AppendPathDelim(UnitInfo.GetDirectory);
|
||||
if SearchDirectoryInSearchPath(CurIncPath,CurDirectory)<1 then
|
||||
begin
|
||||
if AllowAddingDependencies then begin
|
||||
Owners:=PkgBoss.GetPossibleOwnersOfUnit(UnitInfo.Filename,[]);
|
||||
try
|
||||
if (Owners<>nil) then begin
|
||||
for i:=0 to Owners.Count-1 do begin
|
||||
if TObject(Owners[i]) is TLazPackage then begin
|
||||
APackage:=TLazPackage(Owners[i]);
|
||||
if IDEMessageDialog(lisAddPackageRequirement,
|
||||
Format(lisAddPackageToProject, [APackage.IDAsString]),
|
||||
mtConfirmation,[mbYes,mbCancel],'')<>mrYes
|
||||
then
|
||||
exit;
|
||||
PkgBoss.AddProjectDependency(Project1,APackage);
|
||||
DependencyAdded:=true;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
Owners.Free;
|
||||
end;
|
||||
end;
|
||||
// include file is not in a package => extend include path
|
||||
ShortDir:=CurDirectory;
|
||||
if (not Project1.IsVirtual) then
|
||||
ShortDir:=CreateRelativePath(ShortDir,Project1.ProjectDirectory);
|
||||
if MessageDlg(lisAddToIncludeSearchPath,
|
||||
Format(lisTheNewIncludeFileIsNotYetInTheIncludeSearchPathAdd, [#13,
|
||||
CurDirectory]),
|
||||
mtConfirmation,[mbYes,mbNo],0)=mrYes
|
||||
then begin
|
||||
Project1.CompilerOptions.IncludePath:=
|
||||
MergeSearchPaths(Project1.CompilerOptions.IncludePath,ShortDir);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TMainIDE.ProjInspectorAddUnitToProject(Sender: TObject;
|
||||
AnUnitInfo: TUnitInfo): TModalresult;
|
||||
var
|
||||
@ -16019,8 +16078,11 @@ begin
|
||||
//debugln(['TMainIDE.ProjInspectorAddUnitToProject ',AnUnitInfo.Filename]);
|
||||
BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[]);
|
||||
AnUnitInfo.IsPartOfProject:=true;
|
||||
DependencyAdded:=false;
|
||||
if FilenameIsPascalUnit(AnUnitInfo.Filename) then
|
||||
CheckUnitDirIsInSearchPath(AnUnitInfo,false,DependencyAdded);
|
||||
CheckDirIsInUnitSearchPath(AnUnitInfo,false,DependencyAdded)
|
||||
else if CompareFileExt(AnUnitInfo.Filename,'inc',false)=0 then
|
||||
CheckDirIsInIncludeSearchPath(AnUnitInfo,false,DependencyAdded);
|
||||
if FilenameIsPascalUnit(AnUnitInfo.Filename)
|
||||
and (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags)
|
||||
then begin
|
||||
|
Loading…
Reference in New Issue
Block a user