It appears that the command-line flag parsing logic doesn't take path names with spaces into account; at least on Windows.
# run.bat
cls
"C:\Users\Chris Smith\Desktop\protobuf-csharp-3.0.0-alpha-4\protobuf-3.0.0-alpha-4\cmake\build\Debug\protoc.exe" ^
-I="C:\Users\Chris Smith\Documents\GitHub\kythe\kythe\proto\" ^
--csharp_out="C:\Users\Chris Smith\Desktop\" ^
C:\Users\Chris Smith\Documents\GitHub\kythe\kythe\proto\storage.proto
Output:
--csharp_out=C:\Users\Chris: warning: directory does not exist.
Missing output directives.
I'm pretty surprised by this. I would have expected -I="C:\path with spaces\" to work because of the quoting. However, despite trying lots of methods protoc just stops parsing the command-line argument when it comes to the first space.
@anandolee could you please take a look?
Confirming this issue here. :+1:
@xfxyjwf would it be more appropriate to label this a "bug" rather than "enhancement"?
This issue is even in the released, non-beta version of protobuf. Really surprised by it, as it makes integrating into a build process nasty (have to worry that the person who is going to build drops the source in a path with a space). Should definitely be a bug and not an enhancement.
Googling showed this issue is actually that protobuf is considering the \ before the endquote as an escape sequence.
I'm guessing most folks using this are using Visual Studio macros like $(ProjectDir) which have that trailing \ . For me, a fix that worked was to actually append "." before the endquote, as this means remove the trailing \ . I was a bit surprised it worked, as protobuf is super sensitive about relative paths for these parameters (the reason many folks resort to "$(ProjectDir)" instead of %"(FullPath).." but apparently it can cope with the trailing slash elimination.
So I've got this working with a path with spaces:
<protoc containing dir>\protoc.exe -I="$(ProjectDir)." --cpp_out="$(ProjectDir)." "%(FullPath)"
Most helpful comment
Googling showed this issue is actually that protobuf is considering the \ before the endquote as an escape sequence.
I'm guessing most folks using this are using Visual Studio macros like $(ProjectDir) which have that trailing \ . For me, a fix that worked was to actually append "." before the endquote, as this means remove the trailing \ . I was a bit surprised it worked, as protobuf is super sensitive about relative paths for these parameters (the reason many folks resort to "$(ProjectDir)" instead of %"(FullPath).." but apparently it can cope with the trailing slash elimination.
So I've got this working with a path with spaces:
<protoc containing dir>\protoc.exe -I="$(ProjectDir)." --cpp_out="$(ProjectDir)." "%(FullPath)"