Integrate Google Protocol Buffers .proto files to Visual C++ 2010

前端 未结 2 954
梦谈多话
梦谈多话 2020-12-31 07:07

I\'ve added a custom build step to my Visual Studio project files which generates the google protobuf .h/.cc files from th

相关标签:
2条回答
  • 2020-12-31 07:21

    Follow these detailed instructions to specify Custom Build Tool.

    Considering your proto file resides together with .h/.cpp files in standard project configuration, here are values to be inserted in Custom Build Tool:

    Command Line: 
    path\to\protoc --proto_path=$(ProjectDir) --cpp_out=$(ProjectDir) %(FullPath)
    Outputs: 
    $(ProjectDir)%(Filename).pb.h;$(ProjectDir)%(Filename).pb.cc
    

    Please note usage of item metadata macros, which replaced some of deprecated macros (like $(InputDir) and $(InputName)).

    Now Protocol Buffers compiler will be run only when Input file (i.e. %(FullPath)) is newer than "Outputs".

    0 讨论(0)
  • 2020-12-31 07:34

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

    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

    and (maybe?) kmote00:

    ... 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.)

    0 讨论(0)
提交回复
热议问题