execute multiple .proto files

3,591 views
Skip to first unread message

joel

unread,
Jan 26, 2012, 11:13:38 AM1/26/12
to prot...@googlegroups.com
hi everyone i try to execute with msbuild multiple .proto files in the same
command

here's my code it is pretty simple but I can't see what I'm doing wrong

Thanks


<Target Name = "Main">

<Message Text="Generating DTO for c++"/>

<ItemGroup>
<ProtoFiles
Include="test1.proto"/>
<ProtoFiles
Include="test2.proto"/>
</ItemGroup>


<Exec Command="$(THISPATH)\protobuff\protoc.exe --cpp_out=. @(ProtoFiles)"/>


/>

</Target>

Tom Swirly

unread,
Jan 26, 2012, 12:28:26 PM1/26/12
to Protocol Buffers
First, you aren't giving us the error messages!  So how can we help you?

Second, you can't "execute" protocol buffer files - they're data descriptions - you can compile them into some programming language, which is compiled into an object file....



--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.




--
     /t

http://radio.swirly.com - art music radio 24/7 366/1000

joel

unread,
Jan 26, 2012, 12:48:20 PM1/26/12
to prot...@googlegroups.com
sorry i just copy and paste an other message i don't want to execute I want to
compile!! and here's my error message:

Project "c:\dir1\dir2\dir3\prototest.xml" on node 0 (default targets).
Generating DTO for c++
test1.proto;test2.proto: No such file or directory
c:\dir1\dir2\dir3\dir4\dir5\dir6\dir7\prototest.xml(20,7): error MSB3073: The
command "C:\code\protobuf\protoc.exe --cpp_out=. test1.proto;test2.proto" exited
with code 1.


Tom Swirly

unread,
Jan 26, 2012, 12:54:20 PM1/26/12
to joel, prot...@googlegroups.com
You're trying to compile the single file named "test1.proto;test2.proto" instead of the two files test.proto and test2.proto.  I assume this is something to do with your build file (is it Ant?  I'm not an expert in it anyway).

Either separate the file names with spaces or (probably better) arrange it so the files are compiled individually.



--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.

joel

unread,
Jan 26, 2012, 1:02:22 PM1/26/12
to prot...@googlegroups.com

I'm not a expert too ... I can't compile individually because
both file depend on the other. I think i will merge everything
in 1 proto ... it's gonna be long but
more simple!!

Tom Swirly

unread,
Jan 26, 2012, 1:20:23 PM1/26/12
to joel, prot...@googlegroups.com
On Thu, Jan 26, 2012 at 1:02 PM, joel <joel.lafo...@usherbrooke.ca> wrote:

I'm not a expert too ... I can't compile individually because
both file depend on  the other.

You should set the proto path using --proto_path to be the root directory of your protocol buffer files, and then you don't need to compile them together.

But if you're saying that test1.proto depends on test2.proto, and test2.proto depends on test1.proto - well, that's simply a bad idea.  I'm not 100% sure that the protocol buffer compiler will even accept that (though it probably will), but it's a terrible idea conceptually.

Because there are no forward references and no cycles, you can always break up your protocol buffer files so that this doesn't happen!


 
I think i will merge everything
in 1 proto ... it's gonna be long but
more simple!!

Unless there are only ever going to be two protocol buffers, and their files are small, this is not a great idea.  It's going to make your builds progressively longer, it makes maintenance harder, there's no good reason for it.

Take the extra time and master this tool - it's extremely powerful and flexible, the small amounts of time you spend now will pay off 10x over your project.

 

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.

joel

unread,
Jan 26, 2012, 1:58:51 PM1/26/12
to prot...@googlegroups.com
Yeah you are right i will check what i can do with this and I'll post back if I
have other question

Do you have an example to see how using --proto_path

Thanks


Tom Swirly

unread,
Jan 26, 2012, 2:05:13 PM1/26/12
to joel, prot...@googlegroups.com
This is the script I use to compile my protocol buffer files.  The last few lines are the key ones - I use "find" to locate all the protocol buffer files relative to the root directory $SRC_ROOT and then pass all of those files to the protocol compiler, and it stores the results elsewhere, under $PROTO_ROOT.

I have quite a lot of proto files, so this is very convenient so that my generated _pb.cc and .pb.h files don't litter my source directories (and so I can blow away all the generated files without fear...)

Sorry, I won't be able to help with more details on how I do it, have fun!


PACKAGE=protobuf
CONFIG=debug

source "$ROOT/rec/scripts/variables.sh"

SRC_ROOT="$ROOT/rec/src"
PROTO_ROOT="$ROOT/rec/genfiles/proto"

mkdir -p "$PROTO_ROOT"
echo "Deleting `find "$PROTO_ROOT" -name \*.pb.\* | wc -l` compiled files."
find "$PROTO_ROOT" -name \*.pb.\* | xargs rm

find "$SRC_ROOT" -name \*.proto |\
 xargs "$INSTALL_DIR/bin/protoc"\
   --proto_path "$SRC_ROOT"\
   --proto_path "$ROOT/build/$CONFIG/protobuf/include"\
   --cpp_out="$PROTO_ROOT"




--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.

Reply all
Reply to author
Forward
0 new messages