可以将 gprbuild 配置为输出 gnatprep 预处理源吗? [英] Can gprbuild be configured to output gnatprep preprocessed sources?

查看:19
本文介绍了可以将 gprbuild 配置为输出 gnatprep 预处理源吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 gpr 项目,它使用 gnatprep 来预处理源文件.但是现在我有一个需要已经预处理过的源文件的工具.我知道我可以找到每个源文件并通过 gnatprep 运行它:

I have a gpr project which uses gnatprep to preprocess source files. But now I have a tool which needs the already preprocessed source files. I know that I can hunt down each source file and run it through gnatprep:

find . -type f -iname '*.ad[sb]' -exec gnatprep -DSymbol=value {} {}.prep \;

但我想利用项目文件来找到正确的源文件并通过它们.我的项目文件还定义了要使用的各种符号值,我必须将其添加到上面的命令中.是否可以通过 .gpr 文件中的某些参数?例如

But I'd like to leverage the project file to find the right source files and pass them through. My project file also defines the various symbol values to use, which I would have to add to the command above. Is it possible through some parameter in the .gpr file? E.g.

   for Object_Dir use 'obj';
   for Preprocessed_Sources_Dir use 'wow_that_was_easy';

推荐答案

您可以使用 -gnateG 选项告诉编译器将预处理源保留在 Object_Dir 中,像这样,在项目文件中:

You can tell the compiler to leave the preprocessed sources in the Object_Dir with the -gnateG option, like so, in the project file:

   package Compiler is
      for Default_Switches ("Ada") use ("-gnateDFoo=""Bar""", "-gnateG" );
   end Compiler;

预处理后的源代码将被命名为 .prep,例如 foo.adb ->foo.adb.prep

The preprocessed source will then be named <original_filename>.prep, for example foo.adb -> foo.adb.prep

对于您的后续问题,您必须将预处理器选项放在一个单独的文件中,例如 prep.def:

For your followup-question, you'd have to put the preprocessor options in a separate file, for example prep.def:

* -u -c -DFoo="Bar"

或者,如果您想为每个文件指定选项:

or, if you want to specify options per file:

"foo.adb" -u -c -DFoo="Bar"

然后告诉编译器使用带有 gnatep= 选项的文件:

And then tell the compiler to use that file with the gnatep= option:

package Compiler is
   for Default_Switches ("Ada") use ("-gnateG", "-gnatep=" & Foo'Project_Dir & "prep.def" );
end Compiler;

这篇关于可以将 gprbuild 配置为输出 gnatprep 预处理源吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆