Ada 库 GPR 项目:为什么 gprinstall 不起作用?
Ada library GPR project : why gprinstall does not work?
我有一个可以成功构建的 GPR 库项目(静态或动态类型与此处无关)。
我知道 gprinstall
提供了管理库交付的方法,即:
- 准备 GPR 文件以使用库
- 根据原GPR中给出的条件(定义目录)提供库文件(.a或.dll)
- 根据类似条件提供库接口文件
这背后的想法是让用户仅 "with" 新的 GPR 才能看到接口文件(.ads
例如在 Ada 中)。
但是,我无法使 gprinstall 工作。以下命令
E:\DEV\Projets\Ada\LibA>gprinstall --dry-run -p -m -f -P LibA.gpr
只给出:
Install project LibA
-v
verbose 选项一点线索也没有。
(项目显然已经构建成功,代码文件与理解无关)
这是我的 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;
在使用 Install
包选项和命令行之后,我终于明白了一些事情:
- 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
- gprinstall 默认复制所有源文件(
-a
默认激活)。您可以使用命令行开关 -m
. 更改它
Install_Root := "../INSTALL_BUILDS/";
中指示的文件夹从GNAT bin路径开始评估(由于环境变量:PATH=E:\DEV\GNAT17\bin;...
)
- 安装包选项引起的文件夹层次结构用于多个 gprinstall 交付。我在下面 Production_Options 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
我有一个可以成功构建的 GPR 库项目(静态或动态类型与此处无关)。
我知道 gprinstall
提供了管理库交付的方法,即:
- 准备 GPR 文件以使用库
- 根据原GPR中给出的条件(定义目录)提供库文件(.a或.dll)
- 根据类似条件提供库接口文件
这背后的想法是让用户仅 "with" 新的 GPR 才能看到接口文件(.ads
例如在 Ada 中)。
但是,我无法使 gprinstall 工作。以下命令
E:\DEV\Projets\Ada\LibA>gprinstall --dry-run -p -m -f -P LibA.gpr
只给出:
Install project LibA
-v
verbose 选项一点线索也没有。
(项目显然已经构建成功,代码文件与理解无关)
这是我的 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;
在使用 Install
包选项和命令行之后,我终于明白了一些事情:
- 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 - gprinstall 默认复制所有源文件(
-a
默认激活)。您可以使用命令行开关-m
. 更改它
Install_Root := "../INSTALL_BUILDS/";
中指示的文件夹从GNAT bin路径开始评估(由于环境变量:PATH=E:\DEV\GNAT17\bin;...
)- 安装包选项引起的文件夹层次结构用于多个 gprinstall 交付。我在下面 Production_Options 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