我有一个项目,其中包含几个具有相同名称但位于不同文件夹中的文件。
Ex:
->sources
->src
- a.c
- b.c
->stub
- a.c
- z.c
在我的gpr文件中,
包括了源代码for Source_Dirs use ( "sources/**" )
现在,我想通过使用原始“ Excluded_Source_File”忽略src中的文件。
不幸的是,该原语需要一个文件名,而不是完整路径,因此当我要忽略a.c时,它将忽略src和stub中的两个文件。
for Excluded_Source_Files use ( "sources/src/a.c" ); -- KO by gprbuild
for Excluded_Source_Files use ( "a.c" ); -- OK but ignore both
有人知道我如何做到这一点,而无需更改当前的文件夹体系结构和重命名文件吗?
答案 0 :(得分:6)
听起来像您想要的是一个项目扩展,即。创建第二个项目文件,扩展第一个文件。在此秒项目文件中,您可以覆盖a.c
project Stubbed extends "my_project.gpr" is
for Source_Dirs use ("stub");
end Stubbed;
中了解有关项目范围的更多信息
答案 1 :(得分:6)
我会使用scenario variables;而且,听起来Excluded_Source_Dirs
很有用。
type Source_T is ("normal", "stubbed");
Sources : Source_T := external ("SOURCES", "normal");
然后选择
for Source_Dirs use ("sources/**");
case Sources is
when "normal" =>
for Excluded_Source_Dirs use ("sources/stub");
when "stubbed" =>
for Excluded_Source_Dirs use ("sources/src");
end case;
或
for Source_Dirs use ("sources");
case Sources is
when "normal" =>
for Source_Dirs use project'Source_Dirs & "sources/src";
when "stubbed" =>
for Source_Dirs use project'Source_Dirs & "sources/stub";
end case;
无论哪种情况,
gprbuild -P prj
(您可以添加默认的-XSOURCES=normal
)或
gprbuild -P prj -XSOURCES=stubbed