* Add FPMake-plugin dependencies to unit path + test

git-svn-id: trunk@36072 -
This commit is contained in:
joost 2017-05-03 20:34:55 +00:00
parent 987cf2a9cf
commit 50fea20003
9 changed files with 206 additions and 1 deletions

6
.gitattributes vendored
View File

@ -3445,6 +3445,12 @@ packages/fppkg/tests/packages/base/packagevarianta/src/packagevariantbaseunit.pp
packages/fppkg/tests/packages/base/packagevarianta/src/packagevariantversionbonly.pp svneol=native#text/pascal
packages/fppkg/tests/packages/base/packagevariantp/fpmake.pp svneol=native#text/pascal
packages/fppkg/tests/packages/base/packagevariantp/src/packagevariantp.pp svneol=native#text/pascal
packages/fppkg/tests/packages/specific/plugindependencies/packageusingplugin/fpmake.pp svneol=native#text/pascal
packages/fppkg/tests/packages/specific/plugindependencies/packageusingplugin/src/packageusingpluginunit.pas svneol=native#text/pascal
packages/fppkg/tests/packages/specific/plugindependencies/plugindependency/fpmake.pp svneol=native#text/pascal
packages/fppkg/tests/packages/specific/plugindependencies/plugindependency/src/plugindependencyunit.pas svneol=native#text/pascal
packages/fppkg/tests/packages/specific/plugindependencies/pluginpackage/fpmake.pp svneol=native#text/pascal
packages/fppkg/tests/packages/specific/plugindependencies/pluginpackage/src/pluginunit.pas svneol=native#text/pascal
packages/fppkg/tests/packages/specific/transmitoptions/packagea/fpmake.pp svneol=native#text/pascal
packages/fppkg/tests/packages/specific/transmitoptions/packagea/src/PackageAUnitA.pas svneol=native#text/pascal
packages/fppkg/tests/packages/specific/transmitoptions/packageb1/fpmake.pp svneol=native#text/pascal

View File

@ -180,6 +180,35 @@ var
OOptions:=OOptions+maybequoted(s);
end;
procedure AddDependencySearchPaths(APackageName: string);
var
i: Integer;
D: TFPDependency;
UnitDir: string;
Package: TFPPackage;
begin
Package := PackageManager.FindPackage(APackageName, pkgpkInstalled);
if not assigned(Package) then
begin
Error(SErrMissingInstallPackage, [PackageName]);
end;
for i := 0 to Package.Dependencies.Count -1 do
begin
D := Package.Dependencies[i];
if (PackageManager.CompilerOptions.CompilerOS in D.OSes) and
(PackageManager.CompilerOptions.CompilerCPU in D.CPUs) then
begin
if CheckUnitDir(D.PackageName, UnitDir) then
begin
AddDependencySearchPaths(D.PackageName);
AddOption('-Fu'+UnitDir)
end
else
Error(SErrMissingInstallPackage, [D.PackageName]);
end;
end;
end;
Var
i : Integer;
TempBuildDir,
@ -191,6 +220,7 @@ Var
FPMKUnitDepAvailable: Boolean;
FPMKUnitDepPackage: TFPPackage;
P : TFPPackage;
DepPackage: TFPPackage;
begin
P:=DeterminePackage;
NeedFPMKUnitSource:=false;
@ -236,7 +266,10 @@ begin
if FPMKUnitDepAvailable then
begin
if CheckUnitDir(FPMKUnitDeps[i].package,DepDir) then
AddOption('-Fu'+DepDir)
begin
AddDependencySearchPaths(FPMKUnitDeps[i].package);
AddOption('-Fu'+DepDir)
end
else
Error(SErrMissingInstallPackage,[FPMKUnitDeps[i].package]);
if FPMKUnitDeps[i].def<>'' then

View File

@ -37,6 +37,7 @@ type
procedure TestTransmitOptions;
procedure TestPackageVariantPackage;
procedure TestFPMakeCommandLikePackageVariants;
procedure TestFpmakePluginDependencies;
end;
{ TFullFPCInstallationSetup }
@ -324,6 +325,19 @@ begin
end;
procedure TFullFPCInstallationTests.TestFpmakePluginDependencies;
begin
// A fpmake-plugin could have it's own dependencies. These dependencies have
// to be installed, and it's path must be used to compile the fpmake-executable.
TFullFPCInstallationSetup.SyncPackageIntoCurrentTest('packageusingplugin', 'plugindependencies');
TFullFPCInstallationSetup.SyncPackageIntoCurrentTest('plugindependency', 'plugindependencies');
TFullFPCInstallationSetup.SyncPackageIntoCurrentTest('pluginpackage', 'plugindependencies');
RunFppkgIndir(TFullFPCInstallationSetup.GetCurrentTestBasePackagesPath + 'plugindependency', ['install'], 'Install dependency');
RunFppkgIndir(TFullFPCInstallationSetup.GetCurrentTestBasePackagesPath + 'pluginpackage', ['install'], 'Install plugin');
RunFppkgIndir(TFullFPCInstallationSetup.GetCurrentTestBasePackagesPath + 'packageusingplugin', ['install'], 'Install package that depends on plugin');
end;
procedure TFullFPCInstallationTests.TestListPackages;
var
s: String;

View File

@ -0,0 +1,34 @@
{$mode objfpc}{$H+}
program fpmake;
uses fpmkunit;
Var
P : TPackage;
T : TTarget;
begin
With Installer do
begin
P:=AddPackage('packageusingplugin');
P.Version:='33.32.23';
P.Author := 'Joost van der Sluis';
P.License := 'GPL';
P.HomepageURL := 'www.freepascal.org';
P.Description := 'A package that depends on a plugin';
P.Dependencies.Add('fpmkunit');
// In principle this is strange: when a package depends on a plugin, it should
// have this plugin explicitely added as a dependency. But there are also
// optional plugins which are automatically used when they are available.
// Here we have a non-optional plugin, but without an explicit dependency
// to test if the plugin is added automatically, as an optional plugin.
TestPlugin;
P.SourcePath.Add('src');
T:=P.Targets.AddUnit('packageusingpluginunit.pas');
Run;
end;
end.

View File

@ -0,0 +1,16 @@
Unit PackageUsingPluginUnit;
{$mode objfpc}{$H+}
interface
function PackageUsingPluginUnitFunction: Boolean;
implementation
function PackageUsingPluginUnitFunction: Boolean;
begin
Result := True;
end;
end.

View File

@ -0,0 +1,27 @@
{$mode objfpc}{$H+}
program fpmake;
uses fpmkunit;
Var
P : TPackage;
T : TTarget;
begin
With Installer do
begin
P:=AddPackage('plugindependency');
P.Version:='12.32.23';
P.Author := 'Joost van der Sluis';
P.License := 'GPL';
P.HomepageURL := 'www.freepascal.org';
P.Description := 'Package on which the plugin depends';
P.Dependencies.Add('fpmkunit');
P.SourcePath.Add('src');
T:=P.Targets.AddUnit('plugindependencyunit.pas');
Run;
end;
end.

View File

@ -0,0 +1,23 @@
unit PluginDependencyUnit;
{$mode objfpc}{$H+}
interface
uses
fpmkunit;
procedure PluginDependencyUnitProc;
implementation
type
TCustomInstallerHack = class(TCustomInstaller);
procedure PluginDependencyUnitProc;
begin
TCustomInstallerHack(Installer).Log(vlInfo, 'The plugin-dependency is used');
end;
end.

View File

@ -0,0 +1,31 @@
{$mode objfpc}{$H+}
program fpmake;
uses fpmkunit;
Var
P : TPackage;
T : TTarget;
begin
With Installer do
begin
P:=AddPackage('pluginpack');
P.Version:='3.32.23';
P.Author := 'Joost van der Sluis';
P.License := 'GPL';
P.HomepageURL := 'www.freepascal.org';
P.Description := 'A fpmake-plugin with a dependency';
P.Dependencies.Add('fpmkunit');
P.Dependencies.Add('plugindependency');
P.SourcePath.Add('src');
P.IsFPMakeAddIn := True;
T:=P.Targets.AddUnit('pluginunit.pas');
T.IsFPMakePlugin := True;
Run;
end;
end.

View File

@ -0,0 +1,21 @@
unit PluginUnit;
{$mode objfpc}{$H+}
interface
uses
fpmkunit,
PluginDependencyUnit;
procedure TestPlugin;
implementation
procedure TestPlugin;
begin
PluginDependencyUnitProc;
end;
end.