将Google协议缓冲区.proto文件集成到Visual C ++ 2010 [英] Integrate Google Protocol Buffers .proto files to Visual C++ 2010

查看:65
本文介绍了将Google协议缓冲区.proto文件集成到Visual C ++ 2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的 Visual Studio 项目文件中添加了自定义生成步骤,该文件会从中生成 google protobuf .h/.cc文件.proto输入文件.但是我一直想知道是否只有在原始文件的内容已更改的情况下才可以开始编译?

I've added a custom build step to my Visual Studio project files which generates the google protobuf .h/.cc files from the .proto input files. But I've been wondering if it's possible to start a compile only if the content of the proto files has changed?

是否有一种方法可以从自定义构建步骤准确地告诉VisualStudio?将原型文件集成到Visual Studio构建解决方案的最佳方法是什么?

Is there a way to tell VisualStudio from a custom build step exactly that? What is the optimal way to integrate proto files into a visual studio build solution?

目前,在每次构建时,都会更新.proto文件,然后还会更新输出.h/.cc文件的时间戳...然后,该文件会重新编译与此相关的所有内容.在仍然可以直接从Visual Studio进行构建的同时,还有更好的方法吗?

At the moment, at every build the .proto file is updated which then also updates the time stamp of the output .h/.cc files ...which then issues a recompile of everything dependent from that. Is there a better way around it, while still building them directly from visual studio?

推荐答案

也许

Maybe this helps. Especially look at the post of Igor Zavoychinskiy:

解决这个棘手问题的方法实际上很简单:在输出部分您应指定完整路径.这在任何地方都没有明确说明但是如果没有此检查器,便无法找到文件,因此,假设它们不存在.例如用于protobuffers编译输出部分将如下所示:

Solution of this nasty problem is actually simple: in outputs sections you should specify full path(s). This isn't explicitly stated anywhere but without this checker just fails to find the files and, hence, assumes they don't exist. For example for protobuffers compiling outputs section will be like this:

$(InputDir)\ $(InputName).pb.cc; $(InputDir)\ $(InputName).pb.h

$(InputDir)\$(InputName).pb.cc;$(InputDir)\$(InputName).pb.h

和(也许是?)kmote00:

and (maybe?) kmote00:

...底线:我只需要确保我的输出"条目正确与(用户定义的)"OutputFile"属性中的默认值匹配.(非常感谢,这也消除了对两遍构建的需求,是我以前忍受的另一个烦恼.)

... Bottom line: I just had to make sure my "Outputs" entry exactly matched the Default Value in the (user-defined) "OutputFile" property. (Thankfully this also obviated the need for a two-pass build, which was another annoyance I had previously put up with.)

这篇关于将Google协议缓冲区.proto文件集成到Visual C ++ 2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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