I've implemented the basic workings of package dependency in fpmkunit.
Please find attached a patch against tagged FPC2.6.2. 

Could someone (like Michael f.i.) please review the patch and let me
know (either on the list or by pm) what you think? The patch does not
include code that recusively searches the packages, although I'm not
sure this is what you would like as circular dependencies will get more
difficult to find. Either way the patch will be expanded to include this
kind of a check once the basic working version is approved. You can test
with the test app that I attached earlier. 

BTW: Lots of OSS nowadays use online review tools in combination with
their bugtrackers. Would such a tool help the core developers in their
work to review and resolve patches? One interesting tool is
http://phabricator.org/ [2] 

Regards, Darius 

Darius Blaszyk schreef op 6 apr '14: 

> Hi all,
> I'm trying to use fpmake for my own project which is built up of a couple of 
> packages. The final application has a dependency on these packages. 
> 
> Which I have done like this: 
> 
> P := AddPackage('my_app'); 
> 
> P.Directory := 'app'; 
> 
> T := P.Targets.AddProgram('hello.pp'); 
> 
> T.Dependencies.Add('my_pkg'); 
> 
> However, adding the dendencies does not add the units output dir to the 
> target. I think it would be a good idea to do this by default. Do you agree? 
> 
> Please find the output of my test case (which is also attached) below. 
> 
> Regards, Darius 
> 
> C:developrepositorytest>fpmake -v 
> 
> Start compiling package my_pkg for target x86_64-win64. 
> 
> Creating output dir "pkgunitsx86_64-win64" 
> 
> Compiling target testunit 
> 
> Executing command "fpc -Twin64 -Px86_64 -FUpkgunitsx86_64-win64 
> -FuC:lazarusfpc2.6.2unitsx86_64-win64rtl pkgtestunit.pas" 
> 
> Free Pascal Compiler version 2.6.2 [2014/02/28] for x86_64 
> 
> Copyright (c) 1993-2012 by Florian Klaempfl and others 
> 
> Target OS: Win64 for x64 
> 
> Compiling pkgtestunit.pas 
> 
> 14 lines compiled, 0.0 sec 
> 
> Generating "pkgunitsx86_64-win64fpunits.cfg" 
> 
> [ 67%] Compiled package my_pkg 
> 
> Warning: Circular dependency detected when compiling package my_app with 
> package my_app 
> 
> Start compiling package my_app for target x86_64-win64. 
> 
> Creating output dir "appunitsx86_64-win64" 
> 
> Creating output dir "appbinx86_64-win64" 
> 
> Warning: Target hello of package my_app depends on another package (my_pkg). 
> These kind of dependencies are not processed 
> 
> Compiling target hello 
> 
> Executing command "fpc -Twin64 -Px86_64 -FEappbinx86_64-win64 
> -FUappunitsx86_64-win64 -FuC:lazarusfpc2.6.2unitsx86_64-win64rtl -Fuapp 
> apphello.pp" 
> 
> Free Pascal Compiler version 2.6.2 [2014/02/28] for x86_64 
> 
> Copyright (c) 1993-2012 by Florian Klaempfl and others 
> 
> Target OS: Win64 for x64 
> 
> Compiling apphello.pp 
> 
> hello.pp(6,3) Fatal: Can't find unit testunit used by hello 
> 
> Fatal: Compilation aborted 
> 
> Error: C:lazarusfpc2.6.2binx86_64-win64ppcx64.exe returned an error exitcode 
> (normal if you did not specify a source file to be compiled) 
> 
> The installer encountered the following error: 
> 
> External command "fpc -Twin64 -Px86_64 -FEappbinx86_64-win64 
> -FUappunitsx86_64-win64 -FuC:lazarusfpc2.6.2unitsx86_64-win64rtl -Fuapp 
> apphello.pp" failed with exit code 1. Console output: 
> 
> Free Pascal Compiler version 2.6.2 [2014/02/28] for x86_64 
> 
> Copyright (c) 1993-2012 by Florian Klaempfl and others 
> 
> Target OS: Win64 for x64 
> 
> Compiling apphello.pp 
> 
> hello.pp(6,3) Fatal: Can't find unit testunit used by hello 
> 
> Fatal: Compilation aborted 
> 
> Error: C:lazarusfpc2.6.2binx86_64-win64ppcx64.exe returned an error exitcode 
> (normal if you did not specify a source file to be compiled) 
> 
> _______________________________________________
> fpc-pascal maillist - fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal [1]
 

Links:
------
[1] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[2] http://phabricator.org/
--- C:/develop/blender_port/fpmkunit.pp	Sun Apr  6 14:04:26 2014
+++ C:/lazarus/fpc/2.6.2/source/packages/fpmkunit/src/fpmkunit.pp	Sun Apr  6 13:52:23 2014
@@ -943,7 +943,6 @@ Type
     //package commands
     function  GetUnitDir(APackage:TPackage):String;
     procedure AddDependencyPaths(L: TStrings; DependencyType: TDependencyType; ATarget: TTarget);
-    procedure AddPackageDependencyPaths(L: TStrings; ATarget: TTarget);
     procedure AddDependencyUnitPaths(L:TStrings;APackage: TPackage);
   Public
     Constructor Create(AOwner : TComponent); override;
@@ -1179,8 +1178,6 @@ type
   end;
 
 var
-  DefInstaller : TCustomInstaller;
-
   CustomFpmakeCommandlineOptions: TStrings;
   CustomFpMakeCommandlineValues: TStrings;
 
@@ -1232,6 +1229,7 @@ ResourceString
   SWarnSourceFileNotFound  = 'Warning: Source file "%s" from package %s not found for %s';
   SWarnIncludeFileNotFound = 'Warning: Include file "%s" from package %s not found for %s';
   SWarnDepUnitNotFound     = 'Warning: Dependency on unit %s is not supported for %s';
+  SWarnTargetDependsOnPackage = 'Warning: Target %s of package %s depends on another package (%s). These kind of dependencies are not processed';
   SWarnDependOnOtherPlatformPackage = 'Warning: Package %s depends on package %s which is not available for the %s platform';
   SWarnStartCompilingPackage = 'Start compiling package %s for target %s.';
   SWarnCompilingPackagecompleteProgress = '[%3.0f%%] Compiled package %s';
@@ -4719,30 +4717,7 @@ begin
     end;
 end;
 
-procedure TBuildEngine.AddPackageDependencyPaths(L: TStrings; ATarget: TTarget);
-Var
-  I : Integer;
-  D : TDependency;
-  SD : String;
-  APackage: TPackage;
-begin
-  For I:=0 to ATarget.Dependencies.Count-1 do
-    begin
-      D:=ATarget.Dependencies[i];
-      if (D.DependencyType=depPackage) and
-         (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes) then
-        begin
-          APackage := DefInstaller.Packages[D.Value];
 
-          SD := ExcludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(APackage.Directory) + APackage.GetUnitsOutputDir(Defaults.CPU,Defaults.OS));
-
-          if SD<>'' then
-            L.Add(SD);
-        end;
-    end;
-end;
-
-
 procedure TBuildEngine.AddDependencyUnitPaths(L:TStrings;APackage: TPackage);
 Var
   I : Integer;
@@ -4835,13 +4810,6 @@ begin
   for i:=0 to L.Count-1 do
     Args.Add('-Fu'+AddPathPrefix(APackage,L[i]));
   FreeAndNil(L);
-  // Package Dirs
-  L:=TUnsortedDuplicatesStringList.Create;
-  L.Duplicates:=dupIgnore;
-  AddPackageDependencyPaths(L,ATarget);
-  for i:=0 to L.Count-1 do
-    Args.Add('-Fu'+L[i]);
-  FreeAndNil(L);
   // Include Path
   L:=TUnsortedDuplicatesStringList.Create;
   L.Duplicates:=dupIgnore;
@@ -5048,7 +5016,10 @@ begin
                         Result:=FileNewer(TFN,OFN);
                       end;
                   end;
-                depPackage : ;
+                depPackage :
+                  begin
+                    log(vlWarning,SWarnTargetDependsOnPackage,[ATarget.Name, APackage.Name, d.Value]);
+                  end;
               end;
               if result then
                 break;
@@ -5113,7 +5084,7 @@ begin
     begin
       D:=ATarget.Dependencies[i];
       if (D.DependencyType=depPackage) then
-
+        log(vlWarning,SWarnTargetDependsOnPackage,[ATarget.Name, APackage.Name, d.Value])
       else if (D.DependencyType=depUnit) and
          (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes) then
         begin
@@ -6898,6 +6869,9 @@ end;
                                  Default Instances
 ****************************************************************************}
 
+var
+  DefInstaller : TCustomInstaller;
+
 Function Installer(InstallerClass: TInstallerClass): TCustomInstaller;
 begin
   If Not Assigned(DefInstaller) then
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to