dllshared-librariesstatic-librariesgnat-gpsgprinstall

Ada library GPR project : why gprinstall does not work?


I have a GPR library project wichi builds successfully (the static or dynamic kind is not relevant here). I know that gprinstall provides means to manage the delivery of the library, i.e.:

  1. prepare a GPR file to use the library
  2. provide the library file (.a or .dll) according conditions given in the original GPR (defined directories)
  3. provide the library interface files according similar conditions

The idea behind this is for users to only "with" the new GPR in order to see the interface file (.ads for instance in Ada).

However, I can't manage to make gprinstall work. The following command

E:\DEV\Projets\Ada\LibA>gprinstall --dry-run -p -m -f -P LibA.gpr

gives only :

Install project LibA

The -v verbose option gives not a single little piece of a clue. (the project is obviously successfully built and code files are not really relevant for the comprehension)


Here is my GPR files :

with "../Production_Options/Production_Options.gpr";
with "../InterfaceA/InterfaceA.gpr";

library project LibA is
   for Source_Dirs       use ("src") & InterfaceA.Interface_Files;
   for Object_Dir        use "obj";
   for Library_Name      use project'Name;
   for Library_Dir       use "Library";
   for Library_Ali_Dir   use "Library_Ali";
   for Library_Src_Dir   use "Public_Interfaces";
   for Library_Interface use (InterfaceA.Interface_Name);
   for Library_Kind      use "static";

   package Install extends Production_Options.Install is
      for Prefix use Production_Options.Install'Prefix & Production_Options.Install.Install_Libs & project'Name;
      for Mode use "dev";
      for Side_Debug use "true";
   end Install;
   -- various renames of Productions_Options
end LibA;

project InterfaceA is

   Interface_Files := (project'Project_Dir & "src");
   Interface_Name  := "InterfaceA";

   for Source_Dirs use ();

end InterfaceA;

My options GPR:

project Production_Options is
   for Source_Dirs use ();
   -- various switches for compiler, builder, clean, binder, ide, linker, namling, pretty printer ...
   package Install is
      Install_Root := "../INSTALL_BUILDS/";
      Install_Exe  := "EXECUTABLES/";
      Install_Libs := "LIBS/";
      Install_Root_Exe  := Install_Root & Install_Exe;
      Install_Root_Libs := Install_Root & Install_Libs;
      for Prefix         use Install_Root;
      for Lib_Subdir     use "BIN";
      for Ali_Subdir     use "ALI";
      for Sources_Subdir use "SRC";
      for Project_Subdir use "GPR";
   end Install;
end Production_Options;

Solution

  • After playing around with the Install package options and the command line, I finally realized a few things :

    1. The for Mode use "dev" option in the GPR file makes the gprinstall tool completly numb. AT first, I could not find reliable documentation for this on Adacore (http://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/gnat_project_manager.html#installing-a-library-with-project-files) but it was little be more clear here https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/companion_tools.html#installing-with-gprinstall
    2. gprinstall copies ALL sources by default (-a activated by default). You can change that using the command line switch -m.
    3. the folder indicated in Install_Root := "../INSTALL_BUILDS/"; is evaluated starting from the GNAT bin path (due to environment variable: PATH=E:\DEV\GNAT\2017\bin;...)
    4. The folders hierarchy induced by the Install package options is intended for several gprinstall deliveries. I indicated that below in comment part of the Production_Options GPR.

    With these GPRs :

    library project LibA is
       for Source_Dirs       use ("src") & InterfaceA.Interface_Files;
       for Object_Dir        use "obj";
       for Library_Name      use project'Name;
       for Library_Dir       use "Library";
       for Library_Ali_Dir   use "Library_Ali";
       for Library_Src_Dir   use "Public_Interfaces";
       for Library_Interface use (InterfaceA.Interface_Name);
       for Library_Kind      use "static";
    
       package Install extends Production_Options.Install is
          for Prefix use Production_Options.Install.Install_Root_Libs;
    
          -- makes gprinstall silent and numb in --dry-run mode ?!
          -- for Mode use "dev";
          for Side_Debug use "true";
       end Install;
       -- various renames of Productions_Options
    end LibA;
    
    project Production_Options is
       package Install is
          Install_Root := project'Project_Dir & "../INSTALL_BUILDS/";
          Install_Exe  := "EXECUTABLES/";
          Install_Libs := "LIBS/";
          Install_Root_Exe  := Install_Root & Install_Exe;
          Install_Root_Libs := Install_Root & Install_Libs;
          for Prefix         use Install_Root;
          for Exec_Subdir    use "EXE";
          for Lib_Subdir     use "BIN";
          for Ali_Subdir     use "ALI";
          for Sources_Subdir use "SRC";
          for Project_Subdir use "GPR";
          --
          -- |                      with my settings: |_INSTALL_BUILDS
          -- |_Prefix                                   |_LIBS
          --      |_Exec_Subdir                           |_Exec_Subdir
          --        |_liba                                  |_liba would contain exe if it was an exe project
          --      |_Lib_Subdir                            |_Lib_Subdir
          --         |_liba                                 |_liba contains the .a file
          --      |_Ali_Subdir                            |_Ali_Subdir
          --        |_liba                                  |_liba contains the ali files
          --      |_Sources_Subdir                        |_Sources_Subdir
          --         |_liba                                 |_liba contains the src files
       end Install;
    end Production_Options;
    

    The command gprinstall -m --dry-run -p -f -P LibA.gpr now works properly.

    Here is the output you might obtain :

    E:\DEV\Projets\Ada\LibA>gprinstall -d -m -p -f -P LibA.gpr
    Install project LibA
    cp E:\DEV\Projets\Ada\InterfaceA\src\InterfaceA.ads E:\DEV\GNAT\INSTALL_BUILDS\LIBS\SRC\liba\interfacea.ads
    cp E:\DEV\Projets\Ada\LibA\Library_Ali\interfacea.ali E:\DEV\GNAT\INSTALL_BUILDS\LIBS\ALI\liba\interfacea.ali
    cp E:\DEV\Projets\Ada\LibA\Library\libliba.a E:\DEV\GNAT\INSTALL_BUILDS\LIBS\BIN\liba\libliba.a
    
    Project E:\DEV\GNAT\INSTALL_BUILDS\LIBS\GPR\liba\LibA.gpr would be installed
    
    --  This project has been generated by GPRINSTALL GPL 2017 (20170515) (i686-pc-mingw32)
    library project LibA is
       type BUILD_KIND is ("default");
       BUILD : BUILD_KIND := external("LIBA_BUILD", "default");
       for Languages use ("Ada");
       case BUILD is
          when "default" =>
             for Source_Dirs use ("../SRC/");
             for Library_Dir use "../BIN/";
             for Library_ALI_Dir use "../ALI/";
             for Library_Kind use "static";
             for Library_Interface use ("interfacea");
       end case;
       for Library_Name use "liba";
       package Naming is
          for dot_replacement use "-";
          for casing use "MixedCase";
          case BUILD is
             when "default" =>
                for body_suffix ("ada") use ".adb";
                for spec_suffix ("ada") use ".ads";
          end case;
       end Naming;
       package Linker is
          case BUILD is
             when "default" =>
                null;
          end case;
       end Linker;
       package Install is
          for Active use "False";
       end Install;
       for Externally_Built use "True";
    end LibA;
    

    Complete sources can be found here : https://github.com/LoneWanderer-GH/Samples-GPR-Aggregate-Libs