Ada库GPR项目:为什么gprinstall不起作用?

时间:2018-05-21 01:58:50

标签: dll shared-libraries static-libraries gnat-gps gprinstall

我有一个成功构建的GPR库项目(静态或动态类型在这里不相关)。 我知道gprinstall提供了管理图书馆交付的方法,即:

  1. 准备GPR文件以使用库
  2. 根据原始GPR(定义目录)中给出的条件提供库文件(.a或.dll)
  3. 根据类似条件提供库接口文件
  4. 这背后的想法是,用户只能“使用”新的GPR,以便查看接口文件(例如Ada中的.ads)。

    但是,我无法让gprinstall工作。以下命令

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

    仅提供:

    Install project LibA
    

    -v详细选项不提供任何一条线索。 (该项目显然已成功构建,代码文件与理解无关)

    这是我的GPR文件:

    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;
    

    我的选择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;
    

1 个答案:

答案 0 :(得分:0)

在使用Install包选项和命令行后,我终于意识到了一些事情:

  1. GPR文件中的for Mode use "dev"选项使gprinstall工具完全麻木。首先,我在Adacore上找不到可靠的文档(http://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/gnat_project_manager.html#installing-a-library-with-project-files) 但在https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/companion_tools.html#installing-with-gprinstall
  2. 这里显得更加清晰
  3. gprinstall默认复制所有源(默认情况下已激活-a)。您可以使用命令行开关-m更改它。
  4. Install_Root := "../INSTALL_BUILDS/";中指示的文件夹从GNAT bin路径开始评估(由于环境变量:PATH=E:\DEV\GNAT\2017\bin;...
  5. 安装包选项引发的文件夹层次结构适用于多个gprinstall交付。我在下面的Production_Options GPR的评论部分中指出。
  6. 使用这些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.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;
    

    命令gprinstall -m --dry-run -p -f -P LibA.gpr现在可以正常运行。

    以下是您可能获得的输出:

    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;
    

    完整的消息来源可以在这里找到: https://github.com/LoneWanderer-GH/Samples-GPR-Aggregate-Libs